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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 267863004: Fix for SkMatrixConvolutionImageFilter with large borders. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Simplify further Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.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 "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 result.allocN32Pixels(width, height); 391 result.allocN32Pixels(width, height);
392 SkCanvas canvas(result); 392 SkCanvas canvas(result);
393 canvas.clear(0); 393 canvas.clear(0);
394 394
395 SkPaint paint; 395 SkPaint paint;
396 paint.setImageFilter(filter); 396 paint.setImageFilter(filter);
397 SkRect rect = SkRect::Make(SkIRect::MakeWH(width, height)); 397 SkRect rect = SkRect::Make(SkIRect::MakeWH(width, height));
398 canvas.drawRect(rect, paint); 398 canvas.drawRect(rect, paint);
399 } 399 }
400 400
401 DEF_TEST(ImageFilterMatrixConvolutionBorder, reporter) {
402 // Check that a filter with borders outside the target bounds
403 // does not crash.
404 SkScalar kernel[3] = {
405 0, 0, 0,
406 };
407 SkISize kernelSize = SkISize::Make(3, 1);
408 SkScalar gain = SK_Scalar1, bias = 0;
409 SkIPoint kernelOffset = SkIPoint::Make(2, 0);
410
411 SkAutoTUnref<SkImageFilter> filter(
412 SkMatrixConvolutionImageFilter::Create(
413 kernelSize, kernel, gain, bias, kernelOffset,
414 SkMatrixConvolutionImageFilter::kClamp_TileMode, true));
415
416 SkBitmap result;
417
418 int width = 10, height = 10;
419 result.allocN32Pixels(width, height);
420 SkCanvas canvas(result);
421 canvas.clear(0);
422
423 SkPaint filterPaint;
424 filterPaint.setImageFilter(filter);
425 SkRect bounds = SkRect::MakeWH(1, 10);
426 SkRect rect = SkRect::Make(SkIRect::MakeWH(width, height));
427 SkPaint rectPaint;
428 canvas.saveLayer(&bounds, &filterPaint);
429 canvas.drawRect(rect, rectPaint);
430 canvas.restore();
431 }
432
401 DEF_TEST(ImageFilterCropRect, reporter) { 433 DEF_TEST(ImageFilterCropRect, reporter) {
402 SkBitmap temp; 434 SkBitmap temp;
403 temp.allocN32Pixels(100, 100); 435 temp.allocN32Pixels(100, 100);
404 SkBitmapDevice device(temp); 436 SkBitmapDevice device(temp);
405 test_crop_rects(&device, reporter); 437 test_crop_rects(&device, reporter);
406 } 438 }
407 439
408 DEF_TEST(ImageFilterMatrixTest, reporter) { 440 DEF_TEST(ImageFilterMatrixTest, reporter) {
409 SkBitmap temp; 441 SkBitmap temp;
410 temp.allocN32Pixels(100, 100); 442 temp.allocN32Pixels(100, 100);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 611 }
580 612
581 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { 613 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) {
582 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 614 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
583 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 615 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
584 SkImageInfo::MakeN32Pre mul(1, 1), 616 SkImageInfo::MakeN32Pre mul(1, 1),
585 0)); 617 0));
586 test_xfermode_cropped_input(device, reporter); 618 test_xfermode_cropped_input(device, reporter);
587 } 619 }
588 #endif 620 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMatrixConvolutionImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698