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

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

Issue 959003002: cc: Clear the invalidation history when moving between compositors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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.cc ('k') | cc/resources/display_list_recording_source.h » ('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 "cc/layers/content_layer_client.h" 7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/picture_layer_impl.h" 8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/resources/resource_update_queue.h" 9 #include "cc/resources/resource_update_queue.h"
10 #include "cc/test/fake_layer_tree_host.h" 10 #include "cc/test/fake_layer_tree_host.h"
11 #include "cc/test/fake_picture_layer.h"
11 #include "cc/test/fake_picture_layer_impl.h" 12 #include "cc/test/fake_picture_layer_impl.h"
12 #include "cc/test/fake_proxy.h" 13 #include "cc/test/fake_proxy.h"
13 #include "cc/test/impl_side_painting_settings.h" 14 #include "cc/test/impl_side_painting_settings.h"
14 #include "cc/trees/occlusion_tracker.h" 15 #include "cc/trees/occlusion_tracker.h"
15 #include "cc/trees/single_thread_proxy.h" 16 #include "cc/trees/single_thread_proxy.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 namespace cc { 19 namespace cc {
19 namespace { 20 namespace {
20 21
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 FakeLayerTreeHost::Create(&host_client, settings); 105 FakeLayerTreeHost::Create(&host_client, settings);
105 host->SetRootLayer(layer); 106 host->SetRootLayer(layer);
106 107
107 // Tile-grid is set according to its setting. 108 // Tile-grid is set according to its setting.
108 gfx::Size size = 109 gfx::Size size =
109 layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting(); 110 layer->GetRecordingSourceForTesting()->GetTileGridSizeForTesting();
110 EXPECT_EQ(size.width(), 123); 111 EXPECT_EQ(size.width(), 123);
111 EXPECT_EQ(size.height(), 123); 112 EXPECT_EQ(size.height(), 123);
112 } 113 }
113 114
115 TEST(PictureLayerTest, NonMonotonicSourceFrameNumber) {
enne (OOO) 2015/02/26 20:46:04 How would this fail before the change?
danakj 2015/02/26 21:10:23 It would DCHECK.
danakj 2015/02/26 21:17:25 Added comment.
116 LayerTreeSettings settings;
117 settings.single_thread_proxy_scheduler = false;
118
119 FakeLayerTreeHostClient host_client1(FakeLayerTreeHostClient::DIRECT_3D);
120 FakeLayerTreeHostClient host_client2(FakeLayerTreeHostClient::DIRECT_3D);
121 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
122 new TestSharedBitmapManager());
123
124 MockContentLayerClient client;
125 scoped_refptr<FakePictureLayer> layer = FakePictureLayer::Create(&client);
126
127 scoped_ptr<LayerTreeHost> host1 = LayerTreeHost::CreateSingleThreaded(
128 &host_client1, &host_client1, shared_bitmap_manager.get(), nullptr,
129 settings, base::MessageLoopProxy::current(), nullptr);
130 host_client1.SetLayerTreeHost(host1.get());
131
132 scoped_ptr<LayerTreeHost> host2 = LayerTreeHost::CreateSingleThreaded(
133 &host_client2, &host_client2, shared_bitmap_manager.get(), nullptr,
134 settings, base::MessageLoopProxy::current(), nullptr);
135 host_client2.SetLayerTreeHost(host2.get());
136
137 // The PictureLayer is put in one LayerTreeHost.
138 host1->SetRootLayer(layer);
139 // Do a main frame, record the picture layers.
140 EXPECT_EQ(0u, layer->update_count());
141 layer->SetNeedsDisplay();
142 host1->Composite(base::TimeTicks::Now());
143 EXPECT_EQ(1u, layer->update_count());
144 EXPECT_EQ(1, host1->source_frame_number());
145
146 // The source frame number in |host1| is now higher than host2.
147 layer->SetNeedsDisplay();
148 host1->Composite(base::TimeTicks::Now());
149 EXPECT_EQ(2u, layer->update_count());
150 EXPECT_EQ(2, host1->source_frame_number());
151
152 // Then moved to another LayerTreeHost.
153 host1->SetRootLayer(nullptr);
154 host2->SetRootLayer(layer);
155
156 // Do a main frame, record the picture layers. The frame number has changed
157 // non-monotonically.
158 layer->SetNeedsDisplay();
159 host2->Composite(base::TimeTicks::Now());
160 EXPECT_EQ(3u, layer->update_count());
161 EXPECT_EQ(1, host2->source_frame_number());
162 }
163
114 } // namespace 164 } // namespace
115 } // namespace cc 165 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/resources/display_list_recording_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698