aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/complexclip.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-12-17 14:38:49 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-17 14:38:49 -0800
commit6ae83cf7f633c3aa101b66509ab29a61592e1980 (patch)
tree0056a1ef75a554fcd4b5170fbf43ff220d7bd91a /gm/complexclip.cpp
parentbb63cb7d1c4d19bbd07383db97932b34575b5574 (diff)
add inverted path draw cases to complexclip gm
Diffstat (limited to 'gm/complexclip.cpp')
-rw-r--r--gm/complexclip.cpp53
1 files changed, 33 insertions, 20 deletions
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 61a19fd486..ebb7707c9c 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -18,14 +18,12 @@ static const SkColor gClipAColor = SK_ColorBLUE;
static const SkColor gClipBColor = SK_ColorRED;
class ComplexClipGM : public GM {
- bool fDoAAClip;
- bool fDoSaveLayer;
public:
- ComplexClipGM(bool aaclip, bool saveLayer)
+ ComplexClipGM(bool aaclip, bool saveLayer, bool invertDraw)
: fDoAAClip(aaclip)
- , fDoSaveLayer(saveLayer) {
+ , fDoSaveLayer(saveLayer)
+ , fInvertDraw(invertDraw) {
this->setBGColor(0xFFDDDDDD);
-// this->setBGColor(SkColorSetRGB(0xB0,0xDD,0xB0));
}
protected:
@@ -36,9 +34,10 @@ protected:
SkString onShortName() {
SkString str;
- str.printf("complexclip_%s%s",
+ str.printf("complexclip_%s%s%s",
fDoAAClip ? "aa" : "bw",
- fDoSaveLayer ? "_layer" : "");
+ fDoSaveLayer ? "_layer" : "",
+ fInvertDraw ? "_invert" : "");
return str;
}
@@ -60,7 +59,11 @@ protected:
path.quadTo(SkIntToScalar(150), SkIntToScalar(150), SkIntToScalar(125), SkIntToScalar(150));
path.lineTo(SkIntToScalar(50), SkIntToScalar(150));
path.close();
- path.setFillType(SkPath::kEvenOdd_FillType);
+ if (fInvertDraw) {
+ path.setFillType(SkPath::kInverseEvenOdd_FillType);
+ } else {
+ path.setFillType(SkPath::kEvenOdd_FillType);
+ }
SkPaint pathPaint;
pathPaint.setAntiAlias(true);
pathPaint.setColor(gPathColor);
@@ -134,6 +137,16 @@ protected:
canvas->clipPath(clipA, SkRegion::kIntersect_Op, fDoAAClip);
canvas->clipPath(clipB, gOps[op].fOp, fDoAAClip);
+ // In the inverse case we need to prevent the draw from covering the whole
+ // canvas.
+ if (fInvertDraw) {
+ SkRect rectClip = clipA.getBounds();
+ rectClip.join(path.getBounds());
+ rectClip.join(path.getBounds());
+ rectClip.outset(5, 5);
+ canvas->clipRect(rectClip);
+ }
+
// draw path clipped
canvas->drawPath(path, pathPaint);
canvas->restore();
@@ -181,22 +194,22 @@ private:
canvas->drawPath(clipB, paint);
}
+ bool fDoAAClip;
+ bool fDoSaveLayer;
+ bool fInvertDraw;
+
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
-// aliased and anti-aliased w/o a layer
-static GM* gFact0(void*) { return new ComplexClipGM(false, false); }
-static GM* gFact1(void*) { return new ComplexClipGM(true, false); }
-
-// aliased and anti-aliased w/ a layer
-static GM* gFact2(void*) { return new ComplexClipGM(false, true); }
-static GM* gFact3(void*) { return new ComplexClipGM(true, true); }
-
-static GMRegistry gReg0(gFact0);
-static GMRegistry gReg1(gFact1);
-static GMRegistry gReg2(gFact2);
-static GMRegistry gReg3(gFact3);
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, false, false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, false, true)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, true, false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, true, true)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, false, false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, false, true)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, true, false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true, true, true)); )
}