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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1201983006: Clean up usage of SkSurfaceProps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | 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 "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 break; 393 break;
394 } 394 }
395 } 395 }
396 } 396 }
397 397
398 DEF_TEST(TestNegativeBlurSigma, reporter) { 398 DEF_TEST(TestNegativeBlurSigma, reporter) {
399 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 399 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
400 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 400 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
401 401
402 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); 402 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
403 SkImageFilter::Proxy proxy(device, props); 403 SkImageFilter::Proxy proxy(device);
404 404
405 test_negative_blur_sigma(&proxy, reporter); 405 test_negative_blur_sigma(&proxy, reporter);
406 } 406 }
407 407
408 DEF_TEST(ImageFilterDrawTiled, reporter) { 408 DEF_TEST(ImageFilterDrawTiled, reporter) {
409 // Check that all filters when drawn tiled (with subsequent clip rects) exac tly 409 // Check that all filters when drawn tiled (with subsequent clip rects) exac tly
410 // match the same filters drawn with a single full-canvas bitmap draw. 410 // match the same filters drawn with a single full-canvas bitmap draw.
411 // Tests pass by not asserting. 411 // Tests pass by not asserting.
412 412
413 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode)); 413 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED, SkXfermode::kSrcIn_Mode));
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 canvas.saveLayer(&bounds, &filterPaint); 766 canvas.saveLayer(&bounds, &filterPaint);
767 canvas.drawRect(rect, rectPaint); 767 canvas.drawRect(rect, rectPaint);
768 canvas.restore(); 768 canvas.restore();
769 } 769 }
770 770
771 DEF_TEST(ImageFilterCropRect, reporter) { 771 DEF_TEST(ImageFilterCropRect, reporter) {
772 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 772 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
773 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 773 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
774 774
775 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); 775 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
776 SkImageFilter::Proxy proxy(device, props); 776 SkImageFilter::Proxy proxy(device);
777 777
778 test_crop_rects(&proxy, reporter); 778 test_crop_rects(&proxy, reporter);
779 } 779 }
780 780
781 DEF_TEST(ImageFilterMatrix, reporter) { 781 DEF_TEST(ImageFilterMatrix, reporter) {
782 SkBitmap temp; 782 SkBitmap temp;
783 temp.allocN32Pixels(100, 100); 783 temp.allocN32Pixels(100, 100);
784 SkCanvas canvas(temp); 784 SkCanvas canvas(temp);
785 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); 785 canvas.scale(SkIntToScalar(2), SkIntToScalar(2));
786 786
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint); 878 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint);
879 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 879 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
880 880
881 SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture .get())); 881 SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture .get()));
882 882
883 SkBitmap result; 883 SkBitmap result;
884 SkIPoint offset; 884 SkIPoint offset;
885 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), NUL L); 885 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), NUL L);
886 SkBitmap bitmap; 886 SkBitmap bitmap;
887 bitmap.allocN32Pixels(2, 2); 887 bitmap.allocN32Pixels(2, 2);
888 SkBitmapDevice device(bitmap, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost _InitType)); 888 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
889 SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFo ntHost_InitType)); 889 SkBitmapDevice device(bitmap, props);
890 SkImageFilter::Proxy proxy(&device);
890 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re sult, &offset)); 891 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re sult, &offset));
891 } 892 }
892 893
893 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { 894 DEF_TEST(ImageFilterEmptySaveLayer, reporter) {
894 // Even when there's an empty saveLayer()/restore(), ensure that an image 895 // Even when there's an empty saveLayer()/restore(), ensure that an image
895 // filter or color filter which affects transparent black still draws. 896 // filter or color filter which affects transparent black still draws.
896 897
897 SkBitmap bitmap; 898 SkBitmap bitmap;
898 bitmap.allocN32Pixels(10, 10); 899 bitmap.allocN32Pixels(10, 10);
899 SkCanvas canvas(bitmap); 900 SkCanvas canvas(bitmap);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 SkBitmap temp; 1117 SkBitmap temp;
1117 temp.allocN32Pixels(100, 100); 1118 temp.allocN32Pixels(100, 100);
1118 SkCanvas canvas(temp); 1119 SkCanvas canvas(temp);
1119 test_xfermode_cropped_input(&canvas, reporter); 1120 test_xfermode_cropped_input(&canvas, reporter);
1120 } 1121 }
1121 1122
1122 DEF_TEST(ComposedImageFilterOffset, reporter) { 1123 DEF_TEST(ComposedImageFilterOffset, reporter) {
1123 SkBitmap bitmap; 1124 SkBitmap bitmap;
1124 bitmap.allocN32Pixels(100, 100); 1125 bitmap.allocN32Pixels(100, 100);
1125 bitmap.eraseARGB(0, 0, 0, 0); 1126 bitmap.eraseARGB(0, 0, 0, 0);
1126 SkBitmapDevice device(bitmap, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost _InitType)); 1127 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1127 SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFo ntHost_InitType)); 1128 SkBitmapDevice device(bitmap, props);
1129 SkImageFilter::Proxy proxy(&device);
1128 1130
1129 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); 1131 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20));
1130 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, N ULL, &cropRect)); 1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, N ULL, &cropRect));
1131 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); 1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur());
1132 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur Filter, offsetFilter.get())); 1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur Filter, offsetFilter.get()));
1133 SkBitmap result; 1135 SkBitmap result;
1134 SkIPoint offset; 1136 SkIPoint offset;
1135 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); 1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL);
1136 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, & result, &offset)); 1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, & result, &offset));
1137 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); 1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0);
1138 } 1140 }
1139 1141
1140 #if SK_SUPPORT_GPU 1142 #if SK_SUPPORT_GPU
1141 const SkSurfaceProps gProps = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_Ini tType);
1142 1143
1143 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { 1144 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
1144 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 1145 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
1145 if (NULL == context) { 1146 if (NULL == context) {
1146 return; 1147 return;
1147 } 1148 }
1149 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1150
1148 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 1151 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
1149 SkSurface::kNo_Budgeted , 1152 SkSurface::kNo_Budgeted ,
1150 SkImageInfo::MakeN32Pre mul(100, 100), 1153 SkImageInfo::MakeN32Pre mul(100, 100),
1151 0, 1154 0,
1152 &gProps)); 1155 &props));
1153 SkImageFilter::Proxy proxy(device, gProps); 1156 SkImageFilter::Proxy proxy(device);
1154 1157
1155 test_crop_rects(&proxy, reporter); 1158 test_crop_rects(&proxy, reporter);
1156 } 1159 }
1157 1160
1158 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { 1161 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) {
1159 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 1162 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
1160 if (NULL == context) { 1163 if (NULL == context) {
1161 return; 1164 return;
1162 } 1165 }
1166 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1167
1163 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 1168 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
1164 SkSurface::kNo_Budgeted , 1169 SkSurface::kNo_Budgeted ,
1165 SkImageInfo::MakeN32Pre mul(100, 100), 1170 SkImageInfo::MakeN32Pre mul(100, 100),
1166 0, 1171 0,
1167 &gProps)); 1172 &props));
1168 SkCanvas canvas(device); 1173 SkCanvas canvas(device);
1169 1174
1170 test_huge_blur(&canvas, reporter); 1175 test_huge_blur(&canvas, reporter);
1171 } 1176 }
1172 1177
1173 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { 1178 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) {
1174 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 1179 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
1175 if (NULL == context) { 1180 if (NULL == context) {
1176 return; 1181 return;
1177 } 1182 }
1183 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1184
1178 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 1185 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
1179 SkSurface::kNo_Budgeted , 1186 SkSurface::kNo_Budgeted ,
1180 SkImageInfo::MakeN32Pre mul(1, 1), 1187 SkImageInfo::MakeN32Pre mul(1, 1),
1181 0, 1188 0,
1182 &gProps)); 1189 &props));
1183 SkCanvas canvas(device); 1190 SkCanvas canvas(device);
1184 1191
1185 test_xfermode_cropped_input(&canvas, reporter); 1192 test_xfermode_cropped_input(&canvas, reporter);
1186 } 1193 }
1187 1194
1188 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { 1195 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
1189 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 1196 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
1190 if (NULL == context) { 1197 if (NULL == context) {
1191 return; 1198 return;
1192 } 1199 }
1200 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1201
1193 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 1202 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
1194 SkSurface::kNo_Budgeted , 1203 SkSurface::kNo_Budgeted ,
1195 SkImageInfo::MakeN32Pre mul(1, 1), 1204 SkImageInfo::MakeN32Pre mul(1, 1),
1196 0, 1205 0,
1197 &gProps)); 1206 &props));
1198 SkImageFilter::Proxy proxy(device, gProps); 1207 SkImageFilter::Proxy proxy(device);
1199 1208
1200 test_negative_blur_sigma(&proxy, reporter); 1209 test_negative_blur_sigma(&proxy, reporter);
1201 } 1210 }
1202 #endif 1211 #endif
OLDNEW
« no previous file with comments | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698