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

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: Test code refactor 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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 static_cast<FakeClientPictureCache*>(host->client_picture_cache()); 88 static_cast<FakeClientPictureCache*>(host->client_picture_cache());
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(inputs_.nearest_neighbor, layer->inputs_.nearest_neighbor); 97 EXPECT_EQ(inputs_.nearest_neighbor, layer->inputs_.nearest_neighbor);
98 EXPECT_EQ(inputs_.recorded_viewport, layer->inputs_.recorded_viewport);
99
100 // The DisplayItemLists are equal if they are both null or they are both not
101 // null and render to the same thing.
102 bool display_lists_equal =
103 !inputs_.display_list && !layer->inputs_.display_list;
104 if (inputs_.display_list && layer->inputs_.display_list) {
105 display_lists_equal = AreDisplayListDrawingResultsSame(
106 inputs_.recorded_viewport, inputs_.display_list.get(),
107 layer->inputs_.display_list.get());
108 }
109 EXPECT_EQ(display_lists_equal, true);
vmpstr 2016/07/27 18:18:37 EXPECT_TRUE(dispay_lists_equal)
Menglin 2016/07/29 23:50:14 Done.
98 } 110 }
99 111
100 std::vector<uint32_t> GetPictureIds() { 112 std::vector<uint32_t> GetPictureIds() {
101 std::vector<uint32_t> ids; 113 std::vector<uint32_t> ids;
102 const DisplayItemList* display_list = 114 const DisplayItemList* display_list = inputs_.display_list.get();
103 recording_source()->GetDisplayItemList();
104 if (!display_list) 115 if (!display_list)
105 return ids; 116 return ids;
106 117
107 for (auto it = display_list->begin(); it != display_list->end(); ++it) { 118 for (auto it = display_list->begin(); it != display_list->end(); ++it) {
108 sk_sp<const SkPicture> picture = it->GetPicture(); 119 sk_sp<const SkPicture> picture = it->GetPicture();
109 if (!picture) 120 if (!picture)
110 continue; 121 continue;
111 122
112 ids.push_back(picture->uniqueID()); 123 ids.push_back(picture->uniqueID());
113 } 124 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 FakeLayerTreeHostClient host_client; 448 FakeLayerTreeHostClient host_client;
438 TestTaskGraphRunner task_graph_runner; 449 TestTaskGraphRunner task_graph_runner;
439 std::unique_ptr<FakeLayerTreeHost> host = 450 std::unique_ptr<FakeLayerTreeHost> host =
440 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); 451 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
441 host->SetRootLayer(layer); 452 host->SetRootLayer(layer);
442 453
443 // Update layers to initialize the recording source. 454 // Update layers to initialize the recording source.
444 gfx::Size layer_bounds(200, 200); 455 gfx::Size layer_bounds(200, 200);
445 gfx::Rect layer_rect(layer_bounds); 456 gfx::Rect layer_rect(layer_bounds);
446 Region invalidation(layer_rect); 457 Region invalidation(layer_rect);
458
459 gfx::Rect new_recorded_viewport = client->PaintableRegion();
460 scoped_refptr<DisplayItemList> display_list =
461 client->PaintContentsToDisplayList(
462 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
463 size_t painter_reported_memory_usage =
464 client->GetApproximateUnsharedMemoryUsage();
447 recording_source->UpdateAndExpandInvalidation( 465 recording_source->UpdateAndExpandInvalidation(
448 client, &invalidation, layer_bounds, 1, RecordingSource::RECORD_NORMALLY); 466 client, &invalidation, layer_bounds, new_recorded_viewport, display_list,
467 painter_reported_memory_usage);
449 468
450 // Layer is suitable for gpu rasterization by default. 469 // Layer is suitable for gpu rasterization by default.
451 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization());
452 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); 470 EXPECT_TRUE(layer->IsSuitableForGpuRasterization());
453 471
454 // Veto gpu rasterization. 472 // Veto gpu rasterization.
455 recording_source->SetForceUnsuitableForGpuRasterization(true); 473 layer->SetForceUnsuitableForGpuRasterization(true);
456 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization());
457 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); 474 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
458 } 475 }
459 476
460 // PicturePile uses the source frame number as a unit for measuring invalidation 477 // PicturePile uses the source frame number as a unit for measuring invalidation
461 // frequency. When a pile moves between compositors, the frame number increases 478 // frequency. When a pile moves between compositors, the frame number increases
462 // non-monotonically. This executes that code path under this scenario allowing 479 // non-monotonically. This executes that code path under this scenario allowing
463 // for the code to verify correctness with DCHECKs. 480 // for the code to verify correctness with DCHECKs.
464 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { 481 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) {
465 LayerTreeSettings settings; 482 LayerTreeSettings settings;
466 settings.single_thread_proxy_scheduler = false; 483 settings.single_thread_proxy_scheduler = false;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // Do a main frame, record the picture layers. The frame number has changed 543 // Do a main frame, record the picture layers. The frame number has changed
527 // non-monotonically. 544 // non-monotonically.
528 layer->SetNeedsDisplay(); 545 layer->SetNeedsDisplay();
529 host2->Composite(base::TimeTicks::Now()); 546 host2->Composite(base::TimeTicks::Now());
530 EXPECT_EQ(3, layer->update_count()); 547 EXPECT_EQ(3, layer->update_count());
531 EXPECT_EQ(1, host2->source_frame_number()); 548 EXPECT_EQ(1, host2->source_frame_number());
532 } 549 }
533 550
534 } // namespace 551 } // namespace
535 } // namespace cc 552 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698