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/playback/display_item_list.h" | 5 #include "cc/playback/display_item_list.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/trace_event/trace_event_argument.h" |
12 #include "cc/output/filter_operation.h" | 13 #include "cc/output/filter_operation.h" |
13 #include "cc/output/filter_operations.h" | 14 #include "cc/output/filter_operations.h" |
14 #include "cc/paint/paint_canvas.h" | 15 #include "cc/paint/paint_canvas.h" |
15 #include "cc/paint/paint_flags.h" | 16 #include "cc/paint/paint_flags.h" |
16 #include "cc/paint/paint_record.h" | 17 #include "cc/paint/paint_record.h" |
17 #include "cc/paint/paint_recorder.h" | 18 #include "cc/paint/paint_recorder.h" |
18 #include "cc/paint/paint_surface.h" | 19 #include "cc/paint/paint_surface.h" |
19 #include "cc/playback/clip_display_item.h" | 20 #include "cc/playback/clip_display_item.h" |
20 #include "cc/playback/clip_path_display_item.h" | 21 #include "cc/playback/clip_path_display_item.h" |
21 #include "cc/playback/compositing_display_item.h" | 22 #include "cc/playback/compositing_display_item.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 memory_usage = list->ApproximateMemoryUsage(); | 311 memory_usage = list->ApproximateMemoryUsage(); |
311 EXPECT_GE(memory_usage, record_size); | 312 EXPECT_GE(memory_usage, record_size); |
312 EXPECT_LE(memory_usage, 2 * record_size); | 313 EXPECT_LE(memory_usage, 2 * record_size); |
313 } | 314 } |
314 | 315 |
315 TEST(DisplayItemListTest, AsValueWithNoItems) { | 316 TEST(DisplayItemListTest, AsValueWithNoItems) { |
316 auto list = make_scoped_refptr(new DisplayItemList); | 317 auto list = make_scoped_refptr(new DisplayItemList); |
317 list->SetRetainVisualRectsForTesting(true); | 318 list->SetRetainVisualRectsForTesting(true); |
318 list->Finalize(); | 319 list->Finalize(); |
319 | 320 |
320 std::string value = list->AsValue(true)->ToString(); | 321 std::string value = list->CreateTracedValue(true)->ToString(); |
321 EXPECT_EQ(value.find("\"layer_rect\": [0,0,0,0]"), std::string::npos); | 322 EXPECT_EQ(value.find("\"layer_rect\": [0,0,0,0]"), std::string::npos); |
322 EXPECT_NE(value.find("\"items\":[]"), std::string::npos); | 323 EXPECT_NE(value.find("\"items\":[]"), std::string::npos); |
323 EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos); | 324 EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos); |
324 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); | 325 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); |
325 | 326 |
326 value = list->AsValue(false)->ToString(); | 327 value = list->CreateTracedValue(false)->ToString(); |
327 EXPECT_EQ(value.find("\"layer_rect\": [0,0,0,0]"), std::string::npos); | 328 EXPECT_EQ(value.find("\"layer_rect\": [0,0,0,0]"), std::string::npos); |
328 EXPECT_EQ(value.find("\"items\":"), std::string::npos); | 329 EXPECT_EQ(value.find("\"items\":"), std::string::npos); |
329 EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos); | 330 EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos); |
330 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); | 331 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); |
331 } | 332 } |
332 | 333 |
333 TEST(DisplayItemListTest, AsValueWithItems) { | 334 TEST(DisplayItemListTest, AsValueWithItems) { |
334 gfx::Rect layer_rect = gfx::Rect(1, 2, 8, 9); | 335 gfx::Rect layer_rect = gfx::Rect(1, 2, 8, 9); |
335 auto list = make_scoped_refptr(new DisplayItemList); | 336 auto list = make_scoped_refptr(new DisplayItemList); |
336 list->SetRetainVisualRectsForTesting(true); | 337 list->SetRetainVisualRectsForTesting(true); |
337 gfx::Transform transform; | 338 gfx::Transform transform; |
338 transform.Translate(6.f, 7.f); | 339 transform.Translate(6.f, 7.f); |
339 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(transform); | 340 list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(transform); |
340 AppendFirstSerializationTestPicture(list, layer_rect.size()); | 341 AppendFirstSerializationTestPicture(list, layer_rect.size()); |
341 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 342 list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
342 list->Finalize(); | 343 list->Finalize(); |
343 | 344 |
344 std::string value = list->AsValue(true)->ToString(); | 345 std::string value = list->CreateTracedValue(true)->ToString(); |
345 EXPECT_EQ(value.find("\"layer_rect\": [0,0,42,42]"), std::string::npos); | 346 EXPECT_EQ(value.find("\"layer_rect\": [0,0,42,42]"), std::string::npos); |
346 EXPECT_NE(value.find("{\"items\":[\"TransformDisplayItem"), | 347 EXPECT_NE(value.find("{\"items\":[\"TransformDisplayItem"), |
347 std::string::npos); | 348 std::string::npos); |
348 EXPECT_NE(value.find("visualRect: [0,0 42x42]"), std::string::npos); | 349 EXPECT_NE(value.find("visualRect: [0,0 42x42]"), std::string::npos); |
349 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); | 350 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); |
350 | 351 |
351 value = list->AsValue(false)->ToString(); | 352 value = list->CreateTracedValue(false)->ToString(); |
352 EXPECT_EQ(value.find("\"layer_rect\": [0,0,42,42]"), std::string::npos); | 353 EXPECT_EQ(value.find("\"layer_rect\": [0,0,42,42]"), std::string::npos); |
353 EXPECT_EQ(value.find("{\"items\":[\"TransformDisplayItem"), | 354 EXPECT_EQ(value.find("{\"items\":[\"TransformDisplayItem"), |
354 std::string::npos); | 355 std::string::npos); |
355 EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos); | 356 EXPECT_EQ(value.find("visualRect: [0,0 42x42]"), std::string::npos); |
356 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); | 357 EXPECT_NE(value.find("\"skp64\":"), std::string::npos); |
357 } | 358 } |
358 | 359 |
359 TEST(DisplayItemListTest, SizeEmpty) { | 360 TEST(DisplayItemListTest, SizeEmpty) { |
360 auto list = make_scoped_refptr(new DisplayItemList); | 361 auto list = make_scoped_refptr(new DisplayItemList); |
361 EXPECT_EQ(0u, list->size()); | 362 EXPECT_EQ(0u, list->size()); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); | 670 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); |
670 | 671 |
671 EXPECT_EQ(4u, list->size()); | 672 EXPECT_EQ(4u, list->size()); |
672 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0)); | 673 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0)); |
673 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1)); | 674 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1)); |
674 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(2)); | 675 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(2)); |
675 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(3)); | 676 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(3)); |
676 } | 677 } |
677 | 678 |
678 } // namespace cc | 679 } // namespace cc |
OLD | NEW |