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

Side by Side 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, 3 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 6296 matching lines...) Expand 10 before | Expand all | Expand 10 after
6307 6307
6308 host_impl_->DeleteUIResource(ui_resource_id); 6308 host_impl_->DeleteUIResource(ui_resource_id);
6309 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6309 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6310 EXPECT_EQ(0u, context3d->NumTextures()); 6310 EXPECT_EQ(0u, context3d->NumTextures());
6311 6311
6312 // Should not change state for multiple deletion on one UIResourceId 6312 // Should not change state for multiple deletion on one UIResourceId
6313 host_impl_->DeleteUIResource(ui_resource_id); 6313 host_impl_->DeleteUIResource(ui_resource_id);
6314 EXPECT_EQ(0u, context3d->NumTextures()); 6314 EXPECT_EQ(0u, context3d->NumTextures());
6315 } 6315 }
6316 6316
6317 TEST_F(LayerTreeHostImplTest, EvictUIResourceWhenNotVisible) {
6318 scoped_ptr<TestWebGraphicsContext3D> context =
6319 TestWebGraphicsContext3D::Create();
6320 TestWebGraphicsContext3D* context3d = context.get();
6321 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface();
6322 host_impl_->InitializeRenderer(output_surface.Pass());
6323
6324 scoped_ptr<LayerImpl> scoped_root =
6325 LayerImpl::Create(host_impl_->active_tree(), 1);
6326 host_impl_->active_tree()->SetRootLayer(scoped_root.Pass());
6327
6328 EXPECT_EQ(0u, context3d->NumTextures());
6329
6330 UIResourceId uid1 = 1;
6331 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create(
6332 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1));
6333 host_impl_->CreateUIResource(uid1, bitmap);
6334 EXPECT_EQ(1u, context3d->NumTextures());
6335 ResourceProvider::ResourceId id1 = host_impl_->ResourceIdForUIResource(uid1);
6336 EXPECT_NE(0u, id1);
6337
6338 UIResourceId uid2 = 2;
6339 host_impl_->CreateUIResource(uid2, bitmap);
6340 ResourceProvider::ResourceId id2 = host_impl_->ResourceIdForUIResource(uid2);
6341 EXPECT_NE(0u, id2);
6342 EXPECT_NE(id1, id2);
6343 EXPECT_EQ(2u, context3d->NumTextures());
6344
6345 EXPECT_TRUE(host_impl_->CanDraw());
6346
6347 host_impl_->SetVisible(false);
6348 EXPECT_EQ(0u, context3d->NumTextures());
6349 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid1));
6350 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid2));
6351
6352 EXPECT_FALSE(host_impl_->CanDraw());
6353 }
6354
6317 } // namespace 6355 } // namespace
6318 } // namespace cc 6356 } // namespace cc
OLDNEW
« 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