Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: skia/ext/platform_canvas_unittest.cc

Issue 11138024: Simplify platform_canvas.h by recognizing that PlatformCanvas does not actually extend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 // Radius used by some tests to draw a rounded-corner rectangle. 188 // Radius used by some tests to draw a rounded-corner rectangle.
189 const SkScalar kRadius = 2.0; 189 const SkScalar kRadius = 2.0;
190 190
191 } 191 }
192 192
193 // This just checks that our checking code is working properly, it just uses 193 // This just checks that our checking code is working properly, it just uses
194 // regular skia primitives. 194 // regular skia primitives.
195 TEST(PlatformCanvas, SkLayer) { 195 TEST(PlatformCanvas, SkLayer) {
196 // Create the canvas initialized to opaque white. 196 // Create the canvas initialized to opaque white.
197 PlatformCanvas canvas(16, 16, true); 197 SkAutoTUnref<PlatformCanvas> holder(CreatePlatformCanvas(16, 16, true));
198 PlatformCanvas& canvas = *holder.get();
198 canvas.drawColor(SK_ColorWHITE); 199 canvas.drawColor(SK_ColorWHITE);
199 200
200 // Make a layer and fill it completely to make sure that the bounds are 201 // Make a layer and fill it completely to make sure that the bounds are
201 // correct. 202 // correct.
202 { 203 {
203 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); 204 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
204 canvas.drawColor(SK_ColorBLACK); 205 canvas.drawColor(SK_ColorBLACK);
205 } 206 }
206 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH)); 207 EXPECT_TRUE(VerifyBlackRect(canvas, kLayerX, kLayerY, kLayerW, kLayerH));
207 } 208 }
208 209
209 #if !defined(USE_AURA) // http://crbug.com/154358 210 #if !defined(USE_AURA) // http://crbug.com/154358
210 211
211 // Test native clipping. 212 // Test native clipping.
212 TEST(PlatformCanvas, ClipRegion) { 213 TEST(PlatformCanvas, ClipRegion) {
213 // Initialize a white canvas 214 // Initialize a white canvas
214 PlatformCanvas canvas(16, 16, true); 215 SkAutoTUnref<PlatformCanvas> holder(CreatePlatformCanvas(16, 16, true));
216 PlatformCanvas& canvas = *holder.get();
215 canvas.drawColor(SK_ColorWHITE); 217 canvas.drawColor(SK_ColorWHITE);
216 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); 218 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE));
217 219
218 // Test that initially the canvas has no clip region, by filling it 220 // Test that initially the canvas has no clip region, by filling it
219 // with a black rectangle. 221 // with a black rectangle.
220 // Note: Don't use LayerSaver, since internally it sets a clip region. 222 // Note: Don't use LayerSaver, since internally it sets a clip region.
221 DrawNativeRect(canvas, 0, 0, 16, 16); 223 DrawNativeRect(canvas, 0, 0, 16, 16);
222 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK)); 224 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorBLACK));
223 225
224 // Test that intersecting disjoint clip rectangles sets an empty clip region 226 // Test that intersecting disjoint clip rectangles sets an empty clip region
225 canvas.drawColor(SK_ColorWHITE); 227 canvas.drawColor(SK_ColorWHITE);
226 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); 228 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE));
227 { 229 {
228 LayerSaver layer(canvas, 0, 0, 16, 16); 230 LayerSaver layer(canvas, 0, 0, 16, 16);
229 AddClip(canvas, 2, 3, 4, 5); 231 AddClip(canvas, 2, 3, 4, 5);
230 AddClip(canvas, 4, 9, 10, 10); 232 AddClip(canvas, 4, 9, 10, 10);
231 DrawNativeRect(canvas, 0, 0, 16, 16); 233 DrawNativeRect(canvas, 0, 0, 16, 16);
232 } 234 }
233 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE)); 235 EXPECT_TRUE(VerifyCanvasColor(canvas, SK_ColorWHITE));
234 } 236 }
235 237
236 #endif // !defined(USE_AURA) 238 #endif // !defined(USE_AURA)
237 239
238 // Test the layers get filled properly by native rendering. 240 // Test the layers get filled properly by native rendering.
239 TEST(PlatformCanvas, FillLayer) { 241 TEST(PlatformCanvas, FillLayer) {
240 // Create the canvas initialized to opaque white. 242 // Create the canvas initialized to opaque white.
241 PlatformCanvas canvas(16, 16, true); 243 SkAutoTUnref<PlatformCanvas> holder(CreatePlatformCanvas(16, 16, true));
244 PlatformCanvas& canvas = *holder.get();
242 245
243 // Make a layer and fill it completely to make sure that the bounds are 246 // Make a layer and fill it completely to make sure that the bounds are
244 // correct. 247 // correct.
245 canvas.drawColor(SK_ColorWHITE); 248 canvas.drawColor(SK_ColorWHITE);
246 { 249 {
247 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); 250 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
248 DrawNativeRect(canvas, 0, 0, 100, 100); 251 DrawNativeRect(canvas, 0, 0, 100, 100);
249 #if defined(OS_WIN) 252 #if defined(OS_WIN)
250 MakeOpaque(&canvas, 0, 0, 100, 100); 253 MakeOpaque(&canvas, 0, 0, 100, 100);
251 #endif 254 #endif
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 293 }
291 canvas.restore(); 294 canvas.restore();
292 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH)); 295 EXPECT_TRUE(VerifyBlackRect(canvas, kInnerX, kInnerY, kInnerW, kInnerH));
293 } 296 }
294 297
295 #if !defined(USE_AURA) // http://crbug.com/154358 298 #if !defined(USE_AURA) // http://crbug.com/154358
296 299
297 // Test that translation + make layer works properly. 300 // Test that translation + make layer works properly.
298 TEST(PlatformCanvas, TranslateLayer) { 301 TEST(PlatformCanvas, TranslateLayer) {
299 // Create the canvas initialized to opaque white. 302 // Create the canvas initialized to opaque white.
300 PlatformCanvas canvas(16, 16, true); 303 SkAutoTUnref<PlatformCanvas> holder(CreatePlatformCanvas(16, 16, true));
304 PlatformCanvas& canvas = *holder.get();
301 305
302 // Make a layer and fill it completely to make sure that the bounds are 306 // Make a layer and fill it completely to make sure that the bounds are
303 // correct. 307 // correct.
304 canvas.drawColor(SK_ColorWHITE); 308 canvas.drawColor(SK_ColorWHITE);
305 canvas.save(); 309 canvas.save();
306 canvas.translate(1, 1); 310 canvas.translate(1, 1);
307 { 311 {
308 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH); 312 LayerSaver layer(canvas, kLayerX, kLayerY, kLayerW, kLayerH);
309 DrawNativeRect(canvas, 0, 0, 100, 100); 313 DrawNativeRect(canvas, 0, 0, 100, 100);
310 #if defined(OS_WIN) 314 #if defined(OS_WIN)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 393 }
390 canvas.restore(); 394 canvas.restore();
391 EXPECT_TRUE(VerifyRoundedRect(canvas, SK_ColorWHITE, SK_ColorBLACK, 395 EXPECT_TRUE(VerifyRoundedRect(canvas, SK_ColorWHITE, SK_ColorBLACK,
392 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); 396 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH));
393 #endif 397 #endif
394 } 398 }
395 399
396 #endif // #if !defined(USE_AURA) 400 #endif // #if !defined(USE_AURA)
397 401
398 } // namespace skia 402 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698