diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-01 17:54:05 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-01 17:54:05 +0000 |
commit | 44a42ea8b22a845a419b8ae3b47c4619fdec0215 (patch) | |
tree | 8b53d792fd9a01190c1830a8afdcb8fd3b11437f /tests | |
parent | 0ab7c77a2c964f90338ef314ce04e4f9a05d45b4 (diff) |
1. remove references to (deprecated) SkGpuCanvas
2. remove references to setDevice (soon to be deprecated)
Review URL: https://codereview.appspot.com/6597055
git-svn-id: http://skia.googlecode.com/svn/trunk@5751 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PremulAlphaRoundTripTest.cpp | 11 | ||||
-rw-r--r-- | tests/ReadPixelsTest.cpp | 15 | ||||
-rw-r--r-- | tests/ReadWriteAlphaTest.cpp | 5 | ||||
-rw-r--r-- | tests/WritePixelsTest.cpp | 18 |
4 files changed, 23 insertions, 26 deletions
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp index f2f1613d95..17fb42a41c 100644 --- a/tests/PremulAlphaRoundTripTest.cpp +++ b/tests/PremulAlphaRoundTripTest.cpp @@ -48,24 +48,25 @@ static const SkCanvas::Config8888 gUnpremulConfigs[] = { void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContext* context) { - SkCanvas canvas; + SkAutoTUnref<SkDevice> device; for (int dtype = 0; dtype < 2; ++dtype) { if (0 == dtype) { - canvas.setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, + device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, 256, 256, - false))->unref(); + false)); } else { #if !SK_SUPPORT_GPU || defined(SK_SCALAR_IS_FIXED) // GPU device known not to work in the fixed pt build. continue; #else - canvas.setDevice(new SkGpuDevice(context, + device.reset(new SkGpuDevice(context, SkBitmap::kARGB_8888_Config, 256, - 256))->unref(); + 256)); #endif } + SkCanvas canvas(device); SkBitmap readBmp1; readBmp1.setConfig(SkBitmap::kARGB_8888_Config, 256, 256); diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 80ced213bd..8b47906315 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -109,7 +109,7 @@ void fillCanvas(SkCanvas* canvas) { static SkBitmap bmp; if (bmp.isNull()) { bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H); - bool alloc = bmp.allocPixels(); + SkDEBUGCODE(bool alloc =) bmp.allocPixels(); SkASSERT(alloc); SkAutoLockPixels alp(bmp); intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels()); @@ -255,8 +255,6 @@ void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init) { } void ReadPixelsTest(skiatest::Reporter* reporter, GrContext* context) { - SkCanvas canvas; - const SkIRect testRects[] = { // entire thing DEV_RECT, @@ -305,23 +303,24 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContext* context) { }; for (int dtype = 0; dtype < 2; ++dtype) { - + SkAutoTUnref<SkDevice> device; if (0 == dtype) { - canvas.setDevice(new SkDevice(SkBitmap::kARGB_8888_Config, + device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, - false))->unref(); + false)); } else { // GPU device known not to work in the fixed pt build. #if defined(SK_SCALAR_IS_FIXED) || !SK_SUPPORT_GPU continue; #else - canvas.setDevice(new SkGpuDevice(context, + device.reset(new SkGpuDevice(context, SkBitmap::kARGB_8888_Config, DEV_W, - DEV_H))->unref(); + DEV_H)); #endif } + SkCanvas canvas(device); fillCanvas(&canvas); static const SkCanvas::Config8888 gReadConfigs[] = { diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 751c9128c4..eea78ce6c0 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -77,9 +77,8 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContext* context) REPORTER_ASSERT(reporter, match); // Now try writing on the single channel texture - SkCanvas canvas; - - canvas.setDevice(new SkGpuDevice(context, texture->asRenderTarget()))->unref(); + SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, texture->asRenderTarget())); + SkCanvas canvas(device); SkPaint paint; diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index e482fd5d8b..f5c4175308 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -301,32 +301,29 @@ static const CanvasConfig gCanvasConfigs[] = { #endif }; -bool setupCanvas(SkCanvas* canvas, const CanvasConfig& c, GrContext* grCtx) { +SkDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) { switch (c.fDevType) { case kRaster_DevType: { SkBitmap bmp; size_t rowBytes = c.fTightRowBytes ? 0 : 4 * DEV_W + 100; bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, rowBytes); if (!bmp.allocPixels()) { - return false; + sk_throw(); + return NULL; } // if rowBytes isn't tight then set the padding to a known value if (rowBytes) { SkAutoLockPixels alp(bmp); memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize()); } - canvas->setDevice(new SkDevice(bmp))->unref(); - break; + return new SkDevice(bmp); } #if SK_SUPPORT_GPU case kGpu_DevType: - canvas->setDevice(new SkGpuDevice(grCtx, - SkBitmap::kARGB_8888_Config, - DEV_W, DEV_H))->unref(); - break; + return new SkGpuDevice(grCtx, SkBitmap::kARGB_8888_Config, DEV_W, DEV_H); #endif } - return true; + return NULL; } bool setupBitmap(SkBitmap* bitmap, @@ -400,7 +397,8 @@ void WritePixelsTest(skiatest::Reporter* reporter, GrContext* context) { }; for (size_t i = 0; i < SK_ARRAY_COUNT(gCanvasConfigs); ++i) { - REPORTER_ASSERT(reporter, setupCanvas(&canvas, gCanvasConfigs[i], context)); + SkAutoTUnref<SkDevice> device(createDevice(gCanvasConfigs[i], context)); + SkCanvas canvas(device); static const SkCanvas::Config8888 gSrcConfigs[] = { SkCanvas::kNative_Premul_Config8888, |