aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-12 13:48:46 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-12 13:48:46 +0000
commit50a69a0727076d6590a23dd0f6501371573c7d28 (patch)
tree6d0189eece12746f03de4877516dfc163bc7bb06 /gm
parent027de226c144d9e6b7a76acb2e904952b5620a5e (diff)
Altered complexclip GM to test out saveLayer w/ a bound and clipping
Diffstat (limited to 'gm')
-rw-r--r--gm/complexclip.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 30bb50b988..3783669b7e 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -19,8 +19,11 @@ static const SkColor gClipBColor = SK_ColorRED;
class ComplexClipGM : public GM {
bool fDoAAClip;
+ bool fSaveLayer;
public:
- ComplexClipGM(bool aaclip) : fDoAAClip(aaclip) {
+ ComplexClipGM(bool aaclip, bool saveLayer)
+ : fDoAAClip(aaclip)
+ , fSaveLayer(saveLayer) {
this->setBGColor(0xFFDDDDDD);
// this->setBGColor(SkColorSetRGB(0xB0,0xDD,0xB0));
}
@@ -29,7 +32,9 @@ protected:
SkString onShortName() {
SkString str;
- str.printf("complexclip_%s", fDoAAClip ? "aa" : "bw");
+ str.printf("complexclip_%s%s",
+ fDoAAClip ? "aa" : "bw",
+ fSaveLayer ? "_layer" : "");
return str;
}
@@ -90,6 +95,15 @@ protected:
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4);
+ if (fSaveLayer) {
+ SkRect bounds = SkRect::MakeXYWH(100, 100, 1000, 750);
+ SkPaint boundPaint;
+ boundPaint.setColor(SK_ColorRED);
+ boundPaint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawRect(bounds, boundPaint);
+ canvas->saveLayer(&bounds, NULL);
+ }
+
for (int invBits = 0; invBits < 4; ++invBits) {
canvas->save();
for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) {
@@ -129,6 +143,10 @@ protected:
canvas->restore();
canvas->translate(0, SkIntToScalar(250));
}
+
+ if (fSaveLayer) {
+ canvas->restore();
+ }
}
private:
void drawHairlines(SkCanvas* canvas, const SkPath& path,
@@ -154,10 +172,17 @@ private:
//////////////////////////////////////////////////////////////////////////////
-static GM* gFact0(void*) { return new ComplexClipGM(false); }
-static GM* gFact1(void*) { return new ComplexClipGM(true); }
+// 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);
}