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

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: copy dst rather than src 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 {
robertphillips 2016/03/16 13:54:53 add \n somewhere in here to limit to 100 cols ?
jbroman 2016/03/16 14:51:37 Done.
757 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create(null ptr, offset.get(), nullptr));
758 SkRect bounds = SkRect::MakeWH(100, 100);
robertphillips 2016/03/16 13:54:53 add 'what' after that's ?
jbroman 2016/03/16 14:51:37 Done.
759 // Intentionally aliasing here, as that's the real callers do.
760 composite->computeFastBounds(bounds, &bounds);
761 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
762 }
763 {
robertphillips 2016/03/16 13:54:53 \n in here too
jbroman 2016/03/16 14:51:37 Done.
764 SkAutoTUnref<SkImageFilter> composite(SkXfermodeImageFilter::Create(null ptr, nullptr, offset.get()));
765 SkRect bounds = SkRect::MakeWH(100, 100);
766 // Intentionally aliasing here, as that's the real callers do.
767 composite->computeFastBounds(bounds, &bounds);
768 REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
769 }
770 }
771
752 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy, 772 static void test_imagefilter_merge_result_size(SkImageFilter::Proxy* proxy,
753 skiatest::Reporter* reporter, 773 skiatest::Reporter* reporter,
754 GrContext* context) { 774 GrContext* context) {
755 SkBitmap greenBM; 775 SkBitmap greenBM;
756 greenBM.allocN32Pixels(20, 20); 776 greenBM.allocN32Pixels(20, 20);
757 greenBM.eraseColor(SK_ColorGREEN); 777 greenBM.eraseColor(SK_ColorGREEN);
758 SkAutoTUnref<SkImage> greenImage(SkImage::NewFromBitmap(greenBM)); 778 SkAutoTUnref<SkImage> greenImage(SkImage::NewFromBitmap(greenBM));
759 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get())); 779 SkAutoTUnref<SkImageFilter> source(SkImageSource::Create(greenImage.get()));
760 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s ource.get())); 780 SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(source.get(), s ource.get()));
761 781
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 test_xfermode_cropped_input(&canvas, reporter); 1505 test_xfermode_cropped_input(&canvas, reporter);
1486 } 1506 }
1487 1507
1488 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { 1508 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
1489 SkAutoTUnref<SkSurface> surface( 1509 SkAutoTUnref<SkSurface> surface(
1490 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, 1510 SkSurface::NewRenderTarget(context, SkBudgeted::kYes,
1491 SkImageInfo::MakeN32Premul(100, 100))); 1511 SkImageInfo::MakeN32Premul(100, 100)));
1492 test_large_blur_input(reporter, surface->getCanvas()); 1512 test_large_blur_input(reporter, surface->getCanvas());
1493 } 1513 }
1494 #endif 1514 #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