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

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

Issue 119430: Update webkit to r44571 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 6 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 | « DEPS ('k') | webkit/tools/layout_tests/test_expectations.txt » ('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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 *pixel_addr = SkColorSetARGB( 310 *pixel_addr = SkColorSetARGB(
311 SkColorGetA(color), 311 SkColorGetA(color),
312 (SkColorGetR(color) * 255 + alpha_offset) / alpha, 312 (SkColorGetR(color) * 255 + alpha_offset) / alpha,
313 (SkColorGetG(color) * 255 + alpha_offset) / alpha, 313 (SkColorGetG(color) * 255 + alpha_offset) / alpha,
314 (SkColorGetB(color) * 255 + alpha_offset) / alpha); 314 (SkColorGetB(color) * 255 + alpha_offset) / alpha);
315 } 315 }
316 } 316 }
317 } 317 }
318 } 318 }
319 319
320 void LoadPngFileToSkBitmap(const std::wstring& filename, SkBitmap* bitmap) { 320 void LoadPngFileToSkBitmap(const std::wstring& filename,
321 SkBitmap* bitmap,
322 bool is_opaque) {
321 Vector<char> compressed; 323 Vector<char> compressed;
322 ReadFileToVector(filename, &compressed); 324 ReadFileToVector(filename, &compressed);
323 EXPECT_TRUE(compressed.size()); 325 EXPECT_TRUE(compressed.size());
324 WebCore::PNGImageDecoder decoder; 326 WebCore::PNGImageDecoder decoder;
325 decoder.setData(WebCore::SharedBuffer::adoptVector(compressed).get(), true); 327 decoder.setData(WebCore::SharedBuffer::adoptVector(compressed).get(), true);
326 *bitmap = decoder.frameBufferAtIndex(0)->bitmap(); 328 *bitmap = decoder.frameBufferAtIndex(0)->bitmap();
327 EXPECT_FALSE(bitmap->isOpaque()); 329 EXPECT_EQ(is_opaque, bitmap->isOpaque());
328 Premultiply(*bitmap); 330 Premultiply(*bitmap);
329 } 331 }
330 332
331 } // namespace 333 } // namespace
332 334
333 // Streams an image. 335 // Streams an image.
334 inline std::ostream& operator<<(std::ostream& out, const Image& image) { 336 inline std::ostream& operator<<(std::ostream& out, const Image& image) {
335 return out << "Image(" << image.width() << ", " 337 return out << "Image(" << image.width() << ", "
336 << image.height() << ", " << image.row_length() << ")"; 338 << image.height() << ", " << image.row_length() << ")";
337 } 339 }
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 path.addCircle(50, 75, 10); 788 path.addCircle(50, 75, 10);
787 vcanvas_->drawPath(path, paint); 789 vcanvas_->drawPath(path, paint);
788 pcanvas_->drawPath(path, paint); 790 pcanvas_->drawPath(path, paint);
789 EXPECT_EQ(0., ProcessImage(L"circle")); 791 EXPECT_EQ(0., ProcessImage(L"circle"));
790 } 792 }
791 } 793 }
792 794
793 TEST_F(VectorCanvasTest, Bitmaps) { 795 TEST_F(VectorCanvasTest, Bitmaps) {
794 { 796 {
795 SkBitmap bitmap; 797 SkBitmap bitmap;
796 LoadPngFileToSkBitmap(test_file(L"bitmap_opaque.png"), &bitmap); 798 LoadPngFileToSkBitmap(test_file(L"bitmap_opaque.png"), &bitmap, true);
797 vcanvas_->drawBitmap(bitmap, 13, 3, NULL); 799 vcanvas_->drawBitmap(bitmap, 13, 3, NULL);
798 pcanvas_->drawBitmap(bitmap, 13, 3, NULL); 800 pcanvas_->drawBitmap(bitmap, 13, 3, NULL);
799 EXPECT_EQ(0., ProcessImage(L"opaque")); 801 EXPECT_EQ(0., ProcessImage(L"opaque"));
800 } 802 }
801 803
802 { 804 {
803 SkBitmap bitmap; 805 SkBitmap bitmap;
804 LoadPngFileToSkBitmap(test_file(L"bitmap_alpha.png"), &bitmap); 806 LoadPngFileToSkBitmap(test_file(L"bitmap_alpha.png"), &bitmap, false);
805 vcanvas_->drawBitmap(bitmap, 5, 15, NULL); 807 vcanvas_->drawBitmap(bitmap, 5, 15, NULL);
806 pcanvas_->drawBitmap(bitmap, 5, 15, NULL); 808 pcanvas_->drawBitmap(bitmap, 5, 15, NULL);
807 EXPECT_EQ(0., ProcessImage(L"alpha")); 809 EXPECT_EQ(0., ProcessImage(L"alpha"));
808 } 810 }
809 } 811 }
810 812
811 TEST_F(VectorCanvasTest, ClippingRect) { 813 TEST_F(VectorCanvasTest, ClippingRect) {
812 SkBitmap bitmap; 814 SkBitmap bitmap;
813 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap); 815 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
816 true);
814 SkRect rect; 817 SkRect rect;
815 rect.fLeft = 2; 818 rect.fLeft = 2;
816 rect.fTop = 2; 819 rect.fTop = 2;
817 rect.fRight = 30.5f; 820 rect.fRight = 30.5f;
818 rect.fBottom = 30.5f; 821 rect.fBottom = 30.5f;
819 vcanvas_->clipRect(rect); 822 vcanvas_->clipRect(rect);
820 pcanvas_->clipRect(rect); 823 pcanvas_->clipRect(rect);
821 824
822 vcanvas_->drawBitmap(bitmap, 13, 3, NULL); 825 vcanvas_->drawBitmap(bitmap, 13, 3, NULL);
823 pcanvas_->drawBitmap(bitmap, 13, 3, NULL); 826 pcanvas_->drawBitmap(bitmap, 13, 3, NULL);
824 EXPECT_EQ(0., ProcessImage(L"rect")); 827 EXPECT_EQ(0., ProcessImage(L"rect"));
825 } 828 }
826 829
827 TEST_F(VectorCanvasTest, ClippingPath) { 830 TEST_F(VectorCanvasTest, ClippingPath) {
828 SkBitmap bitmap; 831 SkBitmap bitmap;
829 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap); 832 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
833 true);
830 SkPath path; 834 SkPath path;
831 path.addCircle(20, 20, 10); 835 path.addCircle(20, 20, 10);
832 vcanvas_->clipPath(path); 836 vcanvas_->clipPath(path);
833 pcanvas_->clipPath(path); 837 pcanvas_->clipPath(path);
834 838
835 vcanvas_->drawBitmap(bitmap, 14, 3, NULL); 839 vcanvas_->drawBitmap(bitmap, 14, 3, NULL);
836 pcanvas_->drawBitmap(bitmap, 14, 3, NULL); 840 pcanvas_->drawBitmap(bitmap, 14, 3, NULL);
837 EXPECT_EQ(0., ProcessImage(L"path")); 841 EXPECT_EQ(0., ProcessImage(L"path"));
838 } 842 }
839 843
840 TEST_F(VectorCanvasTest, ClippingCombined) { 844 TEST_F(VectorCanvasTest, ClippingCombined) {
841 SkBitmap bitmap; 845 SkBitmap bitmap;
842 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap); 846 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
847 true);
843 848
844 SkRect rect; 849 SkRect rect;
845 rect.fLeft = 2; 850 rect.fLeft = 2;
846 rect.fTop = 2; 851 rect.fTop = 2;
847 rect.fRight = 30.5f; 852 rect.fRight = 30.5f;
848 rect.fBottom = 30.5f; 853 rect.fBottom = 30.5f;
849 vcanvas_->clipRect(rect); 854 vcanvas_->clipRect(rect);
850 pcanvas_->clipRect(rect); 855 pcanvas_->clipRect(rect);
851 SkPath path; 856 SkPath path;
852 path.addCircle(20, 20, 10); 857 path.addCircle(20, 20, 10);
853 vcanvas_->clipPath(path, SkRegion::kUnion_Op); 858 vcanvas_->clipPath(path, SkRegion::kUnion_Op);
854 pcanvas_->clipPath(path, SkRegion::kUnion_Op); 859 pcanvas_->clipPath(path, SkRegion::kUnion_Op);
855 860
856 vcanvas_->drawBitmap(bitmap, 15, 3, NULL); 861 vcanvas_->drawBitmap(bitmap, 15, 3, NULL);
857 pcanvas_->drawBitmap(bitmap, 15, 3, NULL); 862 pcanvas_->drawBitmap(bitmap, 15, 3, NULL);
858 EXPECT_EQ(0., ProcessImage(L"combined")); 863 EXPECT_EQ(0., ProcessImage(L"combined"));
859 } 864 }
860 865
861 TEST_F(VectorCanvasTest, ClippingIntersect) { 866 TEST_F(VectorCanvasTest, ClippingIntersect) {
862 SkBitmap bitmap; 867 SkBitmap bitmap;
863 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap); 868 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
869 true);
864 870
865 SkRect rect; 871 SkRect rect;
866 rect.fLeft = 2; 872 rect.fLeft = 2;
867 rect.fTop = 2; 873 rect.fTop = 2;
868 rect.fRight = 30.5f; 874 rect.fRight = 30.5f;
869 rect.fBottom = 30.5f; 875 rect.fBottom = 30.5f;
870 vcanvas_->clipRect(rect); 876 vcanvas_->clipRect(rect);
871 pcanvas_->clipRect(rect); 877 pcanvas_->clipRect(rect);
872 SkPath path; 878 SkPath path;
873 path.addCircle(23, 23, 15); 879 path.addCircle(23, 23, 15);
874 vcanvas_->clipPath(path); 880 vcanvas_->clipPath(path);
875 pcanvas_->clipPath(path); 881 pcanvas_->clipPath(path);
876 882
877 vcanvas_->drawBitmap(bitmap, 15, 3, NULL); 883 vcanvas_->drawBitmap(bitmap, 15, 3, NULL);
878 pcanvas_->drawBitmap(bitmap, 15, 3, NULL); 884 pcanvas_->drawBitmap(bitmap, 15, 3, NULL);
879 EXPECT_EQ(0., ProcessImage(L"intersect")); 885 EXPECT_EQ(0., ProcessImage(L"intersect"));
880 } 886 }
881 887
882 TEST_F(VectorCanvasTest, ClippingClean) { 888 TEST_F(VectorCanvasTest, ClippingClean) {
883 SkBitmap bitmap; 889 SkBitmap bitmap;
884 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap); 890 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
891 true);
885 { 892 {
886 SkRegion old_region(pcanvas_->getTotalClip()); 893 SkRegion old_region(pcanvas_->getTotalClip());
887 SkRect rect; 894 SkRect rect;
888 rect.fLeft = 2; 895 rect.fLeft = 2;
889 rect.fTop = 2; 896 rect.fTop = 2;
890 rect.fRight = 30.5f; 897 rect.fRight = 30.5f;
891 rect.fBottom = 30.5f; 898 rect.fBottom = 30.5f;
892 vcanvas_->clipRect(rect); 899 vcanvas_->clipRect(rect);
893 pcanvas_->clipRect(rect); 900 pcanvas_->clipRect(rect);
894 901
895 vcanvas_->drawBitmap(bitmap, 15, 3, NULL); 902 vcanvas_->drawBitmap(bitmap, 15, 3, NULL);
896 pcanvas_->drawBitmap(bitmap, 15, 3, NULL); 903 pcanvas_->drawBitmap(bitmap, 15, 3, NULL);
897 EXPECT_EQ(0., ProcessImage(L"clipped")); 904 EXPECT_EQ(0., ProcessImage(L"clipped"));
898 vcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); 905 vcanvas_->clipRegion(old_region, SkRegion::kReplace_Op);
899 pcanvas_->clipRegion(old_region, SkRegion::kReplace_Op); 906 pcanvas_->clipRegion(old_region, SkRegion::kReplace_Op);
900 } 907 }
901 { 908 {
902 // Verify that the clipping region has been fixed back. 909 // Verify that the clipping region has been fixed back.
903 vcanvas_->drawBitmap(bitmap, 55, 3, NULL); 910 vcanvas_->drawBitmap(bitmap, 55, 3, NULL);
904 pcanvas_->drawBitmap(bitmap, 55, 3, NULL); 911 pcanvas_->drawBitmap(bitmap, 55, 3, NULL);
905 EXPECT_EQ(0., ProcessImage(L"unclipped")); 912 EXPECT_EQ(0., ProcessImage(L"unclipped"));
906 } 913 }
907 } 914 }
908 915
909 TEST_F(VectorCanvasTest, DISABLED_Matrix) { 916 TEST_F(VectorCanvasTest, DISABLED_Matrix) {
910 SkBitmap bitmap; 917 SkBitmap bitmap;
911 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap); 918 LoadPngFileToSkBitmap(test_file(L"..\\bitmaps\\bitmap_opaque.png"), &bitmap,
919 true);
912 { 920 {
913 vcanvas_->translate(15, 3); 921 vcanvas_->translate(15, 3);
914 pcanvas_->translate(15, 3); 922 pcanvas_->translate(15, 3);
915 vcanvas_->drawBitmap(bitmap, 0, 0, NULL); 923 vcanvas_->drawBitmap(bitmap, 0, 0, NULL);
916 pcanvas_->drawBitmap(bitmap, 0, 0, NULL); 924 pcanvas_->drawBitmap(bitmap, 0, 0, NULL);
917 EXPECT_EQ(0., ProcessImage(L"translate1")); 925 EXPECT_EQ(0., ProcessImage(L"translate1"));
918 } 926 }
919 { 927 {
920 vcanvas_->translate(-30, -23); 928 vcanvas_->translate(-30, -23);
921 pcanvas_->translate(-30, -23); 929 pcanvas_->translate(-30, -23);
(...skipping 22 matching lines...) Expand all
944 { 952 {
945 vcanvas_->rotate(67); 953 vcanvas_->rotate(67);
946 pcanvas_->rotate(67); 954 pcanvas_->rotate(67);
947 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); 955 vcanvas_->drawBitmap(bitmap, 20, -50, NULL);
948 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); 956 pcanvas_->drawBitmap(bitmap, 20, -50, NULL);
949 EXPECT_EQ(0., ProcessImage(L"rotate")); 957 EXPECT_EQ(0., ProcessImage(L"rotate"));
950 } 958 }
951 } 959 }
952 960
953 } // namespace skia 961 } // namespace skia
OLDNEW
« no previous file with comments | « DEPS ('k') | webkit/tools/layout_tests/test_expectations.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698