fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "experimental/svg/model/SkSVGGradient.h" |
| 12 | #include "experimental/svg/model/SkSVGTypes.h" |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 13 | |
Florin Malita | df007e1 | 2017-10-09 15:14:13 -0400 | [diff] [blame] | 14 | class SkSVGLinearGradient final : public SkSVGGradient { |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 15 | public: |
Brian Salomon | d3b6597 | 2017-03-22 12:05:03 -0400 | [diff] [blame] | 16 | ~SkSVGLinearGradient() override = default; |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 17 | static sk_sp<SkSVGLinearGradient> Make() { |
| 18 | return sk_sp<SkSVGLinearGradient>(new SkSVGLinearGradient()); |
| 19 | } |
| 20 | |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 21 | void setX1(const SkSVGLength&); |
| 22 | void setY1(const SkSVGLength&); |
| 23 | void setX2(const SkSVGLength&); |
| 24 | void setY2(const SkSVGLength&); |
| 25 | |
| 26 | protected: |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 27 | void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override; |
| 28 | |
Florin Malita | df007e1 | 2017-10-09 15:14:13 -0400 | [diff] [blame] | 29 | sk_sp<SkShader> onMakeShader(const SkSVGRenderContext&, |
| 30 | const SkColor*, const SkScalar*, int count, |
Mike Reed | fae8fce | 2019-04-03 10:27:45 -0400 | [diff] [blame] | 31 | SkTileMode, const SkMatrix&) const override; |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 32 | private: |
| 33 | SkSVGLinearGradient(); |
| 34 | |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 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 | |
Florin Malita | df007e1 | 2017-10-09 15:14:13 -0400 | [diff] [blame] | 40 | typedef SkSVGGradient INHERITED; |
fmalita | 28d5b72 | 2016-09-12 17:06:47 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | #endif // SkSVGLinearGradient_DEFINED |