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));
}
SkString onShortName() {
SkString str;
- str.printf("complexclip_%s", fDoAAClip ? "aa" : "bw");
+ str.printf("complexclip_%s%s",
+ fDoAAClip ? "aa" : "bw",
+ fSaveLayer ? "_layer" : "");
return str;
}
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) {
canvas->restore();
canvas->translate(0, SkIntToScalar(250));
}
+
+ if (fSaveLayer) {
+ canvas->restore();
+ }
}
private:
void drawHairlines(SkCanvas* canvas, const SkPath& path,
//////////////////////////////////////////////////////////////////////////////
-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);
}