OLD | NEW |
---|---|
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/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4174 } | 4174 } |
4175 | 4175 |
4176 virtual void AfterTest() OVERRIDE {} | 4176 virtual void AfterTest() OVERRIDE {} |
4177 | 4177 |
4178 FakeContentLayerClient client_; | 4178 FakeContentLayerClient client_; |
4179 scoped_refptr<FakePictureLayer> root_layer_; | 4179 scoped_refptr<FakePictureLayer> root_layer_; |
4180 }; | 4180 }; |
4181 | 4181 |
4182 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); | 4182 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); |
4183 | 4183 |
4184 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { | |
4185 public: | |
4186 LayerTreeHostTestAbortEvictedTextures() | |
4187 : num_will_begin_frames_(0), num_impl_commits_(0) {} | |
4188 | |
4189 protected: | |
4190 virtual void SetupTree() OVERRIDE { | |
4191 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); | |
4192 root_layer->SetScrollable(true); | |
4193 root_layer->SetBounds(gfx::Size(200, 200)); | |
4194 root_layer->SetMaxScrollOffset(gfx::Vector2d(100, 100)); | |
4195 root_layer->SetIsDrawable(true); | |
4196 | |
4197 layer_tree_host()->SetRootLayer(root_layer); | |
4198 LayerTreeHostTest::SetupTree(); | |
4199 } | |
4200 | |
4201 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | |
4202 | |
4203 virtual void WillBeginFrame() OVERRIDE { | |
4204 num_will_begin_frames_++; | |
4205 switch (num_will_begin_frames_) { | |
4206 case 2: | |
4207 // Send a redraw to the compositor thread. This will (wrongly) be | |
4208 // ignored unless aborting resets the texture state. | |
4209 PostSetNeedsRedrawToMainThread(); | |
danakj
2013/08/06 19:36:53
nit: You're on the main thread, you can just LTH->
enne (OOO)
2013/08/06 21:41:21
Done.
| |
4210 break; | |
4211 } | |
4212 } | |
4213 | |
4214 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
4215 num_impl_commits_++; | |
4216 } | |
4217 | |
4218 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
4219 switch (impl->SourceAnimationFrameNumber()) { | |
4220 case 1: | |
4221 // Trigger an abortable commit. | |
4222 impl->active_tree()->root_layer()->ScrollBy(gfx::Vector2d(1, 1)); | |
4223 // Prevent draws until that commit. | |
4224 impl->active_tree()->SetContentsTexturesPurged(); | |
4225 EXPECT_FALSE(impl->CanDraw()); | |
4226 impl->SetNeedsCommit(); | |
danakj
2013/08/06 19:36:53
why? didn't scrollby do this?
enne (OOO)
2013/08/06 21:41:21
Maybe it should, but it doesn't. This normally ge
| |
4227 break; | |
4228 case 2: | |
4229 EndTest(); | |
4230 break; | |
4231 } | |
4232 } | |
4233 | |
4234 virtual void AfterTest() OVERRIDE { | |
4235 // Ensure that the commit was truly aborted. | |
4236 EXPECT_EQ(2, num_will_begin_frames_); | |
4237 EXPECT_EQ(1, num_impl_commits_); | |
4238 } | |
4239 | |
4240 private: | |
4241 int num_will_begin_frames_; | |
4242 int num_impl_commits_; | |
4243 }; | |
4244 | |
4245 // Commits can only be aborted when using the thread proxy. | |
4246 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); | |
4247 | |
4184 } // namespace | 4248 } // namespace |
4249 | |
danakj
2013/08/06 19:36:53
?
enne (OOO)
2013/08/06 21:41:21
Presubmit style.
| |
4185 } // namespace cc | 4250 } // namespace cc |
OLD | NEW |