From 2e5b4c52c59f838af0e0a2e5550dcffa4d3756cd Mon Sep 17 00:00:00 2001 From: robertphillips Date: Tue, 19 May 2015 04:35:38 -0700 Subject: 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 --- gm/nested.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'gm/nested.cpp') diff --git a/gm/nested.cpp b/gm/nested.cpp index 3dd2c2c27e..518a864613 100644 --- a/gm/nested.cpp +++ b/gm/nested.cpp @@ -14,7 +14,7 @@ namespace skiagm { // 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 @@ protected: SkString onShortName() override { SkString name("nested"); + if (fFlipped) { + name.append("_flipY"); + } if (fDoAA) { name.append("_aa"); } else { @@ -87,9 +90,8 @@ protected: } } - 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 @@ protected: 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 @@ private: 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); ) } -- cgit v1.2.3