| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const int kLayerY = 3; | 180 const int kLayerY = 3; |
| 181 const int kLayerW = 9; | 181 const int kLayerW = 9; |
| 182 const int kLayerH = 7; | 182 const int kLayerH = 7; |
| 183 | 183 |
| 184 // Size used by some tests to draw a rectangle inside the layer. | 184 // Size used by some tests to draw a rectangle inside the layer. |
| 185 const int kInnerX = 4; | 185 const int kInnerX = 4; |
| 186 const int kInnerY = 5; | 186 const int kInnerY = 5; |
| 187 const int kInnerW = 2; | 187 const int kInnerW = 2; |
| 188 const int kInnerH = 3; | 188 const int kInnerH = 3; |
| 189 | 189 |
| 190 // Radius used by some tests to draw a rounded-corner rectangle. | |
| 191 const SkScalar kRadius = 2.0; | |
| 192 | |
| 193 } | 190 } |
| 194 | 191 |
| 195 // 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 |
| 196 // regular skia primitives. | 193 // regular skia primitives. |
| 197 TEST(PlatformCanvas, SkLayer) { | 194 TEST(PlatformCanvas, SkLayer) { |
| 198 // Create the canvas initialized to opaque white. | 195 // Create the canvas initialized to opaque white. |
| 199 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true)); | 196 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true)); |
| 200 canvas->drawColor(SK_ColorWHITE); | 197 canvas->drawColor(SK_ColorWHITE); |
| 201 | 198 |
| 202 // Make a layer and fill it completely to make sure that the bounds are | 199 // Make a layer and fill it completely to make sure that the bounds are |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 canvas->translate(1, 1); | 371 canvas->translate(1, 1); |
| 375 { | 372 { |
| 376 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 373 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 377 canvas->drawColor(SK_ColorWHITE); | 374 canvas->drawColor(SK_ColorWHITE); |
| 378 canvas->translate(1, 1); | 375 canvas->translate(1, 1); |
| 379 | 376 |
| 380 SkPath path; | 377 SkPath path; |
| 381 SkRect rect; | 378 SkRect rect; |
| 382 rect.iset(kInnerX - 1, kInnerY - 1, | 379 rect.iset(kInnerX - 1, kInnerY - 1, |
| 383 kInnerX + kInnerW, kInnerY + kInnerH); | 380 kInnerX + kInnerW, kInnerY + kInnerH); |
| 381 const SkScalar kRadius = 2.0; |
| 384 path.addRoundRect(rect, kRadius, kRadius); | 382 path.addRoundRect(rect, kRadius, kRadius); |
| 385 canvas->clipPath(path); | 383 canvas->clipPath(path); |
| 386 | 384 |
| 387 DrawNativeRect(*canvas, 0, 0, 100, 100); | 385 DrawNativeRect(*canvas, 0, 0, 100, 100); |
| 388 #if defined(OS_WIN) | 386 #if defined(OS_WIN) |
| 389 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH); | 387 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH); |
| 390 #endif | 388 #endif |
| 391 } | 389 } |
| 392 canvas->restore(); | 390 canvas->restore(); |
| 393 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, | 391 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 448 |
| 451 sk_bitmap.lockPixels(); | 449 sk_bitmap.lockPixels(); |
| 452 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); | 450 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); |
| 453 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); | 451 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); |
| 454 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); | 452 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); |
| 455 sk_bitmap.unlockPixels(); | 453 sk_bitmap.unlockPixels(); |
| 456 } | 454 } |
| 457 | 455 |
| 458 | 456 |
| 459 } // namespace skia | 457 } // namespace skia |
| OLD | NEW |