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

Unified Diff: tests/LayerDrawLooperTest.cpp

Issue 155513012: [WIP] Add Context to SkDrawLooper. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments Created 6 years, 9 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 | « src/effects/SkLayerDrawLooper.cpp ('k') | tests/QuickRejectTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/LayerDrawLooperTest.cpp
diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp
index 68dd5e06e7bbbafdd5bd6ddf637841a8a8401f8f..1facb23b510dae972e7942fea632a8793649c439 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -15,6 +15,7 @@
#include "SkRect.h"
#include "SkRefCnt.h"
#include "SkScalar.h"
+#include "SkSmallAllocator.h"
#include "SkXfermode.h"
#include "Test.h"
@@ -57,10 +58,12 @@ static void test_frontToBack(skiatest::Reporter* reporter) {
SkCanvas canvas(&device);
SkPaint paint;
SkAutoTUnref<SkLayerDrawLooper> looper(looperBuilder.detachLooper());
- looper->init(&canvas);
+ SkSmallAllocator<1, 32> allocator;
+ void* buffer = allocator.reserveT<SkDrawLooper::Context>(looper->contextSize());
+ SkDrawLooper::Context* context = looper->createContext(&canvas, buffer);
// 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());
@@ -68,14 +71,14 @@ 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));
}
static void test_backToFront(skiatest::Reporter* reporter) {
@@ -95,10 +98,12 @@ static void test_backToFront(skiatest::Reporter* reporter) {
SkCanvas canvas(&device);
SkPaint paint;
SkAutoTUnref<SkLayerDrawLooper> looper(looperBuilder.detachLooper());
- looper->init(&canvas);
+ SkSmallAllocator<1, 32> allocator;
+ void* buffer = allocator.reserveT<SkDrawLooper::Context>(looper->contextSize());
+ SkDrawLooper::Context* context = looper->createContext(&canvas, buffer);
// 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());
@@ -106,14 +111,14 @@ 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));
}
static void test_mixed(skiatest::Reporter* reporter) {
@@ -133,10 +138,12 @@ static void test_mixed(skiatest::Reporter* reporter) {
SkCanvas canvas(&device);
SkPaint paint;
SkAutoTUnref<SkLayerDrawLooper> looper(looperBuilder.detachLooper());
- looper->init(&canvas);
+ SkSmallAllocator<1, 32> allocator;
+ void* buffer = allocator.reserveT<SkDrawLooper::Context>(looper->contextSize());
+ SkDrawLooper::Context* context = looper->createContext(&canvas, buffer);
// 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());
@@ -144,14 +151,14 @@ 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));
}
DEF_TEST(LayerDrawLooper, reporter) {
« no previous file with comments | « src/effects/SkLayerDrawLooper.cpp ('k') | tests/QuickRejectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698