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 4198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4209 } | 4209 } |
4210 | 4210 |
4211 virtual void AfterTest() OVERRIDE {} | 4211 virtual void AfterTest() OVERRIDE {} |
4212 | 4212 |
4213 FakeContentLayerClient client_; | 4213 FakeContentLayerClient client_; |
4214 scoped_refptr<FakePictureLayer> root_layer_; | 4214 scoped_refptr<FakePictureLayer> root_layer_; |
4215 }; | 4215 }; |
4216 | 4216 |
4217 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); | 4217 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); |
4218 | 4218 |
| 4219 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { |
| 4220 public: |
| 4221 LayerTreeHostTestAbortEvictedTextures() |
| 4222 : num_will_begin_frames_(0), num_impl_commits_(0) {} |
| 4223 |
| 4224 protected: |
| 4225 virtual void SetupTree() OVERRIDE { |
| 4226 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); |
| 4227 root_layer->SetBounds(gfx::Size(200, 200)); |
| 4228 root_layer->SetIsDrawable(true); |
| 4229 |
| 4230 layer_tree_host()->SetRootLayer(root_layer); |
| 4231 LayerTreeHostTest::SetupTree(); |
| 4232 } |
| 4233 |
| 4234 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 4235 |
| 4236 virtual void WillBeginFrame() OVERRIDE { |
| 4237 num_will_begin_frames_++; |
| 4238 switch (num_will_begin_frames_) { |
| 4239 case 2: |
| 4240 // Send a redraw to the compositor thread. This will (wrongly) be |
| 4241 // ignored unless aborting resets the texture state. |
| 4242 layer_tree_host()->SetNeedsRedraw(); |
| 4243 break; |
| 4244 } |
| 4245 } |
| 4246 |
| 4247 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 4248 num_impl_commits_++; |
| 4249 } |
| 4250 |
| 4251 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 4252 switch (impl->SourceAnimationFrameNumber()) { |
| 4253 case 1: |
| 4254 // Prevent draws until commit. |
| 4255 impl->active_tree()->SetContentsTexturesPurged(); |
| 4256 EXPECT_FALSE(impl->CanDraw()); |
| 4257 // Trigger an abortable commit. |
| 4258 impl->SetNeedsCommit(); |
| 4259 break; |
| 4260 case 2: |
| 4261 EndTest(); |
| 4262 break; |
| 4263 } |
| 4264 } |
| 4265 |
| 4266 virtual void AfterTest() OVERRIDE { |
| 4267 // Ensure that the commit was truly aborted. |
| 4268 EXPECT_EQ(2, num_will_begin_frames_); |
| 4269 EXPECT_EQ(1, num_impl_commits_); |
| 4270 } |
| 4271 |
| 4272 private: |
| 4273 int num_will_begin_frames_; |
| 4274 int num_impl_commits_; |
| 4275 }; |
| 4276 |
| 4277 // Commits can only be aborted when using the thread proxy. |
| 4278 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); |
| 4279 |
4219 } // namespace | 4280 } // namespace |
| 4281 |
4220 } // namespace cc | 4282 } // namespace cc |
OLD | NEW |