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

Unified 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: Remove unneeded scrolling from 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/prioritized_resource_manager.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 44a1c942a01a071d7b2541de7ec5443e19d3274b..67411aa4468b5b5a26c04d65cb15c8292294fe01 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -4216,5 +4216,67 @@ class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest {
MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport);
+class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest {
+ public:
+ LayerTreeHostTestAbortEvictedTextures()
+ : num_will_begin_frames_(0), num_impl_commits_(0) {}
+
+ protected:
+ virtual void SetupTree() OVERRIDE {
+ scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create();
+ root_layer->SetBounds(gfx::Size(200, 200));
+ root_layer->SetIsDrawable(true);
+
+ layer_tree_host()->SetRootLayer(root_layer);
+ LayerTreeHostTest::SetupTree();
+ }
+
+ virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
+
+ virtual void WillBeginFrame() OVERRIDE {
+ num_will_begin_frames_++;
+ switch (num_will_begin_frames_) {
+ case 2:
+ // Send a redraw to the compositor thread. This will (wrongly) be
+ // ignored unless aborting resets the texture state.
+ layer_tree_host()->SetNeedsRedraw();
+ break;
+ }
+ }
+
+ virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ num_impl_commits_++;
+ }
+
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
+ switch (impl->SourceAnimationFrameNumber()) {
+ case 1:
+ // Prevent draws until commit.
+ impl->active_tree()->SetContentsTexturesPurged();
+ EXPECT_FALSE(impl->CanDraw());
+ // Trigger an abortable commit.
+ impl->SetNeedsCommit();
+ break;
+ case 2:
+ EndTest();
+ break;
+ }
+ }
+
+ virtual void AfterTest() OVERRIDE {
+ // Ensure that the commit was truly aborted.
+ EXPECT_EQ(2, num_will_begin_frames_);
+ EXPECT_EQ(1, num_impl_commits_);
+ }
+
+ private:
+ int num_will_begin_frames_;
+ int num_impl_commits_;
+};
+
+// Commits can only be aborted when using the thread proxy.
+MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures);
+
} // namespace
+
} // namespace cc
« no previous file with comments | « cc/resources/prioritized_resource_manager.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698