• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "experimental/svg/model/SkSVGGradient.h"
12 #include "experimental/svg/model/SkSVGTypes.h"
13 
14 class SkSVGLinearGradient final : public SkSVGGradient {
15 public:
16     ~SkSVGLinearGradient() override = default;
Make()17     static sk_sp<SkSVGLinearGradient> Make() {
18         return sk_sp<SkSVGLinearGradient>(new SkSVGLinearGradient());
19     }
20 
21     void setX1(const SkSVGLength&);
22     void setY1(const SkSVGLength&);
23     void setX2(const SkSVGLength&);
24     void setY2(const SkSVGLength&);
25 
26 protected:
27     void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
28 
29     sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&,
30                                  const SkColor*, const SkScalar*, int count,
31                                  SkTileMode, const SkMatrix&) const override;
32 private:
33     SkSVGLinearGradient();
34 
35     SkSVGLength fX1 = SkSVGLength(0  , SkSVGLength::Unit::kPercentage);
36     SkSVGLength fY1 = SkSVGLength(0  , SkSVGLength::Unit::kPercentage);
37     SkSVGLength fX2 = SkSVGLength(100, SkSVGLength::Unit::kPercentage);
38     SkSVGLength fY2 = SkSVGLength(0  , SkSVGLength::Unit::kPercentage);
39 
40     typedef SkSVGGradient INHERITED;
41 };
42 
43 #endif // SkSVGLinearGradient_DEFINED
44