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

Unified Diff: tests/LayerDrawLooperTest.cpp

Issue 2488523003: Make SkSmallAllocator obey the RAII invariants and be expandable (Closed)
Patch Set: Strip pointer to make correct type Created 4 years, 1 month 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/core/SkSmallAllocator.h ('k') | tests/SmallAllocatorTest.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 4897fd28844fad377744fd95af3391e72d76ab7c..7b3aa298832bd09ecd4f07459fabf1285841797e 100644
--- a/tests/LayerDrawLooperTest.cpp
+++ b/tests/LayerDrawLooperTest.cpp
@@ -60,8 +60,11 @@ static void test_frontToBack(skiatest::Reporter* reporter) {
SkPaint paint;
auto looper(looperBuilder.detach());
SkSmallAllocator<1, 32> allocator;
- void* buffer = allocator.reserveT<SkDrawLooper::Context>(looper->contextSize());
- SkDrawLooper::Context* context = looper->createContext(&canvas, buffer);
+ SkDrawLooper::Context* context = allocator.createWithIniter(
+ looper->contextSize(),
+ [&](void* buffer) {
+ return looper->createContext(&canvas, buffer);
+ });
// The back layer should come first.
REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
@@ -100,8 +103,11 @@ static void test_backToFront(skiatest::Reporter* reporter) {
SkPaint paint;
auto looper(looperBuilder.detach());
SkSmallAllocator<1, 32> allocator;
- void* buffer = allocator.reserveT<SkDrawLooper::Context>(looper->contextSize());
- SkDrawLooper::Context* context = looper->createContext(&canvas, buffer);
+ SkDrawLooper::Context* context = allocator.createWithIniter(
+ looper->contextSize(),
+ [&](void* buffer) {
+ return looper->createContext(&canvas, buffer);
+ });
// The back layer should come first.
REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
@@ -140,8 +146,11 @@ static void test_mixed(skiatest::Reporter* reporter) {
SkPaint paint;
sk_sp<SkDrawLooper> looper(looperBuilder.detach());
SkSmallAllocator<1, 32> allocator;
- void* buffer = allocator.reserveT<SkDrawLooper::Context>(looper->contextSize());
- SkDrawLooper::Context* context = looper->createContext(&canvas, buffer);
+ SkDrawLooper::Context* context = allocator.createWithIniter(
+ looper->contextSize(),
+ [&](void* buffer) {
+ return looper->createContext(&canvas, buffer);
+ });
// The back layer should come first.
REPORTER_ASSERT(reporter, context->next(&canvas, &paint));
« no previous file with comments | « src/core/SkSmallAllocator.h ('k') | tests/SmallAllocatorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698