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 "src/shaders/gradients/SkGradientShaderPriv.h" 12 13 class SkLinearGradient : public SkGradientShaderBase { 14 public: 15 SkLinearGradient(const SkPoint pts[2], const Descriptor&); 16 17 GradientType asAGradient(GradientInfo* info) const override; 18 #if SK_SUPPORT_GPU 19 std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override; 20 #endif 21 22 protected: 23 SkLinearGradient(SkReadBuffer& buffer); 24 void flatten(SkWriteBuffer& buffer) const override; 25 #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT 26 Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override; 27 #endif 28 29 void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline, 30 SkRasterPipeline* postPipeline) const final; 31 32 33 private: 34 SK_FLATTENABLE_HOOKS(SkLinearGradient) 35 36 class LinearGradient4fContext; 37 38 friend class SkGradientShader; 39 typedef SkGradientShaderBase INHERITED; 40 const SkPoint fStart; 41 const SkPoint fEnd; 42 }; 43 44 #endif 45