Chromium Code Reviews| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // Radius used by some tests to draw a rounded-corner rectangle. | 187 // Radius used by some tests to draw a rounded-corner rectangle. |
| 188 const SkScalar kRadius = 2.0; | 188 const SkScalar kRadius = 2.0; |
| 189 | 189 |
| 190 } | 190 } |
| 191 | 191 |
| 192 // This just checks that our checking code is working properly, it just uses | 192 // This just checks that our checking code is working properly, it just uses |
| 193 // regular skia primitives. | 193 // regular skia primitives. |
| 194 TEST(PlatformCanvas, SkLayer) { | 194 TEST(PlatformCanvas, SkLayer) { |
| 195 // Create the canvas initialized to opaque white. | 195 // Create the canvas initialized to opaque white. |
| 196 PlatformCanvas canvas(16, 16, true); | 196 PlatformCanvas canvas(16, 16, true); |
| 197 canvas.drawARGB(0, 0, 0, 0); | |
|
alokp
2012/03/01 17:09:02
eraseARGB? and everywhere else.
Jeff Timanus
2012/03/01 18:35:49
I was confused by this too.
SkCanvas (& PlatformC
| |
| 197 canvas.drawColor(SK_ColorWHITE); | 198 canvas.drawColor(SK_ColorWHITE); |
| 198 | 199 |
| 199 // Make a layer and fill it completely to make sure that the bounds are | 200 // Make a layer and fill it completely to make sure that the bounds are |
| 200 // correct. | 201 // correct. |
| 201 { | 202 { |
| 202 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 203 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 203 canvas.drawColor(SK_ColorBLACK); | 204 canvas.drawColor(SK_ColorBLACK); |
| 204 } | 205 } |
| 205 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); | 206 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); |
| 206 } | 207 } |
| 207 | 208 |
| 208 // Test native clipping. | 209 // Test native clipping. |
| 209 TEST(PlatformCanvas, ClipRegion) { | 210 TEST(PlatformCanvas, ClipRegion) { |
| 210 // Initialize a white canvas | 211 // Initialize a white canvas |
| 211 PlatformCanvas canvas(16, 16, true); | 212 PlatformCanvas canvas(16, 16, true); |
| 213 canvas.drawARGB(0, 0, 0, 0); | |
| 212 canvas.drawColor(SK_ColorWHITE); | 214 canvas.drawColor(SK_ColorWHITE); |
| 213 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 215 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 214 | 216 |
| 215 // Test that initially the canvas has no clip region, by filling it | 217 // Test that initially the canvas has no clip region, by filling it |
| 216 // with a black rectangle. | 218 // with a black rectangle. |
| 217 // Note: Don't use LayerSaver, since internally it sets a clip region. | 219 // Note: Don't use LayerSaver, since internally it sets a clip region. |
| 218 DrawNativeRect(canvas, 0, 0, 16, 16); | 220 DrawNativeRect(canvas, 0, 0, 16, 16); |
| 219 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); | 221 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); |
| 220 | 222 |
| 221 // Test that intersecting disjoint clip rectangles sets an empty clip region | 223 // Test that intersecting disjoint clip rectangles sets an empty clip region |
| 222 canvas.drawColor(SK_ColorWHITE); | 224 canvas.drawColor(SK_ColorWHITE); |
| 223 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 225 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 224 { | 226 { |
| 225 LayerSaver layer(canvas, 0, 0, 16, 16); | 227 LayerSaver layer(canvas, 0, 0, 16, 16); |
| 226 AddClip(canvas, 2, 3, 4, 5); | 228 AddClip(canvas, 2, 3, 4, 5); |
| 227 AddClip(canvas, 4, 9, 10, 10); | 229 AddClip(canvas, 4, 9, 10, 10); |
| 228 DrawNativeRect(canvas, 0, 0, 16, 16); | 230 DrawNativeRect(canvas, 0, 0, 16, 16); |
| 229 } | 231 } |
| 230 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 232 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 231 } | 233 } |
| 232 | 234 |
| 233 // Test the layers get filled properly by native rendering. | 235 // Test the layers get filled properly by native rendering. |
| 234 TEST(PlatformCanvas, FillLayer) { | 236 TEST(PlatformCanvas, FillLayer) { |
| 235 // Create the canvas initialized to opaque white. | 237 // Create the canvas initialized to opaque white. |
| 236 PlatformCanvas canvas(16, 16, true); | 238 PlatformCanvas canvas(16, 16, true); |
| 239 canvas.drawARGB(0, 0, 0, 0); | |
| 237 | 240 |
| 238 // Make a layer and fill it completely to make sure that the bounds are | 241 // Make a layer and fill it completely to make sure that the bounds are |
| 239 // correct. | 242 // correct. |
| 240 canvas.drawColor(SK_ColorWHITE); | 243 canvas.drawColor(SK_ColorWHITE); |
| 241 { | 244 { |
| 242 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 245 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 243 DrawNativeRect(canvas, 0, 0, 100, 100); | 246 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 244 #if defined(OS_WIN) | 247 #if defined(OS_WIN) |
| 245 MakeOpaque(&canvas, 0, 0, 100, 100); | 248 MakeOpaque(&canvas, 0, 0, 100, 100); |
| 246 #endif | 249 #endif |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 #endif | 287 #endif |
| 285 } | 288 } |
| 286 canvas.restore(); | 289 canvas.restore(); |
| 287 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 290 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 288 } | 291 } |
| 289 | 292 |
| 290 // Test that translation + make layer works properly. | 293 // Test that translation + make layer works properly. |
| 291 TEST(PlatformCanvas, TranslateLayer) { | 294 TEST(PlatformCanvas, TranslateLayer) { |
| 292 // Create the canvas initialized to opaque white. | 295 // Create the canvas initialized to opaque white. |
| 293 PlatformCanvas canvas(16, 16, true); | 296 PlatformCanvas canvas(16, 16, true); |
| 297 canvas.drawARGB(0, 0, 0, 0); | |
| 294 | 298 |
| 295 // Make a layer and fill it completely to make sure that the bounds are | 299 // Make a layer and fill it completely to make sure that the bounds are |
| 296 // correct. | 300 // correct. |
| 297 canvas.drawColor(SK_ColorWHITE); | 301 canvas.drawColor(SK_ColorWHITE); |
| 298 canvas.save(); | 302 canvas.save(); |
| 299 canvas.translate(1, 1); | 303 canvas.translate(1, 1); |
| 300 { | 304 { |
| 301 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 305 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 302 DrawNativeRect(canvas, 0, 0, 100, 100); | 306 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 303 #if defined(OS_WIN) | 307 #if defined(OS_WIN) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 384 MakeOpaque(&canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 381 #endif | 385 #endif |
| 382 } | 386 } |
| 383 canvas.restore(); | 387 canvas.restore(); |
| 384 EXPECT_TRUE(VerifyRoundedRect(canvas, SK_ColorWHITE, SK_ColorBLACK, | 388 EXPECT_TRUE(VerifyRoundedRect(canvas, SK_ColorWHITE, SK_ColorBLACK, |
| 385 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); | 389 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); |
| 386 #endif | 390 #endif |
| 387 } | 391 } |
| 388 | 392 |
| 389 } // namespace skia | 393 } // namespace skia |
| OLD | NEW |