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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkBitmapDevice.h" | 9 #include "SkBitmapDevice.h" |
10 #include "SkBitmapSource.h" | 10 #include "SkBitmapSource.h" |
11 #include "SkBlurImageFilter.h" | 11 #include "SkBlurImageFilter.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkColorFilterImageFilter.h" | 13 #include "SkColorFilterImageFilter.h" |
14 #include "SkColorMatrixFilter.h" | 14 #include "SkColorMatrixFilter.h" |
15 #include "SkComposeImageFilter.h" | 15 #include "SkComposeImageFilter.h" |
16 #include "SkDisplacementMapEffect.h" | 16 #include "SkDisplacementMapEffect.h" |
17 #include "SkDropShadowImageFilter.h" | 17 #include "SkDropShadowImageFilter.h" |
18 #include "SkFlattenableSerialization.h" | 18 #include "SkFlattenableSerialization.h" |
19 #include "SkGradientShader.h" | 19 #include "SkGradientShader.h" |
20 #include "SkLightingImageFilter.h" | 20 #include "SkLightingImageFilter.h" |
21 #include "SkMatrixConvolutionImageFilter.h" | 21 #include "SkMatrixConvolutionImageFilter.h" |
22 #include "SkMergeImageFilter.h" | 22 #include "SkMergeImageFilter.h" |
23 #include "SkMorphologyImageFilter.h" | 23 #include "SkMorphologyImageFilter.h" |
24 #include "SkOffsetImageFilter.h" | 24 #include "SkOffsetImageFilter.h" |
25 #include "SkPerlinNoiseShader.h" | 25 #include "SkPerlinNoiseShader.h" |
26 #include "SkPicture.h" | 26 #include "SkPicture.h" |
27 #include "SkPictureImageFilter.h" | 27 #include "SkPictureImageFilter.h" |
28 #include "SkPictureRecorder.h" | 28 #include "SkPictureRecorder.h" |
| 29 #include "SkPoint3.h" |
29 #include "SkReadBuffer.h" | 30 #include "SkReadBuffer.h" |
30 #include "SkRect.h" | 31 #include "SkRect.h" |
31 #include "SkRectShaderImageFilter.h" | 32 #include "SkRectShaderImageFilter.h" |
32 #include "SkTileImageFilter.h" | 33 #include "SkTileImageFilter.h" |
33 #include "SkXfermodeImageFilter.h" | 34 #include "SkXfermodeImageFilter.h" |
34 #include "Test.h" | 35 #include "Test.h" |
35 | 36 |
36 #if SK_SUPPORT_GPU | 37 #if SK_SUPPORT_GPU |
37 #include "GrContextFactory.h" | 38 #include "GrContextFactory.h" |
38 #include "SkGpuDevice.h" | 39 #include "SkGpuDevice.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 238 |
238 { | 239 { |
239 // Tests pass by not asserting | 240 // Tests pass by not asserting |
240 SkBitmap bitmap, result; | 241 SkBitmap bitmap, result; |
241 make_small_bitmap(bitmap); | 242 make_small_bitmap(bitmap); |
242 result.allocN32Pixels(kBitmapSize, kBitmapSize); | 243 result.allocN32Pixels(kBitmapSize, kBitmapSize); |
243 | 244 |
244 { | 245 { |
245 // This tests for : | 246 // This tests for : |
246 // 1 ) location at (0,0,1) | 247 // 1 ) location at (0,0,1) |
247 SkPoint3 location(0, 0, SK_Scalar1); | 248 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); |
248 // 2 ) location and target at same value | 249 // 2 ) location and target at same value |
249 SkPoint3 target(location.fX, location.fY, location.fZ); | 250 SkPoint3 target = SkPoint3::Make(location.fX, location.fY, location.
fZ); |
250 // 3 ) large negative specular exponent value | 251 // 3 ) large negative specular exponent value |
251 SkScalar specularExponent = -1000; | 252 SkScalar specularExponent = -1000; |
252 | 253 |
253 SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap)); | 254 SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap)); |
254 SkPaint paint; | 255 SkPaint paint; |
255 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular( | 256 paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular( |
256 location, target, specularExponent, 180, | 257 location, target, specularExponent, 180, |
257 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1, | 258 0xFFFFFFFF, SK_Scalar1, SK_Scalar1, SK_Scalar1, |
258 bmSrc))->unref(); | 259 bmSrc))->unref(); |
259 SkCanvas canvas(result); | 260 SkCanvas canvas(result); |
(...skipping 10 matching lines...) Expand all Loading... |
270 // Tests pass by not asserting. | 271 // Tests pass by not asserting. |
271 SkBitmap bitmap; | 272 SkBitmap bitmap; |
272 bitmap.allocN32Pixels(100, 100); | 273 bitmap.allocN32Pixels(100, 100); |
273 bitmap.eraseARGB(0, 0, 0, 0); | 274 bitmap.eraseARGB(0, 0, 0, 0); |
274 | 275 |
275 SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80)); | 276 SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80)); |
276 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60)); | 277 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60)); |
277 SkAutoTUnref<SkImageFilter> input(make_grayscale(NULL, &inputCropRect)); | 278 SkAutoTUnref<SkImageFilter> input(make_grayscale(NULL, &inputCropRect)); |
278 | 279 |
279 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); | 280 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); |
280 SkPoint3 location(0, 0, SK_Scalar1); | 281 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); |
281 SkPoint3 target(SK_Scalar1, SK_Scalar1, SK_Scalar1); | |
282 SkScalar kernel[9] = { | 282 SkScalar kernel[9] = { |
283 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 283 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
284 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), | 284 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), |
285 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 285 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
286 }; | 286 }; |
287 SkISize kernelSize = SkISize::Make(3, 3); | 287 SkISize kernelSize = SkISize::Make(3, 3); |
288 SkScalar gain = SK_Scalar1, bias = 0; | 288 SkScalar gain = SK_Scalar1, bias = 0; |
289 | 289 |
290 SkImageFilter* filters[] = { | 290 SkImageFilter* filters[] = { |
291 SkColorFilterImageFilter::Create(cf.get(), input.get(), &cropRect), | 291 SkColorFilterImageFilter::Create(cf.get(), input.get(), &cropRect), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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)); |
414 SkPoint3 location(0, 0, SK_Scalar1); | 414 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); |
415 SkPoint3 target(SK_Scalar1, SK_Scalar1, SK_Scalar1); | |
416 SkScalar kernel[9] = { | 415 SkScalar kernel[9] = { |
417 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 416 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
418 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), | 417 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), |
419 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 418 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
420 }; | 419 }; |
421 SkISize kernelSize = SkISize::Make(3, 3); | 420 SkISize kernelSize = SkISize::Make(3, 3); |
422 SkScalar gain = SK_Scalar1, bias = 0; | 421 SkScalar gain = SK_Scalar1, bias = 0; |
423 SkScalar five = SkIntToScalar(5); | 422 SkScalar five = SkIntToScalar(5); |
424 | 423 |
425 SkAutoTUnref<SkImageFilter> gradient_source(SkBitmapSource::Create(make_grad
ient_circle(64, 64))); | 424 SkAutoTUnref<SkImageFilter> gradient_source(SkBitmapSource::Create(make_grad
ient_circle(64, 64))); |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 SkSurface::kNo_Budgeted
, | 1205 SkSurface::kNo_Budgeted
, |
1207 SkImageInfo::MakeN32Pre
mul(1, 1), | 1206 SkImageInfo::MakeN32Pre
mul(1, 1), |
1208 0, | 1207 0, |
1209 &props, | 1208 &props, |
1210 SkGpuDevice::kUninit_In
itContents)); | 1209 SkGpuDevice::kUninit_In
itContents)); |
1211 SkImageFilter::Proxy proxy(device); | 1210 SkImageFilter::Proxy proxy(device); |
1212 | 1211 |
1213 test_negative_blur_sigma(&proxy, reporter); | 1212 test_negative_blur_sigma(&proxy, reporter); |
1214 } | 1213 } |
1215 #endif | 1214 #endif |
OLD | NEW |