| 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" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "SkGpuDevice.h" | 40 #include "SkGpuDevice.h" |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 static const int kBitmapSize = 4; | 43 static const int kBitmapSize = 4; |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 class MatrixTestImageFilter : public SkImageFilter { | 47 class MatrixTestImageFilter : public SkImageFilter { |
| 48 public: | 48 public: |
| 49 MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expected
Matrix) | 49 MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expected
Matrix) |
| 50 : SkImageFilter(0, NULL), fReporter(reporter), fExpectedMatrix(expectedMat
rix) { | 50 : SkImageFilter(0, nullptr), fReporter(reporter), fExpectedMatrix(expected
Matrix) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx, | 53 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx, |
| 54 SkBitmap* result, SkIPoint* offset) const overrid
e { | 54 SkBitmap* result, SkIPoint* offset) const overrid
e { |
| 55 REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix); | 55 REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix); |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 SK_TO_STRING_OVERRIDE() | 59 SK_TO_STRING_OVERRIDE() |
| 60 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) | 60 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 SkIntToScalar(i)), lightPaint); | 116 SkIntToScalar(i)), lightPaint); |
| 117 canvas.drawRect(SkRect::MakeXYWH(SkIntToScalar(i), | 117 canvas.drawRect(SkRect::MakeXYWH(SkIntToScalar(i), |
| 118 SkIntToScalar(i), | 118 SkIntToScalar(i), |
| 119 SkIntToScalar(i), | 119 SkIntToScalar(i), |
| 120 SkIntToScalar(i)), darkPaint); | 120 SkIntToScalar(i)), darkPaint); |
| 121 canvas.restore(); | 121 canvas.restore(); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) { | 126 static SkImageFilter* make_scale(float amount, SkImageFilter* input = nullptr) { |
| 127 SkScalar s = amount; | 127 SkScalar s = amount; |
| 128 SkScalar matrix[20] = { s, 0, 0, 0, 0, | 128 SkScalar matrix[20] = { s, 0, 0, 0, 0, |
| 129 0, s, 0, 0, 0, | 129 0, s, 0, 0, 0, |
| 130 0, 0, s, 0, 0, | 130 0, 0, s, 0, 0, |
| 131 0, 0, 0, s, 0 }; | 131 0, 0, 0, s, 0 }; |
| 132 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); | 132 SkAutoTUnref<SkColorFilter> filter(SkColorMatrixFilter::Create(matrix)); |
| 133 return SkColorFilterImageFilter::Create(filter, input); | 133 return SkColorFilterImageFilter::Create(filter, input); |
| 134 } | 134 } |
| 135 | 135 |
| 136 static SkImageFilter* make_grayscale(SkImageFilter* input, const SkImageFilter::
CropRect* cropRect) { | 136 static SkImageFilter* make_grayscale(SkImageFilter* input, const SkImageFilter::
CropRect* cropRect) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorB
LUE, | 148 SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorB
LUE, |
| 149 SkXfermod
e::kSrcIn_Mode)); | 149 SkXfermod
e::kSrcIn_Mode)); |
| 150 return SkColorFilterImageFilter::Create(filter, input, cropRect); | 150 return SkColorFilterImageFilter::Create(filter, input, cropRect); |
| 151 } | 151 } |
| 152 | 152 |
| 153 DEF_TEST(ImageFilter, reporter) { | 153 DEF_TEST(ImageFilter, reporter) { |
| 154 { | 154 { |
| 155 // Check that two non-clipping color-matrice-filters concatenate into a
single filter. | 155 // Check that two non-clipping color-matrice-filters concatenate into a
single filter. |
| 156 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f)); | 156 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f)); |
| 157 SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrigh
tness)); | 157 SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrigh
tness)); |
| 158 REPORTER_ASSERT(reporter, NULL == quarterBrightness->getInput(0)); | 158 REPORTER_ASSERT(reporter, nullptr == quarterBrightness->getInput(0)); |
| 159 SkColorFilter* cf; | 159 SkColorFilter* cf; |
| 160 REPORTER_ASSERT(reporter, quarterBrightness->asColorFilter(&cf)); | 160 REPORTER_ASSERT(reporter, quarterBrightness->asColorFilter(&cf)); |
| 161 REPORTER_ASSERT(reporter, cf->asColorMatrix(NULL)); | 161 REPORTER_ASSERT(reporter, cf->asColorMatrix(nullptr)); |
| 162 cf->unref(); | 162 cf->unref(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 { | 165 { |
| 166 // Check that a clipping color-matrice-filter followed by a color-matric
e-filters | 166 // Check that a clipping color-matrice-filter followed by a color-matric
e-filters |
| 167 // concatenates into a single filter, but not a matrixfilter (due to cla
mping). | 167 // concatenates into a single filter, but not a matrixfilter (due to cla
mping). |
| 168 SkAutoTUnref<SkImageFilter> doubleBrightness(make_scale(2.0f)); | 168 SkAutoTUnref<SkImageFilter> doubleBrightness(make_scale(2.0f)); |
| 169 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f, doubleBright
ness)); | 169 SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f, doubleBright
ness)); |
| 170 REPORTER_ASSERT(reporter, NULL == halfBrightness->getInput(0)); | 170 REPORTER_ASSERT(reporter, nullptr == halfBrightness->getInput(0)); |
| 171 SkColorFilter* cf; | 171 SkColorFilter* cf; |
| 172 REPORTER_ASSERT(reporter, halfBrightness->asColorFilter(&cf)); | 172 REPORTER_ASSERT(reporter, halfBrightness->asColorFilter(&cf)); |
| 173 REPORTER_ASSERT(reporter, !cf->asColorMatrix(NULL)); | 173 REPORTER_ASSERT(reporter, !cf->asColorMatrix(nullptr)); |
| 174 cf->unref(); | 174 cf->unref(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 { | 177 { |
| 178 // Check that a color filter image filter without a crop rect can be | 178 // Check that a color filter image filter without a crop rect can be |
| 179 // expressed as a color filter. | 179 // expressed as a color filter. |
| 180 SkAutoTUnref<SkImageFilter> gray(make_grayscale(NULL, NULL)); | 180 SkAutoTUnref<SkImageFilter> gray(make_grayscale(nullptr, nullptr)); |
| 181 REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL)); | 181 REPORTER_ASSERT(reporter, true == gray->asColorFilter(nullptr)); |
| 182 } | 182 } |
| 183 | 183 |
| 184 { | 184 { |
| 185 // Check that a colorfilterimage filter without a crop rect but with an
input | 185 // Check that a colorfilterimage filter without a crop rect but with an
input |
| 186 // that is another colorfilterimage can be expressed as a colorfilter (c
omposed). | 186 // that is another colorfilterimage can be expressed as a colorfilter (c
omposed). |
| 187 SkAutoTUnref<SkImageFilter> mode(make_blue(NULL, NULL)); | 187 SkAutoTUnref<SkImageFilter> mode(make_blue(nullptr, nullptr)); |
| 188 SkAutoTUnref<SkImageFilter> gray(make_grayscale(mode, NULL)); | 188 SkAutoTUnref<SkImageFilter> gray(make_grayscale(mode, nullptr)); |
| 189 REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL)); | 189 REPORTER_ASSERT(reporter, true == gray->asColorFilter(nullptr)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 { | 192 { |
| 193 // Test that if we exceed the limit of what ComposeColorFilter can combi
ne, we still | 193 // Test that if we exceed the limit of what ComposeColorFilter can combi
ne, we still |
| 194 // can build the DAG and won't assert if we call asColorFilter. | 194 // can build the DAG and won't assert if we call asColorFilter. |
| 195 SkAutoTUnref<SkImageFilter> filter(make_blue(NULL, NULL)); | 195 SkAutoTUnref<SkImageFilter> filter(make_blue(nullptr, nullptr)); |
| 196 const int kWayTooManyForComposeColorFilter = 100; | 196 const int kWayTooManyForComposeColorFilter = 100; |
| 197 for (int i = 0; i < kWayTooManyForComposeColorFilter; ++i) { | 197 for (int i = 0; i < kWayTooManyForComposeColorFilter; ++i) { |
| 198 filter.reset(make_blue(filter, NULL)); | 198 filter.reset(make_blue(filter, nullptr)); |
| 199 // the first few of these will succeed, but after we hit the interna
l limit, | 199 // the first few of these will succeed, but after we hit the interna
l limit, |
| 200 // it will then return false. | 200 // it will then return false. |
| 201 (void)filter->asColorFilter(NULL); | 201 (void)filter->asColorFilter(nullptr); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 { | 205 { |
| 206 // Check that a color filter image filter with a crop rect cannot | 206 // Check that a color filter image filter with a crop rect cannot |
| 207 // be expressed as a color filter. | 207 // be expressed as a color filter. |
| 208 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(0, 0, 100, 100)); | 208 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(0, 0, 100, 100)); |
| 209 SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(NULL, &cropRect)
); | 209 SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(nullptr, &cropRe
ct)); |
| 210 REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(NULL)); | 210 REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(nullptr))
; |
| 211 } | 211 } |
| 212 | 212 |
| 213 { | 213 { |
| 214 // Check that two non-commutative matrices are concatenated in | 214 // Check that two non-commutative matrices are concatenated in |
| 215 // the correct order. | 215 // the correct order. |
| 216 SkScalar blueToRedMatrix[20] = { 0 }; | 216 SkScalar blueToRedMatrix[20] = { 0 }; |
| 217 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1; | 217 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1; |
| 218 SkScalar redToGreenMatrix[20] = { 0 }; | 218 SkScalar redToGreenMatrix[20] = { 0 }; |
| 219 redToGreenMatrix[5] = redToGreenMatrix[18] = SK_Scalar1; | 219 redToGreenMatrix[5] = redToGreenMatrix[18] = SK_Scalar1; |
| 220 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueTo
RedMatrix)); | 220 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueTo
RedMatrix)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 static void test_crop_rects(SkImageFilter::Proxy* proxy, skiatest::Reporter* rep
orter) { | 269 static void test_crop_rects(SkImageFilter::Proxy* proxy, skiatest::Reporter* rep
orter) { |
| 270 // Check that all filters offset to their absolute crop rect, | 270 // Check that all filters offset to their absolute crop rect, |
| 271 // unaffected by the input crop rect. | 271 // unaffected by the input crop rect. |
| 272 // Tests pass by not asserting. | 272 // Tests pass by not asserting. |
| 273 SkBitmap bitmap; | 273 SkBitmap bitmap; |
| 274 bitmap.allocN32Pixels(100, 100); | 274 bitmap.allocN32Pixels(100, 100); |
| 275 bitmap.eraseARGB(0, 0, 0, 0); | 275 bitmap.eraseARGB(0, 0, 0, 0); |
| 276 | 276 |
| 277 SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80)); | 277 SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80)); |
| 278 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60)); | 278 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60)); |
| 279 SkAutoTUnref<SkImageFilter> input(make_grayscale(NULL, &inputCropRect)); | 279 SkAutoTUnref<SkImageFilter> input(make_grayscale(nullptr, &inputCropRect)); |
| 280 | 280 |
| 281 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); | 281 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode)); |
| 282 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); | 282 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); |
| 283 SkScalar kernel[9] = { | 283 SkScalar kernel[9] = { |
| 284 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 284 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
| 285 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), | 285 SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1), |
| 286 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), | 286 SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1), |
| 287 }; | 287 }; |
| 288 SkISize kernelSize = SkISize::Make(3, 3); | 288 SkISize kernelSize = SkISize::Make(3, 3); |
| 289 SkScalar gain = SK_Scalar1, bias = 0; | 289 SkScalar gain = SK_Scalar1, bias = 0; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 308 SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.g
et()), | 308 SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.g
et()), |
| 309 SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mo
de), input.get(), input.get(), &cropRect), | 309 SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mo
de), input.get(), input.get(), &cropRect), |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { | 312 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { |
| 313 SkImageFilter* filter = filters[i]; | 313 SkImageFilter* filter = filters[i]; |
| 314 SkBitmap result; | 314 SkBitmap result; |
| 315 SkIPoint offset; | 315 SkIPoint offset; |
| 316 SkString str; | 316 SkString str; |
| 317 str.printf("filter %d", static_cast<int>(i)); | 317 str.printf("filter %d", static_cast<int>(i)); |
| 318 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); | 318 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullpt
r); |
| 319 REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(proxy, bitmap, ctx
, | 319 REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(proxy, bitmap, ctx
, |
| 320 &result, &offset), str.c_str()); | 320 &result, &offset), str.c_str()); |
| 321 REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, st
r.c_str()); | 321 REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, st
r.c_str()); |
| 322 } | 322 } |
| 323 | 323 |
| 324 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { | 324 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { |
| 325 SkSafeUnref(filters[i]); | 325 SkSafeUnref(filters[i]); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 static SkBitmap make_gradient_circle(int width, int height) { | 329 static SkBitmap make_gradient_circle(int width, int height) { |
| 330 SkBitmap bitmap; | 330 SkBitmap bitmap; |
| 331 SkScalar x = SkIntToScalar(width / 2); | 331 SkScalar x = SkIntToScalar(width / 2); |
| 332 SkScalar y = SkIntToScalar(height / 2); | 332 SkScalar y = SkIntToScalar(height / 2); |
| 333 SkScalar radius = SkMinScalar(x, y) * 0.8f; | 333 SkScalar radius = SkMinScalar(x, y) * 0.8f; |
| 334 bitmap.allocN32Pixels(width, height); | 334 bitmap.allocN32Pixels(width, height); |
| 335 SkCanvas canvas(bitmap); | 335 SkCanvas canvas(bitmap); |
| 336 canvas.clear(0x00000000); | 336 canvas.clear(0x00000000); |
| 337 SkColor colors[2]; | 337 SkColor colors[2]; |
| 338 colors[0] = SK_ColorWHITE; | 338 colors[0] = SK_ColorWHITE; |
| 339 colors[1] = SK_ColorBLACK; | 339 colors[1] = SK_ColorBLACK; |
| 340 SkAutoTUnref<SkShader> shader( | 340 SkAutoTUnref<SkShader> shader( |
| 341 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, NULL
, 2, | 341 SkGradientShader::CreateRadial(SkPoint::Make(x, y), radius, colors, null
ptr, 2, |
| 342 SkShader::kClamp_TileMode) | 342 SkShader::kClamp_TileMode) |
| 343 ); | 343 ); |
| 344 SkPaint paint; | 344 SkPaint paint; |
| 345 paint.setShader(shader); | 345 paint.setShader(shader); |
| 346 canvas.drawCircle(x, y, radius, paint); | 346 canvas.drawCircle(x, y, radius, paint); |
| 347 return bitmap; | 347 return bitmap; |
| 348 } | 348 } |
| 349 | 349 |
| 350 static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Repo
rter* reporter) { | 350 static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Repo
rter* reporter) { |
| 351 // Check that SkBlurImageFilter will accept a negative sigma, either in | 351 // Check that SkBlurImageFilter will accept a negative sigma, either in |
| 352 // the given arguments or after CTM application. | 352 // the given arguments or after CTM application. |
| 353 int width = 32, height = 32; | 353 int width = 32, height = 32; |
| 354 SkScalar five = SkIntToScalar(5); | 354 SkScalar five = SkIntToScalar(5); |
| 355 | 355 |
| 356 SkAutoTUnref<SkBlurImageFilter> positiveFilter( | 356 SkAutoTUnref<SkBlurImageFilter> positiveFilter( |
| 357 SkBlurImageFilter::Create(five, five) | 357 SkBlurImageFilter::Create(five, five) |
| 358 ); | 358 ); |
| 359 | 359 |
| 360 SkAutoTUnref<SkBlurImageFilter> negativeFilter( | 360 SkAutoTUnref<SkBlurImageFilter> negativeFilter( |
| 361 SkBlurImageFilter::Create(-five, five) | 361 SkBlurImageFilter::Create(-five, five) |
| 362 ); | 362 ); |
| 363 | 363 |
| 364 SkBitmap gradient = make_gradient_circle(width, height); | 364 SkBitmap gradient = make_gradient_circle(width, height); |
| 365 SkBitmap positiveResult1, negativeResult1; | 365 SkBitmap positiveResult1, negativeResult1; |
| 366 SkBitmap positiveResult2, negativeResult2; | 366 SkBitmap positiveResult2, negativeResult2; |
| 367 SkIPoint offset; | 367 SkIPoint offset; |
| 368 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); | 368 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); |
| 369 positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset)
; | 369 positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset)
; |
| 370 negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset)
; | 370 negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset)
; |
| 371 SkMatrix negativeScale; | 371 SkMatrix negativeScale; |
| 372 negativeScale.setScale(-SK_Scalar1, SK_Scalar1); | 372 negativeScale.setScale(-SK_Scalar1, SK_Scalar1); |
| 373 SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeLargest(), NU
LL); | 373 SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeLargest(), nu
llptr); |
| 374 positiveFilter->filterImage(proxy, gradient, negativeCTX, &negativeResult2,
&offset); | 374 positiveFilter->filterImage(proxy, gradient, negativeCTX, &negativeResult2,
&offset); |
| 375 negativeFilter->filterImage(proxy, gradient, negativeCTX, &positiveResult2,
&offset); | 375 negativeFilter->filterImage(proxy, gradient, negativeCTX, &positiveResult2,
&offset); |
| 376 SkAutoLockPixels lockP1(positiveResult1); | 376 SkAutoLockPixels lockP1(positiveResult1); |
| 377 SkAutoLockPixels lockP2(positiveResult2); | 377 SkAutoLockPixels lockP2(positiveResult2); |
| 378 SkAutoLockPixels lockN1(negativeResult1); | 378 SkAutoLockPixels lockN1(negativeResult1); |
| 379 SkAutoLockPixels lockN2(negativeResult2); | 379 SkAutoLockPixels lockN2(negativeResult2); |
| 380 for (int y = 0; y < height; y++) { | 380 for (int y = 0; y < height; y++) { |
| 381 int diffs = memcmp(positiveResult1.getAddr32(0, y), negativeResult1.getA
ddr32(0, y), positiveResult1.rowBytes()); | 381 int diffs = memcmp(positiveResult1.getAddr32(0, y), negativeResult1.getA
ddr32(0, y), positiveResult1.rowBytes()); |
| 382 REPORTER_ASSERT(reporter, !diffs); | 382 REPORTER_ASSERT(reporter, !diffs); |
| 383 if (diffs) { | 383 if (diffs) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, | 462 SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, |
| 463 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode) }, | 463 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode) }, |
| 464 { "diffuse lighting", SkLightingImageFilter::CreatePointLitDiffuse( | 464 { "diffuse lighting", SkLightingImageFilter::CreatePointLitDiffuse( |
| 465 location, SK_ColorGREEN, 0, 0) }, | 465 location, SK_ColorGREEN, 0, 0) }, |
| 466 { "specular lighting", | 466 { "specular lighting", |
| 467 SkLightingImageFilter::CreatePointLitSpecular(location, SK_ColorGR
EEN, 0, 0, 0) }, | 467 SkLightingImageFilter::CreatePointLitSpecular(location, SK_ColorGR
EEN, 0, 0, 0) }, |
| 468 { "matrix convolution", | 468 { "matrix convolution", |
| 469 SkMatrixConvolutionImageFilter::Create( | 469 SkMatrixConvolutionImageFilter::Create( |
| 470 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), | 470 kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), |
| 471 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false) }, | 471 SkMatrixConvolutionImageFilter::kRepeat_TileMode, false) }, |
| 472 { "merge", SkMergeImageFilter::Create(NULL, NULL, SkXfermode::kSrcOver_M
ode) }, | 472 { "merge", SkMergeImageFilter::Create(nullptr, nullptr, SkXfermode::kSrc
Over_Mode) }, |
| 473 { "merge with disjoint inputs", SkMergeImageFilter::Create( | 473 { "merge with disjoint inputs", SkMergeImageFilter::Create( |
| 474 rectShaderFilterLeft, rectShaderFilterRight, SkXfermode::kSrcOver_
Mode) }, | 474 rectShaderFilterLeft, rectShaderFilterRight, SkXfermode::kSrcOver_
Mode) }, |
| 475 { "offset", SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1) }, | 475 { "offset", SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1) }, |
| 476 { "dilate", SkDilateImageFilter::Create(3, 2) }, | 476 { "dilate", SkDilateImageFilter::Create(3, 2) }, |
| 477 { "erode", SkErodeImageFilter::Create(2, 3) }, | 477 { "erode", SkErodeImageFilter::Create(2, 3) }, |
| 478 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), | 478 { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50), |
| 479 SkRect::MakeXYWH(0, 0, 100, 100), NU
LL) }, | 479 SkRect::MakeXYWH(0, 0, 100, 100), nu
llptr) }, |
| 480 { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuali
ty) }, | 480 { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuali
ty) }, |
| 481 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get())
}, | 481 { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get())
}, |
| 482 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte
r.get()) }, | 482 { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilte
r.get()) }, |
| 483 { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShad
erFilter.get()) }, | 483 { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShad
erFilter.get()) }, |
| 484 }; | 484 }; |
| 485 | 485 |
| 486 SkBitmap untiledResult, tiledResult; | 486 SkBitmap untiledResult, tiledResult; |
| 487 int width = 64, height = 64; | 487 int width = 64, height = 64; |
| 488 untiledResult.allocN32Pixels(width, height); | 488 untiledResult.allocN32Pixels(width, height); |
| 489 tiledResult.allocN32Pixels(width, height); | 489 tiledResult.allocN32Pixels(width, height); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 // Check that matrix filter when drawn tiled with BBH exactly | 565 // Check that matrix filter when drawn tiled with BBH exactly |
| 566 // matches the same thing drawn without BBH. | 566 // matches the same thing drawn without BBH. |
| 567 // Tests pass by not asserting. | 567 // Tests pass by not asserting. |
| 568 | 568 |
| 569 const int width = 200, height = 200; | 569 const int width = 200, height = 200; |
| 570 const int tileSize = 100; | 570 const int tileSize = 100; |
| 571 SkBitmap result1, result2; | 571 SkBitmap result1, result2; |
| 572 SkRTreeFactory factory; | 572 SkRTreeFactory factory; |
| 573 | 573 |
| 574 draw_saveLayer_picture(width, height, tileSize, &factory, &result1); | 574 draw_saveLayer_picture(width, height, tileSize, &factory, &result1); |
| 575 draw_saveLayer_picture(width, height, tileSize, NULL, &result2); | 575 draw_saveLayer_picture(width, height, tileSize, nullptr, &result2); |
| 576 | 576 |
| 577 for (int y = 0; y < height; y++) { | 577 for (int y = 0; y < height; y++) { |
| 578 int diffs = memcmp(result1.getAddr32(0, y), result2.getAddr32(0, y), res
ult1.rowBytes()); | 578 int diffs = memcmp(result1.getAddr32(0, y), result2.getAddr32(0, y), res
ult1.rowBytes()); |
| 579 REPORTER_ASSERT(reporter, !diffs); | 579 REPORTER_ASSERT(reporter, !diffs); |
| 580 if (diffs) { | 580 if (diffs) { |
| 581 break; | 581 break; |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 static SkImageFilter* makeBlur(SkImageFilter* input = NULL) { | 586 static SkImageFilter* makeBlur(SkImageFilter* input = nullptr) { |
| 587 return SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, input); | 587 return SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, input); |
| 588 } | 588 } |
| 589 | 589 |
| 590 static SkImageFilter* makeDropShadow(SkImageFilter* input = NULL) { | 590 static SkImageFilter* makeDropShadow(SkImageFilter* input = nullptr) { |
| 591 return SkDropShadowImageFilter::Create( | 591 return SkDropShadowImageFilter::Create( |
| 592 SkIntToScalar(100), SkIntToScalar(100), | 592 SkIntToScalar(100), SkIntToScalar(100), |
| 593 SkIntToScalar(10), SkIntToScalar(10), | 593 SkIntToScalar(10), SkIntToScalar(10), |
| 594 SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMo
de, | 594 SK_ColorBLUE, SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMo
de, |
| 595 input, NULL); | 595 input, nullptr); |
| 596 } | 596 } |
| 597 | 597 |
| 598 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { | 598 DEF_TEST(ImageFilterBlurThenShadowBounds, reporter) { |
| 599 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); | 599 SkAutoTUnref<SkImageFilter> filter1(makeBlur()); |
| 600 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); | 600 SkAutoTUnref<SkImageFilter> filter2(makeDropShadow(filter1.get())); |
| 601 | 601 |
| 602 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); | 602 SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100); |
| 603 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); | 603 SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236); |
| 604 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); | 604 filter2->filterBounds(bounds, SkMatrix::I(), &bounds); |
| 605 | 605 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 composedFilter->computeFastBounds(boundsSrc, &boundsDst); | 640 composedFilter->computeFastBounds(boundsSrc, &boundsDst); |
| 641 | 641 |
| 642 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); | 642 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); |
| 643 } | 643 } |
| 644 | 644 |
| 645 static void draw_blurred_rect(SkCanvas* canvas) { | 645 static void draw_blurred_rect(SkCanvas* canvas) { |
| 646 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8
), 0)); | 646 SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(SkIntToScalar(8
), 0)); |
| 647 SkPaint filterPaint; | 647 SkPaint filterPaint; |
| 648 filterPaint.setColor(SK_ColorWHITE); | 648 filterPaint.setColor(SK_ColorWHITE); |
| 649 filterPaint.setImageFilter(filter); | 649 filterPaint.setImageFilter(filter); |
| 650 canvas->saveLayer(NULL, &filterPaint); | 650 canvas->saveLayer(nullptr, &filterPaint); |
| 651 SkPaint whitePaint; | 651 SkPaint whitePaint; |
| 652 whitePaint.setColor(SK_ColorWHITE); | 652 whitePaint.setColor(SK_ColorWHITE); |
| 653 canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); | 653 canvas->drawRect(SkRect::Make(SkIRect::MakeWH(4, 4)), whitePaint); |
| 654 canvas->restore(); | 654 canvas->restore(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 static void draw_picture_clipped(SkCanvas* canvas, const SkRect& clipRect, const
SkPicture* picture) { | 657 static void draw_picture_clipped(SkCanvas* canvas, const SkRect& clipRect, const
SkPicture* picture) { |
| 658 canvas->save(); | 658 canvas->save(); |
| 659 canvas->clipRect(clipRect); | 659 canvas->clipRect(clipRect); |
| 660 canvas->drawPicture(picture); | 660 canvas->drawPicture(picture); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 679 | 679 |
| 680 canvas1.clear(0); | 680 canvas1.clear(0); |
| 681 canvas2.clear(0); | 681 canvas2.clear(0); |
| 682 | 682 |
| 683 SkRTreeFactory factory; | 683 SkRTreeFactory factory; |
| 684 | 684 |
| 685 SkPictureRecorder recorder1, recorder2; | 685 SkPictureRecorder recorder1, recorder2; |
| 686 // The only difference between these two pictures is that one has RTree acel
eration. | 686 // The only difference between these two pictures is that one has RTree acel
eration. |
| 687 SkCanvas* recordingCanvas1 = recorder1.beginRecording(SkIntToScalar(width), | 687 SkCanvas* recordingCanvas1 = recorder1.beginRecording(SkIntToScalar(width), |
| 688 SkIntToScalar(height), | 688 SkIntToScalar(height), |
| 689 NULL, 0); | 689 nullptr, 0); |
| 690 SkCanvas* recordingCanvas2 = recorder2.beginRecording(SkIntToScalar(width), | 690 SkCanvas* recordingCanvas2 = recorder2.beginRecording(SkIntToScalar(width), |
| 691 SkIntToScalar(height), | 691 SkIntToScalar(height), |
| 692 &factory, 0); | 692 &factory, 0); |
| 693 draw_blurred_rect(recordingCanvas1); | 693 draw_blurred_rect(recordingCanvas1); |
| 694 draw_blurred_rect(recordingCanvas2); | 694 draw_blurred_rect(recordingCanvas2); |
| 695 SkAutoTUnref<SkPicture> picture1(recorder1.endRecording()); | 695 SkAutoTUnref<SkPicture> picture1(recorder1.endRecording()); |
| 696 SkAutoTUnref<SkPicture> picture2(recorder2.endRecording()); | 696 SkAutoTUnref<SkPicture> picture2(recorder2.endRecording()); |
| 697 for (int y = 0; y < height; y += tileSize) { | 697 for (int y = 0; y < height; y += tileSize) { |
| 698 for (int x = 0; x < width; x += tileSize) { | 698 for (int x = 0; x < width; x += tileSize) { |
| 699 SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, til
eSize)); | 699 SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, til
eSize)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 SkMatrix expectedMatrix = canvas.getTotalMatrix(); | 787 SkMatrix expectedMatrix = canvas.getTotalMatrix(); |
| 788 | 788 |
| 789 SkRTreeFactory factory; | 789 SkRTreeFactory factory; |
| 790 SkPictureRecorder recorder; | 790 SkPictureRecorder recorder; |
| 791 SkCanvas* recordingCanvas = recorder.beginRecording(100, 100, &factory, 0); | 791 SkCanvas* recordingCanvas = recorder.beginRecording(100, 100, &factory, 0); |
| 792 | 792 |
| 793 SkPaint paint; | 793 SkPaint paint; |
| 794 SkAutoTUnref<MatrixTestImageFilter> imageFilter( | 794 SkAutoTUnref<MatrixTestImageFilter> imageFilter( |
| 795 new MatrixTestImageFilter(reporter, expectedMatrix)); | 795 new MatrixTestImageFilter(reporter, expectedMatrix)); |
| 796 paint.setImageFilter(imageFilter.get()); | 796 paint.setImageFilter(imageFilter.get()); |
| 797 recordingCanvas->saveLayer(NULL, &paint); | 797 recordingCanvas->saveLayer(nullptr, &paint); |
| 798 SkPaint solidPaint; | 798 SkPaint solidPaint; |
| 799 solidPaint.setColor(0xFFFFFFFF); | 799 solidPaint.setColor(0xFFFFFFFF); |
| 800 recordingCanvas->save(); | 800 recordingCanvas->save(); |
| 801 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); | 801 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); |
| 802 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); | 802 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); |
| 803 recordingCanvas->restore(); // scale | 803 recordingCanvas->restore(); // scale |
| 804 recordingCanvas->restore(); // saveLayer | 804 recordingCanvas->restore(); // saveLayer |
| 805 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 805 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 806 | 806 |
| 807 canvas.drawPicture(picture); | 807 canvas.drawPicture(picture); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 // Create an SkPicture which simply draws a green 1x1 rectangle. | 875 // Create an SkPicture which simply draws a green 1x1 rectangle. |
| 876 SkPaint greenPaint; | 876 SkPaint greenPaint; |
| 877 greenPaint.setColor(SK_ColorGREEN); | 877 greenPaint.setColor(SK_ColorGREEN); |
| 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
lptr); |
| 886 SkBitmap bitmap; | 886 SkBitmap bitmap; |
| 887 bitmap.allocN32Pixels(2, 2); | 887 bitmap.allocN32Pixels(2, 2); |
| 888 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 888 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 889 SkBitmapDevice device(bitmap, props); | 889 SkBitmapDevice device(bitmap, props); |
| 890 SkImageFilter::Proxy proxy(&device); | 890 SkImageFilter::Proxy proxy(&device); |
| 891 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re
sult, &offset)); | 891 REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &re
sult, &offset)); |
| 892 } | 892 } |
| 893 | 893 |
| 894 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { | 894 DEF_TEST(ImageFilterEmptySaveLayer, reporter) { |
| 895 // 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 917 recordingCanvas->saveLayer(&bounds, &imageFilterPaint); | 917 recordingCanvas->saveLayer(&bounds, &imageFilterPaint); |
| 918 recordingCanvas->restore(); | 918 recordingCanvas->restore(); |
| 919 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 919 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 920 | 920 |
| 921 canvas.clear(0); | 921 canvas.clear(0); |
| 922 canvas.drawPicture(picture); | 922 canvas.drawPicture(picture); |
| 923 uint32_t pixel = *bitmap.getAddr32(0, 0); | 923 uint32_t pixel = *bitmap.getAddr32(0, 0); |
| 924 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 924 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 925 | 925 |
| 926 recordingCanvas = recorder.beginRecording(10, 10, &factory, 0); | 926 recordingCanvas = recorder.beginRecording(10, 10, &factory, 0); |
| 927 recordingCanvas->saveLayer(NULL, &imageFilterPaint); | 927 recordingCanvas->saveLayer(nullptr, &imageFilterPaint); |
| 928 recordingCanvas->restore(); | 928 recordingCanvas->restore(); |
| 929 SkAutoTUnref<SkPicture> picture2(recorder.endRecording()); | 929 SkAutoTUnref<SkPicture> picture2(recorder.endRecording()); |
| 930 | 930 |
| 931 canvas.clear(0); | 931 canvas.clear(0); |
| 932 canvas.drawPicture(picture2); | 932 canvas.drawPicture(picture2); |
| 933 pixel = *bitmap.getAddr32(0, 0); | 933 pixel = *bitmap.getAddr32(0, 0); |
| 934 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 934 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 935 | 935 |
| 936 recordingCanvas = recorder.beginRecording(10, 10, &factory, 0); | 936 recordingCanvas = recorder.beginRecording(10, 10, &factory, 0); |
| 937 recordingCanvas->saveLayer(&bounds, &colorFilterPaint); | 937 recordingCanvas->saveLayer(&bounds, &colorFilterPaint); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 962 temp.allocN32Pixels(100, 100); | 962 temp.allocN32Pixels(100, 100); |
| 963 SkCanvas canvas(temp); | 963 SkCanvas canvas(temp); |
| 964 test_huge_blur(&canvas, reporter); | 964 test_huge_blur(&canvas, reporter); |
| 965 } | 965 } |
| 966 | 966 |
| 967 DEF_TEST(MatrixConvolutionSanityTest, reporter) { | 967 DEF_TEST(MatrixConvolutionSanityTest, reporter) { |
| 968 SkScalar kernel[1] = { 0 }; | 968 SkScalar kernel[1] = { 0 }; |
| 969 SkScalar gain = SK_Scalar1, bias = 0; | 969 SkScalar gain = SK_Scalar1, bias = 0; |
| 970 SkIPoint kernelOffset = SkIPoint::Make(1, 1); | 970 SkIPoint kernelOffset = SkIPoint::Make(1, 1); |
| 971 | 971 |
| 972 // Check that an enormous (non-allocatable) kernel gives a NULL filter. | 972 // Check that an enormous (non-allocatable) kernel gives a nullptr filter. |
| 973 SkAutoTUnref<SkImageFilter> conv(SkMatrixConvolutionImageFilter::Create( | 973 SkAutoTUnref<SkImageFilter> conv(SkMatrixConvolutionImageFilter::Create( |
| 974 SkISize::Make(1<<30, 1<<30), | 974 SkISize::Make(1<<30, 1<<30), |
| 975 kernel, | 975 kernel, |
| 976 gain, | 976 gain, |
| 977 bias, | 977 bias, |
| 978 kernelOffset, | 978 kernelOffset, |
| 979 SkMatrixConvolutionImageFilter::kRepeat_TileMode, | 979 SkMatrixConvolutionImageFilter::kRepeat_TileMode, |
| 980 false)); | 980 false)); |
| 981 | 981 |
| 982 REPORTER_ASSERT(reporter, NULL == conv.get()); | 982 REPORTER_ASSERT(reporter, nullptr == conv.get()); |
| 983 | 983 |
| 984 // Check that a NULL kernel gives a NULL filter. | 984 // Check that a nullptr kernel gives a nullptr filter. |
| 985 conv.reset(SkMatrixConvolutionImageFilter::Create( | 985 conv.reset(SkMatrixConvolutionImageFilter::Create( |
| 986 SkISize::Make(1, 1), | 986 SkISize::Make(1, 1), |
| 987 NULL, | 987 nullptr, |
| 988 gain, | 988 gain, |
| 989 bias, | 989 bias, |
| 990 kernelOffset, | 990 kernelOffset, |
| 991 SkMatrixConvolutionImageFilter::kRepeat_TileMode, | 991 SkMatrixConvolutionImageFilter::kRepeat_TileMode, |
| 992 false)); | 992 false)); |
| 993 | 993 |
| 994 REPORTER_ASSERT(reporter, NULL == conv.get()); | 994 REPORTER_ASSERT(reporter, nullptr == conv.get()); |
| 995 | 995 |
| 996 // Check that a kernel width < 1 gives a NULL filter. | 996 // Check that a kernel width < 1 gives a nullptr filter. |
| 997 conv.reset(SkMatrixConvolutionImageFilter::Create( | 997 conv.reset(SkMatrixConvolutionImageFilter::Create( |
| 998 SkISize::Make(0, 1), | 998 SkISize::Make(0, 1), |
| 999 kernel, | 999 kernel, |
| 1000 gain, | 1000 gain, |
| 1001 bias, | 1001 bias, |
| 1002 kernelOffset, | 1002 kernelOffset, |
| 1003 SkMatrixConvolutionImageFilter::kRepeat_TileMode, | 1003 SkMatrixConvolutionImageFilter::kRepeat_TileMode, |
| 1004 false)); | 1004 false)); |
| 1005 | 1005 |
| 1006 REPORTER_ASSERT(reporter, NULL == conv.get()); | 1006 REPORTER_ASSERT(reporter, nullptr == conv.get()); |
| 1007 | 1007 |
| 1008 // Check that kernel height < 1 gives a NULL filter. | 1008 // Check that kernel height < 1 gives a nullptr filter. |
| 1009 conv.reset(SkMatrixConvolutionImageFilter::Create( | 1009 conv.reset(SkMatrixConvolutionImageFilter::Create( |
| 1010 SkISize::Make(1, -1), | 1010 SkISize::Make(1, -1), |
| 1011 kernel, | 1011 kernel, |
| 1012 gain, | 1012 gain, |
| 1013 bias, | 1013 bias, |
| 1014 kernelOffset, | 1014 kernelOffset, |
| 1015 SkMatrixConvolutionImageFilter::kRepeat_TileMode, | 1015 SkMatrixConvolutionImageFilter::kRepeat_TileMode, |
| 1016 false)); | 1016 false)); |
| 1017 | 1017 |
| 1018 REPORTER_ASSERT(reporter, NULL == conv.get()); | 1018 REPORTER_ASSERT(reporter, nullptr == conv.get()); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 static void test_xfermode_cropped_input(SkCanvas* canvas, skiatest::Reporter* re
porter) { | 1021 static void test_xfermode_cropped_input(SkCanvas* canvas, skiatest::Reporter* re
porter) { |
| 1022 canvas->clear(0); | 1022 canvas->clear(0); |
| 1023 | 1023 |
| 1024 SkBitmap bitmap; | 1024 SkBitmap bitmap; |
| 1025 bitmap.allocN32Pixels(1, 1); | 1025 bitmap.allocN32Pixels(1, 1); |
| 1026 bitmap.eraseARGB(255, 255, 255, 255); | 1026 bitmap.eraseARGB(255, 255, 255, 255); |
| 1027 | 1027 |
| 1028 SkAutoTUnref<SkColorFilter> green( | 1028 SkAutoTUnref<SkColorFilter> green( |
| 1029 SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode))
; | 1029 SkColorFilter::CreateModeFilter(SK_ColorGREEN, SkXfermode::kSrcIn_Mode))
; |
| 1030 SkAutoTUnref<SkColorFilterImageFilter> greenFilter( | 1030 SkAutoTUnref<SkColorFilterImageFilter> greenFilter( |
| 1031 SkColorFilterImageFilter::Create(green.get())); | 1031 SkColorFilterImageFilter::Create(green.get())); |
| 1032 SkImageFilter::CropRect cropRect(SkRect::MakeEmpty()); | 1032 SkImageFilter::CropRect cropRect(SkRect::MakeEmpty()); |
| 1033 SkAutoTUnref<SkColorFilterImageFilter> croppedOut( | 1033 SkAutoTUnref<SkColorFilterImageFilter> croppedOut( |
| 1034 SkColorFilterImageFilter::Create(green.get(), NULL, &cropRect)); | 1034 SkColorFilterImageFilter::Create(green.get(), nullptr, &cropRect)); |
| 1035 | 1035 |
| 1036 // Check that an xfermode image filter whose input has been cropped out stil
l draws the other | 1036 // Check that an xfermode image filter whose input has been cropped out stil
l draws the other |
| 1037 // input. Also check that drawing with both inputs cropped out doesn't cause
a GPU warning. | 1037 // input. Also check that drawing with both inputs cropped out doesn't cause
a GPU warning. |
| 1038 SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrcOver_Mode); | 1038 SkXfermode* mode = SkXfermode::Create(SkXfermode::kSrcOver_Mode); |
| 1039 SkAutoTUnref<SkImageFilter> xfermodeNoFg( | 1039 SkAutoTUnref<SkImageFilter> xfermodeNoFg( |
| 1040 SkXfermodeImageFilter::Create(mode, greenFilter, croppedOut)); | 1040 SkXfermodeImageFilter::Create(mode, greenFilter, croppedOut)); |
| 1041 SkAutoTUnref<SkImageFilter> xfermodeNoBg( | 1041 SkAutoTUnref<SkImageFilter> xfermodeNoBg( |
| 1042 SkXfermodeImageFilter::Create(mode, croppedOut, greenFilter)); | 1042 SkXfermodeImageFilter::Create(mode, croppedOut, greenFilter)); |
| 1043 SkAutoTUnref<SkImageFilter> xfermodeNoFgNoBg( | 1043 SkAutoTUnref<SkImageFilter> xfermodeNoFgNoBg( |
| 1044 SkXfermodeImageFilter::Create(mode, croppedOut, croppedOut)); | 1044 SkXfermodeImageFilter::Create(mode, croppedOut, croppedOut)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1075 | 1075 |
| 1076 SkMatrix matrix; | 1076 SkMatrix matrix; |
| 1077 matrix.setScale(SkIntToScalar(2), SkIntToScalar(2)); | 1077 matrix.setScale(SkIntToScalar(2), SkIntToScalar(2)); |
| 1078 matrix.postTranslate(SkIntToScalar(-20), SkIntToScalar(-20)); | 1078 matrix.postTranslate(SkIntToScalar(-20), SkIntToScalar(-20)); |
| 1079 SkAutoTUnref<SkImageFilter> matrixFilter( | 1079 SkAutoTUnref<SkImageFilter> matrixFilter( |
| 1080 SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuality)); | 1080 SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuality)); |
| 1081 | 1081 |
| 1082 // Test that saveLayer() with a filter nested inside another saveLayer() app
lies the | 1082 // Test that saveLayer() with a filter nested inside another saveLayer() app
lies the |
| 1083 // correct offset to the filter matrix. | 1083 // correct offset to the filter matrix. |
| 1084 SkRect bounds1 = SkRect::MakeXYWH(10, 10, 30, 30); | 1084 SkRect bounds1 = SkRect::MakeXYWH(10, 10, 30, 30); |
| 1085 canvas.saveLayer(&bounds1, NULL); | 1085 canvas.saveLayer(&bounds1, nullptr); |
| 1086 SkPaint filterPaint; | 1086 SkPaint filterPaint; |
| 1087 filterPaint.setImageFilter(matrixFilter); | 1087 filterPaint.setImageFilter(matrixFilter); |
| 1088 SkRect bounds2 = SkRect::MakeXYWH(20, 20, 10, 10); | 1088 SkRect bounds2 = SkRect::MakeXYWH(20, 20, 10, 10); |
| 1089 canvas.saveLayer(&bounds2, &filterPaint); | 1089 canvas.saveLayer(&bounds2, &filterPaint); |
| 1090 SkPaint greenPaint; | 1090 SkPaint greenPaint; |
| 1091 greenPaint.setColor(SK_ColorGREEN); | 1091 greenPaint.setColor(SK_ColorGREEN); |
| 1092 canvas.drawRect(bounds2, greenPaint); | 1092 canvas.drawRect(bounds2, greenPaint); |
| 1093 canvas.restore(); | 1093 canvas.restore(); |
| 1094 canvas.restore(); | 1094 canvas.restore(); |
| 1095 SkPaint strokePaint; | 1095 SkPaint strokePaint; |
| 1096 strokePaint.setStyle(SkPaint::kStroke_Style); | 1096 strokePaint.setStyle(SkPaint::kStroke_Style); |
| 1097 strokePaint.setColor(SK_ColorRED); | 1097 strokePaint.setColor(SK_ColorRED); |
| 1098 | 1098 |
| 1099 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul
_SkAlphaType); | 1099 SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul
_SkAlphaType); |
| 1100 uint32_t pixel; | 1100 uint32_t pixel; |
| 1101 canvas.readPixels(info, &pixel, 4, 25, 25); | 1101 canvas.readPixels(info, &pixel, 4, 25, 25); |
| 1102 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 1102 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 1103 | 1103 |
| 1104 // Test that drawSprite() with a filter nested inside a saveLayer() applies
the | 1104 // Test that drawSprite() with a filter nested inside a saveLayer() applies
the |
| 1105 // correct offset to the filter matrix. | 1105 // correct offset to the filter matrix. |
| 1106 canvas.clear(0x0); | 1106 canvas.clear(0x0); |
| 1107 canvas.readPixels(info, &pixel, 4, 25, 25); | 1107 canvas.readPixels(info, &pixel, 4, 25, 25); |
| 1108 canvas.saveLayer(&bounds1, NULL); | 1108 canvas.saveLayer(&bounds1, nullptr); |
| 1109 canvas.drawSprite(bitmap, 20, 20, &filterPaint); | 1109 canvas.drawSprite(bitmap, 20, 20, &filterPaint); |
| 1110 canvas.restore(); | 1110 canvas.restore(); |
| 1111 | 1111 |
| 1112 canvas.readPixels(info, &pixel, 4, 25, 25); | 1112 canvas.readPixels(info, &pixel, 4, 25, 25); |
| 1113 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 1113 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 1114 } | 1114 } |
| 1115 | 1115 |
| 1116 DEF_TEST(XfermodeImageFilterCroppedInput, reporter) { | 1116 DEF_TEST(XfermodeImageFilterCroppedInput, reporter) { |
| 1117 SkBitmap temp; | 1117 SkBitmap temp; |
| 1118 temp.allocN32Pixels(100, 100); | 1118 temp.allocN32Pixels(100, 100); |
| 1119 SkCanvas canvas(temp); | 1119 SkCanvas canvas(temp); |
| 1120 test_xfermode_cropped_input(&canvas, reporter); | 1120 test_xfermode_cropped_input(&canvas, reporter); |
| 1121 } | 1121 } |
| 1122 | 1122 |
| 1123 DEF_TEST(ComposedImageFilterOffset, reporter) { | 1123 DEF_TEST(ComposedImageFilterOffset, reporter) { |
| 1124 SkBitmap bitmap; | 1124 SkBitmap bitmap; |
| 1125 bitmap.allocN32Pixels(100, 100); | 1125 bitmap.allocN32Pixels(100, 100); |
| 1126 bitmap.eraseARGB(0, 0, 0, 0); | 1126 bitmap.eraseARGB(0, 0, 0, 0); |
| 1127 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1127 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1128 SkBitmapDevice device(bitmap, props); | 1128 SkBitmapDevice device(bitmap, props); |
| 1129 SkImageFilter::Proxy proxy(&device); | 1129 SkImageFilter::Proxy proxy(&device); |
| 1130 | 1130 |
| 1131 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); | 1131 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); |
| 1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, N
ULL, &cropRect)); | 1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, n
ullptr, &cropRect)); |
| 1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); | 1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); |
| 1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur
Filter, offsetFilter.get())); | 1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur
Filter, offsetFilter.get())); |
| 1135 SkBitmap result; | 1135 SkBitmap result; |
| 1136 SkIPoint offset; | 1136 SkIPoint offset; |
| 1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); | 1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); |
| 1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &
result, &offset)); | 1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &
result, &offset)); |
| 1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); | 1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 DEF_TEST(PartialCropRect, reporter) { | 1142 DEF_TEST(PartialCropRect, reporter) { |
| 1143 SkBitmap bitmap; | 1143 SkBitmap bitmap; |
| 1144 bitmap.allocN32Pixels(100, 100); | 1144 bitmap.allocN32Pixels(100, 100); |
| 1145 bitmap.eraseARGB(0, 0, 0, 0); | 1145 bitmap.eraseARGB(0, 0, 0, 0); |
| 1146 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1146 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1147 SkBitmapDevice device(bitmap, props); | 1147 SkBitmapDevice device(bitmap, props); |
| 1148 SkImageFilter::Proxy proxy(&device); | 1148 SkImageFilter::Proxy proxy(&device); |
| 1149 | 1149 |
| 1150 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), | 1150 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), |
| 1151 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k
HasHeight_CropEdge); | 1151 SkImageFilter::CropRect::kHasWidth_CropEdge | SkImageFilter::CropRect::k
HasHeight_CropEdge); |
| 1152 SkAutoTUnref<SkImageFilter> filter(make_grayscale(NULL, &cropRect)); | 1152 SkAutoTUnref<SkImageFilter> filter(make_grayscale(nullptr, &cropRect)); |
| 1153 SkBitmap result; | 1153 SkBitmap result; |
| 1154 SkIPoint offset; | 1154 SkIPoint offset; |
| 1155 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); | 1155 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), nullptr); |
| 1156 REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result,
&offset)); | 1156 REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result,
&offset)); |
| 1157 REPORTER_ASSERT(reporter, offset.fX == 0); | 1157 REPORTER_ASSERT(reporter, offset.fX == 0); |
| 1158 REPORTER_ASSERT(reporter, offset.fY == 0); | 1158 REPORTER_ASSERT(reporter, offset.fY == 0); |
| 1159 REPORTER_ASSERT(reporter, result.width() == 20); | 1159 REPORTER_ASSERT(reporter, result.width() == 20); |
| 1160 REPORTER_ASSERT(reporter, result.height() == 30); | 1160 REPORTER_ASSERT(reporter, result.height() == 30); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 DEF_TEST(ImageFilterCanComputeFastBounds, reporter) { | 1163 DEF_TEST(ImageFilterCanComputeFastBounds, reporter) { |
| 1164 | 1164 |
| 1165 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); | 1165 SkPoint3 location = SkPoint3::Make(0, 0, SK_Scalar1); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 SkTableColorFilter::CreateARGB(allOne, identity, identity, identity)); | 1209 SkTableColorFilter::CreateARGB(allOne, identity, identity, identity)); |
| 1210 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); | 1210 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); |
| 1211 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); | 1211 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); |
| 1212 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); | 1212 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 #if SK_SUPPORT_GPU | 1215 #if SK_SUPPORT_GPU |
| 1216 | 1216 |
| 1217 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 1217 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { |
| 1218 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1218 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 1219 if (NULL == context) { | 1219 if (nullptr == context) { |
| 1220 return; | 1220 return; |
| 1221 } | 1221 } |
| 1222 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1222 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1223 | 1223 |
| 1224 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1224 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 1225 SkSurface::kNo_Budgeted
, | 1225 SkSurface::kNo_Budgeted
, |
| 1226 SkImageInfo::MakeN32Pre
mul(100, 100), | 1226 SkImageInfo::MakeN32Pre
mul(100, 100), |
| 1227 0, | 1227 0, |
| 1228 &props, | 1228 &props, |
| 1229 SkGpuDevice::kUninit_In
itContents)); | 1229 SkGpuDevice::kUninit_In
itContents)); |
| 1230 SkImageFilter::Proxy proxy(device); | 1230 SkImageFilter::Proxy proxy(device); |
| 1231 | 1231 |
| 1232 test_crop_rects(&proxy, reporter); | 1232 test_crop_rects(&proxy, reporter); |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { | 1235 DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { |
| 1236 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1236 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 1237 if (NULL == context) { | 1237 if (nullptr == context) { |
| 1238 return; | 1238 return; |
| 1239 } | 1239 } |
| 1240 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1240 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1241 | 1241 |
| 1242 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1242 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 1243 SkSurface::kNo_Budgeted
, | 1243 SkSurface::kNo_Budgeted
, |
| 1244 SkImageInfo::MakeN32Pre
mul(100, 100), | 1244 SkImageInfo::MakeN32Pre
mul(100, 100), |
| 1245 0, | 1245 0, |
| 1246 &props, | 1246 &props, |
| 1247 SkGpuDevice::kUninit_In
itContents)); | 1247 SkGpuDevice::kUninit_In
itContents)); |
| 1248 SkCanvas canvas(device); | 1248 SkCanvas canvas(device); |
| 1249 | 1249 |
| 1250 test_huge_blur(&canvas, reporter); | 1250 test_huge_blur(&canvas, reporter); |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 1253 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
| 1254 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1254 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 1255 if (NULL == context) { | 1255 if (nullptr == context) { |
| 1256 return; | 1256 return; |
| 1257 } | 1257 } |
| 1258 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1258 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1259 | 1259 |
| 1260 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1260 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 1261 SkSurface::kNo_Budgeted
, | 1261 SkSurface::kNo_Budgeted
, |
| 1262 SkImageInfo::MakeN32Pre
mul(1, 1), | 1262 SkImageInfo::MakeN32Pre
mul(1, 1), |
| 1263 0, | 1263 0, |
| 1264 &props, | 1264 &props, |
| 1265 SkGpuDevice::kUninit_In
itContents)); | 1265 SkGpuDevice::kUninit_In
itContents)); |
| 1266 SkCanvas canvas(device); | 1266 SkCanvas canvas(device); |
| 1267 | 1267 |
| 1268 test_xfermode_cropped_input(&canvas, reporter); | 1268 test_xfermode_cropped_input(&canvas, reporter); |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { | 1271 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { |
| 1272 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1272 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 1273 if (NULL == context) { | 1273 if (nullptr == context) { |
| 1274 return; | 1274 return; |
| 1275 } | 1275 } |
| 1276 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1276 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1277 | 1277 |
| 1278 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1278 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 1279 SkSurface::kNo_Budgeted
, | 1279 SkSurface::kNo_Budgeted
, |
| 1280 SkImageInfo::MakeN32Pre
mul(1, 1), | 1280 SkImageInfo::MakeN32Pre
mul(1, 1), |
| 1281 0, | 1281 0, |
| 1282 &props, | 1282 &props, |
| 1283 SkGpuDevice::kUninit_In
itContents)); | 1283 SkGpuDevice::kUninit_In
itContents)); |
| 1284 SkImageFilter::Proxy proxy(device); | 1284 SkImageFilter::Proxy proxy(device); |
| 1285 | 1285 |
| 1286 test_negative_blur_sigma(&proxy, reporter); | 1286 test_negative_blur_sigma(&proxy, reporter); |
| 1287 } | 1287 } |
| 1288 #endif | 1288 #endif |
| OLD | NEW |