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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1800263002: Fix pointer aliasing bug in SkImageFilter::computeFastBounds. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: code review comments on unit test Created 4 years, 9 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
« no previous file with comments | « src/core/SkImageFilter.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 742
743 SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); 743 SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
744 SkRect expectedBounds = SkRect::MakeXYWH( 744 SkRect expectedBounds = SkRect::MakeXYWH(
745 SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar( 112)); 745 SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar( 112));
746 SkRect boundsDst = SkRect::MakeEmpty(); 746 SkRect boundsDst = SkRect::MakeEmpty();
747 composedFilter->computeFastBounds(boundsSrc, &boundsDst); 747 composedFilter->computeFastBounds(boundsSrc, &boundsDst);
748 748
749 REPORTER_ASSERT(reporter, boundsDst == expectedBounds); 749 REPORTER_ASSERT(reporter, boundsDst == expectedBounds);
750 } 750 }
751 751
752 DEF_TEST(ImageFilterUnionBounds, reporter) {
753 SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create(50, 0));
754 // Regardless of which order they appear in, the image filter bounds should
755 // be combined correctly.
756 {
757 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create(
758 nullptr, offset.get(), nullptr));
759 SkRect bounds = SkRect::MakeWH(100, 100);
760 // Intentionally aliasing here, as that's what the real callers do.
761 composite->computeFastBounds(bounds, &bounds);
762 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
763 }
764 {
765 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create(
766 nullptr, nullptr, offset.get()));
767 SkRect bounds = SkRect::MakeWH(100, 100);
768 // Intentionally aliasing here, as that's what the real callers do.
769 composite->computeFastBounds(bounds, &bounds);
770 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
771 }
772 }
773
752 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy, 774 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy,
753 skiatest::Reporter* reporter, 775 skiatest::Reporter* reporter,
754 GrContext* context) { 776 GrContext* context) {
755 SkBitmap greenBM; 777 SkBitmap greenBM;
756 greenBM.allocN32Pixels(20, 20); 778 greenBM.allocN32Pixels(20, 20);
757 greenBM.eraseColor(SK_ColorGREEN); 779 greenBM.eraseColor(SK_ColorGREEN);
758 SkAutoTUnref<SkImage> greenImage(SkImage::NewFromBitmap(greenBM)); 780 SkAutoTUnref<SkImage> greenImage(SkImage::NewFromBitmap(greenBM));
759 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get())); 781 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get()));
760 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s ource.get())); 782 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s ource.get()));
761 783
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 test_xfermode_cropped_input(&canvas, reporter); 1507 test_xfermode_cropped_input(&canvas, reporter);
1486 } 1508 }
1487 1509
1488 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { 1510 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
1489 SkAutoTUnref<SkSurface> surface( 1511 SkAutoTUnref<SkSurface> surface(
1490 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, 1512 SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
1491 SkImageInfo::MakeN32Premul(100, 100))); 1513 SkImageInfo::MakeN32Premul(100, 100)));
1492 test_large_blur_input(reporter, surface->getCanvas()); 1514 test_large_blur_input(reporter, surface->getCanvas());
1493 } 1515 }
1494 #endif 1516 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698