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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1530203002: Reland of move drawSprite from canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | « src/utils/debugger/SkDrawCommand.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 static void test_huge_blur(SkCanvas* canvas, skiatest::Reporter* reporter) { 970 static void test_huge_blur(SkCanvas* canvas, skiatest::Reporter* reporter) {
971 SkBitmap bitmap; 971 SkBitmap bitmap;
972 bitmap.allocN32Pixels(100, 100); 972 bitmap.allocN32Pixels(100, 100);
973 bitmap.eraseARGB(0, 0, 0, 0); 973 bitmap.eraseARGB(0, 0, 0, 0);
974 974
975 // Check that a blur with an insane radius does not crash or assert. 975 // Check that a blur with an insane radius does not crash or assert.
976 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(SkIntToScalar(1<< 30), SkIntToScalar(1<<30))); 976 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(SkIntToScalar(1<< 30), SkIntToScalar(1<<30)));
977 977
978 SkPaint paint; 978 SkPaint paint;
979 paint.setImageFilter(blur); 979 paint.setImageFilter(blur);
980 canvas->drawSprite(bitmap, 0, 0, &paint); 980 canvas->drawBitmap(bitmap, 0, 0, &paint);
981 } 981 }
982 982
983 DEF_TEST(HugeBlurImageFilter, reporter) { 983 DEF_TEST(HugeBlurImageFilter, reporter) {
984 SkBitmap temp; 984 SkBitmap temp;
985 temp.allocN32Pixels(100, 100); 985 temp.allocN32Pixels(100, 100);
986 SkCanvas canvas(temp); 986 SkCanvas canvas(temp);
987 test_huge_blur(&canvas, reporter); 987 test_huge_blur(&canvas, reporter);
988 } 988 }
989 989
990 DEF_TEST(MatrixConvolutionSanityTest, reporter) { 990 DEF_TEST(MatrixConvolutionSanityTest, reporter) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrcOver_Mode); 1060 SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrcOver_Mode);
1061 SkAutoTUnref<SkImageFilter> xfermodeNoFg( 1061 SkAutoTUnref<SkImageFilter> xfermodeNoFg(
1062 SkXfermodeImageFilter::Create(mode, greenFilter, croppedOut)); 1062 SkXfermodeImageFilter::Create(mode, greenFilter, croppedOut));
1063 SkAutoTUnref<SkImageFilter> xfermodeNoBg( 1063 SkAutoTUnref<SkImageFilter> xfermodeNoBg(
1064 SkXfermodeImageFilter::Create(mode, croppedOut, greenFilter)); 1064 SkXfermodeImageFilter::Create(mode, croppedOut, greenFilter));
1065 SkAutoTUnref<SkImageFilter> xfermodeNoFgNoBg( 1065 SkAutoTUnref<SkImageFilter> xfermodeNoFgNoBg(
1066 SkXfermodeImageFilter::Create(mode, croppedOut, croppedOut)); 1066 SkXfermodeImageFilter::Create(mode, croppedOut, croppedOut));
1067 1067
1068 SkPaint paint; 1068 SkPaint paint;
1069 paint.setImageFilter(xfermodeNoFg); 1069 paint.setImageFilter(xfermodeNoFg);
1070 canvas->drawSprite(bitmap, 0, 0, &paint); 1070 canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
1071 1071
1072 uint32_t pixel; 1072 uint32_t pixel;
1073 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul _SkAlphaType); 1073 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul _SkAlphaType);
1074 canvas->readPixels(info, &pixel, 4, 0, 0); 1074 canvas->readPixels(info, &pixel, 4, 0, 0);
1075 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1075 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1076 1076
1077 paint.setImageFilter(xfermodeNoBg); 1077 paint.setImageFilter(xfermodeNoBg);
1078 canvas->drawSprite(bitmap, 0, 0, &paint); 1078 canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
1079 canvas->readPixels(info, &pixel, 4, 0, 0); 1079 canvas->readPixels(info, &pixel, 4, 0, 0);
1080 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1080 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1081 1081
1082 paint.setImageFilter(xfermodeNoFgNoBg); 1082 paint.setImageFilter(xfermodeNoFgNoBg);
1083 canvas->drawSprite(bitmap, 0, 0, &paint); 1083 canvas->drawBitmap(bitmap, 0, 0, &paint); // drawSprite
1084 canvas->readPixels(info, &pixel, 4, 0, 0); 1084 canvas->readPixels(info, &pixel, 4, 0, 0);
1085 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1085 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1086 } 1086 }
1087 1087
1088 DEF_TEST(ImageFilterNestedSaveLayer, reporter) { 1088 DEF_TEST(ImageFilterNestedSaveLayer, reporter) {
1089 SkBitmap temp; 1089 SkBitmap temp;
1090 temp.allocN32Pixels(50, 50); 1090 temp.allocN32Pixels(50, 50);
1091 SkCanvas canvas(temp); 1091 SkCanvas canvas(temp);
1092 canvas.clear(0x0); 1092 canvas.clear(0x0);
1093 1093
(...skipping 27 matching lines...) Expand all
1121 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul _SkAlphaType); 1121 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul _SkAlphaType);
1122 uint32_t pixel; 1122 uint32_t pixel;
1123 canvas.readPixels(info, &pixel, 4, 25, 25); 1123 canvas.readPixels(info, &pixel, 4, 25, 25);
1124 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1124 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1125 1125
1126 // Test that drawSprite() with a filter nested inside a saveLayer() applies the 1126 // Test that drawSprite() with a filter nested inside a saveLayer() applies the
1127 // correct offset to the filter matrix. 1127 // correct offset to the filter matrix.
1128 canvas.clear(0x0); 1128 canvas.clear(0x0);
1129 canvas.readPixels(info, &pixel, 4, 25, 25); 1129 canvas.readPixels(info, &pixel, 4, 25, 25);
1130 canvas.saveLayer(&bounds1, nullptr); 1130 canvas.saveLayer(&bounds1, nullptr);
1131 canvas.drawSprite(bitmap, 20, 20, &filterPaint); 1131 canvas.drawBitmap(bitmap, 20, 20, &filterPaint); // drawSprite
1132 canvas.restore(); 1132 canvas.restore();
1133 1133
1134 canvas.readPixels(info, &pixel, 4, 25, 25); 1134 canvas.readPixels(info, &pixel, 4, 25, 25);
1135 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1135 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1136 } 1136 }
1137 1137
1138 DEF_TEST(XfermodeImageFilterCroppedInput, reporter) { 1138 DEF_TEST(XfermodeImageFilterCroppedInput, reporter) {
1139 SkBitmap temp; 1139 SkBitmap temp;
1140 temp.allocN32Pixels(100, 100); 1140 temp.allocN32Pixels(100, 100);
1141 SkCanvas canvas(temp); 1141 SkCanvas canvas(temp);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 SkSurface::kNo_Budgeted , 1312 SkSurface::kNo_Budgeted ,
1313 SkImageInfo::MakeN32Pre mul(1, 1), 1313 SkImageInfo::MakeN32Pre mul(1, 1),
1314 0, 1314 0,
1315 &props, 1315 &props,
1316 SkGpuDevice::kUninit_In itContents)); 1316 SkGpuDevice::kUninit_In itContents));
1317 SkImageFilter::DeviceProxy proxy(device); 1317 SkImageFilter::DeviceProxy proxy(device);
1318 1318
1319 test_negative_blur_sigma(&proxy, reporter); 1319 test_negative_blur_sigma(&proxy, reporter);
1320 } 1320 }
1321 #endif 1321 #endif
OLDNEW
« no previous file with comments | « src/utils/debugger/SkDrawCommand.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698