@@ -2116,6 +2116,25 @@ TEST(DisplayList, ClipRectAffectsClipBounds) {
21162116 ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
21172117}
21182118
2119+ TEST (DisplayList, ClipRectAffectsClipBoundsWithMatrix) {
2120+ DisplayListBuilder builder;
2121+ SkRect clipBounds1 = SkRect::MakeLTRB (0 , 0 , 10 , 10 );
2122+ SkRect clipBounds2 = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
2123+ builder.save ();
2124+ builder.clipRect (clipBounds1, SkClipOp::kIntersect , false );
2125+ builder.translate (10 , 0 );
2126+ builder.clipRect (clipBounds1, SkClipOp::kIntersect , false );
2127+ ASSERT_TRUE (builder.getDestinationClipBounds ().isEmpty ());
2128+ builder.restore ();
2129+
2130+ builder.save ();
2131+ builder.clipRect (clipBounds1, SkClipOp::kIntersect , false );
2132+ builder.translate (-10 , -10 );
2133+ builder.clipRect (clipBounds2, SkClipOp::kIntersect , false );
2134+ ASSERT_EQ (builder.getDestinationClipBounds (), clipBounds1);
2135+ builder.restore ();
2136+ }
2137+
21192138TEST (DisplayList, ClipRRectAffectsClipBounds) {
21202139 DisplayListBuilder builder;
21212140 SkRect clipBounds = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
@@ -2156,6 +2175,28 @@ TEST(DisplayList, ClipRRectAffectsClipBounds) {
21562175 ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
21572176}
21582177
2178+ TEST (DisplayList, ClipRRectAffectsClipBoundsWithMatrix) {
2179+ DisplayListBuilder builder;
2180+ SkRect clipBounds1 = SkRect::MakeLTRB (0 , 0 , 10 , 10 );
2181+ SkRect clipBounds2 = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
2182+ SkRRect clip1 = SkRRect::MakeRectXY (clipBounds1, 3 , 2 );
2183+ SkRRect clip2 = SkRRect::MakeRectXY (clipBounds2, 3 , 2 );
2184+
2185+ builder.save ();
2186+ builder.clipRRect (clip1, SkClipOp::kIntersect , false );
2187+ builder.translate (10 , 0 );
2188+ builder.clipRRect (clip1, SkClipOp::kIntersect , false );
2189+ ASSERT_TRUE (builder.getDestinationClipBounds ().isEmpty ());
2190+ builder.restore ();
2191+
2192+ builder.save ();
2193+ builder.clipRRect (clip1, SkClipOp::kIntersect , false );
2194+ builder.translate (-10 , -10 );
2195+ builder.clipRRect (clip2, SkClipOp::kIntersect , false );
2196+ ASSERT_EQ (builder.getDestinationClipBounds (), clipBounds1);
2197+ builder.restore ();
2198+ }
2199+
21592200TEST (DisplayList, ClipPathAffectsClipBounds) {
21602201 DisplayListBuilder builder;
21612202 SkPath clip = SkPath ().addCircle (10.2 , 11.3 , 2 ).addCircle (20.4 , 25.7 , 2 );
@@ -2196,6 +2237,27 @@ TEST(DisplayList, ClipPathAffectsClipBounds) {
21962237 ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
21972238}
21982239
2240+ TEST (DisplayList, ClipPathAffectsClipBoundsWithMatrix) {
2241+ DisplayListBuilder builder;
2242+ SkRect clipBounds = SkRect::MakeLTRB (0 , 0 , 10 , 10 );
2243+ SkPath clip1 = SkPath ().addCircle (2.5 , 2.5 , 2.5 ).addCircle (7.5 , 7.5 , 2.5 );
2244+ SkPath clip2 = SkPath ().addCircle (12.5 , 12.5 , 2.5 ).addCircle (17.5 , 17.5 , 2.5 );
2245+
2246+ builder.save ();
2247+ builder.clipPath (clip1, SkClipOp::kIntersect , false );
2248+ builder.translate (10 , 0 );
2249+ builder.clipPath (clip1, SkClipOp::kIntersect , false );
2250+ ASSERT_TRUE (builder.getDestinationClipBounds ().isEmpty ());
2251+ builder.restore ();
2252+
2253+ builder.save ();
2254+ builder.clipPath (clip1, SkClipOp::kIntersect , false );
2255+ builder.translate (-10 , -10 );
2256+ builder.clipPath (clip2, SkClipOp::kIntersect , false );
2257+ ASSERT_EQ (builder.getDestinationClipBounds (), clipBounds);
2258+ builder.restore ();
2259+ }
2260+
21992261TEST (DisplayList, DiffClipRectDoesNotAffectClipBounds) {
22002262 DisplayListBuilder builder;
22012263 SkRect diff_clip = SkRect::MakeLTRB (0 , 0 , 15 , 15 );
@@ -2252,6 +2314,30 @@ TEST(DisplayList, DiffClipPathDoesNotAffectClipBounds) {
22522314 ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
22532315}
22542316
2317+ TEST (DisplayList, ClipPathWithInvertFillTypeDoesNotAffectClipBounds) {
2318+ SkRect cull_rect = SkRect::MakeLTRB (0 , 0 , 100.0 , 100.0 );
2319+ DisplayListBuilder builder (cull_rect);
2320+ SkPath clip = SkPath ().addCircle (10.2 , 11.3 , 2 ).addCircle (20.4 , 25.7 , 2 );
2321+ clip.setFillType (SkPathFillType::kInverseWinding );
2322+ builder.clipPath (clip, SkClipOp::kIntersect , false );
2323+
2324+ ASSERT_EQ (builder.getLocalClipBounds (), cull_rect);
2325+ ASSERT_EQ (builder.getDestinationClipBounds (), cull_rect);
2326+ }
2327+
2328+ TEST (DisplayList, DiffClipPathWithInvertFillTypeAffectsClipBounds) {
2329+ SkRect cull_rect = SkRect::MakeLTRB (0 , 0 , 100.0 , 100.0 );
2330+ DisplayListBuilder builder (cull_rect);
2331+ SkPath clip = SkPath ().addCircle (10.2 , 11.3 , 2 ).addCircle (20.4 , 25.7 , 2 );
2332+ clip.setFillType (SkPathFillType::kInverseWinding );
2333+ SkRect clip_bounds = SkRect::MakeLTRB (8.2 , 9.3 , 22.4 , 27.7 );
2334+ SkRect clip_expanded_bounds = SkRect::MakeLTRB (8 , 9 , 23 , 28 );
2335+ builder.clipPath (clip, SkClipOp::kDifference , false );
2336+
2337+ ASSERT_EQ (builder.getLocalClipBounds (), clip_expanded_bounds);
2338+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
2339+ }
2340+
22552341TEST (DisplayList, FlatDrawPointsProducesBounds) {
22562342 SkPoint horizontal_points[2 ] = {{10 , 10 }, {20 , 10 }};
22572343 SkPoint vertical_points[2 ] = {{10 , 10 }, {10 , 20 }};
0 commit comments