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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 23478004: UI resource are evicted when LTH is set to not visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CanDraw returns false when UI resources are evicted 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 98f48668fa557eb5ded6e57117847a16cb1f7757..8f5e0f82b7553b91c096afa0346ebec9a8b0740a 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6314,5 +6314,43 @@ TEST_F(LayerTreeHostImplTest, UIResourceManagement) {
EXPECT_EQ(0u, context3d->NumTextures());
}
+TEST_F(LayerTreeHostImplTest, EvictUIResourceWhenNotVisible) {
+ scoped_ptr<TestWebGraphicsContext3D> context =
+ TestWebGraphicsContext3D::Create();
+ TestWebGraphicsContext3D* context3d = context.get();
+ scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
+ host_impl_->InitializeRenderer(output_surface.Pass());
+
+ scoped_ptr<LayerImpl> scoped_root =
+ LayerImpl::Create(host_impl_->active_tree(), 1);
+ host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
+
+ EXPECT_EQ(0u, context3d->NumTextures());
+
+ UIResourceId uid1 = 1;
+ scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create(
+ new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1));
+ host_impl_->CreateUIResource(uid1, bitmap);
+ EXPECT_EQ(1u, context3d->NumTextures());
+ ResourceProvider::ResourceId id1 = host_impl_->ResourceIdForUIResource(uid1);
+ EXPECT_NE(0u, id1);
+
+ UIResourceId uid2 = 2;
+ host_impl_->CreateUIResource(uid2, bitmap);
+ ResourceProvider::ResourceId id2 = host_impl_->ResourceIdForUIResource(uid2);
+ EXPECT_NE(0u, id2);
+ EXPECT_NE(id1, id2);
+ EXPECT_EQ(2u, context3d->NumTextures());
+
+ EXPECT_TRUE(host_impl_->CanDraw());
+
+ host_impl_->SetVisible(false);
+ EXPECT_EQ(0u, context3d->NumTextures());
+ EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid1));
+ EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid2));
+
+ EXPECT_FALSE(host_impl_->CanDraw());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698