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 6093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6104 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); | 6104 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); |
6105 host_impl_->SetMemoryPolicy(policy2, false); | 6105 host_impl_->SetMemoryPolicy(policy2, false); |
6106 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); | 6106 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); |
6107 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6107 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
6108 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); | 6108 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); |
6109 host_impl_->SetVisible(false); | 6109 host_impl_->SetVisible(false); |
6110 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); | 6110 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); |
6111 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); | 6111 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); |
6112 } | 6112 } |
6113 | 6113 |
| 6114 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 6115 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6116 TestWebGraphicsContext3D::Create(); |
| 6117 TestWebGraphicsContext3D* context3d = context.get(); |
| 6118 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d( |
| 6119 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 6120 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6121 |
| 6122 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6123 |
| 6124 UIResourceId ui_resource_id = 1; |
| 6125 scoped_refptr<UIResourceBitmap> bitmap = |
| 6126 UIResourceBitmap::Create(new uint8_t[1], |
| 6127 UIResourceBitmap::RGBA8, |
| 6128 gfx::Size(1, 1)); |
| 6129 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6130 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6131 ResourceProvider::ResourceId id = |
| 6132 host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 6133 EXPECT_NE(0u, id); |
| 6134 EXPECT_EQ(ResourceProvider::GLTexture, |
| 6135 host_impl_->resource_provider()->GetResourceType(id)); |
| 6136 |
| 6137 // Should return zero for invalid UIResourceId. Number of textures should |
| 6138 // not change. |
| 6139 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1)); |
| 6140 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6141 |
| 6142 host_impl_->DeleteUIResource(ui_resource_id); |
| 6143 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
| 6144 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6145 |
| 6146 // Should not change state for multiple deletion on one UIResourceId |
| 6147 host_impl_->DeleteUIResource(ui_resource_id); |
| 6148 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6149 } |
| 6150 |
6114 } // namespace | 6151 } // namespace |
6115 } // namespace cc | 6152 } // namespace cc |
OLD | NEW |