OLD | NEW |
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 "SkBicubicImageFilter.h" | 8 #include "SkBicubicImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
11 #include "SkBitmapSource.h" | 11 #include "SkBitmapSource.h" |
12 #include "SkBlurImageFilter.h" | 12 #include "SkBlurImageFilter.h" |
13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
14 #include "SkColorFilterImageFilter.h" | 14 #include "SkColorFilterImageFilter.h" |
15 #include "SkColorMatrixFilter.h" | 15 #include "SkColorMatrixFilter.h" |
16 #include "SkDeviceImageFilterProxy.h" | 16 #include "SkDeviceImageFilterProxy.h" |
17 #include "SkDisplacementMapEffect.h" | 17 #include "SkDisplacementMapEffect.h" |
18 #include "SkDropShadowImageFilter.h" | 18 #include "SkDropShadowImageFilter.h" |
19 #include "SkFlattenableBuffers.h" | 19 #include "SkFlattenableBuffers.h" |
20 #include "SkGradientShader.h" | 20 #include "SkGradientShader.h" |
21 #include "SkLightingImageFilter.h" | 21 #include "SkLightingImageFilter.h" |
22 #include "SkMatrixConvolutionImageFilter.h" | 22 #include "SkMatrixConvolutionImageFilter.h" |
23 #include "SkMatrixImageFilter.h" | 23 #include "SkMatrixImageFilter.h" |
24 #include "SkMergeImageFilter.h" | 24 #include "SkMergeImageFilter.h" |
25 #include "SkMorphologyImageFilter.h" | 25 #include "SkMorphologyImageFilter.h" |
26 #include "SkOffsetImageFilter.h" | 26 #include "SkOffsetImageFilter.h" |
27 #include "SkPicture.h" | 27 #include "SkPicture.h" |
| 28 #include "SkPictureImageFilter.h" |
28 #include "SkPictureRecorder.h" | 29 #include "SkPictureRecorder.h" |
29 #include "SkRect.h" | 30 #include "SkRect.h" |
30 #include "SkTileImageFilter.h" | 31 #include "SkTileImageFilter.h" |
31 #include "SkXfermodeImageFilter.h" | 32 #include "SkXfermodeImageFilter.h" |
32 #include "Test.h" | 33 #include "Test.h" |
33 | 34 |
34 #if SK_SUPPORT_GPU | 35 #if SK_SUPPORT_GPU |
35 #include "GrContextFactory.h" | 36 #include "GrContextFactory.h" |
36 #include "SkGpuDevice.h" | 37 #include "SkGpuDevice.h" |
37 #endif | 38 #endif |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 SkScalar gain = SK_Scalar1, bias = 0; | 301 SkScalar gain = SK_Scalar1, bias = 0; |
301 SkScalar five = SkIntToScalar(5); | 302 SkScalar five = SkIntToScalar(5); |
302 | 303 |
303 SkAutoTUnref<SkImageFilter> gradient_source(SkBitmapSource::Create(make_grad
ient_circle(64, 64))); | 304 SkAutoTUnref<SkImageFilter> gradient_source(SkBitmapSource::Create(make_grad
ient_circle(64, 64))); |
304 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(five, five)); | 305 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(five, five)); |
305 SkMatrix matrix; | 306 SkMatrix matrix; |
306 | 307 |
307 matrix.setTranslate(SK_Scalar1, SK_Scalar1); | 308 matrix.setTranslate(SK_Scalar1, SK_Scalar1); |
308 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1); | 309 matrix.postRotate(SkIntToScalar(45), SK_Scalar1, SK_Scalar1); |
309 | 310 |
| 311 SkRTreeFactory factory; |
| 312 SkPictureRecorder recorder; |
| 313 SkCanvas* recordingCanvas = recorder.beginRecording(64, 64, &factory, 0); |
| 314 |
| 315 SkPaint greenPaint; |
| 316 greenPaint.setColor(SK_ColorGREEN); |
| 317 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 30, 20)), g
reenPaint); |
| 318 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 319 SkAutoTUnref<SkImageFilter> pictureFilter(SkPictureImageFilter::Create(pictu
re.get())); |
| 320 |
310 struct { | 321 struct { |
311 const char* fName; | 322 const char* fName; |
312 SkImageFilter* fFilter; | 323 SkImageFilter* fFilter; |
313 } filters[] = { | 324 } filters[] = { |
314 { "color filter", SkColorFilterImageFilter::Create(cf.get()) }, | 325 { "color filter", SkColorFilterImageFilter::Create(cf.get()) }, |
315 { "displacement map", SkDisplacementMapEffect::Create( | 326 { "displacement map", SkDisplacementMapEffect::Create( |
316 SkDisplacementMapEffect::kR_ChannelSelectorType, | 327 SkDisplacementMapEffect::kR_ChannelSelectorType, |
317 SkDisplacementMapEffect::kB_ChannelSelectorType, | 328 SkDisplacementMapEffect::kB_ChannelSelectorType, |
318 20.0f, gradient_source.get()) }, | 329 20.0f, gradient_source.get()) }, |
319 { "blur", SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1) }, | 330 { "blur", SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1) }, |
320 { "drop shadow", SkDropShadowImageFilter::Create( | 331 { "drop shadow", SkDropShadowImageFilter::Create( |
321 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN) }, | 332 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN) }, |
322 { "diffuse lighting", SkLightingImageFilter::CreatePointLitDiffuse( | 333 { "diffuse lighting", SkLightingImageFilter::CreatePointLitDiffuse( |
323 location, SK_ColorGREEN, 0, 0) }, | 334 location, SK_ColorGREEN, 0, 0) }, |
324 { "specular lighting", | 335 { "specular lighting", |
325 SkLightingImageFilter::CreatePointLitSpecular(location, SK_ColorGR
EEN, 0, 0, 0) }, | 336 SkLightingImageFilter::CreatePointLitSpecular(location, SK_ColorGR
EEN, 0, 0, 0) }, |
326 { "matrix convolution", | 337 { "matrix convolution", |
327 SkMatrixConvolutionImageFilter::Create( | 338 SkMatrixConvolutionImageFilter::Create( |
328 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), | 339 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), |
329 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false) }, | 340 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false) }, |
330 { "merge", SkMergeImageFilter::Create(NULL, NULL, SkXfermode::kSrcOver_M
ode) }, | 341 { "merge", SkMergeImageFilter::Create(NULL, NULL, SkXfermode::kSrcOver_M
ode) }, |
331 { "offset", SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1) }, | 342 { "offset", SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1) }, |
332 { "dilate", SkDilateImageFilter::Create(3, 2) }, | 343 { "dilate", SkDilateImageFilter::Create(3, 2) }, |
333 { "erode", SkErodeImageFilter::Create(2, 3) }, | 344 { "erode", SkErodeImageFilter::Create(2, 3) }, |
334 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), | 345 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), |
335 SkRect::MakeXYWH(0, 0, 100, 100), NU
LL) }, | 346 SkRect::MakeXYWH(0, 0, 100, 100), NU
LL) }, |
336 { "matrix", SkMatrixImageFilter::Create(matrix, SkPaint::kLow_FilterLeve
l) }, | 347 { "matrix", SkMatrixImageFilter::Create(matrix, SkPaint::kLow_FilterLeve
l) }, |
337 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get())
}, | 348 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get())
}, |
| 349 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte
r.get()) }, |
338 }; | 350 }; |
339 | 351 |
340 SkBitmap untiledResult, tiledResult; | 352 SkBitmap untiledResult, tiledResult; |
341 int width = 64, height = 64; | 353 int width = 64, height = 64; |
342 untiledResult.allocN32Pixels(width, height); | 354 untiledResult.allocN32Pixels(width, height); |
343 tiledResult.allocN32Pixels(width, height); | 355 tiledResult.allocN32Pixels(width, height); |
344 SkCanvas tiledCanvas(tiledResult); | 356 SkCanvas tiledCanvas(tiledResult); |
345 SkCanvas untiledCanvas(untiledResult); | 357 SkCanvas untiledCanvas(untiledResult); |
346 int tileSize = 8; | 358 int tileSize = 8; |
347 | 359 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 } | 692 } |
681 | 693 |
682 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 694 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
683 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 695 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
684 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 696 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
685 SkImageInfo::MakeN32Pre
mul(1, 1), | 697 SkImageInfo::MakeN32Pre
mul(1, 1), |
686 0)); | 698 0)); |
687 test_xfermode_cropped_input(device, reporter); | 699 test_xfermode_cropped_input(device, reporter); |
688 } | 700 } |
689 #endif | 701 #endif |
OLD | NEW |