Widen the set of nested rects that can be drawn natively on the GPU
authorrobertphillips <robertphillips@google.com>
Tue, 21 Oct 2014 18:25:37 +0000 (11:25 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 21 Oct 2014 18:25:37 +0000 (11:25 -0700)
GrAARectRenderer::fillAANestedRects only handles thin stroked rects correctly if the margins are all the same. It is also correct if all the margins are >= 1.0f. This CL allows such cases to use the fillAANestedRects fast path.

This seems to halve the gpu rendering time of the picture in bug crbug.com/425427.

Review URL: https://codereview.chromium.org/672473002

src/gpu/GrAARectRenderer.cpp
src/gpu/GrContext.cpp

index 2db42cc..edc8f71 100644 (file)
@@ -858,7 +858,7 @@ void GrAARectRenderer::geometryStrokeAARect(GrGpu* gpu,
 
 #ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
     // TODO: this only really works if the X & Y margins are the same all around
-    // the rect
+    // the rect (or if they are all >= 1.0).
     SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight);
     inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft);
     inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop);
index 6ad98ff..b4bcfd3 100755 (executable)
@@ -1082,15 +1082,22 @@ static bool is_nested_rects(GrDrawTarget* target,
     const SkScalar* outer = rects[0].asScalars();
     const SkScalar* inner = rects[1].asScalars();
 
+    bool allEq = true;
+
     SkScalar margin = SkScalarAbs(outer[0] - inner[0]);
+    bool allGoE1 = margin >= SK_Scalar1;
+
     for (int i = 1; i < 4; ++i) {
         SkScalar temp = SkScalarAbs(outer[i] - inner[i]);
+        if (temp < SK_Scalar1) {
+            allGoE1 = false;
+        }
         if (!SkScalarNearlyEqual(margin, temp)) {
-            return false;
+            allEq = false;
         }
     }
 
-    return true;
+    return allEq || allGoE1;
 }
 
 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const GrStrokeInfo& strokeInfo) {