Home | History | Annotate | Download | only in model
      1 /*
      2  * Copyright 2016 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 SkSVGLinearGradient_DEFINED
      9 #define SkSVGLinearGradient_DEFINED
     10 
     11 #include "SkSVGHiddenContainer.h"
     12 #include "SkSVGTypes.h"
     13 
     14 class SkSVGLinearGradient : public SkSVGHiddenContainer {
     15 public:
     16     ~SkSVGLinearGradient() override = default;
     17     static sk_sp<SkSVGLinearGradient> Make() {
     18         return sk_sp<SkSVGLinearGradient>(new SkSVGLinearGradient());
     19     }
     20 
     21     void setHref(const SkSVGStringType&);
     22     void setGradientTransform(const SkSVGTransformType&);
     23     void setSpreadMethod(const SkSVGSpreadMethod&);
     24     void setX1(const SkSVGLength&);
     25     void setY1(const SkSVGLength&);
     26     void setX2(const SkSVGLength&);
     27     void setY2(const SkSVGLength&);
     28 
     29 protected:
     30     bool onAsPaint(const SkSVGRenderContext&, SkPaint*) const override;
     31 
     32     void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
     33 
     34 private:
     35     SkSVGLinearGradient();
     36 
     37     void collectColorStops(const SkSVGRenderContext&,
     38                            SkSTArray<2, SkScalar, true>*,
     39                            SkSTArray<2, SkColor, true>*) const;
     40 
     41     SkSVGLength fX1 = SkSVGLength(0  , SkSVGLength::Unit::kPercentage);
     42     SkSVGLength fY1 = SkSVGLength(0  , SkSVGLength::Unit::kPercentage);
     43     SkSVGLength fX2 = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
     44     SkSVGLength fY2 = SkSVGLength(0  , SkSVGLength::Unit::kPercentage);
     45 
     46     SkSVGStringType    fHref;
     47     SkSVGTransformType fGradientTransform = SkSVGTransformType(SkMatrix::I());
     48     SkSVGSpreadMethod  fSpreadMethod = SkSVGSpreadMethod(SkSVGSpreadMethod::Type::kPad);
     49 
     50     typedef SkSVGHiddenContainer INHERITED;
     51 };
     52 
     53 #endif // SkSVGLinearGradient_DEFINED
     54