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

Side by Side Diff: experimental/svg/model/SkSVGEllipse.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/SkSVGEllipse.h ('k') | experimental/svg/model/SkSVGNode.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 "SkCanvas.h"
9 #include "SkSVGEllipse.h"
10 #include "SkSVGRenderContext.h"
11 #include "SkSVGValue.h"
12
13 SkSVGEllipse::SkSVGEllipse() : INHERITED(SkSVGTag::kEllipse) {}
14
15 void SkSVGEllipse::setCx(const SkSVGLength& cx) {
16 fCx = cx;
17 }
18
19 void SkSVGEllipse::setCy(const SkSVGLength& cy) {
20 fCy = cy;
21 }
22
23 void SkSVGEllipse::setRx(const SkSVGLength& rx) {
24 fRx = rx;
25 }
26
27 void SkSVGEllipse::setRy(const SkSVGLength& ry) {
28 fRy = ry;
29 }
30
31 void SkSVGEllipse::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
32 switch (attr) {
33 case SkSVGAttribute::kCx:
34 if (const auto* cx = v.as<SkSVGLengthValue>()) {
35 this->setCx(*cx);
36 }
37 break;
38 case SkSVGAttribute::kCy:
39 if (const auto* cy = v.as<SkSVGLengthValue>()) {
40 this->setCy(*cy);
41 }
42 break;
43 case SkSVGAttribute::kRx:
44 if (const auto* rx = v.as<SkSVGLengthValue>()) {
45 this->setRx(*rx);
46 }
47 break;
48 case SkSVGAttribute::kRy:
49 if (const auto* ry = v.as<SkSVGLengthValue>()) {
50 this->setRy(*ry);
51 }
52 break;
53 default:
54 this->INHERITED::onSetAttribute(attr, v);
55 }
56 }
57
58 void SkSVGEllipse::onDraw(SkCanvas* canvas, const SkSVGLengthContext& lctx,
59 const SkPaint& paint) const {
60 const auto cx = lctx.resolve(fCx, SkSVGLengthContext::LengthType::kHorizonta l);
61 const auto cy = lctx.resolve(fCy, SkSVGLengthContext::LengthType::kVertical) ;
62 const auto rx = lctx.resolve(fRx, SkSVGLengthContext::LengthType::kHorizonta l);
63 const auto ry = lctx.resolve(fRy, SkSVGLengthContext::LengthType::kVertical) ;
64
65 if (rx > 0 && ry > 0) {
66 canvas->drawOval(SkRect::MakeXYWH(cx - rx / 2, cy - ry / 2, rx * 2, ry * 2), paint);
67 }
68 }
OLDNEW
« no previous file with comments | « experimental/svg/model/SkSVGEllipse.h ('k') | experimental/svg/model/SkSVGNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698