diff options
author | Mike Reed <reed@google.com> | 2017-01-19 11:36:41 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-19 18:31:28 +0000 |
commit | 3726a4ac68821deea7ef4d5472a42f7d35ec4b4e (patch) | |
tree | 1caa4c84140921e0a90157a65bca6cf5ebb20942 /tests/CanvasStateTest.cpp | |
parent | fbff3297876a7c9c77a48be9a6fe62274a58bd8c (diff) |
new hacky api to get cliprgn for android
BUG=skia:
Change-Id: I42711a474906084adb3c888a599ae02505726484
Reviewed-on: https://skia-review.googlesource.com/7220
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests/CanvasStateTest.cpp')
-rw-r--r-- | tests/CanvasStateTest.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp index 9533474c56..38fb3fe8bc 100644 --- a/tests/CanvasStateTest.cpp +++ b/tests/CanvasStateTest.cpp @@ -306,9 +306,11 @@ DEF_TEST(CanvasState_test_soft_clips, reporter) { REPORTER_ASSERT(reporter, !state); } -#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG -#include "SkClipStack.h" DEF_TEST(CanvasState_test_saveLayer_clip, reporter) { + const uint32_t dontSaveFlag = 1 << 31; // secret flag for don't save +#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG + static_assert(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag == dontSaveFlag, ""); +#endif const int WIDTH = 100; const int HEIGHT = 100; const int LAYER_WIDTH = 50; @@ -321,31 +323,21 @@ DEF_TEST(CanvasState_test_saveLayer_clip, reporter) { SkRect bounds = SkRect::MakeWH(SkIntToScalar(LAYER_WIDTH), SkIntToScalar(LAYER_HEIGHT)); canvas.clipRect(SkRect::MakeWH(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT))); - // Check that saveLayer without the kClipToLayer_SaveFlag leaves the - // clip stack unchanged. - canvas.saveLayer(SkCanvas::SaveLayerRec(&bounds, - nullptr, - SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag)); - SkRect clipStackBounds; - SkClipStack::BoundsType boundsType; - canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); - // The clip stack will return its bounds, or it may be "full" : i.e. empty + inside_out. - // Either result is consistent with this test, since the canvas' size is WIDTH/HEIGHT - if (SkClipStack::kInsideOut_BoundsType == boundsType) { - REPORTER_ASSERT(reporter, clipStackBounds.isEmpty()); - } else { - REPORTER_ASSERT(reporter, clipStackBounds.width() == WIDTH); - REPORTER_ASSERT(reporter, clipStackBounds.height() == HEIGHT); - } + SkIRect devClip; + // Check that saveLayer without the kClipToLayer_SaveFlag leaves the clip unchanged. + canvas.saveLayer(SkCanvas::SaveLayerRec(&bounds, nullptr, dontSaveFlag)); + canvas.getClipDeviceBounds(&devClip); + REPORTER_ASSERT(reporter, canvas.isClipRect()); + REPORTER_ASSERT(reporter, devClip.width() == WIDTH); + REPORTER_ASSERT(reporter, devClip.height() == HEIGHT); canvas.restore(); // Check that saveLayer with the kClipToLayer_SaveFlag sets the clip // stack to the layer bounds. canvas.saveLayer(&bounds, nullptr); - canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); - REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH); - REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT); - + canvas.getClipDeviceBounds(&devClip); + REPORTER_ASSERT(reporter, canvas.isClipRect()); + REPORTER_ASSERT(reporter, devClip.width() == LAYER_WIDTH); + REPORTER_ASSERT(reporter, devClip.height() == LAYER_HEIGHT); canvas.restore(); } -#endif |