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 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 SK_TO_STRING_OVERRIDE() 23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient) 24 25 protected: 26 SkLinearGradient(SkReadBuffer& buffer); 27 void flatten(SkWriteBuffer& buffer) const override; 28 Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override; 29 Context* onMakeBurstPipelineContext(const ContextRec&, SkArenaAlloc*) const override; 30 31 void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline, 32 SkRasterPipeline* postPipeline) const final; 33 34 35 sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override; 36 37 private: 38 class LinearGradient4fContext; 39 40 friend class SkGradientShader; 41 typedef SkGradientShaderBase INHERITED; 42 const SkPoint fStart; 43 const SkPoint fEnd; 44 }; 45 46 #endif 47