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" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 DEF_TEST(ImageFilterMatrixTest, reporter) { | 267 DEF_TEST(ImageFilterMatrixTest, reporter) { |
268 SkBitmap temp; | 268 SkBitmap temp; |
269 temp.allocN32Pixels(100, 100); | 269 temp.allocN32Pixels(100, 100); |
270 SkBitmapDevice device(temp); | 270 SkBitmapDevice device(temp); |
271 SkCanvas canvas(&device); | 271 SkCanvas canvas(&device); |
272 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); | 272 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); |
273 | 273 |
274 SkMatrix expectedMatrix = canvas.getTotalMatrix(); | 274 SkMatrix expectedMatrix = canvas.getTotalMatrix(); |
275 | 275 |
276 SkPicture picture; | 276 SkPictureRecorder recorder; |
277 SkCanvas* recordingCanvas = picture.beginRecording(100, 100, | 277 SkCanvas* recordingCanvas = recorder.beginRecording(100, 100, |
278 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); | 278 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); |
279 | 279 |
280 SkPaint paint; | 280 SkPaint paint; |
281 SkAutoTUnref<MatrixTestImageFilter> imageFilter( | 281 SkAutoTUnref<MatrixTestImageFilter> imageFilter( |
282 new MatrixTestImageFilter(reporter, expectedMatrix)); | 282 new MatrixTestImageFilter(reporter, expectedMatrix)); |
283 paint.setImageFilter(imageFilter.get()); | 283 paint.setImageFilter(imageFilter.get()); |
284 SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>( | 284 SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>( |
285 SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag); | 285 SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag); |
286 recordingCanvas->saveLayer(NULL, &paint, saveFlags); | 286 recordingCanvas->saveLayer(NULL, &paint, saveFlags); |
287 SkPaint solidPaint; | 287 SkPaint solidPaint; |
288 solidPaint.setColor(0xFFFFFFFF); | 288 solidPaint.setColor(0xFFFFFFFF); |
289 recordingCanvas->save(); | 289 recordingCanvas->save(); |
290 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); | 290 recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10)); |
291 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); | 291 recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPain
t); |
292 recordingCanvas->restore(); // scale | 292 recordingCanvas->restore(); // scale |
293 recordingCanvas->restore(); // saveLayer | 293 recordingCanvas->restore(); // saveLayer |
294 picture.endRecording(); | 294 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
295 | 295 |
296 canvas.drawPicture(picture); | 296 canvas.drawPicture(*picture); |
297 } | 297 } |
298 | 298 |
299 static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) { | 299 static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) { |
300 SkCanvas canvas(device); | 300 SkCanvas canvas(device); |
301 | 301 |
302 SkBitmap bitmap; | 302 SkBitmap bitmap; |
303 bitmap.allocN32Pixels(100, 100); | 303 bitmap.allocN32Pixels(100, 100); |
304 bitmap.eraseARGB(0, 0, 0, 0); | 304 bitmap.eraseARGB(0, 0, 0, 0); |
305 | 305 |
306 // Check that a blur with an insane radius does not crash or assert. | 306 // Check that a blur with an insane radius does not crash or assert. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 440 } |
441 | 441 |
442 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 442 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
443 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 443 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
444 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 444 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
445 SkImageInfo::MakeN32Pre
mul(1, 1), | 445 SkImageInfo::MakeN32Pre
mul(1, 1), |
446 0)); | 446 0)); |
447 test_xfermode_cropped_input(device, reporter); | 447 test_xfermode_cropped_input(device, reporter); |
448 } | 448 } |
449 #endif | 449 #endif |
OLD | NEW |