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

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: 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
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 EXPECT_EQ(0u, context3d->NumTextures());
6325
6326 UIResourceId uid1 = 1;
6327 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create(
6328 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1));
6329 host_impl_->CreateUIResource(uid1, bitmap);
6330 EXPECT_EQ(1u, context3d->NumTextures());
6331 ResourceProvider::ResourceId id1 = host_impl_->ResourceIdForUIResource(uid1);
6332 EXPECT_NE(0u, id1);
6333
6334 UIResourceId uid2 = 2;
6335 host_impl_->CreateUIResource(uid2, bitmap);
6336 ResourceProvider::ResourceId id2 = host_impl_->ResourceIdForUIResource(uid2);
6337 EXPECT_NE(0u, id2);
6338 EXPECT_NE(id1, id2);
6339 EXPECT_EQ(2u, context3d->NumTextures());
6340
6341 host_impl_->SetVisible(false);
6342 EXPECT_EQ(0u, context3d->NumTextures());
6343 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid1));
6344 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(uid2));
6345 }
6346
6317 } // namespace 6347 } // namespace
6318 } // namespace cc 6348 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698