Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: tests/CanvasStateTest.cpp

Issue 1610193002: Convert CanvasStateTest to the new saveLayer API (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CanvasStateTest.cpp
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index 4f5fb463e3a3461bd0c22bff432d6977c1e92f8f..bd7c325ca2d2265e2c160cbe317b13823f54ed17 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -14,6 +14,7 @@
#include "SkPaint.h"
#include "SkRRect.h"
#include "SkRect.h"
+#include "SkTLazy.h"
#include "Test.h"
// dlopen and the library flag are only used for tests which require this flag.
@@ -71,9 +72,10 @@ DEF_TEST(CanvasState_test_complex_layers, reporter) {
};
const int layerAlpha[] = { 255, 255, 0 };
- const SkCanvas::SaveFlags flags[] = { SkCanvas::kARGB_NoClipLayer_SaveFlag,
- SkCanvas::kARGB_ClipLayer_SaveFlag,
- SkCanvas::kARGB_NoClipLayer_SaveFlag
+ const SkCanvas::SaveLayerFlags flags[] = {
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
+ 0,
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
};
REPORTER_ASSERT(reporter, sizeof(layerAlpha) == sizeof(flags));
@@ -105,8 +107,13 @@ DEF_TEST(CanvasState_test_complex_layers, reporter) {
canvas.drawColor(SK_ColorRED);
for (size_t k = 0; k < SK_ARRAY_COUNT(layerAlpha); ++k) {
+ SkTLazy<SkPaint> paint;
+ if (layerAlpha[k] != 0xFF) {
+ paint.init()->setAlpha(layerAlpha[k]);
+ }
+
// draw a rect within the layer's bounds and again outside the layer's bounds
- canvas.saveLayerAlpha(&rect, layerAlpha[k], flags[k]);
+ canvas.saveLayer(SkCanvas::SaveLayerRec(&rect, paint.getMaybeNull(), flags[k]));
if (j) {
// Capture from the first Skia.
@@ -172,9 +179,10 @@ DEF_TEST(CanvasState_test_complex_clips, reporter) {
SkRegion::kIntersect_Op,
SkRegion::kReplace_Op,
};
- const SkCanvas::SaveFlags flags[] = { SkCanvas::kARGB_NoClipLayer_SaveFlag,
- SkCanvas::kARGB_ClipLayer_SaveFlag,
- SkCanvas::kARGB_NoClipLayer_SaveFlag,
+ const SkCanvas::SaveLayerFlags flags[] = {
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
+ 0,
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
};
REPORTER_ASSERT(reporter, sizeof(clipOps) == sizeof(flags));
@@ -205,9 +213,11 @@ DEF_TEST(CanvasState_test_complex_clips, reporter) {
SkRegion localRegion = clipRegion;
+ SkPaint paint;
+ paint.setAlpha(128);
for (size_t j = 0; j < SK_ARRAY_COUNT(flags); ++j) {
SkRect layerBounds = SkRect::Make(layerRect);
- canvas.saveLayerAlpha(&layerBounds, 128, flags[j]);
+ canvas.saveLayer(SkCanvas::SaveLayerRec(&layerBounds, &paint, flags[j]));
if (i) {
SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
@@ -318,7 +328,9 @@ DEF_TEST(CanvasState_test_saveLayer_clip, reporter) {
// Check that saveLayer without the kClipToLayer_SaveFlag leaves the
// clip stack unchanged.
- canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ canvas.saveLayer(SkCanvas::SaveLayerRec(&bounds,
+ nullptr,
+ SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag));
SkRect clipStackBounds;
SkClipStack::BoundsType boundsType;
canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
@@ -334,7 +346,7 @@ DEF_TEST(CanvasState_test_saveLayer_clip, reporter) {
// Check that saveLayer with the kClipToLayer_SaveFlag sets the clip
// stack to the layer bounds.
- canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas.saveLayer(&bounds, nullptr);
canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH);
REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698