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

Unified Diff: experimental/svg/model/SkSVGRect.cpp

Issue 2234863002: [SVGDom] Add rx/ry support for <rect> (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/svg/model/SkSVGRect.h ('k') | experimental/svg/model/SkSVGShape.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/svg/model/SkSVGRect.cpp
diff --git a/experimental/svg/model/SkSVGRect.cpp b/experimental/svg/model/SkSVGRect.cpp
index b65c2b9974b0a99ac8d04fa9980042e5ebffaa33..cbb18306a58f1f358a8a46464423abee46879789 100644
--- a/experimental/svg/model/SkSVGRect.cpp
+++ b/experimental/svg/model/SkSVGRect.cpp
@@ -29,6 +29,14 @@ void SkSVGRect::setHeight(const SkSVGLength& h) {
fHeight = h;
}
+void SkSVGRect::setRx(const SkSVGLength& rx) {
+ fRx = rx;
+}
+
+void SkSVGRect::setRy(const SkSVGLength& ry) {
+ fRy = ry;
+}
+
void SkSVGRect::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
switch (attr) {
case SkSVGAttribute::kX:
@@ -51,6 +59,16 @@ void SkSVGRect::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
this->setHeight(*h);
}
break;
+ case SkSVGAttribute::kRx:
+ if (const auto* rx = v.as<SkSVGLengthValue>()) {
+ this->setRx(*rx);
+ }
+ break;
+ case SkSVGAttribute::kRy:
+ if (const auto* ry = v.as<SkSVGLengthValue>()) {
+ this->setRy(*ry);
+ }
+ break;
default:
this->INHERITED::onSetAttribute(attr, v);
}
@@ -58,5 +76,13 @@ void SkSVGRect::onSetAttribute(SkSVGAttribute attr, const SkSVGValue& v) {
void SkSVGRect::onDraw(SkCanvas* canvas, const SkSVGLengthContext& lctx,
const SkPaint& paint) const {
- canvas->drawRect(lctx.resolveRect(fX, fY, fWidth, fHeight), paint);
+ const SkRect rect = lctx.resolveRect(fX, fY, fWidth, fHeight);
+ const SkScalar rx = lctx.resolve(fRx, SkSVGLengthContext::LengthType::kHorizontal);
+ const SkScalar ry = lctx.resolve(fRy, SkSVGLengthContext::LengthType::kVertical);
+
+ if (rx || ry) {
+ canvas->drawRRect(SkRRect::MakeRectXY(rect, rx, ry), paint);
+ } else {
+ canvas->drawRect(rect, paint);
+ }
}
« no previous file with comments | « experimental/svg/model/SkSVGRect.h ('k') | experimental/svg/model/SkSVGShape.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698