| 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 #include "build/build_config.h" |
| 6 |
| 7 #if defined(OS_WIN) |
| 5 #include <windows.h> | 8 #include <windows.h> |
| 9 #else |
| 10 #include <unistd.h> |
| 11 #endif |
| 6 | 12 |
| 7 #include "base/gfx/platform_canvas_win.h" | 13 #include "base/gfx/platform_canvas.h" |
| 8 #include "base/gfx/platform_device_win.h" | 14 #include "base/gfx/platform_device.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 16 |
| 11 #include "SkColor.h" | 17 #include "SkColor.h" |
| 12 | 18 |
| 13 namespace gfx { | 19 namespace gfx { |
| 14 | 20 |
| 15 namespace { | 21 namespace { |
| 16 | 22 |
| 17 // Return true if the canvas is filled to canvas_color, | 23 // Return true if the canvas is filled to canvas_color, |
| 18 // and contains a single rectangle filled to rect_color. | 24 // and contains a single rectangle filled to rect_color. |
| 19 bool VerifyRect(const PlatformCanvasWin& canvas, | 25 bool VerifyRect(const PlatformCanvas& canvas, |
| 20 uint32_t canvas_color, uint32_t rect_color, | 26 uint32_t canvas_color, uint32_t rect_color, |
| 21 int x, int y, int w, int h) { | 27 int x, int y, int w, int h) { |
| 22 PlatformDeviceWin& device = canvas.getTopPlatformDevice(); | 28 PlatformDevice& device = canvas.getTopPlatformDevice(); |
| 23 const SkBitmap& bitmap = device.accessBitmap(false); | 29 const SkBitmap& bitmap = device.accessBitmap(false); |
| 24 SkAutoLockPixels lock(bitmap); | 30 SkAutoLockPixels lock(bitmap); |
| 25 | 31 |
| 26 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { | 32 for (int cur_y = 0; cur_y < bitmap.height(); cur_y++) { |
| 27 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) { | 33 for (int cur_x = 0; cur_x < bitmap.width(); cur_x++) { |
| 28 if (cur_x >= x && cur_x < x + w && | 34 if (cur_x >= x && cur_x < x + w && |
| 29 cur_y >= y && cur_y < y + h) { | 35 cur_y >= y && cur_y < y + h) { |
| 30 // Inside the square should be rect_color | 36 // Inside the square should be rect_color |
| 31 if (*bitmap.getAddr32(cur_x, cur_y) != rect_color) | 37 if (*bitmap.getAddr32(cur_x, cur_y) != rect_color) |
| 32 return false; | 38 return false; |
| 33 } else { | 39 } else { |
| 34 // Outside the square should be canvas_color | 40 // Outside the square should be canvas_color |
| 35 if (*bitmap.getAddr32(cur_x, cur_y) != canvas_color) | 41 if (*bitmap.getAddr32(cur_x, cur_y) != canvas_color) |
| 36 return false; | 42 return false; |
| 37 } | 43 } |
| 38 } | 44 } |
| 39 } | 45 } |
| 40 return true; | 46 return true; |
| 41 } | 47 } |
| 42 | 48 |
| 43 // Checks whether there is a white canvas with a black square at the given | 49 // Checks whether there is a white canvas with a black square at the given |
| 44 // location in pixels (not in the canvas coordinate system). | 50 // location in pixels (not in the canvas coordinate system). |
| 45 // TODO(ericroman): rename Square to Rect | 51 // TODO(ericroman): rename Square to Rect |
| 46 bool VerifyBlackSquare(const PlatformCanvasWin& canvas, int x, int y, int w, int
h) { | 52 bool VerifyBlackSquare(const PlatformCanvas& canvas, int x, int y, int w, int h)
{ |
| 47 return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h); | 53 return VerifyRect(canvas, SK_ColorWHITE, SK_ColorBLACK, x, y, w, h); |
| 48 } | 54 } |
| 49 | 55 |
| 50 // Check that every pixel in the canvas is a single color. | 56 // Check that every pixel in the canvas is a single color. |
| 51 bool VerifyCanvasColor(const PlatformCanvasWin& canvas, uint32_t canvas_color) { | 57 bool VerifyCanvasColor(const PlatformCanvas& canvas, uint32_t canvas_color) { |
| 52 return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0); | 58 return VerifyRect(canvas, canvas_color, 0, 0, 0, 0, 0); |
| 53 } | 59 } |
| 54 | 60 |
| 55 void DrawGDIRect(PlatformCanvasWin& canvas, int x, int y, int w, int h) { | 61 #if defined(OS_WIN) |
| 62 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 56 HDC dc = canvas.beginPlatformPaint(); | 63 HDC dc = canvas.beginPlatformPaint(); |
| 57 | 64 |
| 58 RECT inner_rc; | 65 RECT inner_rc; |
| 59 inner_rc.left = x; | 66 inner_rc.left = x; |
| 60 inner_rc.top = y; | 67 inner_rc.top = y; |
| 61 inner_rc.right = x + w; | 68 inner_rc.right = x + w; |
| 62 inner_rc.bottom = y + h; | 69 inner_rc.bottom = y + h; |
| 63 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)))
; | 70 FillRect(dc, &inner_rc, reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)))
; |
| 64 | 71 |
| 65 canvas.endPlatformPaint(); | 72 canvas.endPlatformPaint(); |
| 66 } | 73 } |
| 74 #elif defined(OS_MACOSX) |
| 75 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 76 CGContextRef context = canvas.beginPlatformPaint(); |
| 77 |
| 78 CGRect inner_rc = CGRectMake(x, y, w, h); |
| 79 CGFloat black[] = { 0.0, 0.0, 0.0, 1.0 }; // RGBA opaque black |
| 80 CGContextSetFillColor(context, black); |
| 81 CGContextFillRect(context, inner_rc); |
| 82 |
| 83 canvas.endPlatformPaint(); |
| 84 } |
| 85 #else |
| 86 void DrawNativeRect(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 87 NOTIMPLEMENTED(); |
| 88 } |
| 89 #endif |
| 67 | 90 |
| 68 // Clips the contents of the canvas to the given rectangle. This will be | 91 // Clips the contents of the canvas to the given rectangle. This will be |
| 69 // intersected with any existing clip. | 92 // intersected with any existing clip. |
| 70 void AddClip(PlatformCanvasWin& canvas, int x, int y, int w, int h) { | 93 void AddClip(PlatformCanvas& canvas, int x, int y, int w, int h) { |
| 71 SkRect rect; | 94 SkRect rect; |
| 72 rect.set(SkIntToScalar(x), SkIntToScalar(y), | 95 rect.set(SkIntToScalar(x), SkIntToScalar(y), |
| 73 SkIntToScalar(x + w), SkIntToScalar(y + h)); | 96 SkIntToScalar(x + w), SkIntToScalar(y + h)); |
| 74 canvas.clipRect(rect); | 97 canvas.clipRect(rect); |
| 75 } | 98 } |
| 76 | 99 |
| 77 class LayerSaver { | 100 class LayerSaver { |
| 78 public: | 101 public: |
| 79 LayerSaver(PlatformCanvasWin& canvas, int x, int y, int w, int h) | 102 LayerSaver(PlatformCanvas& canvas, int x, int y, int w, int h) |
| 80 : canvas_(canvas), | 103 : canvas_(canvas), |
| 81 x_(x), | 104 x_(x), |
| 82 y_(y), | 105 y_(y), |
| 83 w_(w), | 106 w_(w), |
| 84 h_(h) { | 107 h_(h) { |
| 85 SkRect bounds; | 108 SkRect bounds; |
| 86 bounds.set(SkIntToScalar(x_), SkIntToScalar(y_), | 109 bounds.set(SkIntToScalar(x_), SkIntToScalar(y_), |
| 87 SkIntToScalar(right()), SkIntToScalar(bottom())); | 110 SkIntToScalar(right()), SkIntToScalar(bottom())); |
| 88 canvas_.saveLayer(&bounds, NULL); | 111 canvas_.saveLayer(&bounds, NULL); |
| 89 } | 112 } |
| 90 | 113 |
| 91 ~LayerSaver() { | 114 ~LayerSaver() { |
| 92 canvas_.getTopPlatformDevice().fixupAlphaBeforeCompositing(); | 115 canvas_.getTopPlatformDevice().fixupAlphaBeforeCompositing(); |
| 93 canvas_.restore(); | 116 canvas_.restore(); |
| 94 } | 117 } |
| 95 | 118 |
| 96 int x() const { return x_; } | 119 int x() const { return x_; } |
| 97 int y() const { return y_; } | 120 int y() const { return y_; } |
| 98 int w() const { return w_; } | 121 int w() const { return w_; } |
| 99 int h() const { return h_; } | 122 int h() const { return h_; } |
| 100 | 123 |
| 101 // Returns the EXCLUSIVE far bounds of the layer. | 124 // Returns the EXCLUSIVE far bounds of the layer. |
| 102 int right() const { return x_ + w_; } | 125 int right() const { return x_ + w_; } |
| 103 int bottom() const { return y_ + h_; } | 126 int bottom() const { return y_ + h_; } |
| 104 | 127 |
| 105 private: | 128 private: |
| 106 PlatformCanvasWin& canvas_; | 129 PlatformCanvas& canvas_; |
| 107 int x_, y_, w_, h_; | 130 int x_, y_, w_, h_; |
| 108 }; | 131 }; |
| 109 | 132 |
| 110 // Size used for making layers in many of the below tests. | 133 // Size used for making layers in many of the below tests. |
| 111 const int kLayerX = 2; | 134 const int kLayerX = 2; |
| 112 const int kLayerY = 3; | 135 const int kLayerY = 3; |
| 113 const int kLayerW = 9; | 136 const int kLayerW = 9; |
| 114 const int kLayerH = 7; | 137 const int kLayerH = 7; |
| 115 | 138 |
| 116 // Size used by some tests to draw a rectangle inside the layer. | 139 // Size used by some tests to draw a rectangle inside the layer. |
| 117 const int kInnerX = 4; | 140 const int kInnerX = 4; |
| 118 const int kInnerY = 5; | 141 const int kInnerY = 5; |
| 119 const int kInnerW = 2; | 142 const int kInnerW = 2; |
| 120 const int kInnerH = 3; | 143 const int kInnerH = 3; |
| 121 | 144 |
| 122 } | 145 } |
| 123 | 146 |
| 124 // This just checks that our checking code is working properly, it just uses | 147 // This just checks that our checking code is working properly, it just uses |
| 125 // regular skia primitives. | 148 // regular skia primitives. |
| 126 TEST(PlatformCanvasWin, SkLayer) { | 149 TEST(PlatformCanvas, SkLayer) { |
| 127 // Create the canvas initialized to opaque white. | 150 // Create the canvas initialized to opaque white. |
| 128 PlatformCanvasWin canvas(16, 16, true); | 151 PlatformCanvas canvas(16, 16, true); |
| 129 canvas.drawColor(SK_ColorWHITE); | 152 canvas.drawColor(SK_ColorWHITE); |
| 130 | 153 |
| 131 // Make a layer and fill it completely to make sure that the bounds are | 154 // Make a layer and fill it completely to make sure that the bounds are |
| 132 // correct. | 155 // correct. |
| 133 { | 156 { |
| 134 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 157 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 135 canvas.drawColor(SK_ColorBLACK); | 158 canvas.drawColor(SK_ColorBLACK); |
| 136 } | 159 } |
| 137 EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); | 160 EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); |
| 138 } | 161 } |
| 139 | 162 |
| 140 // Test the GDI clipping. | 163 // Test native clipping. |
| 141 TEST(PlatformCanvasWin, GDIClipRegion) { | 164 TEST(PlatformCanvas, ClipRegion) { |
| 142 // Initialize a white canvas | 165 // Initialize a white canvas |
| 143 PlatformCanvasWin canvas(16, 16, true); | 166 PlatformCanvas canvas(16, 16, true); |
| 144 canvas.drawColor(SK_ColorWHITE); | 167 canvas.drawColor(SK_ColorWHITE); |
| 145 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 168 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 146 | 169 |
| 147 // Test that initially the canvas has no clip region, by filling it | 170 // Test that initially the canvas has no clip region, by filling it |
| 148 // with a black rectangle. | 171 // with a black rectangle. |
| 149 // Note: Don't use LayerSaver, since internally it sets a clip region. | 172 // Note: Don't use LayerSaver, since internally it sets a clip region. |
| 150 DrawGDIRect(canvas, 0, 0, 16, 16); | 173 DrawNativeRect(canvas, 0, 0, 16, 16); |
| 151 canvas.getTopPlatformDevice().fixupAlphaBeforeCompositing(); | 174 canvas.getTopPlatformDevice().fixupAlphaBeforeCompositing(); |
| 152 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); | 175 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); |
| 153 | 176 |
| 154 // Test that intersecting disjoint clip rectangles sets an empty clip region | 177 // Test that intersecting disjoint clip rectangles sets an empty clip region |
| 155 canvas.drawColor(SK_ColorWHITE); | 178 canvas.drawColor(SK_ColorWHITE); |
| 156 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 179 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 157 { | 180 { |
| 158 LayerSaver layer(canvas, 0, 0, 16, 16); | 181 LayerSaver layer(canvas, 0, 0, 16, 16); |
| 159 AddClip(canvas, 2, 3, 4, 5); | 182 AddClip(canvas, 2, 3, 4, 5); |
| 160 AddClip(canvas, 4, 9, 10, 10); | 183 AddClip(canvas, 4, 9, 10, 10); |
| 161 DrawGDIRect(canvas, 0, 0, 16, 16); | 184 DrawNativeRect(canvas, 0, 0, 16, 16); |
| 162 } | 185 } |
| 163 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); | 186 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); |
| 164 } | 187 } |
| 165 | 188 |
| 166 // Test the layers get filled properly by GDI. | 189 // Test the layers get filled properly by native rendering. |
| 167 TEST(PlatformCanvasWin, GDILayer) { | 190 TEST(PlatformCanvas, FillLayer) { |
| 168 // Create the canvas initialized to opaque white. | 191 // Create the canvas initialized to opaque white. |
| 169 PlatformCanvasWin canvas(16, 16, true); | 192 PlatformCanvas canvas(16, 16, true); |
| 170 | 193 |
| 171 // Make a layer and fill it completely to make sure that the bounds are | 194 // Make a layer and fill it completely to make sure that the bounds are |
| 172 // correct. | 195 // correct. |
| 173 canvas.drawColor(SK_ColorWHITE); | 196 canvas.drawColor(SK_ColorWHITE); |
| 174 { | 197 { |
| 175 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 198 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 176 DrawGDIRect(canvas, 0, 0, 100, 100); | 199 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 177 } | 200 } |
| 178 EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); | 201 EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); |
| 179 | 202 |
| 180 // Make a layer and fill it partially to make sure the translation is correct. | 203 // Make a layer and fill it partially to make sure the translation is correct. |
| 181 canvas.drawColor(SK_ColorWHITE); | 204 canvas.drawColor(SK_ColorWHITE); |
| 182 { | 205 { |
| 183 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 206 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 184 DrawGDIRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 207 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 185 } | 208 } |
| 186 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 209 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 187 | 210 |
| 188 // Add a clip on the layer and fill to make sure clip is correct. | 211 // Add a clip on the layer and fill to make sure clip is correct. |
| 189 canvas.drawColor(SK_ColorWHITE); | 212 canvas.drawColor(SK_ColorWHITE); |
| 190 { | 213 { |
| 191 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 214 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 192 canvas.save(); | 215 canvas.save(); |
| 193 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 216 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 194 DrawGDIRect(canvas, 0, 0, 100, 100); | 217 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 195 canvas.restore(); | 218 canvas.restore(); |
| 196 } | 219 } |
| 197 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 220 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 198 | 221 |
| 199 // Add a clip and then make the layer to make sure the clip is correct. | 222 // Add a clip and then make the layer to make sure the clip is correct. |
| 200 canvas.drawColor(SK_ColorWHITE); | 223 canvas.drawColor(SK_ColorWHITE); |
| 201 canvas.save(); | 224 canvas.save(); |
| 202 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 225 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 203 { | 226 { |
| 204 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 227 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 205 DrawGDIRect(canvas, 0, 0, 100, 100); | 228 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 206 } | 229 } |
| 207 canvas.restore(); | 230 canvas.restore(); |
| 208 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); | 231 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); |
| 209 } | 232 } |
| 210 | 233 |
| 211 // Test that translation + make layer works properly. | 234 // Test that translation + make layer works properly. |
| 212 TEST(PlatformCanvasWin, GDITranslateLayer) { | 235 TEST(PlatformCanvas, TranslateLayer) { |
| 213 // Create the canvas initialized to opaque white. | 236 // Create the canvas initialized to opaque white. |
| 214 PlatformCanvasWin canvas(16, 16, true); | 237 PlatformCanvas canvas(16, 16, true); |
| 215 | 238 |
| 216 // Make a layer and fill it completely to make sure that the bounds are | 239 // Make a layer and fill it completely to make sure that the bounds are |
| 217 // correct. | 240 // correct. |
| 218 canvas.drawColor(SK_ColorWHITE); | 241 canvas.drawColor(SK_ColorWHITE); |
| 219 canvas.save(); | 242 canvas.save(); |
| 220 canvas.translate(1, 1); | 243 canvas.translate(1, 1); |
| 221 { | 244 { |
| 222 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 245 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 223 DrawGDIRect(canvas, 0, 0, 100, 100); | 246 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 224 } | 247 } |
| 225 canvas.restore(); | 248 canvas.restore(); |
| 226 EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX + 1, kLayerY + 1, | 249 EXPECT_TRUE(VerifyBlackSquare(canvas, kLayerX + 1, kLayerY + 1, |
| 227 kLayerW, kLayerH)); | 250 kLayerW, kLayerH)); |
| 228 | 251 |
| 229 // Translate then make the layer. | 252 // Translate then make the layer. |
| 230 canvas.drawColor(SK_ColorWHITE); | 253 canvas.drawColor(SK_ColorWHITE); |
| 231 canvas.save(); | 254 canvas.save(); |
| 232 canvas.translate(1, 1); | 255 canvas.translate(1, 1); |
| 233 { | 256 { |
| 234 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 257 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 235 DrawGDIRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 258 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 236 } | 259 } |
| 237 canvas.restore(); | 260 canvas.restore(); |
| 238 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 1, kInnerY + 1, | 261 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 1, kInnerY + 1, |
| 239 kInnerW, kInnerH)); | 262 kInnerW, kInnerH)); |
| 240 | 263 |
| 241 // Make the layer then translate. | 264 // Make the layer then translate. |
| 242 canvas.drawColor(SK_ColorWHITE); | 265 canvas.drawColor(SK_ColorWHITE); |
| 243 canvas.save(); | 266 canvas.save(); |
| 244 { | 267 { |
| 245 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 268 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 246 canvas.translate(1, 1); | 269 canvas.translate(1, 1); |
| 247 DrawGDIRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 270 DrawNativeRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 248 } | 271 } |
| 249 canvas.restore(); | 272 canvas.restore(); |
| 250 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 1, kInnerY + 1, | 273 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 1, kInnerY + 1, |
| 251 kInnerW, kInnerH)); | 274 kInnerW, kInnerH)); |
| 252 | 275 |
| 253 // Translate both before and after, and have a clip. | 276 // Translate both before and after, and have a clip. |
| 254 canvas.drawColor(SK_ColorWHITE); | 277 canvas.drawColor(SK_ColorWHITE); |
| 255 canvas.save(); | 278 canvas.save(); |
| 256 canvas.translate(1, 1); | 279 canvas.translate(1, 1); |
| 257 { | 280 { |
| 258 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); | 281 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); |
| 259 canvas.translate(1, 1); | 282 canvas.translate(1, 1); |
| 260 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); | 283 AddClip(canvas, kInnerX, kInnerY, kInnerW, kInnerH); |
| 261 DrawGDIRect(canvas, 0, 0, 100, 100); | 284 DrawNativeRect(canvas, 0, 0, 100, 100); |
| 262 } | 285 } |
| 263 canvas.restore(); | 286 canvas.restore(); |
| 264 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 2, kInnerY + 2, | 287 EXPECT_TRUE(VerifyBlackSquare(canvas, kInnerX + 2, kInnerY + 2, |
| 265 kInnerW, kInnerH)); | 288 kInnerW, kInnerH)); |
| 266 } | 289 } |
| 267 | 290 |
| 268 } // namespace | 291 } // namespace |
| 269 | 292 |
| OLD | NEW |