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

Unified Diff: src/core/SkDevice.cpp

Issue 424663006: SkCanvas interface for drawing a patch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added array constructor for FwDCubicEvaluator Created 6 years, 5 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
Index: src/core/SkDevice.cpp
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index e71c889451df139dd8e92ed28d9e4a2b57ebf084..153913453e621a4580c7d70f5253ac06b231ba0e 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -6,6 +6,7 @@
*/
#include "SkDevice.h"
+#include "SkDraw.h"
#include "SkMetaData.h"
SkBaseDevice::SkBaseDevice()
@@ -77,6 +78,28 @@ void SkBaseDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
this->drawPath(draw, path, paint, preMatrix, pathIsMutable);
}
+void SkBaseDevice::drawPatch(const SkDraw& draw, const SkPatch& patch, const SkPaint& paint) {
+ SkPatch::VertexData data;
+
+ SkPoint corners[4];
+ patch.getCornerPoints(corners);
+ draw.fMatrix->mapPoints(corners, 4);
+
+ // size in pixels of each partition per axis, adjust this knob
+ int partitionSize = 25;
bsalomon 2014/07/31 17:39:06 static const int kPartitionSize?
dandov 2014/07/31 21:35:40 Done.
+
+ // level of detail per axis, based on the larger side between top and bottom or left and right
+ int lodX = SkMaxScalar(SkScalarAbs(corners[0].x() - corners[1].x()),
bsalomon 2014/07/31 17:39:06 Doesn't this need to be SkScalarSqrt(SkMaxScalar(
dandov 2014/07/31 21:35:40 Completed using an approximate arc length based on
+ SkScalarAbs(corners[3].x() - corners[2].x())) / partitionSize;
+ int lodY = SkMaxScalar(SkScalarAbs(corners[0].y() - corners[3].y()),
+ SkScalarAbs(corners[1].y() - corners[2].y())) / partitionSize;
+
+ // It automatically adjusts lodX and lodY in case it exceeds the number of indices.
+ patch.getVertexData(&data, SkMax32(2, lodX), SkMax32(2, lodY));
+ this->drawVertices(draw, SkCanvas::kTriangles_VertexMode, data.fVertexCount, data.fPoints,
+ data.fTexCoords, data.fColors, NULL, data.fIndices, data.fIndexCount, paint);
+}
+
bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowBytes, int x, int y) {
#ifdef SK_DEBUG
SkASSERT(info.width() > 0 && info.height() > 0);

Powered by Google App Engine
This is Rietveld 408576698