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

Unified Diff: src/utils/SkPatchUtils.cpp

Issue 424663006: SkCanvas interface for drawing a patch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Renamed static functions 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
« src/core/SkGeometry.h ('K') | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkPatchUtils.cpp
diff --git a/src/utils/SkPatchUtils.cpp b/src/utils/SkPatchUtils.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5e6a516006b9707e445ddec23649b65fa5bab700
--- /dev/null
+++ b/src/utils/SkPatchUtils.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkPatchUtils.h"
+
+#include "SkGeometry.h"
+
+SkIPoint SkPatchUtils::GetLevelOfDetail(const SkPatch& patch, const SkMatrix* matrix) {
+
+ SkPoint mapPts[12];
+ matrix->mapPoints(mapPts, patch.getControlPoints(), 12);
+
+ // Approximate length of each cubic.
+ SkPoint pts[4];
+ patch.getTopPoints(pts);
+ matrix->mapPoints(pts, 4);
+ int topLength = approx_arc_length(pts, 4);
+
+ patch.getBottomPoints(pts);
+ matrix->mapPoints(pts, 4);
+ int bottomLength = approx_arc_length(pts, 4);
+
+ patch.getLeftPoints(pts);
+ matrix->mapPoints(pts, 4);
+ int leftLength = approx_arc_length(pts, 4);
+
+ patch.getRightPoints(pts);
+ matrix->mapPoints(pts, 4);
+ int rightLength = approx_arc_length(pts, 4);
+
+ // Level of detail per axis, based on the larger side between top and bottom or left and right
+ int lodX = SkMaxScalar(topLength, bottomLength) / kPartitionSize;
+ int lodY = SkMaxScalar(leftLength, rightLength) / kPartitionSize;
+
+ return SkIPoint::Make(SkMax32(4, lodX), SkMax32(4, lodY));
+}
« src/core/SkGeometry.h ('K') | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698