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

Unified Diff: tests/PictureTest.cpp

Issue 14820021: Fix behavior of SkPicture::kUsePathBoundsForClip_RecordingFlag to handle inverse fills and all clip… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« src/core/SkPictureRecord.cpp ('K') | « src/core/SkPictureRecord.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
===================================================================
--- tests/PictureTest.cpp (revision 9033)
+++ tests/PictureTest.cpp (working copy)
@@ -449,6 +449,105 @@
}
}
+static void test_clip_bound_opt(skiatest::Reporter* reporter) {
+ // Test for crbug.com/229011
+ SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(4), SkIntToScalar(4),
+ SkIntToScalar(2), SkIntToScalar(2));
+ SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(7), SkIntToScalar(7),
+ SkIntToScalar(1), SkIntToScalar(1));
+ SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(6), SkIntToScalar(6),
+ SkIntToScalar(1), SkIntToScalar(1));
+
+ SkPath invPath;
+ invPath.addOval(rect1);
+ invPath.setFillType(SkPath::kInverseEvenOdd_FillType);
+ SkPath path;
+ path.addOval(rect2);
+ SkPath path2;
+ path2.addOval(rect3);
+ SkIRect clipBounds;
+ // Minimalist test set for 100% code coverage of
+ // SkPictureRecord::updateClipConservativelyUsingBounds
+ {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(10, 10,
+ SkPicture::kUsePathBoundsForClip_RecordingFlag);
+ canvas->clipPath(invPath, SkRegion::kIntersect_Op);
+ bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
+ REPORTER_ASSERT(reporter, true == nonEmpty);
+ REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
+ REPORTER_ASSERT(reporter, 0 == clipBounds.fTop);
+ REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom);
+ REPORTER_ASSERT(reporter, 10 == clipBounds.fRight);
+ }
+ {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(10, 10,
+ SkPicture::kUsePathBoundsForClip_RecordingFlag);
+ canvas->clipPath(path, SkRegion::kIntersect_Op);
+ canvas->clipPath(invPath, SkRegion::kIntersect_Op);
+ bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
+ REPORTER_ASSERT(reporter, true == nonEmpty);
+ REPORTER_ASSERT(reporter, 7 == clipBounds.fLeft);
+ REPORTER_ASSERT(reporter, 7 == clipBounds.fTop);
+ REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
+ REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
+ }
+ {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(10, 10,
+ SkPicture::kUsePathBoundsForClip_RecordingFlag);
+ canvas->clipPath(path, SkRegion::kIntersect_Op);
+ canvas->clipPath(invPath, SkRegion::kUnion_Op);
+ bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
+ REPORTER_ASSERT(reporter, true == nonEmpty);
+ REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
+ REPORTER_ASSERT(reporter, 0 == clipBounds.fTop);
+ REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom);
+ REPORTER_ASSERT(reporter, 10 == clipBounds.fRight);
+ }
+ {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(10, 10,
+ SkPicture::kUsePathBoundsForClip_RecordingFlag);
+ canvas->clipPath(path, SkRegion::kDifference_Op);
+ bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
+ REPORTER_ASSERT(reporter, true == nonEmpty);
+ REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
+ REPORTER_ASSERT(reporter, 0 == clipBounds.fTop);
+ REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom);
+ REPORTER_ASSERT(reporter, 10 == clipBounds.fRight);
+ }
+ {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(10, 10,
+ SkPicture::kUsePathBoundsForClip_RecordingFlag);
+ canvas->clipPath(path, SkRegion::kReverseDifference_Op);
+ bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
+ // True clip is actually empty in this case, but the best
+ // determination we can make using only bounds as input is that the
+ // clip is included in the bounds of 'path'.
+ REPORTER_ASSERT(reporter, true == nonEmpty);
+ REPORTER_ASSERT(reporter, 7 == clipBounds.fLeft);
+ REPORTER_ASSERT(reporter, 7 == clipBounds.fTop);
+ REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
+ REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
+ }
+ {
+ SkPicture picture;
+ SkCanvas* canvas = picture.beginRecording(10, 10,
+ SkPicture::kUsePathBoundsForClip_RecordingFlag);
+ canvas->clipPath(path, SkRegion::kIntersect_Op);
+ canvas->clipPath(path2, SkRegion::kXOR_Op);
+ bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
+ REPORTER_ASSERT(reporter, true == nonEmpty);
+ REPORTER_ASSERT(reporter, 6 == clipBounds.fLeft);
+ REPORTER_ASSERT(reporter, 6 == clipBounds.fTop);
+ REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
+ REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
+ }
+}
+
static void TestPicture(skiatest::Reporter* reporter) {
#ifdef SK_DEBUG
test_deleting_empty_playback();
@@ -460,6 +559,7 @@
test_gatherpixelrefs(reporter);
test_bitmap_with_encoded_data(reporter);
test_clone_empty(reporter);
+ test_clip_bound_opt(reporter);
}
#include "TestClassDef.h"
« src/core/SkPictureRecord.cpp ('K') | « src/core/SkPictureRecord.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698