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

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: 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
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..20bd2a948dd427d29017a93b5b62321da4f4b537 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6314,5 +6314,35 @@ 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());
+
+ 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());
+
+ host_impl_->SetVisible(false);
+ EXPECT_EQ(0u, context3d->NumTextures());
+ EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid1));
+ EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid2));
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698