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

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

Issue 1349913002: Cache gpu suitability in DisplayItemList, remove SetUnsuitable...ForTesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Needs more nullptr Created 5 years, 3 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 "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/layers/content_layer_client.h" 8 #include "cc/layers/content_layer_client.h"
9 #include "cc/layers/picture_layer_impl.h" 9 #include "cc/layers/picture_layer_impl.h"
10 #include "cc/playback/display_item_list_settings.h" 10 #include "cc/playback/display_item_list_settings.h"
11 #include "cc/test/fake_display_list_recording_source.h"
11 #include "cc/test/fake_layer_tree_host.h" 12 #include "cc/test/fake_layer_tree_host.h"
12 #include "cc/test/fake_picture_layer.h" 13 #include "cc/test/fake_picture_layer.h"
13 #include "cc/test/fake_picture_layer_impl.h" 14 #include "cc/test/fake_picture_layer_impl.h"
14 #include "cc/test/fake_proxy.h" 15 #include "cc/test/fake_proxy.h"
15 #include "cc/test/test_shared_bitmap_manager.h" 16 #include "cc/test/test_shared_bitmap_manager.h"
16 #include "cc/test/test_task_graph_runner.h" 17 #include "cc/test/test_task_graph_runner.h"
17 #include "cc/trees/single_thread_proxy.h" 18 #include "cc/trees/single_thread_proxy.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace cc { 21 namespace cc {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 72
72 layer->PushPropertiesTo(layer_impl.get()); 73 layer->PushPropertiesTo(layer_impl.get());
73 EXPECT_FALSE(layer_impl->CanHaveTilings()); 74 EXPECT_FALSE(layer_impl->CanHaveTilings());
74 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); 75 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0));
75 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize()); 76 EXPECT_EQ(gfx::Size(), layer_impl->raster_source()->GetSize());
76 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings()); 77 EXPECT_FALSE(layer_impl->raster_source()->HasRecordings());
77 } 78 }
78 } 79 }
79 80
80 TEST(PictureLayerTest, SuitableForGpuRasterization) { 81 TEST(PictureLayerTest, SuitableForGpuRasterization) {
82 scoped_ptr<FakeDisplayListRecordingSource> recording_source_owned(
83 new FakeDisplayListRecordingSource(gfx::Size(100, 100)));
84 FakeDisplayListRecordingSource* recording_source =
85 recording_source_owned.get();
86
81 MockContentLayerClient client; 87 MockContentLayerClient client;
82 scoped_refptr<PictureLayer> layer = 88 scoped_refptr<FakePictureLayer> layer =
83 PictureLayer::Create(LayerSettings(), &client); 89 FakePictureLayer::CreateWithRecordingSource(
90 LayerSettings(), &client, recording_source_owned.Pass());
91
84 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); 92 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D);
85 TestTaskGraphRunner task_graph_runner; 93 TestTaskGraphRunner task_graph_runner;
86 scoped_ptr<FakeLayerTreeHost> host = 94 scoped_ptr<FakeLayerTreeHost> host =
87 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); 95 FakeLayerTreeHost::Create(&host_client, &task_graph_runner);
88 host->SetRootLayer(layer); 96 host->SetRootLayer(layer);
89 RecordingSource* recording_source = layer->GetRecordingSourceForTesting(); 97
98 // Update layers to initialize the recording source.
99 gfx::Size layer_bounds(200, 200);
100 gfx::Rect layer_rect(layer_bounds);
101 Region invalidation(layer_rect);
102 recording_source->UpdateAndExpandInvalidation(
103 &client, &invalidation, layer_bounds, layer_rect, 1,
104 RecordingSource::RECORD_NORMALLY);
90 105
91 // Layer is suitable for gpu rasterization by default. 106 // Layer is suitable for gpu rasterization by default.
92 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization()); 107 EXPECT_TRUE(recording_source->IsSuitableForGpuRasterization());
93 EXPECT_TRUE(layer->IsSuitableForGpuRasterization()); 108 EXPECT_TRUE(layer->IsSuitableForGpuRasterization());
94 109
95 // Veto gpu rasterization. 110 // Veto gpu rasterization.
96 recording_source->SetUnsuitableForGpuRasterizationForTesting(); 111 recording_source->SetUnsuitableForGpuRasterization();
97 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization()); 112 EXPECT_FALSE(recording_source->IsSuitableForGpuRasterization());
98 EXPECT_FALSE(layer->IsSuitableForGpuRasterization()); 113 EXPECT_FALSE(layer->IsSuitableForGpuRasterization());
99 } 114 }
100 115
101 // PicturePile uses the source frame number as a unit for measuring invalidation 116 // PicturePile uses the source frame number as a unit for measuring invalidation
102 // frequency. When a pile moves between compositors, the frame number increases 117 // frequency. When a pile moves between compositors, the frame number increases
103 // non-monotonically. This executes that code path under this scenario allowing 118 // non-monotonically. This executes that code path under this scenario allowing
104 // for the code to verify correctness with DCHECKs. 119 // for the code to verify correctness with DCHECKs.
105 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) { 120 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) {
106 LayerTreeSettings settings; 121 LayerTreeSettings settings;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Do a main frame, record the picture layers. The frame number has changed 168 // Do a main frame, record the picture layers. The frame number has changed
154 // non-monotonically. 169 // non-monotonically.
155 layer->SetNeedsDisplay(); 170 layer->SetNeedsDisplay();
156 host2->Composite(base::TimeTicks::Now()); 171 host2->Composite(base::TimeTicks::Now());
157 EXPECT_EQ(3, layer->update_count()); 172 EXPECT_EQ(3, layer->update_count());
158 EXPECT_EQ(1, host2->source_frame_number()); 173 EXPECT_EQ(1, host2->source_frame_number());
159 } 174 }
160 175
161 } // namespace 176 } // namespace
162 } // namespace cc 177 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/playback/display_item_list.h » ('j') | cc/playback/display_list_recording_source.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698