#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG to get the old behavior
The goal is to remove the feature of saveLayer that allows the canvas to draw outside of the top-most layer.
R=robertphillips@google.com, scroggo@google.com
Review URL: https://codereview.chromium.org/
190723004
git-svn-id: http://skia.googlecode.com/svn/trunk@13730
2bbb7eff-a529-9590-31e7-
b0007b416f81
bezier_quad_effects
bezier_conic_effects
bezier_cubic_effects
+
+# reed: https://codereview.chromium.org/190723004/
+# This change removes an API that this GM was testing. If/when it lands and sticks,
+# I will likely just delete the GM.
+canvas-layer-state
+
// clear the canvas to red
canvas->drawColor(SK_ColorRED);
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
// both rects should appear
drawTestPattern(canvas, 255, SkCanvas::kARGB_NoClipLayer_SaveFlag);
// only the bottom rect should appear
drawTestPattern(canvas, 0, SkCanvas::kARGB_NoClipLayer_SaveFlag);
+#endif
}
virtual uint32_t onGetFlags() const SK_OVERRIDE { return kSkipGPU_Flag; }
#include "SkRegion.h"
#include "SkXfermode.h"
+// if not defined, we always assume ClipToLayer for saveLayer()
+//#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
+
+
//#define SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
//#define SK_SUPPORT_LEGACY_GETCLIPTYPE
//#define SK_SUPPORT_LEGACY_GETTOTALCLIP
kHasAlphaLayer_SaveFlag = 0x04,
/** the layer needs to support 8-bits per color component */
kFullColorLayer_SaveFlag = 0x08,
- /** the layer should clip against the bounds argument */
+ /**
+ * the layer should clip against the bounds argument
+ *
+ * if SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG is undefined, this is treated as always on.
+ */
kClipToLayer_SaveFlag = 0x10,
// helper masks for common choices
kMatrixClip_SaveFlag = 0x03,
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
kARGB_NoClipLayer_SaveFlag = 0x0F,
+#endif
kARGB_ClipLayer_SaveFlag = 0x1F
};
}
static bool bounds_affects_clip(SkCanvas::SaveFlags flags) {
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
return (flags & SkCanvas::kClipToLayer_SaveFlag) != 0;
+#else
+ return true;
+#endif
}
bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags,
int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags, bool justForImageFilter) {
+#ifndef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
+ flags = (SaveFlags)(flags | kClipToLayer_SaveFlag);
+#endif
+
// do this before we create the layer. We don't call the public save() since
// that would invoke a possibly overridden virtual
int count = this->internalSave(flags);
#include "Test.h"
static void test_complex_layers(skiatest::Reporter* reporter) {
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
const int WIDTH = 400;
const int HEIGHT = 400;
const int SPACER = 10;
bitmaps[1].getPixels(),
bitmaps[0].getSize()));
}
+#endif
}
////////////////////////////////////////////////////////////////////////////////
static void test_complex_clips(skiatest::Reporter* reporter) {
-
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
const int WIDTH = 400;
const int HEIGHT = 400;
const int SPACER = 10;
REPORTER_ASSERT(reporter, !memcmp(bitmaps[0].getPixels(),
bitmaps[1].getPixels(),
bitmaps[0].getSize()));
+#endif
}
////////////////////////////////////////////////////////////////////////////////
}
static void test_saveLayer_clip(skiatest::Reporter* reporter) {
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
const int WIDTH = 100;
const int HEIGHT = 100;
const int LAYER_WIDTH = 50;
REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT);
canvas.restore();
+#endif
}
DEF_TEST(CanvasState, reporter) {