OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkSVGNode.h" | 10 #include "SkSVGNode.h" |
11 #include "SkSVGRenderContext.h" | 11 #include "SkSVGRenderContext.h" |
12 #include "SkSVGValue.h" | 12 #include "SkSVGValue.h" |
13 #include "SkTLazy.h" | 13 #include "SkTLazy.h" |
14 | 14 |
15 SkSVGNode::SkSVGNode(SkSVGTag t) : fTag(t) { } | 15 SkSVGNode::SkSVGNode(SkSVGTag t) : fTag(t) { } |
16 | 16 |
17 SkSVGNode::~SkSVGNode() { } | 17 SkSVGNode::~SkSVGNode() { } |
18 | 18 |
19 void SkSVGNode::render(const SkSVGRenderContext& ctx) const { | 19 void SkSVGNode::render(const SkSVGRenderContext& ctx) const { |
20 SkSVGRenderContext localContext(ctx); | 20 SkSVGRenderContext localContext(ctx); |
21 | 21 |
22 if (this->onPrepareToRender(&localContext)) { | 22 if (this->onPrepareToRender(&localContext)) { |
23 this->onRender(localContext); | 23 this->onRender(localContext); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
| 27 bool SkSVGNode::asPaint(const SkSVGRenderContext& ctx, SkPaint* paint) const { |
| 28 SkSVGRenderContext localContext(ctx); |
| 29 |
| 30 return this->onPrepareToRender(&localContext) && this->onAsPaint(localContex
t, paint); |
| 31 } |
| 32 |
27 bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const { | 33 bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const { |
28 ctx->applyPresentationAttributes(fPresentationAttributes); | 34 ctx->applyPresentationAttributes(fPresentationAttributes); |
29 return true; | 35 return true; |
30 } | 36 } |
31 | 37 |
32 void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) { | 38 void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) { |
33 this->onSetAttribute(attr, v); | 39 this->onSetAttribute(attr, v); |
34 } | 40 } |
35 | 41 |
36 void SkSVGNode::setFill(const SkSVGPaint& svgPaint) { | 42 void SkSVGNode::setFill(const SkSVGPaint& svgPaint) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 case SkSVGAttribute::kStrokeWidth: | 106 case SkSVGAttribute::kStrokeWidth: |
101 if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) { | 107 if (const SkSVGLengthValue* strokeWidth = v.as<SkSVGLengthValue>()) { |
102 this->setStrokeWidth(*strokeWidth); | 108 this->setStrokeWidth(*strokeWidth); |
103 } | 109 } |
104 break; | 110 break; |
105 default: | 111 default: |
106 SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag); | 112 SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag); |
107 break; | 113 break; |
108 } | 114 } |
109 } | 115 } |
OLD | NEW |