1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkLinearGradient_DEFINED 9 #define SkLinearGradient_DEFINED 10 11 #include "SkGradientShaderPriv.h" 12 13 class SkLinearGradient : public SkGradientShaderBase { 14 public: 15 SkLinearGradient(const SkPoint pts[2], const Descriptor&); 16 17 size_t contextSize() const override; 18 19 class LinearGradientContext : public SkGradientShaderBase::GradientShaderBaseContext { 20 public: 21 LinearGradientContext(const SkLinearGradient&, const ContextRec&); ~LinearGradientContext()22 ~LinearGradientContext() {} 23 24 void shadeSpan(int x, int y, SkPMColor dstC[], int count) override; 25 void shadeSpan16(int x, int y, uint16_t dstC[], int count) override; 26 27 private: 28 typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED; 29 }; 30 31 BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; 32 GradientType asAGradient(GradientInfo* info) const override; 33 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix& viewM, 34 const SkMatrix*, 35 GrColor*, GrFragmentProcessor**) const override; 36 37 SK_TO_STRING_OVERRIDE() 38 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient) 39 40 protected: 41 SkLinearGradient(SkReadBuffer& buffer); 42 void flatten(SkWriteBuffer& buffer) const override; 43 Context* onCreateContext(const ContextRec&, void* storage) const override; 44 45 private: 46 friend class SkGradientShader; 47 typedef SkGradientShaderBase INHERITED; 48 const SkPoint fStart; 49 const SkPoint fEnd; 50 }; 51 52 #endif 53