OLD | NEW |
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 Loading... |
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 |
OLD | NEW |