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
#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);
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) {