@@ -38,6 +38,112 @@ TEST(DisplayList, CallMethodAfterBuild) {
3838}
3939#endif // NDEBUG
4040
41+ TEST (DisplayList, RecorderInitialClipBounds) {
42+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
43+ SkIRect clip_bounds = SkIRect::MakeWH (100 , 100 );
44+ DisplayListCanvasRecorder recorder (cull_rect);
45+ SkCanvas* canvas = &recorder;
46+ ASSERT_EQ (canvas->getDeviceClipBounds (), clip_bounds);
47+ }
48+
49+ TEST (DisplayList, RecorderInitialClipBoundsNaN) {
50+ SkRect cull_rect = SkRect::MakeWH (SK_ScalarNaN, SK_ScalarNaN);
51+ SkIRect clip_bounds = SkIRect::MakeEmpty ();
52+ DisplayListCanvasRecorder recorder (cull_rect);
53+ SkCanvas* canvas = &recorder;
54+ ASSERT_EQ (canvas->getDeviceClipBounds (), clip_bounds);
55+ }
56+
57+ TEST (DisplayList, RecorderClipBoundsAfterClipRect) {
58+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
59+ SkRect clip_rect = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
60+ SkIRect clip_bounds = SkIRect::MakeLTRB (10 , 10 , 20 , 20 );
61+ DisplayListCanvasRecorder recorder (cull_rect);
62+ SkCanvas* canvas = &recorder;
63+ canvas->clipRect (clip_rect);
64+ ASSERT_EQ (canvas->getDeviceClipBounds (), clip_bounds);
65+ }
66+
67+ TEST (DisplayList, RecorderClipBoundsAfterClipRRect) {
68+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
69+ SkRect clip_rect = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
70+ SkRRect clip_rrect = SkRRect::MakeRectXY (clip_rect, 2 , 2 );
71+ SkIRect clip_bounds = SkIRect::MakeLTRB (10 , 10 , 20 , 20 );
72+ DisplayListCanvasRecorder recorder (cull_rect);
73+ SkCanvas* canvas = &recorder;
74+ canvas->clipRRect (clip_rrect);
75+ ASSERT_EQ (canvas->getDeviceClipBounds (), clip_bounds);
76+ }
77+
78+ TEST (DisplayList, RecorderClipBoundsAfterClipPath) {
79+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
80+ SkPath clip_path = SkPath ().addRect (10 , 10 , 15 , 15 ).addRect (15 , 15 , 20 , 20 );
81+ SkIRect clip_bounds = SkIRect::MakeLTRB (10 , 10 , 20 , 20 );
82+ DisplayListCanvasRecorder recorder (cull_rect);
83+ SkCanvas* canvas = &recorder;
84+ canvas->clipPath (clip_path);
85+ ASSERT_EQ (canvas->getDeviceClipBounds (), clip_bounds);
86+ }
87+
88+ TEST (DisplayList, RecorderInitialClipBoundsNonZero) {
89+ SkRect cull_rect = SkRect::MakeLTRB (10 , 10 , 100 , 100 );
90+ SkIRect clip_bounds = SkIRect::MakeLTRB (10 , 10 , 100 , 100 );
91+ DisplayListCanvasRecorder recorder (cull_rect);
92+ SkCanvas* canvas = &recorder;
93+ ASSERT_EQ (canvas->getDeviceClipBounds (), clip_bounds);
94+ }
95+
96+ TEST (DisplayList, BuilderInitialClipBounds) {
97+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
98+ SkRect clip_bounds = SkRect::MakeWH (100 , 100 );
99+ DisplayListBuilder builder (cull_rect);
100+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
101+ }
102+
103+ TEST (DisplayList, BuilderInitialClipBoundsNaN) {
104+ SkRect cull_rect = SkRect::MakeWH (SK_ScalarNaN, SK_ScalarNaN);
105+ SkRect clip_bounds = SkRect::MakeEmpty ();
106+ DisplayListBuilder builder (cull_rect);
107+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
108+ }
109+
110+ TEST (DisplayList, BuilderClipBoundsAfterClipRect) {
111+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
112+ SkRect clip_rect = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
113+ SkRect clip_bounds = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
114+ DisplayListBuilder builder (cull_rect);
115+ builder.clipRect (clip_rect, SkClipOp::kIntersect , false );
116+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
117+ }
118+
119+ TEST (DisplayList, BuilderClipBoundsAfterClipRRect) {
120+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
121+ SkRect clip_rect = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
122+ SkRRect clip_rrect = SkRRect::MakeRectXY (clip_rect, 2 , 2 );
123+ SkRect clip_bounds = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
124+ DisplayListBuilder builder (cull_rect);
125+ builder.clipRRect (clip_rrect, SkClipOp::kIntersect , false );
126+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
127+ }
128+
129+ TEST (DisplayList, BuilderClipBoundsAfterClipPath) {
130+ SkRect cull_rect = SkRect::MakeWH (100 , 100 );
131+ SkPath clip_path = SkPath ().addRect (10 , 10 , 15 , 15 ).addRect (15 , 15 , 20 , 20 );
132+ SkRect clip_bounds = SkRect::MakeLTRB (10 , 10 , 20 , 20 );
133+ DisplayListCanvasRecorder recorder (cull_rect);
134+ DisplayListBuilder builder (cull_rect);
135+ builder.clipPath (clip_path, SkClipOp::kIntersect , false );
136+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
137+ }
138+
139+ TEST (DisplayList, BuilderInitialClipBoundsNonZero) {
140+ SkRect cull_rect = SkRect::MakeLTRB (10 , 10 , 100 , 100 );
141+ SkRect clip_bounds = SkRect::MakeLTRB (10 , 10 , 100 , 100 );
142+ DisplayListCanvasRecorder recorder (cull_rect);
143+ DisplayListBuilder builder (cull_rect);
144+ ASSERT_EQ (builder.getDestinationClipBounds (), clip_bounds);
145+ }
146+
41147TEST (DisplayList, SingleOpSizes) {
42148 for (auto & group : allGroups) {
43149 for (size_t i = 0 ; i < group.variants .size (); i++) {
0 commit comments