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

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

Issue 9416017: Optionally clear PlatformCanvas instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Address style issues. Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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" 5 #include "build/build_config.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #include <unistd.h> 8 #include <unistd.h>
9 #endif 9 #endif
10 10
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 parent::TearDown(); 386 parent::TearDown();
387 } 387 }
388 388
389 void Init(int size) { 389 void Init(int size) {
390 size_ = size; 390 size_ = size;
391 context_ = new Context(); 391 context_ = new Context();
392 bitmap_ = new Bitmap(*context_, size_, size_); 392 bitmap_ = new Bitmap(*context_, size_, size_);
393 vcanvas_ = new VectorCanvas(VectorPlatformDeviceEmf::CreateDevice( 393 vcanvas_ = new VectorCanvas(VectorPlatformDeviceEmf::CreateDevice(
394 size_, size_, true, context_->context())); 394 size_, size_, true, context_->context()));
395 pcanvas_ = new PlatformCanvas(size_, size_, false); 395 pcanvas_ = new PlatformCanvas(size_, size_,
396 PlatformDevice::FLAGS_INITIALIZED);
396 397
397 // Clear white. 398 // Clear white.
398 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 399 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
399 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 400 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
400 } 401 }
401 402
402 // Compares both canvas and returns the pixel difference in percentage between 403 // Compares both canvas and returns the pixel difference in percentage between
403 // both images. 0 on success and ]0, 100] on failure. 404 // both images. 0 on success and ]0, 100] on failure.
404 double ProcessImage(const FilePath::StringType& filename) { 405 double ProcessImage(const FilePath::StringType& filename) {
405 std::wstring number(base::StringPrintf(L"%02d_", number_++)); 406 std::wstring number(base::StringPrintf(L"%02d_", number_++));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // Do a little mubadumba do get uninitialized stuff. 453 // Do a little mubadumba do get uninitialized stuff.
453 VectorCanvasTest::TearDown(); 454 VectorCanvasTest::TearDown();
454 455
455 // The goal is not to verify that have the same uninitialized data. 456 // The goal is not to verify that have the same uninitialized data.
456 compare_canvas_ = false; 457 compare_canvas_ = false;
457 458
458 context_ = new Context(); 459 context_ = new Context();
459 bitmap_ = new Bitmap(*context_, size_, size_); 460 bitmap_ = new Bitmap(*context_, size_, size_);
460 vcanvas_ = new VectorCanvas(VectorPlatformDeviceEmf::CreateDevice( 461 vcanvas_ = new VectorCanvas(VectorPlatformDeviceEmf::CreateDevice(
461 size_, size_, true, context_->context())); 462 size_, size_, true, context_->context()));
462 pcanvas_ = new PlatformCanvas(size_, size_, false); 463 pcanvas_ = new PlatformCanvas(size_, size_,
464 PlatformDevice::FLAGS_INITIALIZED);
463 465
464 // VectorCanvas default initialization is black. 466 // VectorCanvas default initialization is black.
465 // PlatformCanvas default initialization is almost white 0x01FFFEFD (invalid 467 // PlatformCanvas default initialization is almost white 0x01FFFEFD (invalid
466 // Skia color) in both Debug and Release. See magicTransparencyColor in 468 // Skia color) in both Debug and Release. See magicTransparencyColor in
467 // platform_device.cc 469 // platform_device.cc
468 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("empty"))); 470 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("empty")));
469 } 471 }
470 472
471 TEST_F(VectorCanvasTest, BasicDrawing) { 473 TEST_F(VectorCanvasTest, BasicDrawing) {
472 EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.) 474 EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.)
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 { 973 {
972 vcanvas_->rotate(67); 974 vcanvas_->rotate(67);
973 pcanvas_->rotate(67); 975 pcanvas_->rotate(67);
974 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); 976 vcanvas_->drawBitmap(bitmap, 20, -50, NULL);
975 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); 977 pcanvas_->drawBitmap(bitmap, 20, -50, NULL);
976 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); 978 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate")));
977 } 979 }
978 } 980 }
979 981
980 } // namespace skia 982 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698