| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(awalker): clean up the const/non-const reference handling in this test | 5 // TODO(awalker): clean up the const/non-const reference handling in this test |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_MACOSX) | 9 #if defined(OS_MACOSX) |
| 10 #import <ApplicationServices/ApplicationServices.h> | 10 #import <ApplicationServices/ApplicationServices.h> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Return true if the canvas is filled to canvas_color, and contains a single | 27 // Return true if the canvas is filled to canvas_color, and contains a single |
| 28 // rectangle filled to rect_color. This function ignores the alpha channel, | 28 // rectangle filled to rect_color. This function ignores the alpha channel, |
| 29 // since Windows will sometimes clear the alpha channel when drawing, and we | 29 // since Windows will sometimes clear the alpha channel when drawing, and we |
| 30 // will fix that up later in cases it's necessary. | 30 // will fix that up later in cases it's necessary. |
| 31 bool VerifyRect(const PlatformCanvas& canvas, | 31 bool VerifyRect(const PlatformCanvas& canvas, |
| 32 uint32_t canvas_color, uint32_t rect_color, | 32 uint32_t canvas_color, uint32_t rect_color, |
| 33 int x, int y, int w, int h) { | 33 int x, int y, int w, int h) { |
| 34 PlatformDevice& device = canvas.getTopPlatformDevice(); | 34 SkDevice* device = skia::GetTopDevice(canvas); |
| 35 const SkBitmap& bitmap = device.accessBitmap(false); | 35 const SkBitmap& bitmap = device->accessBitmap(false); |
| 36 SkAutoLockPixels lock(bitmap); | 36 SkAutoLockPixels lock(bitmap); |
| 37 | 37 |
| 38 // For masking out the alpha values. | 38 // For masking out the alpha values. |
| 39 uint32_t alpha_mask = 0xFF << SK_A32_SHIFT; | 39 uint32_t alpha_mask = 0xFF << SK_A32_SHIFT; |
| 40 | 40 |
| 41 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { | 41 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { |
| 42 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) { | 42 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) { |
| 43 if (cur_x >= x && cur_x < x + w && | 43 if (cur_x >= x && cur_x < x + w && |
| 44 cur_y >= y && cur_y < y + h) { | 44 cur_y >= y && cur_y < y + h) { |
| 45 // Inside the square should be rect_color | 45 // Inside the square should be rect_color |
| (...skipping 17 matching lines...) Expand all Loading... |
| 63 static uint32_t alpha_mask = 0xFF << SK_A32_SHIFT; | 63 static uint32_t alpha_mask = 0xFF << SK_A32_SHIFT; |
| 64 return (*bitmap.getAddr32(x, y) | alpha_mask) == (color | alpha_mask); | 64 return (*bitmap.getAddr32(x, y) | alpha_mask) == (color | alpha_mask); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Return true if canvas has something that passes for a rounded-corner | 67 // Return true if canvas has something that passes for a rounded-corner |
| 68 // rectangle. Basically, we're just checking to make sure that the pixels in the | 68 // rectangle. Basically, we're just checking to make sure that the pixels in the |
| 69 // middle are of rect_color and pixels in the corners are of canvas_color. | 69 // middle are of rect_color and pixels in the corners are of canvas_color. |
| 70 bool VerifyRoundedRect(const PlatformCanvas& canvas, | 70 bool VerifyRoundedRect(const PlatformCanvas& canvas, |
| 71 uint32_t canvas_color, uint32_t rect_color, | 71 uint32_t canvas_color, uint32_t rect_color, |
| 72 int x, int y, int w, int h) { | 72 int x, int y, int w, int h) { |
| 73 PlatformDevice& device = canvas.getTopPlatformDevice(); | 73 SkDevice* device = skia::GetTopDevice(canvas); |
| 74 const SkBitmap& bitmap = device.accessBitmap(false); | 74 const SkBitmap& bitmap = device->accessBitmap(false); |
| 75 SkAutoLockPixels lock(bitmap); | 75 SkAutoLockPixels lock(bitmap); |
| 76 | 76 |
| 77 // Check corner points first. They should be of canvas_color. | 77 // Check corner points first. They should be of canvas_color. |
| 78 if (!IsOfColor(bitmap, x, y, canvas_color)) return false; | 78 if (!IsOfColor(bitmap, x, y, canvas_color)) return false; |
| 79 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; | 79 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; |
| 80 if (!IsOfColor(bitmap, x, y + h, canvas_color)) return false; | 80 if (!IsOfColor(bitmap, x, y + h, canvas_color)) return false; |
| 81 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; | 81 if (!IsOfColor(bitmap, x + w, y, canvas_color)) return false; |
| 82 | 82 |
| 83 // Check middle points. They should be of rect_color. | 83 // Check middle points. They should be of rect_color. |
| 84 if (!IsOfColor(bitmap, (x + w / 2), y, rect_color)) return false; | 84 if (!IsOfColor(bitmap, (x + w / 2), y, rect_color)) return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h); | 96 return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Check that every pixel in the canvas is a single color. | 99 // Check that every pixel in the canvas is a single color. |
| 100 bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) { | 100 bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) { |
| 101 return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0); | 101 return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0); |
| 102 } | 102 } |
| 103 | 103 |
| 104 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
| 105 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { | 105 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 106 HDC dc = canvas.beginPlatformPaint(); | 106 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); |
| 107 HDC dc = scoped_platform_paint.GetPlatformSurface(); |
| 107 | 108 |
| 108 RECT inner_rc; | 109 RECT inner_rc; |
| 109 inner_rc.left = x; | 110 inner_rc.left = x; |
| 110 inner_rc.top = y; | 111 inner_rc.top = y; |
| 111 inner_rc.right = x + w; | 112 inner_rc.right = x + w; |
| 112 inner_rc.bottom = y + h; | 113 inner_rc.bottom = y + h; |
| 113 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)))
; | 114 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)))
; |
| 114 | |
| 115 canvas.endPlatformPaint(); | |
| 116 } | 115 } |
| 117 #elif defined(OS_MACOSX) | 116 #elif defined(OS_MACOSX) |
| 118 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { | 117 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 119 CGContextRef context = canvas.beginPlatformPaint(); | 118 skia::ScopedPlatformPaint scoped_platform_paint(&canvas); |
| 120 | 119 CGContextRef context = scoped_platform_paint.GetPlatformSurface(); |
| 120 |
| 121 CGRect inner_rc = CGRectMake(x, y, w, h); | 121 CGRect inner_rc = CGRectMake(x, y, w, h); |
| 122 // RGBA opaque black | 122 // RGBA opaque black |
| 123 CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0); | 123 CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0); |
| 124 CGContextSetFillColorWithColor(context, black); | 124 CGContextSetFillColorWithColor(context, black); |
| 125 CGColorRelease(black); | 125 CGColorRelease(black); |
| 126 CGContextFillRect(context, inner_rc); | 126 CGContextFillRect(context, inner_rc); |
| 127 | |
| 128 canvas.endPlatformPaint(); | |
| 129 } | 127 } |
| 130 #else | 128 #else |
| 131 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { | 129 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 132 notImplemented(); | 130 notImplemented(); |
| 133 } | 131 } |
| 134 #endif | 132 #endif |
| 135 | 133 |
| 136 // Clips the contents of the canvas to the given rectangle. This will be | 134 // Clips the contents of the canvas to the given rectangle. This will be |
| 137 // intersected with any existing clip. | 135 // intersected with any existing clip. |
| 138 void AddClip(PlatformCanvas& canvas, int x, int y, int w, int h) { | 136 void AddClip(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // Create the canvas initialized to opaque white. | 235 // Create the canvas initialized to opaque white. |
| 238 PlatformCanvas canvas(16, 16, true); | 236 PlatformCanvas canvas(16, 16, true); |
| 239 | 237 |
| 240 // Make a layer and fill it completely to make sure that the bounds are | 238 // Make a layer and fill it completely to make sure that the bounds are |
| 241 // correct. | 239 // correct. |
| 242 canvas.drawColor(SK_ColorWHITE); | 240 canvas.drawColor(SK_ColorWHITE); |
| 243 { | 241 { |
| 244 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 242 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 245 DrawNativeRect(canvas, 0, 0, 100, 100); | 243 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 246 #if defined(OS_WIN) | 244 #if defined(OS_WIN) |
| 247 canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100); | 245 MakeOpaque(&canvas, 0, 0, 100, 100); |
| 248 #endif | 246 #endif |
| 249 } | 247 } |
| 250 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); | 248 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); |
| 251 | 249 |
| 252 // Make a layer and fill it partially to make sure the translation is correct. | 250 // Make a layer and fill it partially to make sure the translation is correct. |
| 253 canvas.drawColor(SK_ColorWHITE); | 251 canvas.drawColor(SK_ColorWHITE); |
| 254 { | 252 { |
| 255 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 253 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 256 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 254 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 257 #if defined(OS_WIN) | 255 #if defined(OS_WIN) |
| 258 canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY, | 256 MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 259 kInnerW, kInnerH); | |
| 260 #endif | 257 #endif |
| 261 } | 258 } |
| 262 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 259 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 263 | 260 |
| 264 // Add a clip on the layer and fill to make sure clip is correct. | 261 // Add a clip on the layer and fill to make sure clip is correct. |
| 265 canvas.drawColor(SK_ColorWHITE); | 262 canvas.drawColor(SK_ColorWHITE); |
| 266 { | 263 { |
| 267 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 264 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 268 canvas.save(); | 265 canvas.save(); |
| 269 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 266 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 270 DrawNativeRect(canvas, 0, 0, 100, 100); | 267 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 271 #if defined(OS_WIN) | 268 #if defined(OS_WIN) |
| 272 canvas.getTopPlatformDevice().makeOpaque( | 269 MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 273 kInnerX, kInnerY, kInnerW, kInnerH); | |
| 274 #endif | 270 #endif |
| 275 canvas.restore(); | 271 canvas.restore(); |
| 276 } | 272 } |
| 277 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 273 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 278 | 274 |
| 279 // Add a clip and then make the layer to make sure the clip is correct. | 275 // Add a clip and then make the layer to make sure the clip is correct. |
| 280 canvas.drawColor(SK_ColorWHITE); | 276 canvas.drawColor(SK_ColorWHITE); |
| 281 canvas.save(); | 277 canvas.save(); |
| 282 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 278 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 283 { | 279 { |
| 284 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 280 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 285 DrawNativeRect(canvas, 0, 0, 100, 100); | 281 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 286 #if defined(OS_WIN) | 282 #if defined(OS_WIN) |
| 287 canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100); | 283 MakeOpaque(&canvas, 0, 0, 100, 100); |
| 288 #endif | 284 #endif |
| 289 } | 285 } |
| 290 canvas.restore(); | 286 canvas.restore(); |
| 291 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 287 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 292 } | 288 } |
| 293 | 289 |
| 294 // Test that translation + make layer works properly. | 290 // Test that translation + make layer works properly. |
| 295 TEST(PlatformCanvas, TranslateLayer) { | 291 TEST(PlatformCanvas, TranslateLayer) { |
| 296 // Create the canvas initialized to opaque white. | 292 // Create the canvas initialized to opaque white. |
| 297 PlatformCanvas canvas(16, 16, true); | 293 PlatformCanvas canvas(16, 16, true); |
| 298 | 294 |
| 299 // Make a layer and fill it completely to make sure that the bounds are | 295 // Make a layer and fill it completely to make sure that the bounds are |
| 300 // correct. | 296 // correct. |
| 301 canvas.drawColor(SK_ColorWHITE); | 297 canvas.drawColor(SK_ColorWHITE); |
| 302 canvas.save(); | 298 canvas.save(); |
| 303 canvas.translate(1, 1); | 299 canvas.translate(1, 1); |
| 304 { | 300 { |
| 305 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 301 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 306 DrawNativeRect(canvas, 0, 0, 100, 100); | 302 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 307 #if defined(OS_WIN) | 303 #if defined(OS_WIN) |
| 308 canvas.getTopPlatformDevice().makeOpaque(0, 0, 100, 100); | 304 MakeOpaque(&canvas, 0, 0, 100, 100); |
| 309 #endif | 305 #endif |
| 310 } | 306 } |
| 311 canvas.restore(); | 307 canvas.restore(); |
| 312 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX + 1, kLayerY + 1, | 308 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX + 1, kLayerY + 1, |
| 313 kLayerW, kLayerH)); | 309 kLayerW, kLayerH)); |
| 314 | 310 |
| 315 // Translate then make the layer. | 311 // Translate then make the layer. |
| 316 canvas.drawColor(SK_ColorWHITE); | 312 canvas.drawColor(SK_ColorWHITE); |
| 317 canvas.save(); | 313 canvas.save(); |
| 318 canvas.translate(1, 1); | 314 canvas.translate(1, 1); |
| 319 { | 315 { |
| 320 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 316 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 321 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 317 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 322 #if defined(OS_WIN) | 318 #if defined(OS_WIN) |
| 323 canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY, | 319 MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 324 kInnerW, kInnerH); | |
| 325 #endif | 320 #endif |
| 326 } | 321 } |
| 327 canvas.restore(); | 322 canvas.restore(); |
| 328 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 1, kInnerY + 1, | 323 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 1, kInnerY + 1, |
| 329 kInnerW, kInnerH)); | 324 kInnerW, kInnerH)); |
| 330 | 325 |
| 331 // Make the layer then translate. | 326 // Make the layer then translate. |
| 332 canvas.drawColor(SK_ColorWHITE); | 327 canvas.drawColor(SK_ColorWHITE); |
| 333 canvas.save(); | 328 canvas.save(); |
| 334 { | 329 { |
| 335 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 330 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 336 canvas.translate(1, 1); | 331 canvas.translate(1, 1); |
| 337 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 332 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 338 #if defined(OS_WIN) | 333 #if defined(OS_WIN) |
| 339 canvas.getTopPlatformDevice().makeOpaque(kInnerX, kInnerY, | 334 MakeOpaque(&canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 340 kInnerW, kInnerH); | |
| 341 #endif | 335 #endif |
| 342 } | 336 } |
| 343 canvas.restore(); | 337 canvas.restore(); |
| 344 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 1, kInnerY + 1, | 338 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 1, kInnerY + 1, |
| 345 kInnerW, kInnerH)); | 339 kInnerW, kInnerH)); |
| 346 | 340 |
| 347 // Translate both before and after, and have a clip. | 341 // Translate both before and after, and have a clip. |
| 348 canvas.drawColor(SK_ColorWHITE); | 342 canvas.drawColor(SK_ColorWHITE); |
| 349 canvas.save(); | 343 canvas.save(); |
| 350 canvas.translate(1, 1); | 344 canvas.translate(1, 1); |
| 351 { | 345 { |
| 352 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 346 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 353 canvas.drawColor(SK_ColorWHITE); | 347 canvas.drawColor(SK_ColorWHITE); |
| 354 canvas.translate(1, 1); | 348 canvas.translate(1, 1); |
| 355 AddClip(canvas, kInnerX + 1, kInnerY + 1, kInnerW - 1, kInnerH - 1); | 349 AddClip(canvas, kInnerX + 1, kInnerY + 1, kInnerW - 1, kInnerH - 1); |
| 356 DrawNativeRect(canvas, 0, 0, 100, 100); | 350 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 357 #if defined(OS_WIN) | 351 #if defined(OS_WIN) |
| 358 canvas.getTopPlatformDevice().makeOpaque(kLayerX, kLayerY, | 352 MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 359 kLayerW, kLayerH); | |
| 360 #endif | 353 #endif |
| 361 } | 354 } |
| 362 canvas.restore(); | 355 canvas.restore(); |
| 363 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 3, kInnerY + 3, | 356 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 3, kInnerY + 3, |
| 364 kInnerW - 1, kInnerH - 1)); | 357 kInnerW - 1, kInnerH - 1)); |
| 365 | 358 |
| 366 // TODO(dglazkov): Figure out why this fails on Mac (antialiased clipping?), | 359 // TODO(dglazkov): Figure out why this fails on Mac (antialiased clipping?), |
| 367 // modify test and remove this guard. | 360 // modify test and remove this guard. |
| 368 #if !defined(OS_MACOSX) | 361 #if !defined(OS_MACOSX) |
| 369 // Translate both before and after, and have a path clip. | 362 // Translate both before and after, and have a path clip. |
| 370 canvas.drawColor(SK_ColorWHITE); | 363 canvas.drawColor(SK_ColorWHITE); |
| 371 canvas.save(); | 364 canvas.save(); |
| 372 canvas.translate(1, 1); | 365 canvas.translate(1, 1); |
| 373 { | 366 { |
| 374 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 367 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 375 canvas.drawColor(SK_ColorWHITE); | 368 canvas.drawColor(SK_ColorWHITE); |
| 376 canvas.translate(1, 1); | 369 canvas.translate(1, 1); |
| 377 | 370 |
| 378 SkPath path; | 371 SkPath path; |
| 379 SkRect rect; | 372 SkRect rect; |
| 380 rect.iset(kInnerX - 1, kInnerY - 1, | 373 rect.iset(kInnerX - 1, kInnerY - 1, |
| 381 kInnerX + kInnerW, kInnerY + kInnerH); | 374 kInnerX + kInnerW, kInnerY + kInnerH); |
| 382 path.addRoundRect(rect, kRadius, kRadius); | 375 path.addRoundRect(rect, kRadius, kRadius); |
| 383 canvas.clipPath(path); | 376 canvas.clipPath(path); |
| 384 | 377 |
| 385 DrawNativeRect(canvas, 0, 0, 100, 100); | 378 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 386 #if defined(OS_WIN) | 379 #if defined(OS_WIN) |
| 387 canvas.getTopPlatformDevice().makeOpaque(kLayerX, kLayerY, | 380 MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 388 kLayerW, kLayerH); | |
| 389 #endif | 381 #endif |
| 390 } | 382 } |
| 391 canvas.restore(); | 383 canvas.restore(); |
| 392 EXPECT_TRUE(VerifyRoundedRect(canvas, SK_ColorWHITE, SK_ColorBLACK, | 384 EXPECT_TRUE(VerifyRoundedRect(canvas, SK_ColorWHITE, SK_ColorBLACK, |
| 393 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); | 385 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); |
| 394 #endif | 386 #endif |
| 395 } | 387 } |
| 396 | 388 |
| 397 } // namespace skia | 389 } // namespace skia |
| OLD | NEW |