aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-12-22 11:58:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-22 11:58:30 -0800
commitd990e2f14f14c36c3d0beb303dd0953c7aa1fcfa (patch)
tree28b10e1df0c6709bff31faff6a4535d4734c6693
parent39edf7664f50b6c890b933b5bbed67a8735b349b (diff)
add testing flag to ignore saveLayer bounds
-rw-r--r--include/core/SkCanvas.h4
-rw-r--r--src/core/SkCanvas.cpp14
-rw-r--r--tests/PictureTest.cpp2
-rw-r--r--tests/RecordDrawTest.cpp8
-rw-r--r--tests/RecordOptsTest.cpp4
5 files changed, 27 insertions, 5 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 3bf3250a0e..c5494727fe 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -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&);
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 751fabd666..c7fb2dd47f 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -34,6 +34,14 @@
#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);
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index b98cc4680e..a66185b95b 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -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);
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index e830af4b43..d306cad6e9 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -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){
diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp
index cdc0350e53..dd5035b216 100644
--- a/tests/RecordOptsTest.cpp
+++ b/tests/RecordOptsTest.cpp
@@ -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);