| 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" | 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } | 375 } |
| 376 | 376 |
| 377 void Init(int size) { | 377 void Init(int size) { |
| 378 size_ = size; | 378 size_ = size; |
| 379 context_ = new Context(); | 379 context_ = new Context(); |
| 380 bitmap_ = new Bitmap(*context_, size_, size_); | 380 bitmap_ = new Bitmap(*context_, size_, size_); |
| 381 vcanvas_ = new VectorCanvas(context_->context(), size_, size_); | 381 vcanvas_ = new VectorCanvas(context_->context(), size_, size_); |
| 382 pcanvas_ = new PlatformCanvas(size_, size_, false); | 382 pcanvas_ = new PlatformCanvas(size_, size_, false); |
| 383 | 383 |
| 384 // Clear white. | 384 // Clear white. |
| 385 vcanvas_->drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); | 385 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); |
| 386 pcanvas_->drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); | 386 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); |
| 387 } | 387 } |
| 388 | 388 |
| 389 // Compares both canvas and returns the pixel difference in percentage between | 389 // Compares both canvas and returns the pixel difference in percentage between |
| 390 // both images. 0 on success and ]0, 100] on failure. | 390 // both images. 0 on success and ]0, 100] on failure. |
| 391 double ProcessImage(const std::wstring& filename) { | 391 double ProcessImage(const std::wstring& filename) { |
| 392 std::wstring number(StringPrintf(L"%02d_", number_++)); | 392 std::wstring number(StringPrintf(L"%02d_", number_++)); |
| 393 double diff1 = parent::ProcessCanvas(*vcanvas_, number + L"vc_" + filename); | 393 double diff1 = parent::ProcessCanvas(*vcanvas_, number + L"vc_" + filename); |
| 394 double diff2 = parent::ProcessCanvas(*pcanvas_, number + L"pc_" + filename); | 394 double diff2 = parent::ProcessCanvas(*pcanvas_, number + L"pc_" + filename); |
| 395 if (!compare_canvas_) | 395 if (!compare_canvas_) |
| 396 return std::max(diff1, diff2); | 396 return std::max(diff1, diff2); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 EXPECT_EQ(0., ProcessImage(L"empty")); | 454 EXPECT_EQ(0., ProcessImage(L"empty")); |
| 455 } | 455 } |
| 456 | 456 |
| 457 TEST_F(VectorCanvasTest, BasicDrawing) { | 457 TEST_F(VectorCanvasTest, BasicDrawing) { |
| 458 EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.) | 458 EXPECT_EQ(Image(*vcanvas_).PercentageDifferent(Image(*pcanvas_)), 0.) |
| 459 << L"clean"; | 459 << L"clean"; |
| 460 EXPECT_EQ(0., ProcessImage(L"clean")); | 460 EXPECT_EQ(0., ProcessImage(L"clean")); |
| 461 | 461 |
| 462 // Clear white. | 462 // Clear white. |
| 463 { | 463 { |
| 464 vcanvas_->drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); | 464 vcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); |
| 465 pcanvas_->drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); | 465 pcanvas_->drawARGB(255, 255, 255, 255, SkXfermode::kSrc_Mode); |
| 466 } | 466 } |
| 467 EXPECT_EQ(0., ProcessImage(L"drawARGB")); | 467 EXPECT_EQ(0., ProcessImage(L"drawARGB")); |
| 468 | 468 |
| 469 // Diagonal line top-left to bottom-right. | 469 // Diagonal line top-left to bottom-right. |
| 470 { | 470 { |
| 471 SkPaint paint; | 471 SkPaint paint; |
| 472 // Default color is black. | 472 // Default color is black. |
| 473 vcanvas_->drawLine(10, 10, 90, 90, paint); | 473 vcanvas_->drawLine(10, 10, 90, 90, paint); |
| 474 pcanvas_->drawLine(10, 10, 90, 90, paint); | 474 pcanvas_->drawLine(10, 10, 90, 90, paint); |
| 475 } | 475 } |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 { | 956 { |
| 957 vcanvas_->rotate(67); | 957 vcanvas_->rotate(67); |
| 958 pcanvas_->rotate(67); | 958 pcanvas_->rotate(67); |
| 959 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 959 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 960 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); | 960 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); |
| 961 EXPECT_EQ(0., ProcessImage(L"rotate")); | 961 EXPECT_EQ(0., ProcessImage(L"rotate")); |
| 962 } | 962 } |
| 963 } | 963 } |
| 964 | 964 |
| 965 } // namespace skia | 965 } // namespace skia |
| OLD | NEW |