diff options
Diffstat (limited to 'skia/ext/platform_canvas_unittest.cc')
-rw-r--r-- | skia/ext/platform_canvas_unittest.cc | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/skia/ext/platform_canvas_unittest.cc b/skia/ext/platform_canvas_unittest.cc index 6e43be2..40cdc70 100644 --- a/skia/ext/platform_canvas_unittest.cc +++ b/skia/ext/platform_canvas_unittest.cc @@ -31,8 +31,8 @@ namespace { bool VerifyRect(const PlatformCanvas& canvas, uint32_t canvas_color, uint32_t rect_color, int x, int y, int w, int h) { - PlatformDevice& device = canvas.getTopPlatformDevice(); - const SkBitmap& bitmap = device.accessBitmap(false); + SkDevice* device = skia::GetTopDevice(canvas); + const SkBitmap& bitmap = device->accessBitmap(false); SkAutoLockPixels lock(bitmap); // For masking out the alpha values. @@ -70,8 +70,8 @@ bool IsOfColor(const SkBitmap& bitmap, int x, int y, uint32_t color) { bool VerifyRoundedRect(const PlatformCanvas& canvas, uint32_t canvas_color, uint32_t rect_color, int x, int y, int w, int h) { - PlatformDevice& device = canvas.getTopPlatformDevice(); - const SkBitmap& bitmap = device.accessBitmap(false); + SkDevice* device = skia::GetTopDevice(canvas); + const SkBitmap& bitmap = device->accessBitmap(false); SkAutoLockPixels lock(bitmap); // Check corner points first. They should be of canvas_color. @@ -103,7 +103,8 @@ bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) { #if defined(OS_WIN) void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { - HDC dc = canvas.beginPlatformPaint(); + skia::ScopedPlatformPaint scoped_platform_paint(&canvas); + HDC dc = scoped_platform_paint.GetPlatformSurface(); RECT inner_rc; inner_rc.left = x; @@ -111,21 +112,18 @@ void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { inner_rc.right = x + w; inner_rc.bottom = y + h; FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH))); - - canvas.endPlatformPaint(); } #elif defined(OS_MACOSX) void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { - CGContextRef context = canvas.beginPlatformPaint(); - + skia::ScopedPlatformPaint scoped_platform_paint(&canvas); + CGContextRef context = scoped_platform_paint.GetPlatformSurface(); + CGRect inner_rc = CGRectMake(x, y, w, h); // RGBA opaque black CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0); CGContextSetFillColorWithColor(context, black); CGColorRelease(black); CGContextFillRect(context, inner_rc); - - canvas.endPlatformPaint(); } #else void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { @@ -244,7 +242,7 @@ TEST(PlatformCanvas, FillLayer) { LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); DrawNativeRect(canvas, 0, 0, 100, 100); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100); + MakeOpaque(&canvas, 0, 0, 100, 100); #endif } EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); @@ -255,8 +253,7 @@ TEST(PlatformCanvas, FillLayer) { LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY, - kInnerW, kInnerH); + MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); #endif } EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); @@ -269,8 +266,7 @@ TEST(PlatformCanvas, FillLayer) { AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); DrawNativeRect(canvas, 0, 0, 100, 100); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque( - kInnerX, kInnerY, kInnerW, kInnerH); + MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); #endif canvas.restore(); } @@ -284,7 +280,7 @@ TEST(PlatformCanvas, FillLayer) { LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); DrawNativeRect(canvas, 0, 0, 100, 100); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100); + MakeOpaque(&canvas, 0, 0, 100, 100); #endif } canvas.restore(); @@ -305,7 +301,7 @@ TEST(PlatformCanvas, TranslateLayer) { LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); DrawNativeRect(canvas, 0, 0, 100, 100); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100); + MakeOpaque(&canvas, 0, 0, 100, 100); #endif } canvas.restore(); @@ -320,8 +316,7 @@ TEST(PlatformCanvas, TranslateLayer) { LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY, - kInnerW, kInnerH); + MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); #endif } canvas.restore(); @@ -336,8 +331,7 @@ TEST(PlatformCanvas, TranslateLayer) { canvas.translate(1, 1); DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY, - kInnerW, kInnerH); + MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); #endif } canvas.restore(); @@ -355,8 +349,7 @@ TEST(PlatformCanvas, TranslateLayer) { AddClip(canvas, kInnerX + 1, kInnerY + 1, kInnerW - 1, kInnerH - 1); DrawNativeRect(canvas, 0, 0, 100, 100); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(kLayerX, kLayerY, - kLayerW, kLayerH); + MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH); #endif } canvas.restore(); @@ -384,8 +377,7 @@ TEST(PlatformCanvas, TranslateLayer) { DrawNativeRect(canvas, 0, 0, 100, 100); #if defined(OS_WIN) - canvas.getTopPlatformDevice().makeOpaque(kLayerX, kLayerY, - kLayerW, kLayerH); + MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH); #endif } canvas.restore(); |