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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 16896017: Add a hide_layer_and_subtree() flag to cc::Layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hide-subtree-flag: SetIsDrawable on the new cc_layer Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | ui/compositor/layer.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 EXPECT_LE(1, num_draws_); 154 EXPECT_LE(1, num_draws_);
155 } 155 }
156 156
157 private: 157 private:
158 int num_commits_; 158 int num_commits_;
159 int num_draws_; 159 int num_draws_;
160 }; 160 };
161 161
162 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2); 162 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2);
163 163
164 // Verify that we pass property values in PushPropertiesTo.
165 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
166 protected:
167 virtual void SetupTree() OVERRIDE {
168 scoped_refptr<Layer> root = Layer::Create();
169 root->SetBounds(gfx::Size(10, 10));
170 layer_tree_host()->SetRootLayer(root);
171 LayerTreeHostTest::SetupTree();
172 }
173
174 enum Properties {
175 STARTUP,
176 BOUNDS,
177 HIDE_LAYER_AND_SUBTREE,
178 DRAWS_CONTENT,
179 DONE,
180 };
181
182 virtual void BeginTest() OVERRIDE {
183 index_ = STARTUP;
184 PostSetNeedsCommitToMainThread();
185 }
186
187 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
188 VerifyAfterValues(impl->active_tree()->root_layer());
189 }
190
191 virtual void DidCommitAndDrawFrame() OVERRIDE {
192 SetBeforeValues(layer_tree_host()->root_layer());
193 VerifyBeforeValues(layer_tree_host()->root_layer());
194
195 ++index_;
196 if (index_ == DONE) {
197 EndTest();
198 return;
199 }
200
201 SetAfterValues(layer_tree_host()->root_layer());
202 }
203
204 virtual void AfterTest() OVERRIDE {}
205
206 void VerifyBeforeValues(Layer* layer) {
207 EXPECT_EQ(gfx::Size(10, 10).ToString(), layer->bounds().ToString());
208 EXPECT_FALSE(layer->hide_layer_and_subtree());
209 EXPECT_FALSE(layer->DrawsContent());
210 }
211
212 void SetBeforeValues(Layer* layer) {
213 layer->SetBounds(gfx::Size(10, 10));
214 layer->SetHideLayerAndSubtree(false);
215 layer->SetIsDrawable(false);
216 }
217
218 void VerifyAfterValues(LayerImpl* layer) {
219 switch (static_cast<Properties>(index_)) {
220 case STARTUP:
221 case DONE:
222 break;
223 case BOUNDS:
224 EXPECT_EQ(gfx::Size(20, 20).ToString(), layer->bounds().ToString());
225 break;
226 case HIDE_LAYER_AND_SUBTREE:
227 EXPECT_TRUE(layer->hide_layer_and_subtree());
228 break;
229 case DRAWS_CONTENT:
230 EXPECT_TRUE(layer->DrawsContent());
231 break;
232 }
233 }
234
235 void SetAfterValues(Layer* layer) {
236 switch (static_cast<Properties>(index_)) {
237 case STARTUP:
238 case DONE:
239 break;
240 case BOUNDS:
241 layer->SetBounds(gfx::Size(20, 20));
242 break;
243 case HIDE_LAYER_AND_SUBTREE:
244 layer->SetHideLayerAndSubtree(true);
245 break;
246 case DRAWS_CONTENT:
247 layer->SetIsDrawable(true);
248 break;
249 }
250 }
251
252 int index_;
253 };
254
255 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo);
256
164 // 1 setNeedsRedraw after the first commit has completed should lead to 1 257 // 1 setNeedsRedraw after the first commit has completed should lead to 1
165 // additional draw. 258 // additional draw.
166 class LayerTreeHostTestSetNeedsRedraw : public LayerTreeHostTest { 259 class LayerTreeHostTestSetNeedsRedraw : public LayerTreeHostTest {
167 public: 260 public:
168 LayerTreeHostTestSetNeedsRedraw() : num_commits_(0), num_draws_(0) {} 261 LayerTreeHostTestSetNeedsRedraw() : num_commits_(0), num_draws_(0) {}
169 262
170 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 263 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
171 264
172 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 265 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
173 EXPECT_EQ(0, impl->active_tree()->source_frame_number()); 266 EXPECT_EQ(0, impl->active_tree()->source_frame_number());
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 private: 2951 private:
2859 FakeContentLayerClient client_; 2952 FakeContentLayerClient client_;
2860 scoped_refptr<FakePictureLayer> layer_; 2953 scoped_refptr<FakePictureLayer> layer_;
2861 bool initialized_gl_; 2954 bool initialized_gl_;
2862 }; 2955 };
2863 2956
2864 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize); 2957 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitialize);
2865 2958
2866 } // namespace 2959 } // namespace
2867 } // namespace cc 2960 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | ui/compositor/layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698