Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: experimental/svg/model/SkSVGStop.cpp

Issue 2327233003: [SVGDom] Initial linear gradient support (Closed)
Patch Set: review Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/svg/model/SkSVGStop.h ('k') | experimental/svg/model/SkSVGTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "SkSVGRenderContext.h"
9 #include "SkSVGStop.h"
10 #include "SkSVGValue.h"
11
12 SkSVGStop::SkSVGStop() : INHERITED(SkSVGTag::kStop) {}
13
14 void SkSVGStop::setOffset(const SkSVGLength& offset) {
15 fOffset = offset;
16 }
17
18 void SkSVGStop::setStopColor(const SkSVGColorType& color) {
19 fStopColor = color;
20 }
21
22 void SkSVGStop::setStopOpacity(const SkSVGNumberType& opacity) {
23 fStopOpacity = SkTPin<SkScalar>(opacity.value(), 0, 1);
24 }
25
26 void SkSVGStop::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
27 switch (attr) {
28 case SkSVGAttribute::kOffset:
29 if (const auto* offset = v.as<SkSVGLengthValue>()) {
30 this->setOffset(*offset);
31 }
32 break;
33 case SkSVGAttribute::kStopColor:
34 if (const auto* color = v.as<SkSVGColorValue>()) {
35 this->setStopColor(*color);
36 }
37 break;
38 case SkSVGAttribute::kStopOpacity:
39 if (const auto* opacity = v.as<SkSVGNumberValue>()) {
40 this->setStopOpacity(*opacity);
41 }
42 break;
43 default:
44 this->INHERITED::onSetAttribute(attr, v);
45 }
46 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGStop.h ('k') | experimental/svg/model/SkSVGTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698