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

Unified Diff: tests/LayerDrawLooperTest.cpp

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comments. Created 6 years, 10 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
Index: tests/LayerDrawLooperTest.cpp
diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp
index a1319a50def8377428edf35713ea88b5c965c2e0..2000826c434bc1f84d5b8423fa90d5c29af2289c 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -50,10 +50,10 @@ static void test_frontToBack(skiatest::Reporter* reporter) {
FakeDevice device;
SkCanvas canvas(&device);
SkPaint paint;
- looper->init(&canvas);
+ SkDrawLooper::DrawContext* context = looper->init(&canvas, NULL, 0);
// The back layer should come first.
- REPORTER_ASSERT(reporter, looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
REPORTER_ASSERT(reporter, SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrc_Mode));
canvas.drawRect(SkRect::MakeWH(50.0f, 50.0f), paint);
REPORTER_ASSERT(reporter, 10.0f == device.fLastMatrix.getTranslateX());
@@ -61,14 +61,15 @@ static void test_frontToBack(skiatest::Reporter* reporter) {
paint.reset();
// Then the front layer.
- REPORTER_ASSERT(reporter, looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
REPORTER_ASSERT(reporter, SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode));
canvas.drawRect(SkRect::MakeWH(50.0f, 50.0f), paint);
REPORTER_ASSERT(reporter, 0.0f == device.fLastMatrix.getTranslateX());
REPORTER_ASSERT(reporter, 0.0f == device.fLastMatrix.getTranslateY());
// Only two layers were added, so that should be the end.
- REPORTER_ASSERT(reporter, !looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, !context->next(&canvas, &paint));
+ context->cleanup(NULL);
}
static void test_backToFront(skiatest::Reporter* reporter) {
@@ -87,10 +88,10 @@ static void test_backToFront(skiatest::Reporter* reporter) {
FakeDevice device;
SkCanvas canvas(&device);
SkPaint paint;
- looper->init(&canvas);
+ SkDrawLooper::DrawContext* context = looper->init(&canvas, NULL, 0);
// The back layer should come first.
- REPORTER_ASSERT(reporter, looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
REPORTER_ASSERT(reporter, SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode));
canvas.drawRect(SkRect::MakeWH(50.0f, 50.0f), paint);
REPORTER_ASSERT(reporter, 0.0f == device.fLastMatrix.getTranslateX());
@@ -98,14 +99,15 @@ static void test_backToFront(skiatest::Reporter* reporter) {
paint.reset();
// Then the front layer.
- REPORTER_ASSERT(reporter, looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
REPORTER_ASSERT(reporter, SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrc_Mode));
canvas.drawRect(SkRect::MakeWH(50.0f, 50.0f), paint);
REPORTER_ASSERT(reporter, 10.0f == device.fLastMatrix.getTranslateX());
REPORTER_ASSERT(reporter, 20.0f == device.fLastMatrix.getTranslateY());
// Only two layers were added, so that should be the end.
- REPORTER_ASSERT(reporter, !looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, !context->next(&canvas, &paint));
+ context->cleanup(NULL);
}
static void test_mixed(skiatest::Reporter* reporter) {
@@ -124,10 +126,10 @@ static void test_mixed(skiatest::Reporter* reporter) {
FakeDevice device;
SkCanvas canvas(&device);
SkPaint paint;
- looper->init(&canvas);
+ SkDrawLooper::DrawContext* context = looper->init(&canvas, NULL, 0);
// The back layer should come first.
- REPORTER_ASSERT(reporter, looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
REPORTER_ASSERT(reporter, SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode));
canvas.drawRect(SkRect::MakeWH(50.0f, 50.0f), paint);
REPORTER_ASSERT(reporter, 0.0f == device.fLastMatrix.getTranslateX());
@@ -135,14 +137,15 @@ static void test_mixed(skiatest::Reporter* reporter) {
paint.reset();
// Then the front layer.
- REPORTER_ASSERT(reporter, looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
REPORTER_ASSERT(reporter, SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrc_Mode));
canvas.drawRect(SkRect::MakeWH(50.0f, 50.0f), paint);
REPORTER_ASSERT(reporter, 10.0f == device.fLastMatrix.getTranslateX());
REPORTER_ASSERT(reporter, 20.0f == device.fLastMatrix.getTranslateY());
// Only two layers were added, so that should be the end.
- REPORTER_ASSERT(reporter, !looper->next(&canvas, &paint));
+ REPORTER_ASSERT(reporter, !context->next(&canvas, &paint));
+ context->cleanup(NULL);
}
DEF_TEST(LayerDrawLooper, reporter) {

Powered by Google App Engine
This is Rietveld 408576698