add testing flag to ignore saveLayer bounds
authorreed <reed@google.com>
Mon, 22 Dec 2014 19:58:30 +0000 (11:58 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 22 Dec 2014 19:58:30 +0000 (11:58 -0800)
BUG=skia:

Review URL: https://codereview.chromium.org/819123003

include/core/SkCanvas.h
src/core/SkCanvas.cpp
tests/PictureTest.cpp
tests/RecordDrawTest.cpp
tests/RecordOptsTest.cpp

index 3bf3250a0ec5b883413f45cb00139a9ca1f87721..c5494727fe50d69aeb10a4726421392b316a728b 100644 (file)
@@ -1142,6 +1142,10 @@ public:
     // don't call
     GrRenderTarget* internal_private_accessTopLayerRenderTarget();
 
+    // don't call
+    static void Internal_Private_SetIgnoreSaveLayerBounds(bool);
+    static bool Internal_Private_GetIgnoreSaveLayerBounds();
+
 protected:
     // default impl defers to getDevice()->newSurface(info)
     virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&);
index 751fabd6664ce9618244900d299b7860886cfa87..c7fb2dd47fd0889990e98192c04e06f8b5129b1d 100644 (file)
 #include "GrRenderTarget.h"
 #endif
 
+static bool gIgnoreSaveLayerBounds;
+void SkCanvas::Internal_Private_SetIgnoreSaveLayerBounds(bool ignore) {
+    gIgnoreSaveLayerBounds = ignore;
+}
+bool SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds() {
+    return gIgnoreSaveLayerBounds;
+}
+
 // experimental for faster tiled drawing...
 //#define SK_ENABLE_CLIP_QUICKREJECT
 
@@ -909,6 +917,9 @@ bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveFlags flags,
 }
 
 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) {
+    if (gIgnoreSaveLayerBounds) {
+        bounds = NULL;
+    }
     SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag);
     fSaveCount += 1;
     this->internalSaveLayer(bounds, paint, kARGB_ClipLayer_SaveFlag, false, strategy);
@@ -916,6 +927,9 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint) {
 }
 
 int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags) {
+    if (gIgnoreSaveLayerBounds) {
+        bounds = NULL;
+    }
     SaveLayerStrategy strategy = this->willSaveLayer(bounds, paint, flags);
     fSaveCount += 1;
     this->internalSaveLayer(bounds, paint, flags, false, strategy);
index b98cc4680e1798e68605a6ef6fe62e5460fc1d45..a66185b95b40649699a418d20bef8a82280ec594 100644 (file)
@@ -974,7 +974,7 @@ static void test_savelayer_extraction(skiatest::Reporter* reporter) {
     }
 
     // Now test out the SaveLayer extraction
-    {
+    if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
         SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey();
 
         const SkPicture::AccelData* data = pict->EXPERIMENTAL_getAccelData(key);
index e830af4b430e6582658ffcd6f0db2fdd7042bb05..d306cad6e9fd936efb1084a4b27b345f26f41fcf 100644 (file)
@@ -275,9 +275,11 @@ DEF_TEST(RecordDraw_SaveLayerBoundsAffectsClipBounds, r) {
     TestBBH bbh;
     SkRecordFillBounds(SkRect::MakeWH(50, 50), record, &bbh);
     REPORTER_ASSERT(r, bbh.fEntries.count() == 3);
-    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[0].bounds, SkRect::MakeLTRB(10, 10, 40, 40)));
-    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[1].bounds, SkRect::MakeLTRB(20, 20, 30, 30)));
-    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[2].bounds, SkRect::MakeLTRB(10, 10, 40, 40)));
+    if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
+        REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[0].bounds, SkRect::MakeLTRB(10, 10, 40, 40)));
+        REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[1].bounds, SkRect::MakeLTRB(20, 20, 30, 30)));
+        REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[2].bounds, SkRect::MakeLTRB(10, 10, 40, 40)));
+    }
 }
 
 DEF_TEST(RecordDraw_drawImage, r){
index cdc0350e535ddfc81450a44a50f78a11ebd5afc4..dd5035b216b66e52f156d4e117f0b9943f8913bc 100644 (file)
@@ -131,7 +131,9 @@ DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) {
     recorder.saveLayer(&bounds, NULL);
         recorder.drawRect(draw, goodDrawPaint);
     recorder.restore();
-    assert_savelayer_restore(r, &record, 0, false);
+    if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
+        assert_savelayer_restore(r, &record, 0, false);
+    }
 
     // SaveLayer/Restore removed: no bounds + no paint = no point.
     recorder.saveLayer(NULL, NULL);