| Index: tests/DeferredCanvasTest.cpp
|
| diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
|
| index 62b1b17ffe6e2cd2b184093f6d3239bfc8252ad2..7ef3fed81c1b2b89a67d604bb894e429eef7bf59 100644
|
| --- a/tests/DeferredCanvasTest.cpp
|
| +++ b/tests/DeferredCanvasTest.cpp
|
| @@ -15,6 +15,8 @@
|
| #include "SkShader.h"
|
| #include "SkSurface.h"
|
| #include "Test.h"
|
| +#include "sk_tool_utils.h"
|
| +
|
| #if SK_SUPPORT_GPU
|
| #include "GrContextFactory.h"
|
| #else
|
| @@ -24,6 +26,16 @@ class GrContextFactory;
|
| static const int gWidth = 2;
|
| static const int gHeight = 2;
|
|
|
| +static void callWritePixels(SkCanvas* canvas, const SkBitmap& src, int x, int y,
|
| + SkCanvas::Config8888 config) {
|
| + SkImageInfo info = src.info();
|
| + sk_tool_utils::config8888_to_imagetypes(config, &info.fColorType, &info.fAlphaType);
|
| +
|
| + SkBitmap bm(src);
|
| + bm.lockPixels();
|
| + canvas->writePixels(bm.info(), bm.getPixels(), bm.rowBytes(), x, y);
|
| +}
|
| +
|
| static void create(SkBitmap* bm, SkColor color) {
|
| bm->allocN32Pixels(gWidth, gHeight);
|
| bm->eraseColor(color);
|
| @@ -177,7 +189,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| surface->clearCounts();
|
| - canvas->writePixels(srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| + callWritePixels(canvas, srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| @@ -194,7 +206,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| surface->clearCounts();
|
| - canvas->writePixels(srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| + callWritePixels(canvas, srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
|
| REPORTER_ASSERT(reporter, 1 == surface->fRetainCount);
|
|
|
| @@ -216,7 +228,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| surface->clearCounts();
|
| - canvas->writePixels(srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| + callWritePixels(canvas, srcBitmap, 0, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount);
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| @@ -238,7 +250,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| surface->clearCounts();
|
| - canvas->writePixels(srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| + callWritePixels(canvas, srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| REPORTER_ASSERT(reporter, 1 == surface->fDiscardCount); // because of the clear
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| @@ -262,7 +274,7 @@ static void TestDeferredCanvasWritePixelsToSurface(skiatest::Reporter* reporter)
|
| REPORTER_ASSERT(reporter, 0 == surface->fRetainCount);
|
|
|
| surface->clearCounts();
|
| - canvas->writePixels(srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| + callWritePixels(canvas, srcBitmap, 5, 0, SkCanvas::kRGBA_Unpremul_Config8888);
|
| REPORTER_ASSERT(reporter, 0 == surface->fDiscardCount);
|
| REPORTER_ASSERT(reporter, 1 == surface->fRetainCount);
|
|
|
|
|