aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-10-21 11:25:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-21 11:25:37 -0700
commit183e98559c2edf6b262fa6c6fff7f3013eb42f5a (patch)
tree77354bab368221af62c4d910b111630165cb3184 /src/gpu
parent484bbe5be63d6c516e8b190634117989de0f9a26 (diff)
Widen the set of nested rects that can be drawn natively on the GPU
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
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrAARectRenderer.cpp2
-rwxr-xr-xsrc/gpu/GrContext.cpp11
2 files changed, 10 insertions, 3 deletions
diff --git a/src/gpu/GrAARectRenderer.cpp b/src/gpu/GrAARectRenderer.cpp
index 2db42ccba8..edc8f71dd9 100644
--- a/src/gpu/GrAARectRenderer.cpp
+++ b/src/gpu/GrAARectRenderer.cpp
@@ -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);
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 6ad98ff0f7..b4bcfd3134 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -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) {