| 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_WIN) | 9 #if !defined(OS_WIN) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 y_(y), | 109 y_(y), |
| 110 w_(w), | 110 w_(w), |
| 111 h_(h) { | 111 h_(h) { |
| 112 SkRect bounds; | 112 SkRect bounds; |
| 113 bounds.set(SkIntToScalar(x_), SkIntToScalar(y_), | 113 bounds.set(SkIntToScalar(x_), SkIntToScalar(y_), |
| 114 SkIntToScalar(right()), SkIntToScalar(bottom())); | 114 SkIntToScalar(right()), SkIntToScalar(bottom())); |
| 115 canvas_.saveLayer(&bounds, NULL); | 115 canvas_.saveLayer(&bounds, NULL); |
| 116 } | 116 } |
| 117 | 117 |
| 118 ~LayerSaver() { | 118 ~LayerSaver() { |
| 119 #if defined(OS_WIN) | |
| 120 canvas_.getTopPlatformDevice().fixupAlphaBeforeCompositing(); | |
| 121 #endif | |
| 122 canvas_.restore(); | 119 canvas_.restore(); |
| 123 } | 120 } |
| 124 | 121 |
| 125 int x() const { return x_; } | 122 int x() const { return x_; } |
| 126 int y() const { return y_; } | 123 int y() const { return y_; } |
| 127 int w() const { return w_; } | 124 int w() const { return w_; } |
| 128 int h() const { return h_; } | 125 int h() const { return h_; } |
| 129 | 126 |
| 130 // Returns the EXCLUSIVE far bounds of the layer. | 127 // Returns the EXCLUSIVE far bounds of the layer. |
| 131 int right() const { return x_ + w_; } | 128 int right() const { return x_ + w_; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 TEST(PlatformCanvas, ClipRegion) { | 167 TEST(PlatformCanvas, ClipRegion) { |
| 171 // Initialize a white canvas | 168 // Initialize a white canvas |
| 172 PlatformCanvas canvas(16, 16, true); | 169 PlatformCanvas canvas(16, 16, true); |
| 173 canvas.drawColor(SK_ColorWHITE); | 170 canvas.drawColor(SK_ColorWHITE); |
| 174 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 171 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 175 | 172 |
| 176 // Test that initially the canvas has no clip region, by filling it | 173 // Test that initially the canvas has no clip region, by filling it |
| 177 // with a black rectangle. | 174 // with a black rectangle. |
| 178 // Note: Don't use LayerSaver, since internally it sets a clip region. | 175 // Note: Don't use LayerSaver, since internally it sets a clip region. |
| 179 DrawNativeRect(canvas, 0, 0, 16, 16); | 176 DrawNativeRect(canvas, 0, 0, 16, 16); |
| 180 #if defined(OS_WIN) | |
| 181 canvas.getTopPlatformDevice().fixupAlphaBeforeCompositing(); | |
| 182 #endif | |
| 183 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); | 177 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); |
| 184 | 178 |
| 185 // Test that intersecting disjoint clip rectangles sets an empty clip region | 179 // Test that intersecting disjoint clip rectangles sets an empty clip region |
| 186 canvas.drawColor(SK_ColorWHITE); | 180 canvas.drawColor(SK_ColorWHITE); |
| 187 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 181 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 188 { | 182 { |
| 189 LayerSaver layer(canvas, 0, 0, 16, 16); | 183 LayerSaver layer(canvas, 0, 0, 16, 16); |
| 190 AddClip(canvas, 2, 3, 4, 5); | 184 AddClip(canvas, 2, 3, 4, 5); |
| 191 AddClip(canvas, 4, 9, 10, 10); | 185 AddClip(canvas, 4, 9, 10, 10); |
| 192 DrawNativeRect(canvas, 0, 0, 16, 16); | 186 DrawNativeRect(canvas, 0, 0, 16, 16); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 canvas.translate(1, 1); | 284 canvas.translate(1, 1); |
| 291 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 285 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 292 DrawNativeRect(canvas, 0, 0, 100, 100); | 286 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 293 } | 287 } |
| 294 canvas.restore(); | 288 canvas.restore(); |
| 295 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 2, kInnerY + 2, | 289 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX + 2, kInnerY + 2, |
| 296 kInnerW, kInnerH)); | 290 kInnerW, kInnerH)); |
| 297 } | 291 } |
| 298 | 292 |
| 299 } // namespace skia | 293 } // namespace skia |
| OLD | NEW |