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

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

Issue 2222793002: [SVGDom] Add <svg> viewBox support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: typo Created 4 years, 4 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/SkSVGNode.h ('k') | experimental/svg/model/SkSVGRect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(SkCanvas* canvas, const SkSVGRenderContext& ctx) const { 19 void SkSVGNode::render(const SkSVGRenderContext& ctx) const {
20 SkTCopyOnFirstWrite<SkSVGRenderContext> localContext(ctx); 20 SkSVGRenderContext localContext(ctx);
21 fPresentationAttributes.applyTo(localContext);
22 21
23 SkAutoCanvasRestore acr(canvas, false); 22 if (this->onPrepareToRender(&localContext)) {
24 const SkMatrix& m = this->onLocalMatrix(); 23 this->onRender(localContext);
25 if (!m.isIdentity()) {
26 canvas->save();
27 canvas->concat(m);
28 } 24 }
25 }
29 26
30 this->onRender(canvas, *localContext); 27 bool SkSVGNode::onPrepareToRender(SkSVGRenderContext* ctx) const {
28 fPresentationAttributes.applyTo(ctx);
29 return true;
31 } 30 }
32 31
33 void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) { 32 void SkSVGNode::setAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
34 this->onSetAttribute(attr, v); 33 this->onSetAttribute(attr, v);
35 } 34 }
36 35
37 void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) { 36 void SkSVGNode::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
38 switch (attr) { 37 switch (attr) {
39 case SkSVGAttribute::kFill: 38 case SkSVGAttribute::kFill:
40 if (const SkSVGColorValue* color = v.as<SkSVGColorValue>()) { 39 if (const SkSVGColorValue* color = v.as<SkSVGColorValue>()) {
41 fPresentationAttributes.setFill(*color); 40 fPresentationAttributes.setFill(*color);
42 } 41 }
43 break; 42 break;
44 case SkSVGAttribute::kStroke: 43 case SkSVGAttribute::kStroke:
45 if (const SkSVGColorValue* color = v.as<SkSVGColorValue>()) { 44 if (const SkSVGColorValue* color = v.as<SkSVGColorValue>()) {
46 fPresentationAttributes.setStroke(*color); 45 fPresentationAttributes.setStroke(*color);
47 } 46 }
48 break; 47 break;
49 default: 48 default:
50 SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag); 49 SkDebugf("attribute ID <%d> ignored for node <%d>\n", attr, fTag);
51 break; 50 break;
52 } 51 }
53 } 52 }
54
55 const SkMatrix& SkSVGNode::onLocalMatrix() const {
56 return SkMatrix::I();
57 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGNode.h ('k') | experimental/svg/model/SkSVGRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698