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

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

Issue 2249033003: [SVGDom] Add <circle>, <ellipse> support (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review 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/SkSVGCircle.h ('k') | experimental/svg/model/SkSVGDOM.cpp » ('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 "SkCanvas.h"
9 #include "SkSVGCircle.h"
10 #include "SkSVGRenderContext.h"
11 #include "SkSVGValue.h"
12
13 SkSVGCircle::SkSVGCircle() : INHERITED(SkSVGTag::kCircle) {}
14
15 void SkSVGCircle::setCx(const SkSVGLength& cx) {
16 fCx = cx;
17 }
18
19 void SkSVGCircle::setCy(const SkSVGLength& cy) {
20 fCy = cy;
21 }
22
23 void SkSVGCircle::setR(const SkSVGLength& r) {
24 fR = r;
25 }
26
27 void SkSVGCircle::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
28 switch (attr) {
29 case SkSVGAttribute::kCx:
30 if (const auto* cx = v.as<SkSVGLengthValue>()) {
31 this->setCx(*cx);
32 }
33 break;
34 case SkSVGAttribute::kCy:
35 if (const auto* cy = v.as<SkSVGLengthValue>()) {
36 this->setCy(*cy);
37 }
38 break;
39 case SkSVGAttribute::kR:
40 if (const auto* r = v.as<SkSVGLengthValue>()) {
41 this->setR(*r);
42 }
43 break;
44 default:
45 this->INHERITED::onSetAttribute(attr, v);
46 }
47 }
48
49 void SkSVGCircle::onDraw(SkCanvas* canvas, const SkSVGLengthContext& lctx,
50 const SkPaint& paint) const {
51 const auto cx = lctx.resolve(fCx, SkSVGLengthContext::LengthType::kHorizonta l);
52 const auto cy = lctx.resolve(fCy, SkSVGLengthContext::LengthType::kVertical) ;
53 const auto r = lctx.resolve(fR , SkSVGLengthContext::LengthType::kOther);
54
55 if (r > 0) {
56 canvas->drawCircle(cx, cy, r, paint);
57 }
58 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGCircle.h ('k') | experimental/svg/model/SkSVGDOM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698