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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | 258 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
259 host_impl_->DidDrawAllLayers(frame); | 259 host_impl_->DidDrawAllLayers(frame); |
260 } | 260 } |
261 | 261 |
262 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 262 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
263 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 263 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
264 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 264 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
265 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 265 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
266 float device_scale_factor); | 266 float device_scale_factor); |
267 | 267 |
| 268 virtual void UIResourceLostOnImplThread(UIResourceId uid) OVERRIDE {} |
| 269 |
268 protected: | 270 protected: |
269 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { | 271 virtual scoped_ptr<OutputSurface> CreateOutputSurface() { |
270 return CreateFakeOutputSurface(); | 272 return CreateFakeOutputSurface(); |
271 } | 273 } |
272 | 274 |
273 void DrawOneFrame() { | 275 void DrawOneFrame() { |
274 LayerTreeHostImpl::FrameData frame_data; | 276 LayerTreeHostImpl::FrameData frame_data; |
275 host_impl_->PrepareToDraw(&frame_data, gfx::Rect()); | 277 host_impl_->PrepareToDraw(&frame_data, gfx::Rect()); |
276 host_impl_->DidDrawAllLayers(frame_data); | 278 host_impl_->DidDrawAllLayers(frame_data); |
277 } | 279 } |
(...skipping 5826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6104 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); | 6106 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); |
6105 host_impl_->SetMemoryPolicy(policy2, false); | 6107 host_impl_->SetMemoryPolicy(policy2, false); |
6106 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); | 6108 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); |
6107 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6109 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
6108 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); | 6110 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); |
6109 host_impl_->SetVisible(false); | 6111 host_impl_->SetVisible(false); |
6110 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); | 6112 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); |
6111 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); | 6113 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); |
6112 } | 6114 } |
6113 | 6115 |
| 6116 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 6117 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6118 TestWebGraphicsContext3D::Create(); |
| 6119 TestWebGraphicsContext3D* context3d = context.get(); |
| 6120 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d( |
| 6121 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 6122 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6123 |
| 6124 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6125 |
| 6126 UIResourceId ui_resource_id = 1; |
| 6127 scoped_refptr<UIResourceBitmap> bitmap = |
| 6128 UIResourceBitmap::Create(new uint8_t[1], |
| 6129 UIResourceBitmap::RGBA8, |
| 6130 gfx::Size(1, 1)); |
| 6131 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6132 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6133 ResourceProvider::ResourceId id = |
| 6134 host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 6135 EXPECT_NE(0u, id); |
| 6136 EXPECT_EQ(ResourceProvider::GLTexture, |
| 6137 host_impl_->resource_provider()->GetResourceType(id)); |
| 6138 |
| 6139 // Should return zero for invalid UIResourceId. Number of textures should |
| 6140 // not change. |
| 6141 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1)); |
| 6142 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6143 |
| 6144 host_impl_->DeleteUIResource(ui_resource_id); |
| 6145 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
| 6146 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6147 |
| 6148 // Should not change state for multiple deletion on one UIResourceId |
| 6149 host_impl_->DeleteUIResource(ui_resource_id); |
| 6150 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6151 } |
| 6152 |
6114 } // namespace | 6153 } // namespace |
6115 } // namespace cc | 6154 } // namespace cc |
OLD | NEW |