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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1869763002: Update LightingImageFilter to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments Created 4 years, 8 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/effects/SkLightingImageFilter.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 "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bitmap.allocN32Pixels(width, height); 138 bitmap.allocN32Pixels(width, height);
139 SkCanvas canvas(bitmap); 139 SkCanvas canvas(bitmap);
140 draw_gradient_circle(&canvas, width, height); 140 draw_gradient_circle(&canvas, width, height);
141 return bitmap; 141 return bitmap;
142 } 142 }
143 143
144 class FilterList { 144 class FilterList {
145 public: 145 public:
146 FilterList(sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRe ct = nullptr) { 146 FilterList(sk_sp<SkImageFilter> input, const SkImageFilter::CropRect* cropRe ct = nullptr) {
147 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); 147 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
148 SkScalar kernel[9] = {
149 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
150 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1),
151 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
152 };
153 const SkISize kernelSize = SkISize::Make(3, 3);
154 const SkScalar gain = SK_Scalar1, bias = 0;
155 const SkScalar five = SkIntToScalar(5); 148 const SkScalar five = SkIntToScalar(5);
156 149
157 SkMatrix matrix;
158
159 matrix.setTranslate(SK_Scalar1, SK_Scalar1);
160 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1);
161
162 { 150 {
163 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED, 151 sk_sp<SkColorFilter> cf(SkColorFilter::MakeModeFilter(SK_ColorRED,
164 SkXfermode::kS rcIn_Mode)); 152 SkXfermode::kS rcIn_Mode));
165 153
166 this->addFilter("color filter", 154 this->addFilter("color filter",
167 SkColorFilterImageFilter::Make(cf, input, cropRect).release()); 155 SkColorFilterImageFilter::Make(std::move(cf), input, cropRect));
168 } 156 }
169 157
170 { 158 {
171 sk_sp<SkImage> gradientImage(SkImage::MakeFromBitmap(make_gradient_c ircle(64, 64))); 159 sk_sp<SkImage> gradientImage(SkImage::MakeFromBitmap(make_gradient_c ircle(64, 64)));
172 sk_sp<SkImageFilter> gradientSource(SkImageSource::Make(std::move(gr adientImage))); 160 sk_sp<SkImageFilter> gradientSource(SkImageSource::Make(std::move(gr adientImage)));
173 161
174 this->addFilter("displacement map", SkDisplacementMapEffect::Create( 162 this->addFilter("displacement map",
175 SkDisplacementMapEffect::kR_ChannelSelectorType, 163 sk_sp<SkImageFilter>(SkDisplacementMapEffect::Create(
176 SkDisplacementMapEffect::kB_ChannelSelectorType, 164 SkDisplacementMapEffect::kR_ChannelSelec torType,
177 20.0f, gradientSource.get(), input.get(), cropRect)); 165 SkDisplacementMapEffect::kB_ChannelSelec torType,
166 20.0f, gradientSource.get(), input.get() , cropRect)));
178 } 167 }
179 168
180 this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1, 169 this->addFilter("blur", SkBlurImageFilter::Make(SK_Scalar1,
181 SK_Scalar1, 170 SK_Scalar1,
182 input, 171 input,
183 cropRect).release()); 172 cropRect));
184 this->addFilter("drop shadow", SkDropShadowImageFilter::Make( 173 this->addFilter("drop shadow", SkDropShadowImageFilter::Make(
185 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, 174 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN,
186 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, 175 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
187 input, cropRect).release()); 176 input, cropRect));
188 this->addFilter("diffuse lighting", SkLightingImageFilter::CreatePointLi tDiffuse( 177 this->addFilter("diffuse lighting",
189 location, SK_ColorGREEN, 0, 0, input.get(), cropRect)); 178 SkLightingImageFilter::MakePointLitDiffuse(location, SK_ColorG REEN, 0, 0,
179 input, cropRect));
190 this->addFilter("specular lighting", 180 this->addFilter("specular lighting",
191 SkLightingImageFilter::CreatePointLitSpecular(location, SK_Col orGREEN, 0, 0, 0, 181 SkLightingImageFilter::MakePointLitSpecular(location, SK_Color GREEN, 0, 0, 0,
192 input.get(), cro pRect)); 182 input, cropRect));
193 this->addFilter("matrix convolution", 183 {
184 SkScalar kernel[9] = {
185 SkIntToScalar(1), SkIntToScalar(1), SkIntToScalar(1),
186 SkIntToScalar(1), SkIntToScalar(-7), SkIntToScalar(1),
187 SkIntToScalar(1), SkIntToScalar(1), SkIntToScalar(1),
188 };
189 const SkISize kernelSize = SkISize::Make(3, 3);
190 const SkScalar gain = SK_Scalar1, bias = 0;
191
192 this->addFilter("matrix convolution",
194 SkMatrixConvolutionImageFilter::Make( 193 SkMatrixConvolutionImageFilter::Make(
195 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), 194 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1),
196 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, 195 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false,
197 input, cropRect).release()); 196 input, cropRect));
197 }
198
198 this->addFilter("merge", SkMergeImageFilter::Make(input, input, 199 this->addFilter("merge", SkMergeImageFilter::Make(input, input,
199 SkXfermode::kSrcOver_M ode, 200 SkXfermode::kSrcOver_M ode,
200 cropRect).release()); 201 cropRect));
202
201 { 203 {
202 SkPaint greenColorShaderPaint; 204 SkPaint greenColorShaderPaint;
203 greenColorShaderPaint.setShader(SkShader::MakeColorShader(SK_ColorGR EEN)); 205 greenColorShaderPaint.setShader(SkShader::MakeColorShader(SK_ColorGR EEN));
204 206
205 SkImageFilter::CropRect leftSideCropRect(SkRect::MakeXYWH(0, 0, 32, 64)); 207 SkImageFilter::CropRect leftSideCropRect(SkRect::MakeXYWH(0, 0, 32, 64));
206 sk_sp<SkImageFilter> paintFilterLeft(SkPaintImageFilter::Make(greenC olorShaderPaint, 208 sk_sp<SkImageFilter> paintFilterLeft(SkPaintImageFilter::Make(greenC olorShaderPaint,
207 &leftS ideCropRect)); 209 &leftS ideCropRect));
208 SkImageFilter::CropRect rightSideCropRect(SkRect::MakeXYWH(32, 0, 32 , 64)); 210 SkImageFilter::CropRect rightSideCropRect(SkRect::MakeXYWH(32, 0, 32 , 64));
209 sk_sp<SkImageFilter> paintFilterRight(SkPaintImageFilter::Make(green ColorShaderPaint, 211 sk_sp<SkImageFilter> paintFilterRight(SkPaintImageFilter::Make(green ColorShaderPaint,
210 &righ tSideCropRect)); 212 &righ tSideCropRect));
211 213
212 214
213 this->addFilter("merge with disjoint inputs", SkMergeImageFilter::Ma ke( 215 this->addFilter("merge with disjoint inputs", SkMergeImageFilter::Ma ke(
214 std::move(paintFilterLeft), std::move(paintFilterRight), 216 std::move(paintFilterLeft), std::move(paintFilterRight),
215 SkXfermode::kSrcOver_Mode, cropRect).release()); 217 SkXfermode::kSrcOver_Mode, cropRect));
216 } 218 }
217 219
218 this->addFilter("offset", 220 this->addFilter("offset",
219 SkOffsetImageFilter::Make(SK_Scalar1, SK_Scalar1, input, 221 SkOffsetImageFilter::Make(SK_Scalar1, SK_Scalar1, input,
220 cropRect).release()); 222 cropRect));
221 this->addFilter("dilate", SkDilateImageFilter::Make(3, 2, input, cropRec t).release()); 223 this->addFilter("dilate", SkDilateImageFilter::Make(3, 2, input, cropRec t));
222 this->addFilter("erode", SkErodeImageFilter::Make(2, 3, input, cropRect) .release()); 224 this->addFilter("erode", SkErodeImageFilter::Make(2, 3, input, cropRect) );
223 this->addFilter("tile", SkTileImageFilter::Create( 225 this->addFilter("tile", sk_sp<SkImageFilter>(SkTileImageFilter::Create(
224 SkRect::MakeXYWH(0, 0, 50, 50), 226 SkRect::MakeXYWH(0, 0, 50, 50),
225 cropRect ? cropRect->rect() : SkRect::MakeXYWH(0, 0, 100, 100), 227 cropRect ? cropRect->rect() : SkRect::MakeXYWH(0, 0, 100, 100),
226 input.get())); 228 input.get())));
229
227 if (!cropRect) { 230 if (!cropRect) {
231 SkMatrix matrix;
232
233 matrix.setTranslate(SK_Scalar1, SK_Scalar1);
234 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1);
235
228 this->addFilter("matrix", 236 this->addFilter("matrix",
229 SkImageFilter::MakeMatrixFilter(matrix, kLow_SkFilterQuality, in put).release()); 237 SkImageFilter::MakeMatrixFilter(matrix, kLow_SkFilterQuality, in put));
230 } 238 }
231
232 { 239 {
233 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(five, five, input) ); 240 sk_sp<SkImageFilter> blur(SkBlurImageFilter::Make(five, five, input) );
234 241
235 this->addFilter("blur and offset", SkOffsetImageFilter::Make(five, f ive, 242 this->addFilter("blur and offset", SkOffsetImageFilter::Make(five, f ive,
236 std::mo ve(blur), 243 std::mo ve(blur),
237 cropRec t).release()); 244 cropRec t));
238 } 245 }
239 { 246 {
240 SkRTreeFactory factory; 247 SkRTreeFactory factory;
241 SkPictureRecorder recorder; 248 SkPictureRecorder recorder;
242 SkCanvas* recordingCanvas = recorder.beginRecording(64, 64, &factory , 0); 249 SkCanvas* recordingCanvas = recorder.beginRecording(64, 64, &factory , 0);
243 250
244 SkPaint greenPaint; 251 SkPaint greenPaint;
245 greenPaint.setColor(SK_ColorGREEN); 252 greenPaint.setColor(SK_ColorGREEN);
246 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), greenPaint); 253 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), greenPaint);
247 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture()); 254 sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
248 sk_sp<SkImageFilter> pictureFilter(SkPictureImageFilter::Make(std::m ove(picture))); 255 sk_sp<SkImageFilter> pictureFilter(SkPictureImageFilter::Make(std::m ove(picture)));
249 256
250 this->addFilter("picture and blur", SkBlurImageFilter::Make(five, fi ve, 257 this->addFilter("picture and blur", SkBlurImageFilter::Make(five, fi ve,
251 std::mov e(pictureFilter), 258 std::mov e(pictureFilter),
252 cropRect ).release()); 259 cropRect ));
253 } 260 }
254 { 261 {
255 SkPaint paint; 262 SkPaint paint;
256 paint.setShader(SkPerlinNoiseShader::MakeTurbulence(SK_Scalar1, SK_S calar1, 1, 0)); 263 paint.setShader(SkPerlinNoiseShader::MakeTurbulence(SK_Scalar1, SK_S calar1, 1, 0));
257 sk_sp<SkImageFilter> paintFilter(SkPaintImageFilter::Make(paint)); 264 sk_sp<SkImageFilter> paintFilter(SkPaintImageFilter::Make(paint));
258 265
259 this->addFilter("paint and blur", SkBlurImageFilter::Make(five, five , 266 this->addFilter("paint and blur", SkBlurImageFilter::Make(five, five ,
260 std::move( paintFilter), 267 std::move( paintFilter),
261 cropRect). release()); 268 cropRect)) ;
262 } 269 }
263 this->addFilter("xfermode", SkXfermodeImageFilter::Make( 270 this->addFilter("xfermode", SkXfermodeImageFilter::Make(
264 SkXfermode::Make(SkXfermode::kSrc_Mode), input, input, cropRect).rel ease()); 271 SkXfermode::Make(SkXfermode::kSrc_Mode), input, input, cropRect));
265 } 272 }
266 int count() const { return fFilters.count(); } 273 int count() const { return fFilters.count(); }
267 SkImageFilter* getFilter(int index) const { return fFilters[index].fFilter.g et(); } 274 SkImageFilter* getFilter(int index) const { return fFilters[index].fFilter.g et(); }
268 const char* getName(int index) const { return fFilters[index].fName; } 275 const char* getName(int index) const { return fFilters[index].fName; }
269 private: 276 private:
270 struct Filter { 277 struct Filter {
271 Filter() : fName(nullptr), fFilter(nullptr) {} 278 Filter() : fName(nullptr) {}
272 Filter(const char* name, SkImageFilter* filter) : fName(name), fFilter(f ilter) {} 279 Filter(const char* name, sk_sp<SkImageFilter> filter)
280 : fName(name)
281 , fFilter(std::move(filter)) {
282 }
273 const char* fName; 283 const char* fName;
274 sk_sp<SkImageFilter> fFilter; 284 sk_sp<SkImageFilter> fFilter;
275 }; 285 };
276 void addFilter(const char* name, SkImageFilter* filter) { 286 void addFilter(const char* name, sk_sp<SkImageFilter> filter) {
277 fFilters.push_back(Filter(name, filter)); 287 fFilters.push_back(Filter(name, std::move(filter)));
278 } 288 }
279 289
280 SkTArray<Filter> fFilters; 290 SkTArray<Filter> fFilters;
281 }; 291 };
282 292
283 } 293 }
284 294
285 sk_sp<SkFlattenable> MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) { 295 sk_sp<SkFlattenable> MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) {
286 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 296 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
287 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr() ; 297 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr() ;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // This tests for : 503 // This tests for :
494 // 1 ) location at (0,0,1) 504 // 1 ) location at (0,0,1)
495 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); 505 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
496 // 2 ) location and target at same value 506 // 2 ) location and target at same value
497 SkPoint3 target = SkPoint3::Make(location.fX, location.fY, location. fZ); 507 SkPoint3 target = SkPoint3::Make(location.fX, location.fY, location. fZ);
498 // 3 ) large negative specular exponent value 508 // 3 ) large negative specular exponent value
499 SkScalar specularExponent = -1000; 509 SkScalar specularExponent = -1000;
500 510
501 sk_sp<SkImageFilter> bmSrc(SkImageSource::Make(std::move(image))); 511 sk_sp<SkImageFilter> bmSrc(SkImageSource::Make(std::move(image)));
502 SkPaint paint; 512 SkPaint paint;
503 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular( 513 paint.setImageFilter(SkLightingImageFilter::MakeSpotLitSpecular(
504 location, target, specularExponent, 180, 514 location, target, specularExponent, 180,
505 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1, 515 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1,
506 bmSrc.get()))->unref(); 516 std::move(bmSrc)));
507 SkCanvas canvas(result); 517 SkCanvas canvas(result);
508 SkRect r = SkRect::MakeWH(SkIntToScalar(kBitmapSize), 518 SkRect r = SkRect::MakeWH(SkIntToScalar(kBitmapSize),
509 SkIntToScalar(kBitmapSize)); 519 SkIntToScalar(kBitmapSize));
510 canvas.drawRect(r, paint); 520 canvas.drawRect(r, paint);
511 } 521 }
512 } 522 }
513 } 523 }
514 524
515 static void test_crop_rects(SkImageFilter::Proxy* proxy, 525 static void test_crop_rects(SkImageFilter::Proxy* proxy,
516 skiatest::Reporter* reporter, 526 skiatest::Reporter* reporter,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 skiatest::Reporter* reporter, 628 skiatest::Reporter* reporter,
619 GrContext* context); 629 GrContext* context);
620 630
621 static void run_raster_test(skiatest::Reporter* reporter, 631 static void run_raster_test(skiatest::Reporter* reporter,
622 int widthHeight, 632 int widthHeight,
623 PFTest test) { 633 PFTest test) {
624 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 634 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
625 635
626 const SkImageInfo info = SkImageInfo::MakeN32Premul(widthHeight, widthHeight ); 636 const SkImageInfo info = SkImageInfo::MakeN32Premul(widthHeight, widthHeight );
627 637
628 SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); 638 sk_sp<SkBaseDevice> device(SkBitmapDevice::Create(info, props));
629 SkImageFilter::DeviceProxy proxy(device); 639 SkImageFilter::DeviceProxy proxy(device.get());
630 640
631 (*test)(&proxy, reporter, nullptr); 641 (*test)(&proxy, reporter, nullptr);
632 } 642 }
633 643
634 #if SK_SUPPORT_GPU 644 #if SK_SUPPORT_GPU
635 static void run_gpu_test(skiatest::Reporter* reporter, 645 static void run_gpu_test(skiatest::Reporter* reporter,
636 GrContext* context, 646 GrContext* context,
637 int widthHeight, 647 int widthHeight,
638 PFTest test) { 648 PFTest test) {
639 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 649 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
640 650
641 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 651 sk_sp<SkGpuDevice> device(SkGpuDevice::Create(context,
642 SkBudgeted::kNo, 652 SkBudgeted::kNo,
643 SkImageInfo::MakeN32Pre mul(widthHeight, 653 SkImageInfo::MakeN32Premul(wid thHeight,
644 widthHeight), 654 wid thHeight),
645 0, 655 0,
646 &props, 656 &props,
647 SkGpuDevice::kUninit_In itContents)); 657 SkGpuDevice::kUninit_InitConte nts));
648 SkImageFilter::DeviceProxy proxy(device); 658 SkImageFilter::DeviceProxy proxy(device.get());
649 659
650 (*test)(&proxy, reporter, context); 660 (*test)(&proxy, reporter, context);
651 } 661 }
652 #endif 662 #endif
653 663
654 DEF_TEST(TestNegativeBlurSigma, reporter) { 664 DEF_TEST(TestNegativeBlurSigma, reporter) {
655 run_raster_test(reporter, 100, test_negative_blur_sigma); 665 run_raster_test(reporter, 100, test_negative_blur_sigma);
656 } 666 }
657 667
658 #if SK_SUPPORT_GPU 668 #if SK_SUPPORT_GPU
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 1161
1152 // The result here should be green, since the filter replaces the primitive' s red interior. 1162 // The result here should be green, since the filter replaces the primitive' s red interior.
1153 canvas.clear(0x0); 1163 canvas.clear(0x0);
1154 canvas.drawPicture(outerPicture); 1164 canvas.drawPicture(outerPicture);
1155 uint32_t pixel = *bitmap.getAddr32(0, 0); 1165 uint32_t pixel = *bitmap.getAddr32(0, 0);
1156 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1166 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1157 1167
1158 // Check that, for now, SkPictureImageFilter does not serialize or 1168 // Check that, for now, SkPictureImageFilter does not serialize or
1159 // deserialize its contained picture when the filter is serialized 1169 // deserialize its contained picture when the filter is serialized
1160 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer. 1170 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer.
1161 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get() )); 1171 sk_sp<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get()));
1162 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( 1172 sk_sp<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable(
1163 data->data(), data->size(), SkImageFilter::GetFlattenableType())); 1173 data->data(), data->size(), SkImageFilter::GetFlattenableType()));
1164 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et()); 1174 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et());
1165 1175
1166 redPaintWithFilter.setImageFilter(unflattenedFilter); 1176 redPaintWithFilter.setImageFilter(unflattenedFilter);
1167 SkPictureRecorder crossProcessRecorder; 1177 SkPictureRecorder crossProcessRecorder;
1168 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa ctory, 0); 1178 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa ctory, 0);
1169 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi thFilter); 1179 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi thFilter);
1170 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP icture()); 1180 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP icture());
1171 1181
1172 canvas.clear(0x0); 1182 canvas.clear(0x0);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 } 1554 }
1545 1555
1546 #if SK_SUPPORT_GPU 1556 #if SK_SUPPORT_GPU
1547 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(PartialCropRect_Gpu, reporter, ctxInfo) { 1557 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(PartialCropRect_Gpu, reporter, ctxInfo) {
1548 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_partial_crop_rect); 1558 run_gpu_test(reporter, ctxInfo.fGrContext, 100, test_partial_crop_rect);
1549 } 1559 }
1550 #endif 1560 #endif
1551 1561
1552 DEF_TEST(ImageFilterCanComputeFastBounds, reporter) { 1562 DEF_TEST(ImageFilterCanComputeFastBounds, reporter) {
1553 1563
1554 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); 1564 {
1555 SkAutoTUnref<SkImageFilter> lighting(SkLightingImageFilter::CreatePointLitDi ffuse( 1565 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1);
1556 location, SK_ColorGREEN, 0, 0)); 1566 sk_sp<SkImageFilter> lighting(SkLightingImageFilter::MakePointLitDiffuse (location,
1557 REPORTER_ASSERT(reporter, !lighting->canComputeFastBounds()); 1567 SK_ColorGREEN,
1568 0, 0, nullptr));
1569 REPORTER_ASSERT(reporter, !lighting->canComputeFastBounds());
1570 }
1558 1571
1559 { 1572 {
1560 sk_sp<SkImageFilter> gray(make_grayscale(nullptr, nullptr)); 1573 sk_sp<SkImageFilter> gray(make_grayscale(nullptr, nullptr));
1561 REPORTER_ASSERT(reporter, gray->canComputeFastBounds()); 1574 REPORTER_ASSERT(reporter, gray->canComputeFastBounds());
1562 { 1575 {
1563 SkColorFilter* grayCF; 1576 SkColorFilter* grayCF;
1564 REPORTER_ASSERT(reporter, gray->asAColorFilter(&grayCF)); 1577 REPORTER_ASSERT(reporter, gray->asAColorFilter(&grayCF));
1565 REPORTER_ASSERT(reporter, !grayCF->affectsTransparentBlack()); 1578 REPORTER_ASSERT(reporter, !grayCF->affectsTransparentBlack());
1566 grayCF->unref(); 1579 grayCF->unref();
1567 } 1580 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 DEF_TEST(BlurLargeImage, reporter) { 1691 DEF_TEST(BlurLargeImage, reporter) {
1679 auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100))); 1692 auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100)));
1680 test_large_blur_input(reporter, surface->getCanvas()); 1693 test_large_blur_input(reporter, surface->getCanvas());
1681 } 1694 }
1682 1695
1683 #if SK_SUPPORT_GPU 1696 #if SK_SUPPORT_GPU
1684 1697
1685 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(HugeBlurImageFilter_Gpu, reporter, ctxInfo ) { 1698 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(HugeBlurImageFilter_Gpu, reporter, ctxInfo ) {
1686 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 1699 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1687 1700
1688 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext, 1701 sk_sp<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext,
1689 SkBudgeted::kNo, 1702 SkBudgeted::kNo,
1690 SkImageInfo::MakeN32Pre mul(100, 100), 1703 SkImageInfo::MakeN32Premul(100 , 100),
1691 0, 1704 0,
1692 &props, 1705 &props,
1693 SkGpuDevice::kUninit_In itContents)); 1706 SkGpuDevice::kUninit_InitConte nts));
1694 SkCanvas canvas(device); 1707 SkCanvas canvas(device.get());
1695 1708
1696 test_huge_blur(&canvas, reporter); 1709 test_huge_blur(&canvas, reporter);
1697 } 1710 }
1698 1711
1699 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(XfermodeImageFilterCroppedInput_Gpu, repor ter, ctxInfo) { 1712 DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(XfermodeImageFilterCroppedInput_Gpu, repor ter, ctxInfo) {
1700 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); 1713 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
1701 1714
1702 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext, 1715 sk_sp<SkGpuDevice> device(SkGpuDevice::Create(ctxInfo.fGrContext,
1703 SkBudgeted::kNo, 1716 SkBudgeted::kNo,
1704 SkImageInfo::MakeN32Pre mul(1, 1), 1717 SkImageInfo::MakeN32Premul(1, 1),
1705 0, 1718 0,
1706 &props, 1719 &props,
1707 SkGpuDevice::kUninit_In itContents)); 1720 SkGpuDevice::kUninit_InitConte nts));
1708 SkCanvas canvas(device); 1721 SkCanvas canvas(device.get());
1709 1722
1710 test_xfermode_cropped_input(&canvas, reporter); 1723 test_xfermode_cropped_input(&canvas, reporter);
1711 } 1724 }
1712 1725
1713 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(BlurLargeImage_Gpu, reporter, ctxInfo) { 1726 DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(BlurLargeImage_Gpu, reporter, ctxInfo) {
1714 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe s, 1727 auto surface(SkSurface::MakeRenderTarget(ctxInfo.fGrContext, SkBudgeted::kYe s,
1715 SkImageInfo::MakeN32Premul(100, 100 ))); 1728 SkImageInfo::MakeN32Premul(100, 100 )));
1716 test_large_blur_input(reporter, surface->getCanvas()); 1729 test_large_blur_input(reporter, surface->getCanvas());
1717 } 1730 }
1718 #endif 1731 #endif
OLDNEW
« no previous file with comments | « src/effects/SkLightingImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698