OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/paint/display_item_list.h" | 5 #include "cc/paint/display_item_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list, | 97 void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list, |
98 const gfx::Size& layer_size) { | 98 const gfx::Size& layer_size) { |
99 gfx::PointF offset(2.f, 3.f); | 99 gfx::PointF offset(2.f, 3.f); |
100 PaintRecorder recorder; | 100 PaintRecorder recorder; |
101 | 101 |
102 PaintFlags red_paint; | 102 PaintFlags red_paint; |
103 red_paint.setColor(SK_ColorRED); | 103 red_paint.setColor(SK_ColorRED); |
104 | 104 |
105 PaintCanvas* canvas = recorder.beginRecording(SkRect::MakeXYWH( | 105 SkRect bounds = SkRect::MakeXYWH(offset.x(), offset.y(), layer_size.width(), |
106 offset.x(), offset.y(), layer_size.width(), layer_size.height())); | 106 layer_size.height()); |
| 107 PaintCanvas* canvas = recorder.beginRecording(bounds); |
107 canvas->translate(offset.x(), offset.y()); | 108 canvas->translate(offset.x(), offset.y()); |
108 canvas->drawRect(SkRect::MakeWH(4, 4), red_paint); | 109 canvas->drawRect(SkRect::MakeWH(4, 4), red_paint); |
109 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 110 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
110 kVisualRect, recorder.finishRecordingAsPicture()); | 111 kVisualRect, recorder.finishRecordingAsPicture(), bounds); |
111 } | 112 } |
112 | 113 |
113 } // namespace | 114 } // namespace |
114 | 115 |
115 TEST(DisplayItemListTest, SingleDrawingItem) { | 116 TEST(DisplayItemListTest, SingleDrawingItem) { |
116 gfx::Rect layer_rect(100, 100); | 117 gfx::Rect layer_rect(100, 100); |
117 PaintRecorder recorder; | 118 PaintRecorder recorder; |
118 PaintFlags blue_flags; | 119 PaintFlags blue_flags; |
119 blue_flags.setColor(SK_ColorBLUE); | 120 blue_flags.setColor(SK_ColorBLUE); |
120 PaintFlags red_paint; | 121 PaintFlags red_paint; |
121 red_paint.setColor(SK_ColorRED); | 122 red_paint.setColor(SK_ColorRED); |
122 unsigned char pixels[4 * 100 * 100] = {0}; | 123 unsigned char pixels[4 * 100 * 100] = {0}; |
123 auto list = make_scoped_refptr(new DisplayItemList); | 124 auto list = make_scoped_refptr(new DisplayItemList); |
124 | 125 |
125 gfx::PointF offset(8.f, 9.f); | 126 gfx::PointF offset(8.f, 9.f); |
126 gfx::RectF recording_rect(offset, gfx::SizeF(layer_rect.size())); | 127 gfx::RectF recording_rect(offset, gfx::SizeF(layer_rect.size())); |
127 PaintCanvas* canvas = | 128 PaintCanvas* canvas = |
128 recorder.beginRecording(gfx::RectFToSkRect(recording_rect)); | 129 recorder.beginRecording(gfx::RectFToSkRect(recording_rect)); |
129 canvas->translate(offset.x(), offset.y()); | 130 canvas->translate(offset.x(), offset.y()); |
130 canvas->drawRect(SkRect::MakeLTRB(0.f, 0.f, 60.f, 60.f), red_paint); | 131 canvas->drawRect(SkRect::MakeLTRB(0.f, 0.f, 60.f, 60.f), red_paint); |
131 canvas->drawRect(SkRect::MakeLTRB(50.f, 50.f, 75.f, 75.f), blue_flags); | 132 canvas->drawRect(SkRect::MakeLTRB(50.f, 50.f, 75.f, 75.f), blue_flags); |
132 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 133 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
133 kVisualRect, recorder.finishRecordingAsPicture()); | 134 kVisualRect, recorder.finishRecordingAsPicture(), |
| 135 gfx::RectFToSkRect(recording_rect)); |
134 list->Finalize(); | 136 list->Finalize(); |
135 DrawDisplayList(pixels, layer_rect, list); | 137 DrawDisplayList(pixels, layer_rect, list); |
136 | 138 |
137 SkBitmap expected_bitmap; | 139 SkBitmap expected_bitmap; |
138 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 140 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
139 SkImageInfo info = | 141 SkImageInfo info = |
140 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 142 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
141 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 143 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
142 SkiaPaintCanvas expected_canvas(expected_bitmap); | 144 SkiaPaintCanvas expected_canvas(expected_bitmap); |
143 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 145 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
(...skipping 19 matching lines...) Expand all Loading... |
163 unsigned char pixels[4 * 100 * 100] = {0}; | 165 unsigned char pixels[4 * 100 * 100] = {0}; |
164 auto list = make_scoped_refptr(new DisplayItemList); | 166 auto list = make_scoped_refptr(new DisplayItemList); |
165 | 167 |
166 gfx::PointF first_offset(8.f, 9.f); | 168 gfx::PointF first_offset(8.f, 9.f); |
167 gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size())); | 169 gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size())); |
168 PaintCanvas* canvas = | 170 PaintCanvas* canvas = |
169 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)); | 171 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)); |
170 canvas->translate(first_offset.x(), first_offset.y()); | 172 canvas->translate(first_offset.x(), first_offset.y()); |
171 canvas->drawRect(SkRect::MakeWH(60, 60), red_paint); | 173 canvas->drawRect(SkRect::MakeWH(60, 60), red_paint); |
172 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 174 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
173 kVisualRect, recorder.finishRecordingAsPicture()); | 175 kVisualRect, recorder.finishRecordingAsPicture(), |
| 176 gfx::RectFToSkRect(first_recording_rect)); |
174 | 177 |
175 gfx::Rect clip_rect(60, 60, 10, 10); | 178 gfx::Rect clip_rect(60, 60, 10, 10); |
176 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 179 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
177 clip_rect, std::vector<SkRRect>(), true); | 180 clip_rect, std::vector<SkRRect>(), true); |
178 | 181 |
179 gfx::PointF second_offset(2.f, 3.f); | 182 gfx::PointF second_offset(2.f, 3.f); |
180 gfx::RectF second_recording_rect(second_offset, | 183 gfx::RectF second_recording_rect(second_offset, |
181 gfx::SizeF(layer_rect.size())); | 184 gfx::SizeF(layer_rect.size())); |
182 canvas = recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)); | 185 canvas = recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)); |
183 canvas->translate(second_offset.x(), second_offset.y()); | 186 canvas->translate(second_offset.x(), second_offset.y()); |
184 canvas->drawRect(SkRect::MakeLTRB(50.f, 50.f, 75.f, 75.f), blue_flags); | 187 canvas->drawRect(SkRect::MakeLTRB(50.f, 50.f, 75.f, 75.f), blue_flags); |
185 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 188 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
186 kVisualRect, recorder.finishRecordingAsPicture()); | 189 kVisualRect, recorder.finishRecordingAsPicture(), |
| 190 gfx::RectFToSkRect(second_recording_rect)); |
187 | 191 |
188 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 192 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
189 list->Finalize(); | 193 list->Finalize(); |
190 | 194 |
191 DrawDisplayList(pixels, layer_rect, list); | 195 DrawDisplayList(pixels, layer_rect, list); |
192 | 196 |
193 SkBitmap expected_bitmap; | 197 SkBitmap expected_bitmap; |
194 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 198 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
195 SkImageInfo info = | 199 SkImageInfo info = |
196 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 200 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
(...skipping 23 matching lines...) Expand all Loading... |
220 unsigned char pixels[4 * 100 * 100] = {0}; | 224 unsigned char pixels[4 * 100 * 100] = {0}; |
221 auto list = make_scoped_refptr(new DisplayItemList); | 225 auto list = make_scoped_refptr(new DisplayItemList); |
222 | 226 |
223 gfx::PointF first_offset(8.f, 9.f); | 227 gfx::PointF first_offset(8.f, 9.f); |
224 gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size())); | 228 gfx::RectF first_recording_rect(first_offset, gfx::SizeF(layer_rect.size())); |
225 PaintCanvas* canvas = | 229 PaintCanvas* canvas = |
226 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)); | 230 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)); |
227 canvas->translate(first_offset.x(), first_offset.y()); | 231 canvas->translate(first_offset.x(), first_offset.y()); |
228 canvas->drawRect(SkRect::MakeWH(60, 60), red_paint); | 232 canvas->drawRect(SkRect::MakeWH(60, 60), red_paint); |
229 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 233 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
230 kVisualRect, recorder.finishRecordingAsPicture()); | 234 kVisualRect, recorder.finishRecordingAsPicture(), |
| 235 gfx::RectFToSkRect(first_recording_rect)); |
231 | 236 |
232 gfx::Transform transform; | 237 gfx::Transform transform; |
233 transform.Rotate(45.0); | 238 transform.Rotate(45.0); |
234 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(transform); | 239 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(transform); |
235 | 240 |
236 gfx::PointF second_offset(2.f, 3.f); | 241 gfx::PointF second_offset(2.f, 3.f); |
237 gfx::RectF second_recording_rect(second_offset, | 242 gfx::RectF second_recording_rect(second_offset, |
238 gfx::SizeF(layer_rect.size())); | 243 gfx::SizeF(layer_rect.size())); |
239 canvas = recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)); | 244 canvas = recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)); |
240 canvas->translate(second_offset.x(), second_offset.y()); | 245 canvas->translate(second_offset.x(), second_offset.y()); |
241 canvas->drawRect(SkRect::MakeLTRB(50.f, 50.f, 75.f, 75.f), blue_flags); | 246 canvas->drawRect(SkRect::MakeLTRB(50.f, 50.f, 75.f, 75.f), blue_flags); |
242 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 247 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
243 kVisualRect, recorder.finishRecordingAsPicture()); | 248 kVisualRect, recorder.finishRecordingAsPicture(), |
| 249 gfx::RectFToSkRect(second_recording_rect)); |
244 | 250 |
245 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 251 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
246 list->Finalize(); | 252 list->Finalize(); |
247 | 253 |
248 DrawDisplayList(pixels, layer_rect, list); | 254 DrawDisplayList(pixels, layer_rect, list); |
249 | 255 |
250 SkBitmap expected_bitmap; | 256 SkBitmap expected_bitmap; |
251 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 257 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
252 SkImageInfo info = | 258 SkImageInfo info = |
253 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 259 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 list->CreateAndAppendPairedBeginItem<FilterDisplayItem>( | 302 list->CreateAndAppendPairedBeginItem<FilterDisplayItem>( |
297 filters, filter_bounds, filter_bounds.origin()); | 303 filters, filter_bounds, filter_bounds.origin()); |
298 | 304 |
299 // Include a rect drawing so that filter is actually applied to something. | 305 // Include a rect drawing so that filter is actually applied to something. |
300 { | 306 { |
301 PaintRecorder recorder; | 307 PaintRecorder recorder; |
302 | 308 |
303 PaintFlags red_paint; | 309 PaintFlags red_paint; |
304 red_paint.setColor(SK_ColorRED); | 310 red_paint.setColor(SK_ColorRED); |
305 | 311 |
306 PaintCanvas* canvas = recorder.beginRecording( | 312 SkRect bounds = |
307 SkRect::MakeXYWH(0, 0, layer_rect.width(), layer_rect.height())); | 313 SkRect::MakeXYWH(0, 0, layer_rect.width(), layer_rect.height()); |
| 314 PaintCanvas* canvas = recorder.beginRecording(bounds); |
308 canvas->drawRect( | 315 canvas->drawRect( |
309 SkRect::MakeLTRB(filter_bounds.x(), filter_bounds.y(), | 316 SkRect::MakeLTRB(filter_bounds.x(), filter_bounds.y(), |
310 filter_bounds.right(), filter_bounds.bottom()), | 317 filter_bounds.right(), filter_bounds.bottom()), |
311 red_paint); | 318 red_paint); |
312 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 319 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
313 ToNearestRect(filter_bounds), recorder.finishRecordingAsPicture()); | 320 ToNearestRect(filter_bounds), recorder.finishRecordingAsPicture(), |
| 321 bounds); |
314 } | 322 } |
315 | 323 |
316 list->CreateAndAppendPairedEndItem<EndFilterDisplayItem>(); | 324 list->CreateAndAppendPairedEndItem<EndFilterDisplayItem>(); |
317 list->Finalize(); | 325 list->Finalize(); |
318 | 326 |
319 DrawDisplayList(pixels, layer_rect, list); | 327 DrawDisplayList(pixels, layer_rect, list); |
320 | 328 |
321 SkBitmap expected_bitmap; | 329 SkBitmap expected_bitmap; |
322 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 330 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
323 PaintFlags paint; | 331 PaintFlags paint; |
(...skipping 17 matching lines...) Expand all Loading... |
341 PaintFlags blue_flags; | 349 PaintFlags blue_flags; |
342 blue_flags.setColor(SK_ColorBLUE); | 350 blue_flags.setColor(SK_ColorBLUE); |
343 PaintCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(layer_rect)); | 351 PaintCanvas* canvas = recorder.beginRecording(gfx::RectToSkRect(layer_rect)); |
344 for (int i = 0; i < kNumCommandsInTestSkPicture; i++) | 352 for (int i = 0; i < kNumCommandsInTestSkPicture; i++) |
345 canvas->drawRect(SkRect(), blue_flags); | 353 canvas->drawRect(SkRect(), blue_flags); |
346 sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture(); | 354 sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture(); |
347 size_t record_size = record->bytes_used(); | 355 size_t record_size = record->bytes_used(); |
348 ASSERT_GE(record_size, kNumCommandsInTestSkPicture * sizeof(SkRect)); | 356 ASSERT_GE(record_size, kNumCommandsInTestSkPicture * sizeof(SkRect)); |
349 | 357 |
350 auto list = make_scoped_refptr(new DisplayItemList); | 358 auto list = make_scoped_refptr(new DisplayItemList); |
351 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(kVisualRect, record); | 359 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 360 kVisualRect, record, gfx::RectToSkRect(layer_rect)); |
352 list->Finalize(); | 361 list->Finalize(); |
353 memory_usage = list->ApproximateMemoryUsage(); | 362 memory_usage = list->ApproximateMemoryUsage(); |
354 EXPECT_GE(memory_usage, record_size); | 363 EXPECT_GE(memory_usage, record_size); |
355 EXPECT_LE(memory_usage, 2 * record_size); | 364 EXPECT_LE(memory_usage, 2 * record_size); |
356 } | 365 } |
357 | 366 |
358 TEST(DisplayItemListTest, AsValueWithNoItems) { | 367 TEST(DisplayItemListTest, AsValueWithNoItems) { |
359 auto list = make_scoped_refptr(new DisplayItemList); | 368 auto list = make_scoped_refptr(new DisplayItemList); |
360 list->SetRetainVisualRectsForTesting(true); | 369 list->SetRetainVisualRectsForTesting(true); |
361 list->Finalize(); | 370 list->Finalize(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 410 |
402 TEST(DisplayItemListTest, SizeEmpty) { | 411 TEST(DisplayItemListTest, SizeEmpty) { |
403 auto list = make_scoped_refptr(new DisplayItemList); | 412 auto list = make_scoped_refptr(new DisplayItemList); |
404 EXPECT_EQ(0u, list->size()); | 413 EXPECT_EQ(0u, list->size()); |
405 } | 414 } |
406 | 415 |
407 TEST(DisplayItemListTest, SizeOne) { | 416 TEST(DisplayItemListTest, SizeOne) { |
408 auto list = make_scoped_refptr(new DisplayItemList); | 417 auto list = make_scoped_refptr(new DisplayItemList); |
409 gfx::Rect drawing_bounds(5, 6, 1, 1); | 418 gfx::Rect drawing_bounds(5, 6, 1, 1); |
410 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 419 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
411 drawing_bounds, CreateRectPicture(drawing_bounds)); | 420 drawing_bounds, CreateRectPicture(drawing_bounds), |
| 421 gfx::RectToSkRect(drawing_bounds)); |
412 EXPECT_EQ(1u, list->size()); | 422 EXPECT_EQ(1u, list->size()); |
413 } | 423 } |
414 | 424 |
415 TEST(DisplayItemListTest, SizeMultiple) { | 425 TEST(DisplayItemListTest, SizeMultiple) { |
416 auto list = make_scoped_refptr(new DisplayItemList); | 426 auto list = make_scoped_refptr(new DisplayItemList); |
417 gfx::Rect clip_bounds(5, 6, 7, 8); | 427 gfx::Rect clip_bounds(5, 6, 7, 8); |
418 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 428 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
419 clip_bounds, std::vector<SkRRect>(), true); | 429 clip_bounds, std::vector<SkRRect>(), true); |
420 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 430 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
421 EXPECT_EQ(2u, list->size()); | 431 EXPECT_EQ(2u, list->size()); |
422 } | 432 } |
423 | 433 |
424 TEST(DisplayItemListTest, AppendVisualRectSimple) { | 434 TEST(DisplayItemListTest, AppendVisualRectSimple) { |
425 auto list = make_scoped_refptr(new DisplayItemList); | 435 auto list = make_scoped_refptr(new DisplayItemList); |
426 | 436 |
427 // One drawing: D. | 437 // One drawing: D. |
428 | 438 |
429 gfx::Rect drawing_bounds(5, 6, 7, 8); | 439 gfx::Rect drawing_bounds(5, 6, 7, 8); |
430 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 440 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
431 drawing_bounds, CreateRectPicture(drawing_bounds)); | 441 drawing_bounds, CreateRectPicture(drawing_bounds), |
| 442 gfx::RectToSkRect(drawing_bounds)); |
432 | 443 |
433 EXPECT_EQ(1u, list->size()); | 444 EXPECT_EQ(1u, list->size()); |
434 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(0)); | 445 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(0)); |
435 } | 446 } |
436 | 447 |
437 TEST(DisplayItemListTest, AppendVisualRectEmptyBlock) { | 448 TEST(DisplayItemListTest, AppendVisualRectEmptyBlock) { |
438 auto list = make_scoped_refptr(new DisplayItemList); | 449 auto list = make_scoped_refptr(new DisplayItemList); |
439 | 450 |
440 // One block: B1, E1. | 451 // One block: B1, E1. |
441 | 452 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 auto list = make_scoped_refptr(new DisplayItemList); | 484 auto list = make_scoped_refptr(new DisplayItemList); |
474 | 485 |
475 // One block with one drawing: B1, Da, E1. | 486 // One block with one drawing: B1, Da, E1. |
476 | 487 |
477 gfx::Rect clip_bounds(5, 6, 7, 8); | 488 gfx::Rect clip_bounds(5, 6, 7, 8); |
478 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 489 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
479 clip_bounds, std::vector<SkRRect>(), true); | 490 clip_bounds, std::vector<SkRRect>(), true); |
480 | 491 |
481 gfx::Rect drawing_bounds(5, 6, 1, 1); | 492 gfx::Rect drawing_bounds(5, 6, 1, 1); |
482 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 493 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
483 drawing_bounds, CreateRectPicture(drawing_bounds)); | 494 drawing_bounds, CreateRectPicture(drawing_bounds), |
| 495 gfx::RectToSkRect(drawing_bounds)); |
484 | 496 |
485 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 497 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
486 | 498 |
487 EXPECT_EQ(3u, list->size()); | 499 EXPECT_EQ(3u, list->size()); |
488 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(0)); | 500 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(0)); |
489 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(1)); | 501 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(1)); |
490 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(2)); | 502 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(2)); |
491 } | 503 } |
492 | 504 |
493 TEST(DisplayItemListTest, AppendVisualRectBlockContainingEscapedDrawing) { | 505 TEST(DisplayItemListTest, AppendVisualRectBlockContainingEscapedDrawing) { |
494 auto list = make_scoped_refptr(new DisplayItemList); | 506 auto list = make_scoped_refptr(new DisplayItemList); |
495 | 507 |
496 // One block with one drawing: B1, Da (escapes), E1. | 508 // One block with one drawing: B1, Da (escapes), E1. |
497 | 509 |
498 gfx::Rect clip_bounds(5, 6, 7, 8); | 510 gfx::Rect clip_bounds(5, 6, 7, 8); |
499 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 511 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
500 clip_bounds, std::vector<SkRRect>(), true); | 512 clip_bounds, std::vector<SkRRect>(), true); |
501 | 513 |
502 gfx::Rect drawing_bounds(1, 2, 3, 4); | 514 gfx::Rect drawing_bounds(1, 2, 3, 4); |
503 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 515 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
504 drawing_bounds, CreateRectPicture(drawing_bounds)); | 516 drawing_bounds, CreateRectPicture(drawing_bounds), |
| 517 gfx::RectToSkRect(drawing_bounds)); |
505 | 518 |
506 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 519 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
507 | 520 |
508 EXPECT_EQ(3u, list->size()); | 521 EXPECT_EQ(3u, list->size()); |
509 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(0)); | 522 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(0)); |
510 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(1)); | 523 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(1)); |
511 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(2)); | 524 EXPECT_RECT_EQ(drawing_bounds, list->VisualRectForTesting(2)); |
512 } | 525 } |
513 | 526 |
514 TEST(DisplayItemListTest, | 527 TEST(DisplayItemListTest, |
515 AppendVisualRectDrawingFollowedByBlockContainingEscapedDrawing) { | 528 AppendVisualRectDrawingFollowedByBlockContainingEscapedDrawing) { |
516 auto list = make_scoped_refptr(new DisplayItemList); | 529 auto list = make_scoped_refptr(new DisplayItemList); |
517 | 530 |
518 // One drawing followed by one block with one drawing: Da, B1, Db (escapes), | 531 // One drawing followed by one block with one drawing: Da, B1, Db (escapes), |
519 // E1. | 532 // E1. |
520 | 533 |
521 gfx::Rect drawing_a_bounds(1, 2, 3, 4); | 534 gfx::Rect drawing_a_bounds(1, 2, 3, 4); |
522 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 535 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
523 drawing_a_bounds, CreateRectPicture(drawing_a_bounds)); | 536 drawing_a_bounds, CreateRectPicture(drawing_a_bounds), |
| 537 gfx::RectToSkRect(drawing_a_bounds)); |
524 | 538 |
525 gfx::Rect clip_bounds(5, 6, 7, 8); | 539 gfx::Rect clip_bounds(5, 6, 7, 8); |
526 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 540 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
527 clip_bounds, std::vector<SkRRect>(), true); | 541 clip_bounds, std::vector<SkRRect>(), true); |
528 | 542 |
529 gfx::Rect drawing_b_bounds(13, 14, 1, 1); | 543 gfx::Rect drawing_b_bounds(13, 14, 1, 1); |
530 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 544 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
531 drawing_b_bounds, CreateRectPicture(drawing_b_bounds)); | 545 drawing_b_bounds, CreateRectPicture(drawing_b_bounds), |
| 546 gfx::RectToSkRect(drawing_b_bounds)); |
532 | 547 |
533 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 548 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
534 | 549 |
535 EXPECT_EQ(4u, list->size()); | 550 EXPECT_EQ(4u, list->size()); |
536 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(0)); | 551 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(0)); |
537 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(1)); | 552 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(1)); |
538 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); | 553 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); |
539 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); | 554 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); |
540 } | 555 } |
541 | 556 |
542 TEST(DisplayItemListTest, AppendVisualRectTwoBlocksTwoDrawings) { | 557 TEST(DisplayItemListTest, AppendVisualRectTwoBlocksTwoDrawings) { |
543 auto list = make_scoped_refptr(new DisplayItemList); | 558 auto list = make_scoped_refptr(new DisplayItemList); |
544 | 559 |
545 // Multiple nested blocks with drawings amidst: B1, Da, B2, Db, E2, E1. | 560 // Multiple nested blocks with drawings amidst: B1, Da, B2, Db, E2, E1. |
546 | 561 |
547 gfx::Rect clip_bounds(5, 6, 7, 8); | 562 gfx::Rect clip_bounds(5, 6, 7, 8); |
548 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 563 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
549 clip_bounds, std::vector<SkRRect>(), true); | 564 clip_bounds, std::vector<SkRRect>(), true); |
550 | 565 |
551 gfx::Rect drawing_a_bounds(5, 6, 1, 1); | 566 gfx::Rect drawing_a_bounds(5, 6, 1, 1); |
552 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 567 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
553 drawing_a_bounds, CreateRectPicture(drawing_a_bounds)); | 568 drawing_a_bounds, CreateRectPicture(drawing_a_bounds), |
| 569 gfx::RectToSkRect(drawing_a_bounds)); |
554 | 570 |
555 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); | 571 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); |
556 | 572 |
557 gfx::Rect drawing_b_bounds(7, 8, 1, 1); | 573 gfx::Rect drawing_b_bounds(7, 8, 1, 1); |
558 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 574 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
559 drawing_b_bounds, CreateRectPicture(drawing_b_bounds)); | 575 drawing_b_bounds, CreateRectPicture(drawing_b_bounds), |
| 576 gfx::RectToSkRect(drawing_b_bounds)); |
560 | 577 |
561 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 578 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
562 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 579 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
563 | 580 |
564 EXPECT_EQ(6u, list->size()); | 581 EXPECT_EQ(6u, list->size()); |
565 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); | 582 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); |
566 merged_drawing_bounds.Union(drawing_b_bounds); | 583 merged_drawing_bounds.Union(drawing_b_bounds); |
567 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); | 584 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); |
568 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); | 585 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); |
569 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); | 586 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); |
570 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); | 587 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); |
571 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(4)); | 588 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(4)); |
572 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); | 589 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); |
573 } | 590 } |
574 | 591 |
575 TEST(DisplayItemListTest, | 592 TEST(DisplayItemListTest, |
576 AppendVisualRectTwoBlocksTwoDrawingsInnerDrawingEscaped) { | 593 AppendVisualRectTwoBlocksTwoDrawingsInnerDrawingEscaped) { |
577 auto list = make_scoped_refptr(new DisplayItemList); | 594 auto list = make_scoped_refptr(new DisplayItemList); |
578 | 595 |
579 // Multiple nested blocks with drawings amidst: B1, Da, B2, Db (escapes), E2, | 596 // Multiple nested blocks with drawings amidst: B1, Da, B2, Db (escapes), E2, |
580 // E1. | 597 // E1. |
581 | 598 |
582 gfx::Rect clip_bounds(5, 6, 7, 8); | 599 gfx::Rect clip_bounds(5, 6, 7, 8); |
583 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 600 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
584 clip_bounds, std::vector<SkRRect>(), true); | 601 clip_bounds, std::vector<SkRRect>(), true); |
585 | 602 |
586 gfx::Rect drawing_a_bounds(5, 6, 1, 1); | 603 gfx::Rect drawing_a_bounds(5, 6, 1, 1); |
587 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 604 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
588 drawing_a_bounds, CreateRectPicture(drawing_a_bounds)); | 605 drawing_a_bounds, CreateRectPicture(drawing_a_bounds), |
| 606 gfx::RectToSkRect(drawing_a_bounds)); |
589 | 607 |
590 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); | 608 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); |
591 | 609 |
592 gfx::Rect drawing_b_bounds(1, 2, 3, 4); | 610 gfx::Rect drawing_b_bounds(1, 2, 3, 4); |
593 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 611 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
594 drawing_b_bounds, CreateRectPicture(drawing_b_bounds)); | 612 drawing_b_bounds, CreateRectPicture(drawing_b_bounds), |
| 613 gfx::RectToSkRect(drawing_b_bounds)); |
595 | 614 |
596 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 615 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
597 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 616 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
598 | 617 |
599 EXPECT_EQ(6u, list->size()); | 618 EXPECT_EQ(6u, list->size()); |
600 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); | 619 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); |
601 merged_drawing_bounds.Union(drawing_b_bounds); | 620 merged_drawing_bounds.Union(drawing_b_bounds); |
602 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); | 621 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); |
603 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); | 622 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); |
604 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); | 623 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); |
605 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); | 624 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); |
606 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(4)); | 625 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(4)); |
607 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); | 626 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); |
608 } | 627 } |
609 | 628 |
610 TEST(DisplayItemListTest, | 629 TEST(DisplayItemListTest, |
611 AppendVisualRectTwoBlocksTwoDrawingsOuterDrawingEscaped) { | 630 AppendVisualRectTwoBlocksTwoDrawingsOuterDrawingEscaped) { |
612 auto list = make_scoped_refptr(new DisplayItemList); | 631 auto list = make_scoped_refptr(new DisplayItemList); |
613 | 632 |
614 // Multiple nested blocks with drawings amidst: B1, Da (escapes), B2, Db, E2, | 633 // Multiple nested blocks with drawings amidst: B1, Da (escapes), B2, Db, E2, |
615 // E1. | 634 // E1. |
616 | 635 |
617 gfx::Rect clip_bounds(5, 6, 7, 8); | 636 gfx::Rect clip_bounds(5, 6, 7, 8); |
618 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 637 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
619 clip_bounds, std::vector<SkRRect>(), true); | 638 clip_bounds, std::vector<SkRRect>(), true); |
620 | 639 |
621 gfx::Rect drawing_a_bounds(1, 2, 3, 4); | 640 gfx::Rect drawing_a_bounds(1, 2, 3, 4); |
622 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 641 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
623 drawing_a_bounds, CreateRectPicture(drawing_a_bounds)); | 642 drawing_a_bounds, CreateRectPicture(drawing_a_bounds), |
| 643 gfx::RectToSkRect(drawing_a_bounds)); |
624 | 644 |
625 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); | 645 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); |
626 | 646 |
627 gfx::Rect drawing_b_bounds(7, 8, 1, 1); | 647 gfx::Rect drawing_b_bounds(7, 8, 1, 1); |
628 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 648 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
629 drawing_b_bounds, CreateRectPicture(drawing_b_bounds)); | 649 drawing_b_bounds, CreateRectPicture(drawing_b_bounds), |
| 650 gfx::RectToSkRect(drawing_b_bounds)); |
630 | 651 |
631 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 652 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
632 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 653 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
633 | 654 |
634 EXPECT_EQ(6u, list->size()); | 655 EXPECT_EQ(6u, list->size()); |
635 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); | 656 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); |
636 merged_drawing_bounds.Union(drawing_b_bounds); | 657 merged_drawing_bounds.Union(drawing_b_bounds); |
637 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); | 658 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); |
638 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); | 659 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); |
639 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); | 660 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); |
640 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); | 661 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(3)); |
641 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(4)); | 662 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(4)); |
642 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); | 663 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); |
643 } | 664 } |
644 | 665 |
645 TEST(DisplayItemListTest, | 666 TEST(DisplayItemListTest, |
646 AppendVisualRectTwoBlocksTwoDrawingsBothDrawingsEscaped) { | 667 AppendVisualRectTwoBlocksTwoDrawingsBothDrawingsEscaped) { |
647 auto list = make_scoped_refptr(new DisplayItemList); | 668 auto list = make_scoped_refptr(new DisplayItemList); |
648 | 669 |
649 // Multiple nested blocks with drawings amidst: | 670 // Multiple nested blocks with drawings amidst: |
650 // B1, Da (escapes to the right), B2, Db (escapes to the left), E2, E1. | 671 // B1, Da (escapes to the right), B2, Db (escapes to the left), E2, E1. |
651 | 672 |
652 gfx::Rect clip_bounds(5, 6, 7, 8); | 673 gfx::Rect clip_bounds(5, 6, 7, 8); |
653 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( | 674 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( |
654 clip_bounds, std::vector<SkRRect>(), true); | 675 clip_bounds, std::vector<SkRRect>(), true); |
655 | 676 |
656 gfx::Rect drawing_a_bounds(13, 14, 1, 1); | 677 gfx::Rect drawing_a_bounds(13, 14, 1, 1); |
657 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 678 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
658 drawing_a_bounds, CreateRectPicture(drawing_a_bounds)); | 679 drawing_a_bounds, CreateRectPicture(drawing_a_bounds), |
| 680 gfx::RectToSkRect(drawing_a_bounds)); |
659 | 681 |
660 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); | 682 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(gfx::Transform()); |
661 | 683 |
662 gfx::Rect drawing_b_bounds(1, 2, 3, 4); | 684 gfx::Rect drawing_b_bounds(1, 2, 3, 4); |
663 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 685 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
664 drawing_b_bounds, CreateRectPicture(drawing_b_bounds)); | 686 drawing_b_bounds, CreateRectPicture(drawing_b_bounds), |
| 687 gfx::RectToSkRect(drawing_b_bounds)); |
665 | 688 |
666 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 689 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
667 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 690 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
668 | 691 |
669 EXPECT_EQ(6u, list->size()); | 692 EXPECT_EQ(6u, list->size()); |
670 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); | 693 gfx::Rect merged_drawing_bounds = gfx::Rect(drawing_a_bounds); |
671 merged_drawing_bounds.Union(drawing_b_bounds); | 694 merged_drawing_bounds.Union(drawing_b_bounds); |
672 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); | 695 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(0)); |
673 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); | 696 EXPECT_RECT_EQ(drawing_a_bounds, list->VisualRectForTesting(1)); |
674 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); | 697 EXPECT_RECT_EQ(drawing_b_bounds, list->VisualRectForTesting(2)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 | 743 |
721 // Verify that raster time optimizations for compositing item / draw single op / | 744 // Verify that raster time optimizations for compositing item / draw single op / |
722 // end compositing item can be collapsed together into a single draw op | 745 // end compositing item can be collapsed together into a single draw op |
723 // with the opacity from the compositing item folded in. | 746 // with the opacity from the compositing item folded in. |
724 TEST(DisplayItemListTest, SaveDrawRestore) { | 747 TEST(DisplayItemListTest, SaveDrawRestore) { |
725 auto list = make_scoped_refptr(new DisplayItemList); | 748 auto list = make_scoped_refptr(new DisplayItemList); |
726 | 749 |
727 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( | 750 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( |
728 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); | 751 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); |
729 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 752 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
730 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40)); | 753 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40), |
| 754 gfx::RectToSkRect(kVisualRect)); |
731 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); | 755 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); |
732 list->Finalize(); | 756 list->Finalize(); |
733 | 757 |
734 SaveCountingCanvas canvas; | 758 SaveCountingCanvas canvas; |
735 list->Raster(&canvas); | 759 list->Raster(&canvas); |
736 | 760 |
737 EXPECT_EQ(0, canvas.save_count_); | 761 EXPECT_EQ(0, canvas.save_count_); |
738 EXPECT_EQ(0, canvas.restore_count_); | 762 EXPECT_EQ(0, canvas.restore_count_); |
739 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); | 763 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); |
740 | 764 |
(...skipping 29 matching lines...) Expand all Loading... |
770 // The same as SaveDrawRestore, but with save flags that prevent the | 794 // The same as SaveDrawRestore, but with save flags that prevent the |
771 // optimization. | 795 // optimization. |
772 TEST(DisplayItemListTest, SaveDrawRestoreFail_BadSaveFlags) { | 796 TEST(DisplayItemListTest, SaveDrawRestoreFail_BadSaveFlags) { |
773 auto list = make_scoped_refptr(new DisplayItemList); | 797 auto list = make_scoped_refptr(new DisplayItemList); |
774 | 798 |
775 // Use a blend mode that's not compatible with the SaveDrawRestore | 799 // Use a blend mode that's not compatible with the SaveDrawRestore |
776 // optimization. | 800 // optimization. |
777 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( | 801 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( |
778 80, SkBlendMode::kSrc, nullptr, nullptr, false); | 802 80, SkBlendMode::kSrc, nullptr, nullptr, false); |
779 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 803 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
780 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40)); | 804 kVisualRect, CreateRectPictureWithAlpha(kVisualRect, 40), |
| 805 gfx::RectToSkRect(kVisualRect)); |
781 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); | 806 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); |
782 list->Finalize(); | 807 list->Finalize(); |
783 | 808 |
784 SaveCountingCanvas canvas; | 809 SaveCountingCanvas canvas; |
785 list->Raster(&canvas); | 810 list->Raster(&canvas); |
786 | 811 |
787 EXPECT_EQ(1, canvas.save_count_); | 812 EXPECT_EQ(1, canvas.save_count_); |
788 EXPECT_EQ(1, canvas.restore_count_); | 813 EXPECT_EQ(1, canvas.restore_count_); |
789 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); | 814 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); |
790 EXPECT_LE(40, canvas.paint_.getAlpha()); | 815 EXPECT_LE(40, canvas.paint_.getAlpha()); |
791 } | 816 } |
792 | 817 |
793 // The same as SaveDrawRestore, but with too many ops in the PaintRecord. | 818 // The same as SaveDrawRestore, but with too many ops in the PaintRecord. |
794 TEST(DisplayItemListTest, SaveDrawRestoreFail_TooManyOps) { | 819 TEST(DisplayItemListTest, SaveDrawRestoreFail_TooManyOps) { |
795 sk_sp<const PaintRecord> record; | 820 sk_sp<const PaintRecord> record; |
| 821 SkRect bounds = SkRect::MakeWH(kVisualRect.width(), kVisualRect.height()); |
796 { | 822 { |
797 PaintRecorder recorder; | 823 PaintRecorder recorder; |
798 PaintCanvas* canvas = | 824 PaintCanvas* canvas = recorder.beginRecording(bounds); |
799 recorder.beginRecording(kVisualRect.width(), kVisualRect.height()); | |
800 PaintFlags flags; | 825 PaintFlags flags; |
801 flags.setAlpha(40); | 826 flags.setAlpha(40); |
802 canvas->drawRect(gfx::RectToSkRect(kVisualRect), flags); | 827 canvas->drawRect(gfx::RectToSkRect(kVisualRect), flags); |
803 // Add an extra op here. | 828 // Add an extra op here. |
804 canvas->drawRect(gfx::RectToSkRect(kVisualRect), flags); | 829 canvas->drawRect(gfx::RectToSkRect(kVisualRect), flags); |
805 record = recorder.finishRecordingAsPicture(); | 830 record = recorder.finishRecordingAsPicture(); |
806 } | 831 } |
807 EXPECT_GT(record->size(), 1u); | 832 EXPECT_GT(record->size(), 1u); |
808 | 833 |
809 auto list = make_scoped_refptr(new DisplayItemList); | 834 auto list = make_scoped_refptr(new DisplayItemList); |
810 | 835 |
811 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( | 836 list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>( |
812 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); | 837 80, SkBlendMode::kSrcOver, nullptr, nullptr, false); |
813 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(kVisualRect, | 838 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
814 std::move(record)); | 839 kVisualRect, std::move(record), bounds); |
815 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); | 840 list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>(); |
816 list->Finalize(); | 841 list->Finalize(); |
817 | 842 |
818 SaveCountingCanvas canvas; | 843 SaveCountingCanvas canvas; |
819 list->Raster(&canvas); | 844 list->Raster(&canvas); |
820 | 845 |
821 EXPECT_EQ(1, canvas.save_count_); | 846 EXPECT_EQ(1, canvas.save_count_); |
822 EXPECT_EQ(1, canvas.restore_count_); | 847 EXPECT_EQ(1, canvas.restore_count_); |
823 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); | 848 EXPECT_EQ(gfx::RectToSkRect(kVisualRect), canvas.draw_rect_); |
824 EXPECT_LE(40, canvas.paint_.getAlpha()); | 849 EXPECT_LE(40, canvas.paint_.getAlpha()); |
825 } | 850 } |
826 | 851 |
827 } // namespace cc | 852 } // namespace cc |
OLD | NEW |