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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months 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
« no previous file with comments | « services/native_viewport/platform_viewport_ozone.cc ('k') | skia/ext/vector_canvas_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "skia/ext/platform_canvas.h" 7 #include "skia/ext/platform_canvas.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // 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
202 // correct. 202 // correct.
203 { 203 {
204 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH); 204 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH);
205 canvas->drawColor(SK_ColorBLACK); 205 canvas->drawColor(SK_ColorBLACK);
206 } 206 }
207 EXPECT_TRUE(VerifyBlackRect(*canvas, kLayerX, kLayerY, kLayerW, kLayerH)); 207 EXPECT_TRUE(VerifyBlackRect(*canvas, kLayerX, kLayerY, kLayerW, kLayerH));
208 } 208 }
209 209
210 #if !defined(USE_AURA) // http://crbug.com/154358
211
212 // Test native clipping. 210 // Test native clipping.
213 TEST(PlatformCanvas, ClipRegion) { 211 TEST(PlatformCanvas, ClipRegion) {
214 // Initialize a white canvas 212 // Initialize a white canvas
215 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true)); 213 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true));
216 canvas->drawColor(SK_ColorWHITE); 214 canvas->drawColor(SK_ColorWHITE);
217 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE)); 215 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE));
218 216
219 // 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
220 // with a black rectangle. 218 // with a black rectangle.
221 // 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.
222 DrawNativeRect(*canvas, 0, 0, 16, 16); 220 DrawNativeRect(*canvas, 0, 0, 16, 16);
223 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorBLACK)); 221 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorBLACK));
224 222
225 // Test that intersecting disjoint clip rectangles sets an empty clip region 223 // Test that intersecting disjoint clip rectangles sets an empty clip region
226 canvas->drawColor(SK_ColorWHITE); 224 canvas->drawColor(SK_ColorWHITE);
227 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE)); 225 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE));
228 { 226 {
229 LayerSaver layer(*canvas, 0, 0, 16, 16); 227 LayerSaver layer(*canvas, 0, 0, 16, 16);
230 AddClip(*canvas, 2, 3, 4, 5); 228 AddClip(*canvas, 2, 3, 4, 5);
231 AddClip(*canvas, 4, 9, 10, 10); 229 AddClip(*canvas, 4, 9, 10, 10);
232 DrawNativeRect(*canvas, 0, 0, 16, 16); 230 DrawNativeRect(*canvas, 0, 0, 16, 16);
233 } 231 }
234 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE)); 232 EXPECT_TRUE(VerifyCanvasColor(*canvas, SK_ColorWHITE));
235 } 233 }
236 234
237 #endif // !defined(USE_AURA)
238
239 // Test the layers get filled properly by native rendering. 235 // Test the layers get filled properly by native rendering.
240 TEST(PlatformCanvas, FillLayer) { 236 TEST(PlatformCanvas, FillLayer) {
241 // Create the canvas initialized to opaque white. 237 // Create the canvas initialized to opaque white.
242 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true)); 238 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true));
243 239
244 // Make a layer and fill it completely to make sure that the bounds are 240 // Make a layer and fill it completely to make sure that the bounds are
245 // correct. 241 // correct.
246 canvas->drawColor(SK_ColorWHITE); 242 canvas->drawColor(SK_ColorWHITE);
247 { 243 {
248 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH); 244 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH); 282 LayerSaver layer(*canvas, kLayerX, kLayerY, kLayerW, kLayerH);
287 DrawNativeRect(*canvas, 0, 0, 100, 100); 283 DrawNativeRect(*canvas, 0, 0, 100, 100);
288 #if defined(OS_WIN) 284 #if defined(OS_WIN)
289 MakeOpaque(canvas.get(), 0, 0, 100, 100); 285 MakeOpaque(canvas.get(), 0, 0, 100, 100);
290 #endif 286 #endif
291 } 287 }
292 canvas->restore(); 288 canvas->restore();
293 EXPECT_TRUE(VerifyBlackRect(*canvas, kInnerX, kInnerY, kInnerW, kInnerH)); 289 EXPECT_TRUE(VerifyBlackRect(*canvas, kInnerX, kInnerY, kInnerW, kInnerH));
294 } 290 }
295 291
296 #if !defined(USE_AURA) // http://crbug.com/154358
297
298 // Test that translation + make layer works properly. 292 // Test that translation + make layer works properly.
299 TEST(PlatformCanvas, TranslateLayer) { 293 TEST(PlatformCanvas, TranslateLayer) {
300 // Create the canvas initialized to opaque white. 294 // Create the canvas initialized to opaque white.
301 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true)); 295 RefPtr<SkCanvas> canvas = AdoptRef(CreatePlatformCanvas(16, 16, true));
302 296
303 // Make a layer and fill it completely to make sure that the bounds are 297 // Make a layer and fill it completely to make sure that the bounds are
304 // correct. 298 // correct.
305 canvas->drawColor(SK_ColorWHITE); 299 canvas->drawColor(SK_ColorWHITE);
306 canvas->save(); 300 canvas->save();
307 canvas->translate(1, 1); 301 canvas->translate(1, 1);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 #if defined(OS_WIN) 382 #if defined(OS_WIN)
389 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH); 383 MakeOpaque(canvas.get(), kLayerX, kLayerY, kLayerW, kLayerH);
390 #endif 384 #endif
391 } 385 }
392 canvas->restore(); 386 canvas->restore();
393 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK, 387 EXPECT_TRUE(VerifyRoundedRect(*canvas, SK_ColorWHITE, SK_ColorBLACK,
394 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH)); 388 kInnerX + 1, kInnerY + 1, kInnerW, kInnerH));
395 #endif 389 #endif
396 } 390 }
397 391
398 #endif // #if !defined(USE_AURA)
399
400 TEST(PlatformBitmapTest, PlatformBitmap) { 392 TEST(PlatformBitmapTest, PlatformBitmap) {
401 const int kWidth = 400; 393 const int kWidth = 400;
402 const int kHeight = 300; 394 const int kHeight = 300;
403 scoped_ptr<PlatformBitmap> platform_bitmap(new PlatformBitmap); 395 scoped_ptr<PlatformBitmap> platform_bitmap(new PlatformBitmap);
404 396
405 EXPECT_TRUE(0 == platform_bitmap->GetSurface()); 397 EXPECT_TRUE(0 == platform_bitmap->GetSurface());
406 EXPECT_TRUE(platform_bitmap->GetBitmap().empty()); 398 EXPECT_TRUE(platform_bitmap->GetBitmap().empty());
407 EXPECT_TRUE(platform_bitmap->GetBitmap().isNull()); 399 EXPECT_TRUE(platform_bitmap->GetBitmap().isNull());
408 400
409 EXPECT_TRUE(platform_bitmap->Allocate(kWidth, kHeight, /*is_opaque=*/false)); 401 EXPECT_TRUE(platform_bitmap->Allocate(kWidth, kHeight, /*is_opaque=*/false));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 442
451 sk_bitmap.lockPixels(); 443 sk_bitmap.lockPixels();
452 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20)); 444 EXPECT_EQ(0xDEED1020, *sk_bitmap.getAddr32(10, 20));
453 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30)); 445 EXPECT_EQ(0xDEED2030, *sk_bitmap.getAddr32(20, 30));
454 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40)); 446 EXPECT_EQ(0xDEED3040, *sk_bitmap.getAddr32(30, 40));
455 sk_bitmap.unlockPixels(); 447 sk_bitmap.unlockPixels();
456 } 448 }
457 449
458 450
459 } // namespace skia 451 } // namespace skia
OLDNEW
« no previous file with comments | « services/native_viewport/platform_viewport_ozone.cc ('k') | skia/ext/vector_canvas_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698