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

Unified Diff: src/svg/SkSVGDevice.cpp

Issue 1127933003: Update SVGDevice for RRect and drawPoints (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/svg/SkSVGDevice.cpp
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index 8d2f18a486a89baca2212cc3878b6bf7bca6ef34..480dd92b384cf01df1fc692f267844c79d46cebb 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -603,10 +603,34 @@ void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
SkIntToScalar(this->height())));
}
-void SkSVGDevice::drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
- const SkPoint[], const SkPaint& paint) {
- // todo
- SkDebugf("unsupported operation: drawPoints()\n");
+void SkSVGDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count,
+ const SkPoint pts[], const SkPaint& paint) {
+ SkPath path;
+
+ switch (mode) {
+ // todo
+ case SkCanvas::kPoints_PointMode:
+ SkDebugf("unsupported operation: drawPoints(kPoints_PointMode)\n");
+ break;
+ case SkCanvas::kLines_PointMode:
+ count -= 1;
+ for (size_t i = 0; i < count; i += 2) {
+ path.rewind();
+ path.moveTo(pts[i]);
+ path.lineTo(pts[i+1]);
+ AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+ elem.addPathAttributes(path);
+ }
+ break;
+ case SkCanvas::kPolygon_PointMode:
+ if (count > 1) {
+ path.addPoly(pts, SkToInt(count), false);
+ path.moveTo(pts[0]);
+ AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+ elem.addPathAttributes(path);
+ }
+ break;
+ }
}
void SkSVGDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) {
@@ -622,9 +646,12 @@ void SkSVGDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
ellipse.addAttribute("ry", oval.height() / 2);
}
-void SkSVGDevice::drawRRect(const SkDraw&, const SkRRect& rr, const SkPaint& paint) {
- // todo
- SkDebugf("unsupported operation: drawRRect()\n");
+void SkSVGDevice::drawRRect(const SkDraw& draw, const SkRRect& rr, const SkPaint& paint) {
+ SkPath path;
+ path.addRRect(rr);
+
+ AutoElement elem("path", fWriter, fResourceBucket, draw, paint);
+ elem.addPathAttributes(path);
}
void SkSVGDevice::drawPath(const SkDraw& draw, const SkPath& path, const SkPaint& paint,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698