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

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

Issue 280004: Revert wstring patch (r29078 and follow up commits). It is causing failures o... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « net/tools/crash_cache/crash_cache.cc ('k') | tools/memory_watcher/memory_watcher.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) 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" 5 #include "build/build_config.h"
6 6
7 #include "webkit/tools/test_shell/image_decoder_unittest.h" 7 #include "webkit/tools/test_shell/image_decoder_unittest.h"
8 8
9 #if !defined(OS_WIN) 9 #if !defined(OS_WIN)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void* data_; 77 void* data_;
78 78
79 DISALLOW_COPY_AND_ASSIGN(Bitmap); 79 DISALLOW_COPY_AND_ASSIGN(Bitmap);
80 }; 80 };
81 81
82 // Lightweight raw-bitmap management. The image, once initialized, is immuable. 82 // Lightweight raw-bitmap management. The image, once initialized, is immuable.
83 // It is mainly used for comparison. 83 // It is mainly used for comparison.
84 class Image { 84 class Image {
85 public: 85 public:
86 // Creates the image from the given filename on disk. 86 // Creates the image from the given filename on disk.
87 explicit Image(const FilePath& filename) : ignore_alpha_(true) { 87 Image(const std::wstring& filename) : ignore_alpha_(true) {
88 Vector<char> compressed; 88 Vector<char> compressed;
89 ReadFileToVector(filename, &compressed); 89 ReadFileToVector(filename, &compressed);
90 EXPECT_TRUE(compressed.size()); 90 EXPECT_TRUE(compressed.size());
91 WebCore::PNGImageDecoder decoder; 91 WebCore::PNGImageDecoder decoder;
92 decoder.setData(WebCore::SharedBuffer::adoptVector(compressed).get(), true); 92 decoder.setData(WebCore::SharedBuffer::adoptVector(compressed).get(), true);
93 scoped_ptr<NativeImageSkia> image_data( 93 scoped_ptr<NativeImageSkia> image_data(
94 decoder.frameBufferAtIndex(0)->asNewNativeImage()); 94 decoder.frameBufferAtIndex(0)->asNewNativeImage());
95 SetSkBitmap(*image_data); 95 SetSkBitmap(*image_data);
96 } 96 }
97 97
(...skipping 18 matching lines...) Expand all
116 // Loads the image from a canvas. 116 // Loads the image from a canvas.
117 Image(const SkBitmap& bitmap) : ignore_alpha_(true) { 117 Image(const SkBitmap& bitmap) : ignore_alpha_(true) {
118 SetSkBitmap(bitmap); 118 SetSkBitmap(bitmap);
119 } 119 }
120 120
121 int width() const { return width_; } 121 int width() const { return width_; }
122 int height() const { return height_; } 122 int height() const { return height_; }
123 int row_length() const { return row_length_; } 123 int row_length() const { return row_length_; }
124 124
125 // Save the image to a png file. Used to create the initial test files. 125 // Save the image to a png file. Used to create the initial test files.
126 void SaveToFile(const FilePath& filename) { 126 void SaveToFile(const std::wstring& filename) {
127 std::vector<unsigned char> compressed; 127 std::vector<unsigned char> compressed;
128 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(), 128 ASSERT_TRUE(gfx::PNGCodec::Encode(&*data_.begin(),
129 gfx::PNGCodec::FORMAT_BGRA, 129 gfx::PNGCodec::FORMAT_BGRA,
130 width_, 130 width_,
131 height_, 131 height_,
132 row_length_, 132 row_length_,
133 true, 133 true,
134 &compressed)); 134 &compressed));
135 ASSERT_TRUE(compressed.size()); 135 ASSERT_TRUE(compressed.size());
136 FILE* f = file_util::OpenFile(filename, "wb"); 136 FILE* f = file_util::OpenFile(filename, "wb");
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 ImageTest(ProcessAction default_action) 223 ImageTest(ProcessAction default_action)
224 : action_(default_action) { 224 : action_(default_action) {
225 } 225 }
226 226
227 protected: 227 protected:
228 virtual void SetUp() { 228 virtual void SetUp() {
229 const testing::TestInfo& test_info = 229 const testing::TestInfo& test_info =
230 *testing::UnitTest::GetInstance()->current_test_info(); 230 *testing::UnitTest::GetInstance()->current_test_info();
231 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir_); 231 PathService::Get(base::DIR_SOURCE_ROOT, &test_dir_);
232 test_dir_ = test_dir_.AppendASCII("skia"). 232 file_util::AppendToPath(&test_dir_, L"skia");
233 AppendASCII("ext"). 233 file_util::AppendToPath(&test_dir_, L"ext");
234 AppendASCII("data"). 234 file_util::AppendToPath(&test_dir_, L"data");
235 AppendASCII(test_info.test_case_name()). 235 file_util::AppendToPath(&test_dir_,
236 AppendASCII(test_info.name()); 236 ASCIIToWide(test_info.test_case_name()));
237 file_util::AppendToPath(&test_dir_, ASCIIToWide(test_info.name()));
237 238
238 // Hack for a quick lowercase. We assume all the tests names are ASCII. 239 // Hack for a quick lowercase. We assume all the tests names are ASCII.
239 std::string tmp(WideToASCII(test_dir_.ToWStringHack())); 240 std::string tmp(WideToASCII(test_dir_));
240 for (size_t i = 0; i < tmp.size(); ++i) 241 for (size_t i = 0; i < tmp.size(); ++i)
241 tmp[i] = ToLowerASCII(tmp[i]); 242 tmp[i] = ToLowerASCII(tmp[i]);
242 test_dir_ = FilePath::FromWStringHack(ASCIIToWide(tmp)); 243 test_dir_ = ASCIIToWide(tmp);
243 244
244 if (action_ == GENERATE) { 245 if (action_ == GENERATE) {
245 // Make sure the directory exist. 246 // Make sure the directory exist.
246 file_util::CreateDirectory(test_dir_); 247 file_util::CreateDirectory(test_dir_);
247 } 248 }
248 } 249 }
249 250
250 // Returns the fully qualified path of a data file. 251 // Returns the fully qualified path of a data file.
251 FilePath test_file(const FilePath::StringType& filename) const { 252 std::wstring test_file(const std::wstring& filename) const {
252 // Hack for a quick lowercase. We assume all the test data file names are 253 // Hack for a quick lowercase. We assume all the test data file names are
253 // ASCII. 254 // ASCII.
254 #if defined(OS_WIN) 255 std::string tmp(WideToASCII(filename));
255 std::string tmp = WideToASCII(filename);
256 #else
257 std::string tmp(filename);
258 #endif
259 for (size_t i = 0; i < tmp.size(); ++i) 256 for (size_t i = 0; i < tmp.size(); ++i)
260 tmp[i] = ToLowerASCII(tmp[i]); 257 tmp[i] = ToLowerASCII(tmp[i]);
261 258
262 return test_dir_.AppendASCII(tmp); 259 std::wstring path(test_dir_);
260 file_util::AppendToPath(&path, ASCIIToWide(tmp));
261 return path;
263 } 262 }
264 263
265 // Compares or saves the bitmap currently loaded in the context, depending on 264 // Compares or saves the bitmap currently loaded in the context, depending on
266 // kGenerating value. Returns 0 on success or any positive value between ]0, 265 // kGenerating value. Returns 0 on success or any positive value between ]0,
267 // 100] on failure. The return value is the percentage of difference between 266 // 100] on failure. The return value is the percentage of difference between
268 // the image in the file and the image in the canvas. 267 // the image in the file and the image in the canvas.
269 double ProcessCanvas(const skia::PlatformCanvas& canvas, 268 double ProcessCanvas(const skia::PlatformCanvas& canvas,
270 FilePath::StringType filename) const { 269 std::wstring filename) const {
271 filename = filename + FILE_PATH_LITERAL(".png"); 270 filename += L".png";
272 switch (action_) { 271 switch (action_) {
273 case GENERATE: 272 case GENERATE:
274 SaveImage(canvas, filename); 273 SaveImage(canvas, filename);
275 return 0.; 274 return 0.;
276 case COMPARE: 275 case COMPARE:
277 return CompareImage(canvas, filename); 276 return CompareImage(canvas, filename);
278 case NOOP: 277 case NOOP:
279 return 0; 278 return 0;
280 default: 279 default:
281 // Invalid state, returns that the image is 100 different. 280 // Invalid state, returns that the image is 100 different.
282 return 100.; 281 return 100.;
283 } 282 }
284 } 283 }
285 284
286 // Compares the bitmap currently loaded in the context with the file. Returns 285 // Compares the bitmap currently loaded in the context with the file. Returns
287 // the percentage of pixel difference between both images, between 0 and 100. 286 // the percentage of pixel difference between both images, between 0 and 100.
288 double CompareImage(const skia::PlatformCanvas& canvas, 287 double CompareImage(const skia::PlatformCanvas& canvas,
289 const FilePath::StringType& filename) const { 288 const std::wstring& filename) const {
290 Image image1(canvas); 289 Image image1(canvas);
291 Image image2(test_file(filename)); 290 Image image2(test_file(filename));
292 double diff = image1.PercentageDifferent(image2); 291 double diff = image1.PercentageDifferent(image2);
293 return diff; 292 return diff;
294 } 293 }
295 294
296 // Saves the bitmap currently loaded in the context into the file. 295 // Saves the bitmap currently loaded in the context into the file.
297 void SaveImage(const skia::PlatformCanvas& canvas, 296 void SaveImage(const skia::PlatformCanvas& canvas,
298 const FilePath::StringType& filename) const { 297 const std::wstring& filename) const {
299 Image(canvas).SaveToFile(test_file(filename)); 298 Image(canvas).SaveToFile(test_file(filename));
300 } 299 }
301 300
302 ProcessAction action_; 301 ProcessAction action_;
303 302
304 // Path to directory used to contain the test data. 303 // Path to directory used to contain the test data.
305 FilePath test_dir_; 304 std::wstring test_dir_;
306 305
307 DISALLOW_COPY_AND_ASSIGN(ImageTest); 306 DISALLOW_COPY_AND_ASSIGN(ImageTest);
308 }; 307 };
309 308
310 // Premultiply the Alpha channel on the R, B and G channels. 309 // Premultiply the Alpha channel on the R, B and G channels.
311 void Premultiply(SkBitmap bitmap) { 310 void Premultiply(SkBitmap bitmap) {
312 SkAutoLockPixels lock(bitmap); 311 SkAutoLockPixels lock(bitmap);
313 for (int x = 0; x < bitmap.width(); ++x) { 312 for (int x = 0; x < bitmap.width(); ++x) {
314 for (int y = 0; y < bitmap.height(); ++y) { 313 for (int y = 0; y < bitmap.height(); ++y) {
315 uint32_t* pixel_addr = bitmap.getAddr32(x, y); 314 uint32_t* pixel_addr = bitmap.getAddr32(x, y);
316 uint32_t color = *pixel_addr; 315 uint32_t color = *pixel_addr;
317 BYTE alpha = SkColorGetA(color); 316 BYTE alpha = SkColorGetA(color);
318 if (!alpha) { 317 if (!alpha) {
319 *pixel_addr = 0; 318 *pixel_addr = 0;
320 } else { 319 } else {
321 BYTE alpha_offset = alpha / 2; 320 BYTE alpha_offset = alpha / 2;
322 *pixel_addr = SkColorSetARGB( 321 *pixel_addr = SkColorSetARGB(
323 SkColorGetA(color), 322 SkColorGetA(color),
324 (SkColorGetR(color) * 255 + alpha_offset) / alpha, 323 (SkColorGetR(color) * 255 + alpha_offset) / alpha,
325 (SkColorGetG(color) * 255 + alpha_offset) / alpha, 324 (SkColorGetG(color) * 255 + alpha_offset) / alpha,
326 (SkColorGetB(color) * 255 + alpha_offset) / alpha); 325 (SkColorGetB(color) * 255 + alpha_offset) / alpha);
327 } 326 }
328 } 327 }
329 } 328 }
330 } 329 }
331 330
332 void LoadPngFileToSkBitmap(const FilePath& filename, 331 void LoadPngFileToSkBitmap(const std::wstring& filename,
333 SkBitmap* bitmap, 332 SkBitmap* bitmap,
334 bool is_opaque) { 333 bool is_opaque) {
335 Vector<char> compressed; 334 Vector<char> compressed;
336 ReadFileToVector(filename, &compressed); 335 ReadFileToVector(filename, &compressed);
337 EXPECT_TRUE(compressed.size()); 336 EXPECT_TRUE(compressed.size());
338 WebCore::PNGImageDecoder decoder; 337 WebCore::PNGImageDecoder decoder;
339 decoder.setData(WebCore::SharedBuffer::adoptVector(compressed).get(), true); 338 decoder.setData(WebCore::SharedBuffer::adoptVector(compressed).get(), true);
340 scoped_ptr<NativeImageSkia> image_data( 339 scoped_ptr<NativeImageSkia> image_data(
341 decoder.frameBufferAtIndex(0)->asNewNativeImage()); 340 decoder.frameBufferAtIndex(0)->asNewNativeImage());
342 *bitmap = *image_data; 341 *bitmap = *image_data;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 vcanvas_ = new VectorCanvas(context_->context(), size_, size_); 390 vcanvas_ = new VectorCanvas(context_->context(), size_, size_);
392 pcanvas_ = new PlatformCanvas(size_, size_, false); 391 pcanvas_ = new PlatformCanvas(size_, size_, false);
393 392
394 // Clear white. 393 // Clear white.
395 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 394 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
396 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 395 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
397 } 396 }
398 397
399 // Compares both canvas and returns the pixel difference in percentage between 398 // Compares both canvas and returns the pixel difference in percentage between
400 // both images. 0 on success and ]0, 100] on failure. 399 // both images. 0 on success and ]0, 100] on failure.
401 double ProcessImage(const FilePath::StringType& filename) { 400 double ProcessImage(const std::wstring& filename) {
402 std::wstring number(StringPrintf(L"%02d_", number_++)); 401 std::wstring number(StringPrintf(L"%02d_", number_++));
403 double diff1 = parent::ProcessCanvas(*vcanvas_, number + L"vc_" + filename); 402 double diff1 = parent::ProcessCanvas(*vcanvas_, number + L"vc_" + filename);
404 double diff2 = parent::ProcessCanvas(*pcanvas_, number + L"pc_" + filename); 403 double diff2 = parent::ProcessCanvas(*pcanvas_, number + L"pc_" + filename);
405 if (!compare_canvas_) 404 if (!compare_canvas_)
406 return std::max(diff1, diff2); 405 return std::max(diff1, diff2);
407 406
408 Image image1(*vcanvas_); 407 Image image1(*vcanvas_);
409 Image image2(*pcanvas_); 408 Image image2(*pcanvas_);
410 double diff = image1.PercentageDifferent(image2); 409 double diff = image1.PercentageDifferent(image2);
411 return std::max(std::max(diff1, diff2), diff); 410 return std::max(std::max(diff1, diff2), diff);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 453
455 context_ = new Context(); 454 context_ = new Context();
456 bitmap_ = new Bitmap(*context_, size_, size_); 455 bitmap_ = new Bitmap(*context_, size_, size_);
457 vcanvas_ = new VectorCanvas(context_->context(), size_, size_); 456 vcanvas_ = new VectorCanvas(context_->context(), size_, size_);
458 pcanvas_ = new PlatformCanvas(size_, size_, false); 457 pcanvas_ = new PlatformCanvas(size_, size_, false);
459 458
460 // VectorCanvas default initialization is black. 459 // VectorCanvas default initialization is black.
461 // PlatformCanvas default initialization is almost white 0x01FFFEFD (invalid 460 // PlatformCanvas default initialization is almost white 0x01FFFEFD (invalid
462 // Skia color) in both Debug and Release. See magicTransparencyColor in 461 // Skia color) in both Debug and Release. See magicTransparencyColor in
463 // platform_device.cc 462 // platform_device.cc
464 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("empty"))); 463 EXPECT_EQ(0., ProcessImage(L"empty"));
465 } 464 }
466 465
467 TEST_F(VectorCanvasTest, BasicDrawing) { 466 TEST_F(VectorCanvasTest, BasicDrawing) {
468 EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.) 467 EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.)
469 << L"clean"; 468 << L"clean";
470 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("clean"))); 469 EXPECT_EQ(0., ProcessImage(L"clean"));
471 470
472 // Clear white. 471 // Clear white.
473 { 472 {
474 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 473 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
475 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); 474 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode);
476 } 475 }
477 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawARGB"))); 476 EXPECT_EQ(0., ProcessImage(L"drawARGB"));
478 477
479 // Diagonal line top-left to bottom-right. 478 // Diagonal line top-left to bottom-right.
480 { 479 {
481 SkPaint paint; 480 SkPaint paint;
482 // Default color is black. 481 // Default color is black.
483 vcanvas_->drawLine(10, 10, 90, 90, paint); 482 vcanvas_->drawLine(10, 10, 90, 90, paint);
484 pcanvas_->drawLine(10, 10, 90, 90, paint); 483 pcanvas_->drawLine(10, 10, 90, 90, paint);
485 } 484 }
486 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_black"))); 485 EXPECT_EQ(0., ProcessImage(L"drawLine_black"));
487 486
488 // Rect. 487 // Rect.
489 { 488 {
490 SkPaint paint; 489 SkPaint paint;
491 paint.setColor(SK_ColorGREEN); 490 paint.setColor(SK_ColorGREEN);
492 vcanvas_->drawRectCoords(25, 25, 75, 75, paint); 491 vcanvas_->drawRectCoords(25, 25, 75, 75, paint);
493 pcanvas_->drawRectCoords(25, 25, 75, 75, paint); 492 pcanvas_->drawRectCoords(25, 25, 75, 75, paint);
494 } 493 }
495 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_green"))); 494 EXPECT_EQ(0., ProcessImage(L"drawRect_green"));
496 495
497 // A single-point rect doesn't leave any mark. 496 // A single-point rect doesn't leave any mark.
498 { 497 {
499 SkPaint paint; 498 SkPaint paint;
500 paint.setColor(SK_ColorBLUE); 499 paint.setColor(SK_ColorBLUE);
501 vcanvas_->drawRectCoords(5, 5, 5, 5, paint); 500 vcanvas_->drawRectCoords(5, 5, 5, 5, paint);
502 pcanvas_->drawRectCoords(5, 5, 5, 5, paint); 501 pcanvas_->drawRectCoords(5, 5, 5, 5, paint);
503 } 502 }
504 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_noop"))); 503 EXPECT_EQ(0., ProcessImage(L"drawRect_noop"));
505 504
506 // Rect. 505 // Rect.
507 { 506 {
508 SkPaint paint; 507 SkPaint paint;
509 paint.setColor(SK_ColorBLUE); 508 paint.setColor(SK_ColorBLUE);
510 vcanvas_->drawRectCoords(75, 50, 80, 55, paint); 509 vcanvas_->drawRectCoords(75, 50, 80, 55, paint);
511 pcanvas_->drawRectCoords(75, 50, 80, 55, paint); 510 pcanvas_->drawRectCoords(75, 50, 80, 55, paint);
512 } 511 }
513 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawRect_noop"))); 512 EXPECT_EQ(0., ProcessImage(L"drawRect_noop"));
514 513
515 // Empty again 514 // Empty again
516 { 515 {
517 vcanvas_->drawPaint(SkPaint()); 516 vcanvas_->drawPaint(SkPaint());
518 pcanvas_->drawPaint(SkPaint()); 517 pcanvas_->drawPaint(SkPaint());
519 } 518 }
520 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPaint_black"))); 519 EXPECT_EQ(0., ProcessImage(L"drawPaint_black"));
521 520
522 // Horizontal line left to right. 521 // Horizontal line left to right.
523 { 522 {
524 SkPaint paint; 523 SkPaint paint;
525 paint.setColor(SK_ColorRED); 524 paint.setColor(SK_ColorRED);
526 vcanvas_->drawLine(10, 20, 90, 20, paint); 525 vcanvas_->drawLine(10, 20, 90, 20, paint);
527 pcanvas_->drawLine(10, 20, 90, 20, paint); 526 pcanvas_->drawLine(10, 20, 90, 20, paint);
528 } 527 }
529 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_left_to_right"))); 528 EXPECT_EQ(0., ProcessImage(L"drawLine_left_to_right"));
530 529
531 // Vertical line downward. 530 // Vertical line downward.
532 { 531 {
533 SkPaint paint; 532 SkPaint paint;
534 paint.setColor(SK_ColorRED); 533 paint.setColor(SK_ColorRED);
535 vcanvas_->drawLine(30, 10, 30, 90, paint); 534 vcanvas_->drawLine(30, 10, 30, 90, paint);
536 pcanvas_->drawLine(30, 10, 30, 90, paint); 535 pcanvas_->drawLine(30, 10, 30, 90, paint);
537 } 536 }
538 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawLine_red"))); 537 EXPECT_EQ(0., ProcessImage(L"drawLine_red"));
539 } 538 }
540 539
541 TEST_F(VectorCanvasTest, Circles) { 540 TEST_F(VectorCanvasTest, Circles) {
542 // There is NO WAY to make them agree. At least verify that the output doesn't 541 // There is NO WAY to make them agree. At least verify that the output doesn't
543 // change across versions. This test is disabled. See bug 1060231. 542 // change across versions. This test is disabled. See bug 1060231.
544 compare_canvas_ = false; 543 compare_canvas_ = false;
545 544
546 // Stroked Circle. 545 // Stroked Circle.
547 { 546 {
548 SkPaint paint; 547 SkPaint paint;
549 SkPath path; 548 SkPath path;
550 path.addCircle(50, 75, 10); 549 path.addCircle(50, 75, 10);
551 paint.setStyle(SkPaint::kStroke_Style); 550 paint.setStyle(SkPaint::kStroke_Style);
552 paint.setColor(SK_ColorMAGENTA); 551 paint.setColor(SK_ColorMAGENTA);
553 vcanvas_->drawPath(path, paint); 552 vcanvas_->drawPath(path, paint);
554 pcanvas_->drawPath(path, paint); 553 pcanvas_->drawPath(path, paint);
555 } 554 }
556 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_stroke"))); 555 EXPECT_EQ(0., ProcessImage(L"circle_stroke"));
557 556
558 // Filled Circle. 557 // Filled Circle.
559 { 558 {
560 SkPaint paint; 559 SkPaint paint;
561 SkPath path; 560 SkPath path;
562 path.addCircle(50, 25, 10); 561 path.addCircle(50, 25, 10);
563 paint.setStyle(SkPaint::kFill_Style); 562 paint.setStyle(SkPaint::kFill_Style);
564 vcanvas_->drawPath(path, paint); 563 vcanvas_->drawPath(path, paint);
565 pcanvas_->drawPath(path, paint); 564 pcanvas_->drawPath(path, paint);
566 } 565 }
567 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_fill"))); 566 EXPECT_EQ(0., ProcessImage(L"circle_fill"));
568 567
569 // Stroked Circle over. 568 // Stroked Circle over.
570 { 569 {
571 SkPaint paint; 570 SkPaint paint;
572 SkPath path; 571 SkPath path;
573 path.addCircle(50, 25, 10); 572 path.addCircle(50, 25, 10);
574 paint.setStyle(SkPaint::kStroke_Style); 573 paint.setStyle(SkPaint::kStroke_Style);
575 paint.setColor(SK_ColorBLUE); 574 paint.setColor(SK_ColorBLUE);
576 vcanvas_->drawPath(path, paint); 575 vcanvas_->drawPath(path, paint);
577 pcanvas_->drawPath(path, paint); 576 pcanvas_->drawPath(path, paint);
578 } 577 }
579 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_over_strike"))); 578 EXPECT_EQ(0., ProcessImage(L"circle_over_strike"));
580 579
581 // Stroke and Fill Circle. 580 // Stroke and Fill Circle.
582 { 581 {
583 SkPaint paint; 582 SkPaint paint;
584 SkPath path; 583 SkPath path;
585 path.addCircle(12, 50, 10); 584 path.addCircle(12, 50, 10);
586 paint.setStyle(SkPaint::kStrokeAndFill_Style); 585 paint.setStyle(SkPaint::kStrokeAndFill_Style);
587 paint.setColor(SK_ColorRED); 586 paint.setColor(SK_ColorRED);
588 vcanvas_->drawPath(path, paint); 587 vcanvas_->drawPath(path, paint);
589 pcanvas_->drawPath(path, paint); 588 pcanvas_->drawPath(path, paint);
590 } 589 }
591 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle_stroke_and_fill"))); 590 EXPECT_EQ(0., ProcessImage(L"circle_stroke_and_fill"));
592 591
593 // Line + Quad + Cubic. 592 // Line + Quad + Cubic.
594 { 593 {
595 SkPaint paint; 594 SkPaint paint;
596 SkPath path; 595 SkPath path;
597 paint.setStyle(SkPaint::kStroke_Style); 596 paint.setStyle(SkPaint::kStroke_Style);
598 paint.setColor(SK_ColorGREEN); 597 paint.setColor(SK_ColorGREEN);
599 path.moveTo(1, 1); 598 path.moveTo(1, 1);
600 path.lineTo(60, 40); 599 path.lineTo(60, 40);
601 path.lineTo(80, 80); 600 path.lineTo(80, 80);
602 path.quadTo(20, 50, 10, 90); 601 path.quadTo(20, 50, 10, 90);
603 path.quadTo(50, 20, 90, 10); 602 path.quadTo(50, 20, 90, 10);
604 path.cubicTo(20, 40, 50, 50, 10, 10); 603 path.cubicTo(20, 40, 50, 50, 10, 10);
605 path.cubicTo(30, 20, 50, 50, 90, 10); 604 path.cubicTo(30, 20, 50, 50, 90, 10);
606 path.addRect(90, 90, 95, 96); 605 path.addRect(90, 90, 95, 96);
607 vcanvas_->drawPath(path, paint); 606 vcanvas_->drawPath(path, paint);
608 pcanvas_->drawPath(path, paint); 607 pcanvas_->drawPath(path, paint);
609 } 608 }
610 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("mixed_stroke"))); 609 EXPECT_EQ(0., ProcessImage(L"mixed_stroke"));
611 } 610 }
612 611
613 TEST_F(VectorCanvasTest, LineOrientation) { 612 TEST_F(VectorCanvasTest, LineOrientation) {
614 // There is NO WAY to make them agree. At least verify that the output doesn't 613 // There is NO WAY to make them agree. At least verify that the output doesn't
615 // change across versions. This test is disabled. See bug 1060231. 614 // change across versions. This test is disabled. See bug 1060231.
616 compare_canvas_ = false; 615 compare_canvas_ = false;
617 616
618 // Horizontal lines. 617 // Horizontal lines.
619 { 618 {
620 SkPaint paint; 619 SkPaint paint;
621 paint.setColor(SK_ColorRED); 620 paint.setColor(SK_ColorRED);
622 // Left to right. 621 // Left to right.
623 vcanvas_->drawLine(10, 20, 90, 20, paint); 622 vcanvas_->drawLine(10, 20, 90, 20, paint);
624 pcanvas_->drawLine(10, 20, 90, 20, paint); 623 pcanvas_->drawLine(10, 20, 90, 20, paint);
625 // Right to left. 624 // Right to left.
626 vcanvas_->drawLine(90, 30, 10, 30, paint); 625 vcanvas_->drawLine(90, 30, 10, 30, paint);
627 pcanvas_->drawLine(90, 30, 10, 30, paint); 626 pcanvas_->drawLine(90, 30, 10, 30, paint);
628 } 627 }
629 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("horizontal"))); 628 EXPECT_EQ(0., ProcessImage(L"horizontal"));
630 629
631 // Vertical lines. 630 // Vertical lines.
632 { 631 {
633 SkPaint paint; 632 SkPaint paint;
634 paint.setColor(SK_ColorRED); 633 paint.setColor(SK_ColorRED);
635 // Top down. 634 // Top down.
636 vcanvas_->drawLine(20, 10, 20, 90, paint); 635 vcanvas_->drawLine(20, 10, 20, 90, paint);
637 pcanvas_->drawLine(20, 10, 20, 90, paint); 636 pcanvas_->drawLine(20, 10, 20, 90, paint);
638 // Bottom up. 637 // Bottom up.
639 vcanvas_->drawLine(30, 90, 30, 10, paint); 638 vcanvas_->drawLine(30, 90, 30, 10, paint);
640 pcanvas_->drawLine(30, 90, 30, 10, paint); 639 pcanvas_->drawLine(30, 90, 30, 10, paint);
641 } 640 }
642 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("vertical"))); 641 EXPECT_EQ(0., ProcessImage(L"vertical"));
643 642
644 // Try again with a 180 degres rotation. 643 // Try again with a 180 degres rotation.
645 vcanvas_->rotate(180); 644 vcanvas_->rotate(180);
646 pcanvas_->rotate(180); 645 pcanvas_->rotate(180);
647 646
648 // Horizontal lines (rotated). 647 // Horizontal lines (rotated).
649 { 648 {
650 SkPaint paint; 649 SkPaint paint;
651 paint.setColor(SK_ColorRED); 650 paint.setColor(SK_ColorRED);
652 vcanvas_->drawLine(-10, -25, -90, -25, paint); 651 vcanvas_->drawLine(-10, -25, -90, -25, paint);
653 pcanvas_->drawLine(-10, -25, -90, -25, paint); 652 pcanvas_->drawLine(-10, -25, -90, -25, paint);
654 vcanvas_->drawLine(-90, -35, -10, -35, paint); 653 vcanvas_->drawLine(-90, -35, -10, -35, paint);
655 pcanvas_->drawLine(-90, -35, -10, -35, paint); 654 pcanvas_->drawLine(-90, -35, -10, -35, paint);
656 } 655 }
657 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("horizontal_180"))); 656 EXPECT_EQ(0., ProcessImage(L"horizontal_180"));
658 657
659 // Vertical lines (rotated). 658 // Vertical lines (rotated).
660 { 659 {
661 SkPaint paint; 660 SkPaint paint;
662 paint.setColor(SK_ColorRED); 661 paint.setColor(SK_ColorRED);
663 vcanvas_->drawLine(-25, -10, -25, -90, paint); 662 vcanvas_->drawLine(-25, -10, -25, -90, paint);
664 pcanvas_->drawLine(-25, -10, -25, -90, paint); 663 pcanvas_->drawLine(-25, -10, -25, -90, paint);
665 vcanvas_->drawLine(-35, -90, -35, -10, paint); 664 vcanvas_->drawLine(-35, -90, -35, -10, paint);
666 pcanvas_->drawLine(-35, -90, -35, -10, paint); 665 pcanvas_->drawLine(-35, -90, -35, -10, paint);
667 } 666 }
668 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("vertical_180"))); 667 EXPECT_EQ(0., ProcessImage(L"vertical_180"));
669 } 668 }
670 669
671 TEST_F(VectorCanvasTest, PathOrientation) { 670 TEST_F(VectorCanvasTest, PathOrientation) {
672 // There is NO WAY to make them agree. At least verify that the output doesn't 671 // There is NO WAY to make them agree. At least verify that the output doesn't
673 // change across versions. This test is disabled. See bug 1060231. 672 // change across versions. This test is disabled. See bug 1060231.
674 compare_canvas_ = false; 673 compare_canvas_ = false;
675 674
676 // Horizontal lines. 675 // Horizontal lines.
677 { 676 {
678 SkPaint paint; 677 SkPaint paint;
679 paint.setStyle(SkPaint::kStroke_Style); 678 paint.setStyle(SkPaint::kStroke_Style);
680 paint.setColor(SK_ColorRED); 679 paint.setColor(SK_ColorRED);
681 SkPath path; 680 SkPath path;
682 SkPoint start; 681 SkPoint start;
683 start.set(10, 20); 682 start.set(10, 20);
684 SkPoint end; 683 SkPoint end;
685 end.set(90, 20); 684 end.set(90, 20);
686 path.moveTo(start); 685 path.moveTo(start);
687 path.lineTo(end); 686 path.lineTo(end);
688 vcanvas_->drawPath(path, paint); 687 vcanvas_->drawPath(path, paint);
689 pcanvas_->drawPath(path, paint); 688 pcanvas_->drawPath(path, paint);
690 } 689 }
691 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPath_ltr"))); 690 EXPECT_EQ(0., ProcessImage(L"drawPath_ltr"));
692 691
693 // Horizontal lines. 692 // Horizontal lines.
694 { 693 {
695 SkPaint paint; 694 SkPaint paint;
696 paint.setStyle(SkPaint::kStroke_Style); 695 paint.setStyle(SkPaint::kStroke_Style);
697 paint.setColor(SK_ColorRED); 696 paint.setColor(SK_ColorRED);
698 SkPath path; 697 SkPath path;
699 SkPoint start; 698 SkPoint start;
700 start.set(90, 30); 699 start.set(90, 30);
701 SkPoint end; 700 SkPoint end;
702 end.set(10, 30); 701 end.set(10, 30);
703 path.moveTo(start); 702 path.moveTo(start);
704 path.lineTo(end); 703 path.lineTo(end);
705 vcanvas_->drawPath(path, paint); 704 vcanvas_->drawPath(path, paint);
706 pcanvas_->drawPath(path, paint); 705 pcanvas_->drawPath(path, paint);
707 } 706 }
708 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("drawPath_rtl"))); 707 EXPECT_EQ(0., ProcessImage(L"drawPath_rtl"));
709 } 708 }
710 709
711 TEST_F(VectorCanvasTest, DiagonalLines) { 710 TEST_F(VectorCanvasTest, DiagonalLines) {
712 SkPaint paint; 711 SkPaint paint;
713 paint.setColor(SK_ColorRED); 712 paint.setColor(SK_ColorRED);
714 713
715 vcanvas_->drawLine(10, 10, 90, 90, paint); 714 vcanvas_->drawLine(10, 10, 90, 90, paint);
716 pcanvas_->drawLine(10, 10, 90, 90, paint); 715 pcanvas_->drawLine(10, 10, 90, 90, paint);
717 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("nw-se"))); 716 EXPECT_EQ(0., ProcessImage(L"nw-se"));
718 717
719 // Starting here, there is NO WAY to make them agree. At least verify that the 718 // Starting here, there is NO WAY to make them agree. At least verify that the
720 // output doesn't change across versions. This test is disabled. See bug 719 // output doesn't change across versions. This test is disabled. See bug
721 // 1060231. 720 // 1060231.
722 compare_canvas_ = false; 721 compare_canvas_ = false;
723 722
724 vcanvas_->drawLine(10, 95, 90, 15, paint); 723 vcanvas_->drawLine(10, 95, 90, 15, paint);
725 pcanvas_->drawLine(10, 95, 90, 15, paint); 724 pcanvas_->drawLine(10, 95, 90, 15, paint);
726 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("sw-ne"))); 725 EXPECT_EQ(0., ProcessImage(L"sw-ne"));
727 726
728 vcanvas_->drawLine(90, 10, 10, 90, paint); 727 vcanvas_->drawLine(90, 10, 10, 90, paint);
729 pcanvas_->drawLine(90, 10, 10, 90, paint); 728 pcanvas_->drawLine(90, 10, 10, 90, paint);
730 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("ne-sw"))); 729 EXPECT_EQ(0., ProcessImage(L"ne-sw"));
731 730
732 vcanvas_->drawLine(95, 90, 15, 10, paint); 731 vcanvas_->drawLine(95, 90, 15, 10, paint);
733 pcanvas_->drawLine(95, 90, 15, 10, paint); 732 pcanvas_->drawLine(95, 90, 15, 10, paint);
734 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("se-nw"))); 733 EXPECT_EQ(0., ProcessImage(L"se-nw"));
735 } 734 }
736 735
737 TEST_F(VectorCanvasTest, PathEffects) { 736 TEST_F(VectorCanvasTest, PathEffects) {
738 { 737 {
739 SkPaint paint; 738 SkPaint paint;
740 SkScalar intervals[] = { 1, 1 }; 739 SkScalar intervals[] = { 1, 1 };
741 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals), 740 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals),
742 0); 741 0);
743 paint.setPathEffect(effect)->unref(); 742 paint.setPathEffect(effect)->unref();
744 paint.setColor(SK_ColorMAGENTA); 743 paint.setColor(SK_ColorMAGENTA);
745 paint.setStyle(SkPaint::kStroke_Style); 744 paint.setStyle(SkPaint::kStroke_Style);
746 745
747 vcanvas_->drawLine(10, 10, 90, 10, paint); 746 vcanvas_->drawLine(10, 10, 90, 10, paint);
748 pcanvas_->drawLine(10, 10, 90, 10, paint); 747 pcanvas_->drawLine(10, 10, 90, 10, paint);
749 } 748 }
750 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_line"))); 749 EXPECT_EQ(0., ProcessImage(L"dash_line"));
751 750
752 751
753 // Starting here, there is NO WAY to make them agree. At least verify that the 752 // Starting here, there is NO WAY to make them agree. At least verify that the
754 // output doesn't change across versions. This test is disabled. See bug 753 // output doesn't change across versions. This test is disabled. See bug
755 // 1060231. 754 // 1060231.
756 compare_canvas_ = false; 755 compare_canvas_ = false;
757 756
758 { 757 {
759 SkPaint paint; 758 SkPaint paint;
760 SkScalar intervals[] = { 3, 5 }; 759 SkScalar intervals[] = { 3, 5 };
761 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals), 760 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals),
762 0); 761 0);
763 paint.setPathEffect(effect)->unref(); 762 paint.setPathEffect(effect)->unref();
764 paint.setColor(SK_ColorMAGENTA); 763 paint.setColor(SK_ColorMAGENTA);
765 paint.setStyle(SkPaint::kStroke_Style); 764 paint.setStyle(SkPaint::kStroke_Style);
766 765
767 SkPath path; 766 SkPath path;
768 path.moveTo(10, 15); 767 path.moveTo(10, 15);
769 path.lineTo(90, 15); 768 path.lineTo(90, 15);
770 path.lineTo(90, 90); 769 path.lineTo(90, 90);
771 vcanvas_->drawPath(path, paint); 770 vcanvas_->drawPath(path, paint);
772 pcanvas_->drawPath(path, paint); 771 pcanvas_->drawPath(path, paint);
773 } 772 }
774 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_path"))); 773 EXPECT_EQ(0., ProcessImage(L"dash_path"));
775 774
776 { 775 {
777 SkPaint paint; 776 SkPaint paint;
778 SkScalar intervals[] = { 2, 1 }; 777 SkScalar intervals[] = { 2, 1 };
779 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals), 778 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals),
780 0); 779 0);
781 paint.setPathEffect(effect)->unref(); 780 paint.setPathEffect(effect)->unref();
782 paint.setColor(SK_ColorMAGENTA); 781 paint.setColor(SK_ColorMAGENTA);
783 paint.setStyle(SkPaint::kStroke_Style); 782 paint.setStyle(SkPaint::kStroke_Style);
784 783
785 vcanvas_->drawRectCoords(20, 20, 30, 30, paint); 784 vcanvas_->drawRectCoords(20, 20, 30, 30, paint);
786 pcanvas_->drawRectCoords(20, 20, 30, 30, paint); 785 pcanvas_->drawRectCoords(20, 20, 30, 30, paint);
787 } 786 }
788 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("dash_rect"))); 787 EXPECT_EQ(0., ProcessImage(L"dash_rect"));
789 788
790 // This thing looks like it has been drawn by a 3 years old kid. I haven't 789 // This thing looks like it has been drawn by a 3 years old kid. I haven't
791 // filed a bug on this since I guess nobody is expecting this to look nice. 790 // filed a bug on this since I guess nobody is expecting this to look nice.
792 { 791 {
793 SkPaint paint; 792 SkPaint paint;
794 SkScalar intervals[] = { 1, 1 }; 793 SkScalar intervals[] = { 1, 1 };
795 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals), 794 SkPathEffect* effect = new SkDashPathEffect(intervals, arraysize(intervals),
796 0); 795 0);
797 paint.setPathEffect(effect)->unref(); 796 paint.setPathEffect(effect)->unref();
798 paint.setColor(SK_ColorMAGENTA); 797 paint.setColor(SK_ColorMAGENTA);
799 paint.setStyle(SkPaint::kStroke_Style); 798 paint.setStyle(SkPaint::kStroke_Style);
800 799
801 SkPath path; 800 SkPath path;
802 path.addCircle(50, 75, 10); 801 path.addCircle(50, 75, 10);
803 vcanvas_->drawPath(path, paint); 802 vcanvas_->drawPath(path, paint);
804 pcanvas_->drawPath(path, paint); 803 pcanvas_->drawPath(path, paint);
805 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("circle"))); 804 EXPECT_EQ(0., ProcessImage(L"circle"));
806 } 805 }
807 } 806 }
808 807
809 TEST_F(VectorCanvasTest, Bitmaps) { 808 TEST_F(VectorCanvasTest, Bitmaps) {
810 { 809 {
811 SkBitmap bitmap; 810 SkBitmap bitmap;
812 LoadPngFileToSkBitmap(test_file(L"bitmap_opaque.png"), &bitmap, true); 811 LoadPngFileToSkBitmap(test_file(L"bitmap_opaque.png"), &bitmap, true);
813 vcanvas_->drawBitmap(bitmap, 13, 3, NULL); 812 vcanvas_->drawBitmap(bitmap, 13, 3, NULL);
814 pcanvas_->drawBitmap(bitmap, 13, 3, NULL); 813 pcanvas_->drawBitmap(bitmap, 13, 3, NULL);
815 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("opaque"))); 814 EXPECT_EQ(0., ProcessImage(L"opaque"));
816 } 815 }
817 816
818 { 817 {
819 SkBitmap bitmap; 818 SkBitmap bitmap;
820 LoadPngFileToSkBitmap(test_file(L"bitmap_alpha.png"), &bitmap, false); 819 LoadPngFileToSkBitmap(test_file(L"bitmap_alpha.png"), &bitmap, false);
821 vcanvas_->drawBitmap(bitmap, 5, 15, NULL); 820 vcanvas_->drawBitmap(bitmap, 5, 15, NULL);
822 pcanvas_->drawBitmap(bitmap, 5, 15, NULL); 821 pcanvas_->drawBitmap(bitmap, 5, 15, NULL);
823 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("alpha"))); 822 EXPECT_EQ(0., ProcessImage(L"alpha"));
824 } 823 }
825 } 824 }
826 825
827 TEST_F(VectorCanvasTest, ClippingRect) { 826 TEST_F(VectorCanvasTest, ClippingRect) {
828 SkBitmap bitmap; 827 SkBitmap bitmap;
829 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap, 828 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
830 true); 829 true);
831 SkRect rect; 830 SkRect rect;
832 rect.fLeft = 2; 831 rect.fLeft = 2;
833 rect.fTop = 2; 832 rect.fTop = 2;
834 rect.fRight = 30.5f; 833 rect.fRight = 30.5f;
835 rect.fBottom = 30.5f; 834 rect.fBottom = 30.5f;
836 vcanvas_->clipRect(rect); 835 vcanvas_->clipRect(rect);
837 pcanvas_->clipRect(rect); 836 pcanvas_->clipRect(rect);
838 837
839 vcanvas_->drawBitmap(bitmap, 13, 3, NULL); 838 vcanvas_->drawBitmap(bitmap, 13, 3, NULL);
840 pcanvas_->drawBitmap(bitmap, 13, 3, NULL); 839 pcanvas_->drawBitmap(bitmap, 13, 3, NULL);
841 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rect"))); 840 EXPECT_EQ(0., ProcessImage(L"rect"));
842 } 841 }
843 842
844 TEST_F(VectorCanvasTest, ClippingPath) { 843 TEST_F(VectorCanvasTest, ClippingPath) {
845 SkBitmap bitmap; 844 SkBitmap bitmap;
846 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap, 845 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
847 true); 846 true);
848 SkPath path; 847 SkPath path;
849 path.addCircle(20, 20, 10); 848 path.addCircle(20, 20, 10);
850 vcanvas_->clipPath(path); 849 vcanvas_->clipPath(path);
851 pcanvas_->clipPath(path); 850 pcanvas_->clipPath(path);
852 851
853 vcanvas_->drawBitmap(bitmap, 14, 3, NULL); 852 vcanvas_->drawBitmap(bitmap, 14, 3, NULL);
854 pcanvas_->drawBitmap(bitmap, 14, 3, NULL); 853 pcanvas_->drawBitmap(bitmap, 14, 3, NULL);
855 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("path"))); 854 EXPECT_EQ(0., ProcessImage(L"path"));
856 } 855 }
857 856
858 TEST_F(VectorCanvasTest, ClippingCombined) { 857 TEST_F(VectorCanvasTest, ClippingCombined) {
859 SkBitmap bitmap; 858 SkBitmap bitmap;
860 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap, 859 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
861 true); 860 true);
862 861
863 SkRect rect; 862 SkRect rect;
864 rect.fLeft = 2; 863 rect.fLeft = 2;
865 rect.fTop = 2; 864 rect.fTop = 2;
866 rect.fRight = 30.5f; 865 rect.fRight = 30.5f;
867 rect.fBottom = 30.5f; 866 rect.fBottom = 30.5f;
868 vcanvas_->clipRect(rect); 867 vcanvas_->clipRect(rect);
869 pcanvas_->clipRect(rect); 868 pcanvas_->clipRect(rect);
870 SkPath path; 869 SkPath path;
871 path.addCircle(20, 20, 10); 870 path.addCircle(20, 20, 10);
872 vcanvas_->clipPath(path, SkRegion::kUnion_Op); 871 vcanvas_->clipPath(path, SkRegion::kUnion_Op);
873 pcanvas_->clipPath(path, SkRegion::kUnion_Op); 872 pcanvas_->clipPath(path, SkRegion::kUnion_Op);
874 873
875 vcanvas_->drawBitmap(bitmap, 15, 3, NULL); 874 vcanvas_->drawBitmap(bitmap, 15, 3, NULL);
876 pcanvas_->drawBitmap(bitmap, 15, 3, NULL); 875 pcanvas_->drawBitmap(bitmap, 15, 3, NULL);
877 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("combined"))); 876 EXPECT_EQ(0., ProcessImage(L"combined"));
878 } 877 }
879 878
880 TEST_F(VectorCanvasTest, ClippingIntersect) { 879 TEST_F(VectorCanvasTest, ClippingIntersect) {
881 SkBitmap bitmap; 880 SkBitmap bitmap;
882 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap, 881 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
883 true); 882 true);
884 883
885 SkRect rect; 884 SkRect rect;
886 rect.fLeft = 2; 885 rect.fLeft = 2;
887 rect.fTop = 2; 886 rect.fTop = 2;
888 rect.fRight = 30.5f; 887 rect.fRight = 30.5f;
889 rect.fBottom = 30.5f; 888 rect.fBottom = 30.5f;
890 vcanvas_->clipRect(rect); 889 vcanvas_->clipRect(rect);
891 pcanvas_->clipRect(rect); 890 pcanvas_->clipRect(rect);
892 SkPath path; 891 SkPath path;
893 path.addCircle(23, 23, 15); 892 path.addCircle(23, 23, 15);
894 vcanvas_->clipPath(path); 893 vcanvas_->clipPath(path);
895 pcanvas_->clipPath(path); 894 pcanvas_->clipPath(path);
896 895
897 vcanvas_->drawBitmap(bitmap, 15, 3, NULL); 896 vcanvas_->drawBitmap(bitmap, 15, 3, NULL);
898 pcanvas_->drawBitmap(bitmap, 15, 3, NULL); 897 pcanvas_->drawBitmap(bitmap, 15, 3, NULL);
899 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("intersect"))); 898 EXPECT_EQ(0., ProcessImage(L"intersect"));
900 } 899 }
901 900
902 TEST_F(VectorCanvasTest, ClippingClean) { 901 TEST_F(VectorCanvasTest, ClippingClean) {
903 SkBitmap bitmap; 902 SkBitmap bitmap;
904 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap, 903 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
905 true); 904 true);
906 { 905 {
907 SkRegion old_region(pcanvas_->getTotalClip()); 906 SkRegion old_region(pcanvas_->getTotalClip());
908 SkRect rect; 907 SkRect rect;
909 rect.fLeft = 2; 908 rect.fLeft = 2;
910 rect.fTop = 2; 909 rect.fTop = 2;
911 rect.fRight = 30.5f; 910 rect.fRight = 30.5f;
912 rect.fBottom = 30.5f; 911 rect.fBottom = 30.5f;
913 vcanvas_->clipRect(rect); 912 vcanvas_->clipRect(rect);
914 pcanvas_->clipRect(rect); 913 pcanvas_->clipRect(rect);
915 914
916 vcanvas_->drawBitmap(bitmap, 15, 3, NULL); 915 vcanvas_->drawBitmap(bitmap, 15, 3, NULL);
917 pcanvas_->drawBitmap(bitmap, 15, 3, NULL); 916 pcanvas_->drawBitmap(bitmap, 15, 3, NULL);
918 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("clipped"))); 917 EXPECT_EQ(0., ProcessImage(L"clipped"));
919 vcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); 918 vcanvas_->clipRegion(old_region, SkRegion::kReplace_Op);
920 pcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); 919 pcanvas_->clipRegion(old_region, SkRegion::kReplace_Op);
921 } 920 }
922 { 921 {
923 // Verify that the clipping region has been fixed back. 922 // Verify that the clipping region has been fixed back.
924 vcanvas_->drawBitmap(bitmap, 55, 3, NULL); 923 vcanvas_->drawBitmap(bitmap, 55, 3, NULL);
925 pcanvas_->drawBitmap(bitmap, 55, 3, NULL); 924 pcanvas_->drawBitmap(bitmap, 55, 3, NULL);
926 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("unclipped"))); 925 EXPECT_EQ(0., ProcessImage(L"unclipped"));
927 } 926 }
928 } 927 }
929 928
930 TEST_F(VectorCanvasTest, DISABLED_Matrix) { 929 TEST_F(VectorCanvasTest, DISABLED_Matrix) {
931 SkBitmap bitmap; 930 SkBitmap bitmap;
932 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap, 931 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
933 true); 932 true);
934 { 933 {
935 vcanvas_->translate(15, 3); 934 vcanvas_->translate(15, 3);
936 pcanvas_->translate(15, 3); 935 pcanvas_->translate(15, 3);
937 vcanvas_->drawBitmap(bitmap, 0, 0, NULL); 936 vcanvas_->drawBitmap(bitmap, 0, 0, NULL);
938 pcanvas_->drawBitmap(bitmap, 0, 0, NULL); 937 pcanvas_->drawBitmap(bitmap, 0, 0, NULL);
939 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("translate1"))); 938 EXPECT_EQ(0., ProcessImage(L"translate1"));
940 } 939 }
941 { 940 {
942 vcanvas_->translate(-30, -23); 941 vcanvas_->translate(-30, -23);
943 pcanvas_->translate(-30, -23); 942 pcanvas_->translate(-30, -23);
944 vcanvas_->drawBitmap(bitmap, 0, 0, NULL); 943 vcanvas_->drawBitmap(bitmap, 0, 0, NULL);
945 pcanvas_->drawBitmap(bitmap, 0, 0, NULL); 944 pcanvas_->drawBitmap(bitmap, 0, 0, NULL);
946 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("translate2"))); 945 EXPECT_EQ(0., ProcessImage(L"translate2"));
947 } 946 }
948 vcanvas_->resetMatrix(); 947 vcanvas_->resetMatrix();
949 pcanvas_->resetMatrix(); 948 pcanvas_->resetMatrix();
950 949
951 // For scaling and rotation, they use a different algorithm (nearest 950 // For scaling and rotation, they use a different algorithm (nearest
952 // neighborhood vs smoothing). At least verify that the output doesn't change 951 // neighborhood vs smoothing). At least verify that the output doesn't change
953 // across versions. 952 // across versions.
954 compare_canvas_ = false; 953 compare_canvas_ = false;
955 954
956 { 955 {
957 vcanvas_->scale(SkDoubleToScalar(1.9), SkDoubleToScalar(1.5)); 956 vcanvas_->scale(SkDoubleToScalar(1.9), SkDoubleToScalar(1.5));
958 pcanvas_->scale(SkDoubleToScalar(1.9), SkDoubleToScalar(1.5)); 957 pcanvas_->scale(SkDoubleToScalar(1.9), SkDoubleToScalar(1.5));
959 vcanvas_->drawBitmap(bitmap, 1, 1, NULL); 958 vcanvas_->drawBitmap(bitmap, 1, 1, NULL);
960 pcanvas_->drawBitmap(bitmap, 1, 1, NULL); 959 pcanvas_->drawBitmap(bitmap, 1, 1, NULL);
961 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("scale"))); 960 EXPECT_EQ(0., ProcessImage(L"scale"));
962 } 961 }
963 vcanvas_->resetMatrix(); 962 vcanvas_->resetMatrix();
964 pcanvas_->resetMatrix(); 963 pcanvas_->resetMatrix();
965 964
966 { 965 {
967 vcanvas_->rotate(67); 966 vcanvas_->rotate(67);
968 pcanvas_->rotate(67); 967 pcanvas_->rotate(67);
969 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); 968 vcanvas_->drawBitmap(bitmap, 20, -50, NULL);
970 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); 969 pcanvas_->drawBitmap(bitmap, 20, -50, NULL);
971 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); 970 EXPECT_EQ(0., ProcessImage(L"rotate"));
972 } 971 }
973 } 972 }
974 973
975 } // namespace skia 974 } // namespace skia
OLDNEW
« no previous file with comments | « net/tools/crash_cache/crash_cache.cc ('k') | tools/memory_watcher/memory_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698