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

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

Issue 22469002: cc: Fix aborted commits with evicted textures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix animation test Created 7 years, 4 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
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/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
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->SetScrollable(true);
4228 root_layer->SetBounds(gfx::Size(200, 200));
4229 root_layer->SetMaxScrollOffset(gfx::Vector2d(100, 100));
4230 root_layer->SetIsDrawable(true);
4231
4232 layer_tree_host()->SetRootLayer(root_layer);
4233 LayerTreeHostTest::SetupTree();
4234 }
4235
4236 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4237
4238 virtual void WillBeginFrame() OVERRIDE {
4239 num_will_begin_frames_++;
4240 switch (num_will_begin_frames_) {
4241 case 2:
4242 // Send a redraw to the compositor thread. This will (wrongly) be
4243 // ignored unless aborting resets the texture state.
4244 layer_tree_host()->SetNeedsRedraw();
4245 break;
4246 }
4247 }
4248
4249 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE {
4250 num_impl_commits_++;
4251 }
4252
4253 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
4254 switch (impl->SourceAnimationFrameNumber()) {
4255 case 1:
4256 // Trigger an abortable commit.
4257 impl->active_tree()->root_layer()->ScrollBy(gfx::Vector2d(1, 1));
4258 // Prevent draws until that commit.
4259 impl->active_tree()->SetContentsTexturesPurged();
4260 EXPECT_FALSE(impl->CanDraw());
4261 impl->SetNeedsCommit();
4262 break;
4263 case 2:
4264 EndTest();
4265 break;
4266 }
4267 }
4268
4269 virtual void AfterTest() OVERRIDE {
4270 // Ensure that the commit was truly aborted.
4271 EXPECT_EQ(2, num_will_begin_frames_);
4272 EXPECT_EQ(1, num_impl_commits_);
4273 }
4274
4275 private:
4276 int num_will_begin_frames_;
4277 int num_impl_commits_;
4278 };
4279
4280 // Commits can only be aborted when using the thread proxy.
4281 MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
4282
4219 } // namespace 4283 } // namespace
4284
4220 } // namespace cc 4285 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698