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 5805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6083 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); | 6085 0, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING); |
6084 host_impl_->SetMemoryPolicy(policy2, false); | 6086 host_impl_->SetMemoryPolicy(policy2, false); |
6085 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); | 6087 EXPECT_EQ(actual_policy, host_impl_->ActualManagedMemoryPolicy()); |
6086 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6088 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
6087 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); | 6089 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); |
6088 host_impl_->SetVisible(false); | 6090 host_impl_->SetVisible(false); |
6089 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); | 6091 EXPECT_EQ(policy1.bytes_limit_when_not_visible, current_limit_bytes_); |
6090 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); | 6092 EXPECT_EQ(not_visible_cutoff_value, current_priority_cutoff_value_); |
6091 } | 6093 } |
6092 | 6094 |
| 6095 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 6096 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6097 TestWebGraphicsContext3D::Create(); |
| 6098 TestWebGraphicsContext3D* context3d = context.get(); |
| 6099 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d( |
| 6100 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); |
| 6101 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6102 |
| 6103 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6104 |
| 6105 UIResourceId ui_resource_id = 1; |
| 6106 scoped_refptr<UIResourceBitmap> bitmap = |
| 6107 UIResourceBitmap::Create(new uint8_t[1], |
| 6108 UIResourceBitmap::RGBA8, |
| 6109 gfx::Size(1, 1)); |
| 6110 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6111 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6112 ResourceProvider::ResourceId id = |
| 6113 host_impl_->ResourceIdForUIResource(ui_resource_id); |
| 6114 EXPECT_NE(0u, id); |
| 6115 EXPECT_EQ(ResourceProvider::GLTexture, |
| 6116 host_impl_->resource_provider()->GetResourceType(id)); |
| 6117 |
| 6118 // Should return zero for invalid UIResourceId. Number of textures should |
| 6119 // not change. |
| 6120 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(-1)); |
| 6121 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6122 |
| 6123 host_impl_->DeleteUIResource(ui_resource_id); |
| 6124 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
| 6125 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6126 |
| 6127 // Should not change state for multiple deletion on one UIResourceId |
| 6128 host_impl_->DeleteUIResource(ui_resource_id); |
| 6129 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6130 } |
| 6131 |
6093 } // namespace | 6132 } // namespace |
6094 } // namespace cc | 6133 } // namespace cc |
OLD | NEW |