Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1318)

Side by Side Diff: cc/layers/picture_layer_unittest.cc

Issue 2141233002: cc: Clean up RecordingSource API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ContentLayerClient* painter from UpdateAndExpandInvalidation and sync to head Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/playback/discardable_image_map_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/picture_layer.h" 5 #include "cc/layers/picture_layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 EXPECT_THAT(engine_picture_ids, 89 EXPECT_THAT(engine_picture_ids,
90 testing::UnorderedElementsAreArray( 90 testing::UnorderedElementsAreArray(
91 client_picture_cache->GetAllUsedPictureIds())); 91 client_picture_cache->GetAllUsedPictureIds()));
92 92
93 // Validate that the PictureLayer specific fields are properly set. 93 // Validate that the PictureLayer specific fields are properly set.
94 EXPECT_TRUE(recording_source()->EqualsTo(*layer->recording_source())); 94 EXPECT_TRUE(recording_source()->EqualsTo(*layer->recording_source()));
95 EXPECT_EQ(update_source_frame_number_, layer->update_source_frame_number_); 95 EXPECT_EQ(update_source_frame_number_, layer->update_source_frame_number_);
96 EXPECT_EQ(is_mask_, layer->is_mask_); 96 EXPECT_EQ(is_mask_, layer->is_mask_);
97 EXPECT_EQ(picture_layer_inputs_.nearest_neighbor, 97 EXPECT_EQ(picture_layer_inputs_.nearest_neighbor,
98 layer->picture_layer_inputs_.nearest_neighbor); 98 layer->picture_layer_inputs_.nearest_neighbor);
99 EXPECT_EQ(picture_layer_inputs_.recorded_viewport,
100 layer->picture_layer_inputs_.recorded_viewport);
101
102 // The DisplayItemLists are equal if they are both null or they are both not
103 // null and render to the same thing.
104 bool display_lists_equal = !picture_layer_inputs_.display_list &&
105 !layer->picture_layer_inputs_.display_list;
106 if (picture_layer_inputs_.display_list &&
107 layer->picture_layer_inputs_.display_list) {
108 display_lists_equal = AreDisplayListDrawingResultsSame(
109 picture_layer_inputs_.recorded_viewport,
110 picture_layer_inputs_.display_list.get(),
111 layer->picture_layer_inputs_.display_list.get());
112 }
113 EXPECT_TRUE(display_lists_equal);
99 } 114 }
100 115
101 std::vector<uint32_t> GetPictureIds() { 116 std::vector<uint32_t> GetPictureIds() {
102 std::vector<uint32_t> ids; 117 std::vector<uint32_t> ids;
103 const DisplayItemList* display_list = 118 const DisplayItemList* display_list =
104 recording_source()->GetDisplayItemList(); 119 picture_layer_inputs_.display_list.get();
105 if (!display_list) 120 if (!display_list)
106 return ids; 121 return ids;
107 122
108 for (auto it = display_list->begin(); it != display_list->end(); ++it) { 123 for (auto it = display_list->begin(); it != display_list->end(); ++it) {
109 sk_sp<const SkPicture> picture = it->GetPicture(); 124 sk_sp<const SkPicture> picture = it->GetPicture();
110 if (!picture) 125 if (!picture)
111 continue; 126 continue;
112 127
113 ids.push_back(picture->uniqueID()); 128 ids.push_back(picture->uniqueID());
114 } 129 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 FakeLayerTreeHostClient host_client; 453 FakeLayerTreeHostClient host_client;
439 TestTaskGraphRunner task_graph_runner; 454 TestTaskGraphRunner task_graph_runner;
440 std::unique_ptr<FakeLayerTreeHost> host = 455 std::unique_ptr<FakeLayerTreeHost> host =
441 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); 456 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
442 host->SetRootLayer(layer); 457 host->SetRootLayer(layer);
443 458
444 // Update layers to initialize the recording source. 459 // Update layers to initialize the recording source.
445 gfx::Size layer_bounds(200, 200); 460 gfx::Size layer_bounds(200, 200);
446 gfx::Rect layer_rect(layer_bounds); 461 gfx::Rect layer_rect(layer_bounds);
447 Region invalidation(layer_rect); 462 Region invalidation(layer_rect);
448 recording_source->UpdateAndExpandInvalidation( 463
449 client, &invalidation, layer_bounds, 1, RecordingSource::RECORD_NORMALLY); 464 gfx::Rect new_recorded_viewport = client->PaintableRegion();
465 scoped_refptr<DisplayItemList> display_list =
466 client->PaintContentsToDisplayList(
467 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
468 size_t painter_reported_memory_usage =
469 client->GetApproximateUnsharedMemoryUsage();
470 recording_source->UpdateAndExpandInvalidation(&invalidation, layer_bounds,
471 new_recorded_viewport);
472 recording_source->UpdateDisplayItemList(display_list,
473 painter_reported_memory_usage);
450 474
451 // Layer is suitable for gpu rasterization by default. 475 // Layer is suitable for gpu rasterization by default.
452 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization());
453 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); 476 EXPECT_TRUE(layer->IsSuitableForGpuRasterization());
454 477
455 // Veto gpu rasterization. 478 // Veto gpu rasterization.
456 recording_source->SetForceUnsuitableForGpuRasterization(true); 479 layer->set_force_unsuitable_for_gpu_rasterization(true);
457 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization());
458 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); 480 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
459 } 481 }
460 482
461 // PicturePile uses the source frame number as a unit for measuring invalidation 483 // PicturePile uses the source frame number as a unit for measuring invalidation
462 // frequency. When a pile moves between compositors, the frame number increases 484 // frequency. When a pile moves between compositors, the frame number increases
463 // non-monotonically. This executes that code path under this scenario allowing 485 // non-monotonically. This executes that code path under this scenario allowing
464 // for the code to verify correctness with DCHECKs. 486 // for the code to verify correctness with DCHECKs.
465 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { 487 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) {
466 LayerTreeSettings settings = LayerTreeSettingsForTesting(); 488 LayerTreeSettings settings = LayerTreeSettingsForTesting();
467 settings.single_thread_proxy_scheduler = false; 489 settings.single_thread_proxy_scheduler = false;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // Do a main frame, record the picture layers. The frame number has changed 547 // Do a main frame, record the picture layers. The frame number has changed
526 // non-monotonically. 548 // non-monotonically.
527 layer->SetNeedsDisplay(); 549 layer->SetNeedsDisplay();
528 host2->Composite(base::TimeTicks::Now()); 550 host2->Composite(base::TimeTicks::Now());
529 EXPECT_EQ(3, layer->update_count()); 551 EXPECT_EQ(3, layer->update_count());
530 EXPECT_EQ(1, host2->source_frame_number()); 552 EXPECT_EQ(1, host2->source_frame_number());
531 } 553 }
532 554
533 } // namespace 555 } // namespace
534 } // namespace cc 556 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/playback/discardable_image_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698