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

Unified Diff: tools/sk_tool_utils.cpp

Issue 2203153002: Add new bench for occluded blurmaskfilter draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Appease compilers 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 | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/sk_tool_utils.cpp
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index 9f398e2fc038a711b359b39384633b529a3f38e0..38880f820433175da57c9ac5df2b911f2d7f0b29 100644
--- a/tools/sk_tool_utils.cpp
+++ b/tools/sk_tool_utils.cpp
@@ -463,4 +463,54 @@ SkBitmap slow_blur(const SkBitmap& src, float sigma) {
return dst;
}
+// compute the intersection point between the diagonal and the ellipse in the
+// lower right corner
+static SkPoint intersection(SkScalar w, SkScalar h) {
+ SkASSERT(w > 0.0f || h > 0.0f);
+
+ return SkPoint::Make(w / SK_ScalarSqrt2, h / SK_ScalarSqrt2);
+}
+
+// Use the intersection of the corners' diagonals with their ellipses to shrink
+// the bounding rect
+SkRect compute_central_occluder(const SkRRect& rr) {
+ const SkRect r = rr.getBounds();
+
+ SkScalar newL = r.fLeft, newT = r.fTop, newR = r.fRight, newB = r.fBottom;
+
+ SkVector radii = rr.radii(SkRRect::kUpperLeft_Corner);
+ if (!radii.isZero()) {
+ SkPoint p = intersection(radii.fX, radii.fY);
+
+ newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
+ newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
+ }
+
+ radii = rr.radii(SkRRect::kUpperRight_Corner);
+ if (!radii.isZero()) {
+ SkPoint p = intersection(radii.fX, radii.fY);
+
+ newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
+ newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
+ }
+
+ radii = rr.radii(SkRRect::kLowerRight_Corner);
+ if (!radii.isZero()) {
+ SkPoint p = intersection(radii.fX, radii.fY);
+
+ newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
+ newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
+ }
+
+ radii = rr.radii(SkRRect::kLowerLeft_Corner);
+ if (!radii.isZero()) {
+ SkPoint p = intersection(radii.fX, radii.fY);
+
+ newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
+ newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
+ }
+
+ return SkRect::MakeLTRB(newL, newT, newR, newB);
+}
+
} // namespace sk_tool_utils
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698