@@ -2032,88 +2032,179 @@ TEST(DisplayList, FullTransformAffectsCurrentTransform) {
2032
2032
ASSERT_EQ (curMatrix, matrix);
2033
2033
}
2034
2034
2035
- TEST (DisplayList, ClipRectAffectsCurrentClipBounds ) {
2035
+ TEST (DisplayList, ClipRectAffectsClipBounds ) {
2036
2036
DisplayListBuilder builder;
2037
- SkRect clip = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
2038
- builder.clipRect (clip, SkClipOp::kIntersect , false );
2039
- SkRect curBounds = builder.getClipBounds ();
2040
- ASSERT_EQ (curBounds, clip);
2037
+ SkRect clipBounds = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
2038
+ SkRect clipExpandedBounds = SkRect::MakeLTRB (10 , 11 , 21 , 26 );
2039
+ builder.clipRect (clipBounds, SkClipOp::kIntersect , false );
2040
+
2041
+ // Save initial return values for testing restored values
2042
+ SkRect initialLocalBounds = builder.getLocalClipBounds ();
2043
+ SkRect initialDestinationBounds = builder.getDestinationClipBounds ();
2044
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2045
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2046
+
2047
+ builder.save ();
2041
2048
builder.clipRect ({0 , 0 , 15 , 15 }, SkClipOp::kIntersect , false );
2042
- // CurrentTransform has changed
2043
- ASSERT_NE (builder.getClipBounds (), clip);
2044
- // Previous return values have not
2045
- ASSERT_EQ (curBounds, clip);
2049
+ // Both clip bounds have changed
2050
+ ASSERT_NE (builder.getLocalClipBounds (), clipExpandedBounds);
2051
+ ASSERT_NE (builder.getDestinationClipBounds (), clipBounds);
2052
+ // Previous return values have not changed
2053
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2054
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2055
+ builder.restore ();
2056
+
2057
+ // save/restore returned the values to their original values
2058
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2059
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2060
+
2061
+ builder.save ();
2062
+ builder.scale (2 , 2 );
2063
+ SkRect scaledExpandedBounds = SkRect::MakeLTRB (5 , 5.5 , 10.5 , 13 );
2064
+ ASSERT_EQ (builder.getLocalClipBounds (), scaledExpandedBounds);
2065
+ // Destination bounds are unaffected by transform
2066
+ ASSERT_EQ (builder.getDestinationClipBounds (), clipBounds);
2067
+ builder.restore ();
2068
+
2069
+ // save/restore returned the values to their original values
2070
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2071
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2046
2072
}
2047
2073
2048
- TEST (DisplayList, ClipRRectAffectsCurrentClipBounds ) {
2074
+ TEST (DisplayList, ClipRRectAffectsClipBounds ) {
2049
2075
DisplayListBuilder builder;
2050
- SkRRect clip = SkRRect::MakeRectXY ({10.2 , 11.3 , 20.4 , 25.7 }, 3 , 2 );
2076
+ SkRect clipBounds = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
2077
+ SkRect clipExpandedBounds = SkRect::MakeLTRB (10 , 11 , 21 , 26 );
2078
+ SkRRect clip = SkRRect::MakeRectXY (clipBounds, 3 , 2 );
2051
2079
builder.clipRRect (clip, SkClipOp::kIntersect , false );
2052
- SkRect curBounds = builder.getClipBounds ();
2053
- ASSERT_EQ (curBounds, clip.getBounds ());
2080
+
2081
+ // Save initial return values for testing restored values
2082
+ SkRect initialLocalBounds = builder.getLocalClipBounds ();
2083
+ SkRect initialDestinationBounds = builder.getDestinationClipBounds ();
2084
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2085
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2086
+
2087
+ builder.save ();
2054
2088
builder.clipRect ({0 , 0 , 15 , 15 }, SkClipOp::kIntersect , false );
2055
- // CurrentTransform has changed
2056
- ASSERT_NE (builder.getClipBounds (), clip.getBounds ());
2057
- // Previous return values have not
2058
- ASSERT_EQ (curBounds, clip.getBounds ());
2089
+ // Both clip bounds have changed
2090
+ ASSERT_NE (builder.getLocalClipBounds (), clipExpandedBounds);
2091
+ ASSERT_NE (builder.getDestinationClipBounds (), clipBounds);
2092
+ // Previous return values have not changed
2093
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2094
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2095
+ builder.restore ();
2096
+
2097
+ // save/restore returned the values to their original values
2098
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2099
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2100
+
2101
+ builder.save ();
2102
+ builder.scale (2 , 2 );
2103
+ SkRect scaledExpandedBounds = SkRect::MakeLTRB (5 , 5.5 , 10.5 , 13 );
2104
+ ASSERT_EQ (builder.getLocalClipBounds (), scaledExpandedBounds);
2105
+ // Destination bounds are unaffected by transform
2106
+ ASSERT_EQ (builder.getDestinationClipBounds (), clipBounds);
2107
+ builder.restore ();
2108
+
2109
+ // save/restore returned the values to their original values
2110
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2111
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2059
2112
}
2060
2113
2061
- TEST (DisplayList, ClipPathAffectsCurrentClipBounds ) {
2114
+ TEST (DisplayList, ClipPathAffectsClipBounds ) {
2062
2115
DisplayListBuilder builder;
2063
2116
SkPath clip = SkPath ().addCircle (10.2 , 11.3 , 2 ).addCircle (20.4 , 25.7 , 2 );
2117
+ SkRect clipBounds = SkRect::MakeLTRB (8.2 , 9.3 , 22.4 , 27.7 );
2118
+ SkRect clipExpandedBounds = SkRect::MakeLTRB (8 , 9 , 23 , 28 );
2064
2119
builder.clipPath (clip, SkClipOp::kIntersect , false );
2065
- SkRect curBounds = builder.getClipBounds ();
2066
- ASSERT_EQ (curBounds, clip.getBounds ());
2120
+
2121
+ // Save initial return values for testing restored values
2122
+ SkRect initialLocalBounds = builder.getLocalClipBounds ();
2123
+ SkRect initialDestinationBounds = builder.getDestinationClipBounds ();
2124
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2125
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2126
+
2127
+ builder.save ();
2067
2128
builder.clipRect ({0 , 0 , 15 , 15 }, SkClipOp::kIntersect , false );
2068
- // CurrentTransform has changed
2069
- ASSERT_NE (builder.getClipBounds (), clip.getBounds ());
2070
- // Previous return values have not
2071
- ASSERT_EQ (curBounds, clip.getBounds ());
2129
+ // Both clip bounds have changed
2130
+ ASSERT_NE (builder.getLocalClipBounds (), clipExpandedBounds);
2131
+ ASSERT_NE (builder.getDestinationClipBounds (), clipBounds);
2132
+ // Previous return values have not changed
2133
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2134
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2135
+ builder.restore ();
2136
+
2137
+ // save/restore returned the values to their original values
2138
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2139
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2140
+
2141
+ builder.save ();
2142
+ builder.scale (2 , 2 );
2143
+ SkRect scaledExpandedBounds = SkRect::MakeLTRB (4 , 4.5 , 11.5 , 14 );
2144
+ ASSERT_EQ (builder.getLocalClipBounds (), scaledExpandedBounds);
2145
+ // Destination bounds are unaffected by transform
2146
+ ASSERT_EQ (builder.getDestinationClipBounds (), clipBounds);
2147
+ builder.restore ();
2148
+
2149
+ // save/restore returned the values to their original values
2150
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2151
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2072
2152
}
2073
2153
2074
- TEST (DisplayList, DiffClipRectDoesNotAffectCurrentClipBounds ) {
2154
+ TEST (DisplayList, DiffClipRectDoesNotAffectClipBounds ) {
2075
2155
DisplayListBuilder builder;
2076
2156
SkRect diff_clip = SkRect::MakeLTRB (0 , 0 , 15 , 15 );
2077
- SkRect clip = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
2078
- builder.clipRect (clip, SkClipOp::kIntersect , false );
2157
+ SkRect clipBounds = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
2158
+ SkRect clipExpandedBounds = SkRect::MakeLTRB (10 , 11 , 21 , 26 );
2159
+ builder.clipRect (clipBounds, SkClipOp::kIntersect , false );
2160
+
2161
+ // Save initial return values for testing after kDifference clip
2162
+ SkRect initialLocalBounds = builder.getLocalClipBounds ();
2163
+ SkRect initialDestinationBounds = builder.getDestinationClipBounds ();
2164
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2165
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2166
+
2079
2167
builder.clipRect (diff_clip, SkClipOp::kDifference , false );
2080
- SkRect curBounds = builder.getClipBounds ();
2081
- ASSERT_EQ (curBounds, clip);
2082
- builder.clipRect ({0 , 0 , 15 , 15 }, SkClipOp::kIntersect , false );
2083
- // CurrentTransform has changed
2084
- ASSERT_NE (builder.getClipBounds (), clip);
2085
- // Previous return values have not
2086
- ASSERT_EQ (curBounds, clip);
2168
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2169
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2087
2170
}
2088
2171
2089
- TEST (DisplayList, DiffClipRRectAffectsCurrentClipBounds ) {
2172
+ TEST (DisplayList, DiffClipRRectDoesNotAffectClipBounds ) {
2090
2173
DisplayListBuilder builder;
2091
2174
SkRRect diff_clip = SkRRect::MakeRectXY ({0 , 0 , 15 , 15 }, 1 , 1 );
2175
+ SkRect clipBounds = SkRect::MakeLTRB (10.2 , 11.3 , 20.4 , 25.7 );
2176
+ SkRect clipExpandedBounds = SkRect::MakeLTRB (10 , 11 , 21 , 26 );
2092
2177
SkRRect clip = SkRRect::MakeRectXY ({10.2 , 11.3 , 20.4 , 25.7 }, 3 , 2 );
2093
2178
builder.clipRRect (clip, SkClipOp::kIntersect , false );
2179
+
2180
+ // Save initial return values for testing after kDifference clip
2181
+ SkRect initialLocalBounds = builder.getLocalClipBounds ();
2182
+ SkRect initialDestinationBounds = builder.getDestinationClipBounds ();
2183
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2184
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2185
+
2094
2186
builder.clipRRect (diff_clip, SkClipOp::kDifference , false );
2095
- SkRect curBounds = builder.getClipBounds ();
2096
- ASSERT_EQ (curBounds, clip.getBounds ());
2097
- builder.clipRect ({0 , 0 , 15 , 15 }, SkClipOp::kIntersect , false );
2098
- // CurrentTransform has changed
2099
- ASSERT_NE (builder.getClipBounds (), clip.getBounds ());
2100
- // Previous return values have not
2101
- ASSERT_EQ (curBounds, clip.getBounds ());
2187
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2188
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2102
2189
}
2103
2190
2104
- TEST (DisplayList, DiffClipPathAffectsCurrentClipBounds ) {
2191
+ TEST (DisplayList, DiffClipPathDoesNotAffectClipBounds ) {
2105
2192
DisplayListBuilder builder;
2106
2193
SkPath diff_clip = SkPath ().addRect ({0 , 0 , 15 , 15 });
2107
2194
SkPath clip = SkPath ().addCircle (10.2 , 11.3 , 2 ).addCircle (20.4 , 25.7 , 2 );
2195
+ SkRect clipBounds = SkRect::MakeLTRB (8.2 , 9.3 , 22.4 , 27.7 );
2196
+ SkRect clipExpandedBounds = SkRect::MakeLTRB (8 , 9 , 23 , 28 );
2108
2197
builder.clipPath (clip, SkClipOp::kIntersect , false );
2198
+
2199
+ // Save initial return values for testing after kDifference clip
2200
+ SkRect initialLocalBounds = builder.getLocalClipBounds ();
2201
+ SkRect initialDestinationBounds = builder.getDestinationClipBounds ();
2202
+ ASSERT_EQ (initialLocalBounds, clipExpandedBounds);
2203
+ ASSERT_EQ (initialDestinationBounds, clipBounds);
2204
+
2109
2205
builder.clipPath (diff_clip, SkClipOp::kDifference , false );
2110
- SkRect curBounds = builder.getClipBounds ();
2111
- ASSERT_EQ (curBounds, clip.getBounds ());
2112
- builder.clipRect ({0 , 0 , 15 , 15 }, SkClipOp::kIntersect , false );
2113
- // CurrentTransform has changed
2114
- ASSERT_NE (builder.getClipBounds (), clip.getBounds ());
2115
- // Previous return values have not
2116
- ASSERT_EQ (curBounds, clip.getBounds ());
2206
+ ASSERT_EQ (builder.getLocalClipBounds (), initialLocalBounds);
2207
+ ASSERT_EQ (builder.getDestinationClipBounds (), initialDestinationBounds);
2117
2208
}
2118
2209
2119
2210
} // namespace testing
0 commit comments