| Index: gm/complexclip2.cpp
|
| diff --git a/gm/complexclip2.cpp b/gm/complexclip2.cpp
|
| index 0e8e0bc116301b65c787bf688c2c67b9ce91cb70..2b94ffd661fd091ca2d71556b7af982c7e62c317 100644
|
| --- a/gm/complexclip2.cpp
|
| +++ b/gm/complexclip2.cpp
|
| @@ -15,8 +15,14 @@ namespace skiagm {
|
|
|
| class ComplexClip2GM : public GM {
|
| public:
|
| - ComplexClip2GM(bool doPaths, bool antiAlias)
|
| - : fDoPaths(doPaths)
|
| + enum Clip {
|
| + kRect_Clip,
|
| + kRRect_Clip,
|
| + kPath_Clip
|
| + };
|
| +
|
| + ComplexClip2GM(Clip clip, bool antiAlias)
|
| + : fClip(clip)
|
| , fAntiAlias(antiAlias) {
|
| this->setBGColor(SkColorSetRGB(0xDD,0xA0,0xDD));
|
|
|
| @@ -39,23 +45,28 @@ public:
|
| fHeight = yF - yA;
|
|
|
| fRects[0].set(xB, yB, xE, yE);
|
| - fPaths[0].addRoundRect(fRects[0], SkIntToScalar(5), SkIntToScalar(5));
|
| + fRRects[0].setRectXY(fRects[0], 7, 7);
|
| + fPaths[0].addRoundRect(fRects[0], 5, 5);
|
| fRectColors[0] = SK_ColorRED;
|
|
|
| fRects[1].set(xA, yA, xD, yD);
|
| - fPaths[1].addRoundRect(fRects[1], SkIntToScalar(5), SkIntToScalar(5));
|
| + fRRects[1].setRectXY(fRects[1], 7, 7);
|
| + fPaths[1].addRoundRect(fRects[1], 5, 5);
|
| fRectColors[1] = SK_ColorGREEN;
|
|
|
| fRects[2].set(xC, yA, xF, yD);
|
| - fPaths[2].addRoundRect(fRects[2], SkIntToScalar(5), SkIntToScalar(5));
|
| + fRRects[2].setRectXY(fRects[2], 7, 7);
|
| + fPaths[2].addRoundRect(fRects[2], 5, 5);
|
| fRectColors[2] = SK_ColorBLUE;
|
|
|
| fRects[3].set(xA, yC, xD, yF);
|
| - fPaths[3].addRoundRect(fRects[3], SkIntToScalar(5), SkIntToScalar(5));
|
| + fRRects[3].setRectXY(fRects[3], 7, 7);
|
| + fPaths[3].addRoundRect(fRects[3], 5, 5);
|
| fRectColors[3] = SK_ColorYELLOW;
|
|
|
| fRects[4].set(xC, yC, xF, yF);
|
| - fPaths[4].addRoundRect(fRects[4], SkIntToScalar(5), SkIntToScalar(5));
|
| + fRRects[4].setRectXY(fRects[4], 7, 7);
|
| + fPaths[4].addRoundRect(fRects[4], 5, 5);
|
| fRectColors[4] = SK_ColorCYAN;
|
|
|
| fTotalWidth = kCols * fWidth + SK_Scalar1 * (kCols + 1) * kPadX;
|
| @@ -87,14 +98,27 @@ protected:
|
| static const int kPadX = 20;
|
| static const int kPadY = 20;
|
|
|
| + static const char* ClipStr(Clip clip) {
|
| + switch (clip) {
|
| + case kRect_Clip:
|
| + return "rect";
|
| + case kRRect_Clip:
|
| + return "rrect";
|
| + case kPath_Clip:
|
| + return "path";
|
| + }
|
| + SkDEBUGFAIL("Unknown clip type.");
|
| + return "";
|
| + }
|
| +
|
| virtual SkString onShortName() {
|
| - if (!fDoPaths && !fAntiAlias) {
|
| + if (kRect_Clip == fClip && !fAntiAlias) {
|
| return SkString("complexclip2");
|
| }
|
|
|
| SkString str;
|
| str.printf("complexclip2_%s_%s",
|
| - fDoPaths ? "path" : "rect",
|
| + ClipStr(fClip),
|
| fAntiAlias ? "aa" : "bw");
|
| return str;
|
| }
|
| @@ -123,22 +147,36 @@ protected:
|
| // antialiasing on the clipped draw
|
| for (int k = 0; k < 5; ++k) {
|
| rectPaint.setColor(fRectColors[k]);
|
| - if (fDoPaths) {
|
| - canvas->drawPath(fPaths[k], rectPaint);
|
| - } else {
|
| - canvas->drawRect(fRects[k], rectPaint);
|
| + switch (fClip) {
|
| + case kRect_Clip:
|
| + canvas->drawRect(fRects[k], rectPaint);
|
| + break;
|
| + case kRRect_Clip:
|
| + canvas->drawRRect(fRRects[k], rectPaint);
|
| + break;
|
| + case kPath_Clip:
|
| + canvas->drawPath(fPaths[k], rectPaint);
|
| + break;
|
| }
|
| }
|
|
|
| for (int k = 0; k < 5; ++k) {
|
| - if (fDoPaths) {
|
| - canvas->clipPath(fPaths[k],
|
| - fOps[j*kRows+i][k],
|
| - fAntiAlias);
|
| - } else {
|
| - canvas->clipRect(fRects[k],
|
| - fOps[j*kRows+i][k],
|
| - fAntiAlias);
|
| + switch (fClip) {
|
| + case kRect_Clip:
|
| + canvas->clipRect(fRects[k],
|
| + fOps[j*kRows+i][k],
|
| + fAntiAlias);
|
| + break;
|
| + case kRRect_Clip:
|
| + canvas->clipRRect(fRRects[k],
|
| + fOps[j*kRows+i][k],
|
| + fAntiAlias);
|
| + break;
|
| + case kPath_Clip:
|
| + canvas->clipPath(fPaths[k],
|
| + fOps[j*kRows+i][k],
|
| + fAntiAlias);
|
| + break;
|
| }
|
| }
|
| canvas->drawRect(SkRect::MakeWH(fWidth, fHeight), fillPaint);
|
| @@ -147,9 +185,10 @@ protected:
|
| }
|
| }
|
| private:
|
| - bool fDoPaths;
|
| + Clip fClip;
|
| bool fAntiAlias;
|
| SkRect fRects[5];
|
| + SkRRect fRRects[5];
|
| SkPath fPaths[5];
|
| SkColor fRectColors[5];
|
| SkRegion::Op fOps[kRows * kCols][5];
|
| @@ -163,20 +202,14 @@ private:
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| -// bw rects
|
| -static GM* MyFactory(void*) { return new ComplexClip2GM(false, false); }
|
| -static GMRegistry reg(MyFactory);
|
| -
|
| -// bw paths
|
| -static GM* MyFactory2(void*) { return new ComplexClip2GM(true, false); }
|
| -static GMRegistry reg2(MyFactory2);
|
| -
|
| -// aa rects
|
| -static GM* MyFactory3(void*) { return new ComplexClip2GM(false, true); }
|
| -static GMRegistry reg3(MyFactory3);
|
| +// bw
|
| +DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRect_Clip, false); )
|
| +DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRRect_Clip, false); )
|
| +DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kPath_Clip, false); )
|
|
|
| -// aa paths
|
| -static GM* MyFactory4(void*) { return new ComplexClip2GM(true, true); }
|
| -static GMRegistry reg4(MyFactory4);
|
| +// aa
|
| +DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRect_Clip, true); )
|
| +DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kRRect_Clip, true); )
|
| +DEF_GM( return new ComplexClip2GM(ComplexClip2GM::kPath_Clip, true); )
|
|
|
| }
|
|
|