Fix GrAARectRenderer's handling of unsorted nested rects
What is going on here is that, after the mapPoints in fillAANestedRects, devInside was upside down so the isEmpty check was always firing. I don't see why we need to avoid having devInside sorted.
BUG=488103
Review URL: https://codereview.chromium.org/1135753004
diff --git a/gm/nested.cpp b/gm/nested.cpp
index 3dd2c2c..518a864 100644
--- a/gm/nested.cpp
+++ b/gm/nested.cpp
@@ -14,7 +14,7 @@
// Test out various combinations of nested rects, ovals and rrects.
class NestedGM : public GM {
public:
- NestedGM(bool doAA) : fDoAA(doAA) {
+ NestedGM(bool doAA, bool flipped) : fDoAA(doAA), fFlipped(flipped) {
this->setBGColor(0xFFDDDDDD);
}
@@ -22,6 +22,9 @@
SkString onShortName() override {
SkString name("nested");
+ if (fFlipped) {
+ name.append("_flipY");
+ }
if (fDoAA) {
name.append("_aa");
} else {
@@ -87,9 +90,8 @@
}
}
- canvas->translate(2, 2);
+ SkScalar xOff = 2, yOff = 2;
for (int outerShape = 0; outerShape < kShapeCount; ++outerShape) {
- canvas->save();
for (int innerShape = 0; innerShape < kShapeCount; ++innerShape) {
for (size_t innerRect = 0; innerRect < SK_ARRAY_COUNT(innerRects); ++innerRect) {
SkPath path;
@@ -98,12 +100,23 @@
AddShape(&path, innerRects[innerRect], (Shapes) innerShape,
SkPath::kCCW_Direction);
+ canvas->save();
+ if (fFlipped) {
+ canvas->scale(1.0f, -1.0f);
+ canvas->translate(xOff, -yOff - 40.0f);
+ } else {
+ canvas->translate(xOff, yOff);
+ }
+
canvas->drawPath(path, shapePaint);
- canvas->translate(45, 0);
+ canvas->restore();
+
+ xOff += 45;
}
}
- canvas->restore();
- canvas->translate(0, 45);
+
+ xOff = 2;
+ yOff += 45;
}
}
@@ -113,14 +126,16 @@
static const int kImageHeight = 134;
bool fDoAA;
+ bool fFlipped;
typedef GM INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
-DEF_GM( return new NestedGM(true); )
-DEF_GM( return new NestedGM(false); )
-
+DEF_GM( return new NestedGM(/* doAA = */ true, /* flipped = */ false); )
+DEF_GM( return new NestedGM(/* doAA = */ false, /* flipped = */ false); )
+DEF_GM( return new NestedGM(/* doAA = */ true, /* flipped = */ true); )
+DEF_GM( return new NestedGM(/* doAA = */ false, /* flipped = */ true); )
}