Stopped skipping tests in dm of SkPatch by implementing the
corresponding drawPath calls on classes that derive from SkCanvas.
BUG=skia:
R=egdaniel@google.com, bsalomon@google.com, mtklein@google.com, robertphillips@google.com
Author: dandov@google.com
Review URL: https://codereview.chromium.org/429343004
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 2820bac..17a1f6c 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -917,7 +917,9 @@
}
void SkDeferredCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) {
- //TODO
+ AutoImmediateDrawIfNeeded autoDraw(*this, &paint);
+ this->drawingCanvas()->drawPatch(patch, paint);
+ this->recordedDrawCommand();
}
SkDrawFilter* SkDeferredCanvas::setDrawFilter(SkDrawFilter* filter) {
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index b12928f..3c683e6 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -442,6 +442,19 @@
SkScalarToFloat(vertices[0].fY));
}
+void SkDumpCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) {
+ const SkPoint* points = patch.getControlPoints();
+ const SkColor* color = patch.getColors();
+ //dumps corner points and colors in clockwise order starting on upper-left corner
+ this->dump(kDrawPatch_Verb, &paint, "drawPatch(Vertices{[%f, %f], [%f, %f], [%f, %f], [%f, %f]}\
+ | Colors{[0x%x], [0x%x], [0x%x], [0x%x]})",
+ points[SkPatch::kTopP0_CubicCtrlPts].fX, points[SkPatch::kTopP0_CubicCtrlPts].fY,
+ points[SkPatch::kTopP3_CubicCtrlPts].fX, points[SkPatch::kTopP3_CubicCtrlPts].fY,
+ points[SkPatch::kBottomP3_CubicCtrlPts].fX,points[SkPatch::kBottomP3_CubicCtrlPts].fY,
+ points[SkPatch::kBottomP0_CubicCtrlPts].fX,points[SkPatch::kBottomP0_CubicCtrlPts].fY,
+ color[0], color[1], color[2], color[3]);
+}
+
void SkDumpCanvas::drawData(const void* data, size_t length) {
// this->dump(kDrawData_Verb, NULL, "drawData(%d)", length);
this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length,
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index 11e4a65..b33c99e 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -284,6 +284,13 @@
}
}
+void SkNWayCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) {
+ Iter iter(fList);
+ while (iter.next()) {
+ iter->drawPatch(patch, paint);
+ }
+}
+
void SkNWayCanvas::drawData(const void* data, size_t length) {
Iter iter(fList);
while (iter.next()) {
diff --git a/src/utils/SkPatchUtils.cpp b/src/utils/SkPatchUtils.cpp
index 7dd0a09..ab15290 100644
--- a/src/utils/SkPatchUtils.cpp
+++ b/src/utils/SkPatchUtils.cpp
@@ -7,10 +7,8 @@
#include "SkPatchUtils.h"
-#include "SkGeometry.h"
-
// size in pixels of each partition per axis, adjust this knob
-static const int kPartitionSize = 30;
+static const int kPartitionSize = 15;
/**
* Calculate the approximate arc length given a bezier curve's control points.
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index 3aa459c..1029f40 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -149,6 +149,10 @@
xmode, indices, indexCount, paint);
}
+void SkProxyCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) {
+ fProxy->drawPatch(patch, paint);
+}
+
void SkProxyCanvas::drawData(const void* data, size_t length) {
fProxy->drawData(data, length);
}