Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "cc/test/fake_output_surface.h" | 42 #include "cc/test/fake_output_surface.h" |
| 43 #include "cc/test/fake_output_surface_client.h" | 43 #include "cc/test/fake_output_surface_client.h" |
| 44 #include "cc/test/fake_picture_layer_impl.h" | 44 #include "cc/test/fake_picture_layer_impl.h" |
| 45 #include "cc/test/fake_picture_pile_impl.h" | 45 #include "cc/test/fake_picture_pile_impl.h" |
| 46 #include "cc/test/fake_proxy.h" | 46 #include "cc/test/fake_proxy.h" |
| 47 #include "cc/test/fake_rendering_stats_instrumentation.h" | 47 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| 48 #include "cc/test/fake_video_frame_provider.h" | 48 #include "cc/test/fake_video_frame_provider.h" |
| 49 #include "cc/test/geometry_test_utils.h" | 49 #include "cc/test/geometry_test_utils.h" |
| 50 #include "cc/test/layer_test_common.h" | 50 #include "cc/test/layer_test_common.h" |
| 51 #include "cc/test/render_pass_test_common.h" | 51 #include "cc/test/render_pass_test_common.h" |
| 52 #include "cc/test/test_shared_bitmap_manager.h" | |
| 52 #include "cc/test/test_web_graphics_context_3d.h" | 53 #include "cc/test/test_web_graphics_context_3d.h" |
| 53 #include "cc/trees/layer_tree_impl.h" | 54 #include "cc/trees/layer_tree_impl.h" |
| 54 #include "cc/trees/single_thread_proxy.h" | 55 #include "cc/trees/single_thread_proxy.h" |
| 55 #include "media/base/media.h" | 56 #include "media/base/media.h" |
| 56 #include "testing/gmock/include/gmock/gmock.h" | 57 #include "testing/gmock/include/gmock/gmock.h" |
| 57 #include "testing/gtest/include/gtest/gtest.h" | 58 #include "testing/gtest/include/gtest/gtest.h" |
| 58 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 59 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| 59 #include "ui/gfx/frame_time.h" | 60 #include "ui/gfx/frame_time.h" |
| 60 #include "ui/gfx/rect_conversions.h" | 61 #include "ui/gfx/rect_conversions.h" |
| 61 #include "ui/gfx/size_conversions.h" | 62 #include "ui/gfx/size_conversions.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 OVERRIDE { requested_scrollbar_animation_delay_ = delay; } | 148 OVERRIDE { requested_scrollbar_animation_delay_ = delay; } |
| 148 virtual void DidActivatePendingTree() OVERRIDE {} | 149 virtual void DidActivatePendingTree() OVERRIDE {} |
| 149 virtual void DidManageTiles() OVERRIDE {} | 150 virtual void DidManageTiles() OVERRIDE {} |
| 150 | 151 |
| 151 void set_reduce_memory_result(bool reduce_memory_result) { | 152 void set_reduce_memory_result(bool reduce_memory_result) { |
| 152 reduce_memory_result_ = reduce_memory_result; | 153 reduce_memory_result_ = reduce_memory_result; |
| 153 } | 154 } |
| 154 | 155 |
| 155 bool CreateHostImpl(const LayerTreeSettings& settings, | 156 bool CreateHostImpl(const LayerTreeSettings& settings, |
| 156 scoped_ptr<OutputSurface> output_surface) { | 157 scoped_ptr<OutputSurface> output_surface) { |
| 157 host_impl_ = LayerTreeHostImpl::Create( | 158 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 158 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 159 host_impl_ = LayerTreeHostImpl::Create(settings, |
| 160 this, | |
| 161 &proxy_, | |
| 162 &stats_instrumentation_, | |
| 163 shared_bitmap_manager_.get(), | |
| 164 0); | |
| 159 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); | 165 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); |
| 160 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 166 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 161 return init; | 167 return init; |
| 162 } | 168 } |
| 163 | 169 |
| 164 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 170 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
| 165 root->SetAnchorPoint(gfx::PointF()); | 171 root->SetAnchorPoint(gfx::PointF()); |
| 166 root->SetPosition(gfx::PointF()); | 172 root->SetPosition(gfx::PointF()); |
| 167 root->SetBounds(gfx::Size(10, 10)); | 173 root->SetBounds(gfx::Size(10, 10)); |
| 168 root->SetContentBounds(gfx::Size(10, 10)); | 174 root->SetContentBounds(gfx::Size(10, 10)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 void DrawOneFrame() { | 376 void DrawOneFrame() { |
| 371 LayerTreeHostImpl::FrameData frame_data; | 377 LayerTreeHostImpl::FrameData frame_data; |
| 372 host_impl_->PrepareToDraw(&frame_data, gfx::Rect()); | 378 host_impl_->PrepareToDraw(&frame_data, gfx::Rect()); |
| 373 host_impl_->DidDrawAllLayers(frame_data); | 379 host_impl_->DidDrawAllLayers(frame_data); |
| 374 } | 380 } |
| 375 | 381 |
| 376 FakeProxy proxy_; | 382 FakeProxy proxy_; |
| 377 DebugScopedSetImplThread always_impl_thread_; | 383 DebugScopedSetImplThread always_impl_thread_; |
| 378 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; | 384 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; |
| 379 | 385 |
| 386 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | |
| 380 scoped_ptr<LayerTreeHostImpl> host_impl_; | 387 scoped_ptr<LayerTreeHostImpl> host_impl_; |
| 381 FakeRenderingStatsInstrumentation stats_instrumentation_; | 388 FakeRenderingStatsInstrumentation stats_instrumentation_; |
| 382 bool on_can_draw_state_changed_called_; | 389 bool on_can_draw_state_changed_called_; |
| 383 bool did_notify_ready_to_activate_; | 390 bool did_notify_ready_to_activate_; |
| 384 bool did_request_commit_; | 391 bool did_request_commit_; |
| 385 bool did_request_redraw_; | 392 bool did_request_redraw_; |
| 386 bool did_request_manage_tiles_; | 393 bool did_request_manage_tiles_; |
| 387 bool did_upload_visible_tile_; | 394 bool did_upload_visible_tile_; |
| 388 bool reduce_memory_result_; | 395 bool reduce_memory_result_; |
| 389 base::TimeDelta requested_scrollbar_animation_delay_; | 396 base::TimeDelta requested_scrollbar_animation_delay_; |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1155 ExpectNone(*scroll_info, scroll_layer->id()); | 1162 ExpectNone(*scroll_info, scroll_layer->id()); |
| 1156 } | 1163 } |
| 1157 } | 1164 } |
| 1158 | 1165 |
| 1159 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { | 1166 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { |
| 1160 public: | 1167 public: |
| 1161 LayerTreeHostImplOverridePhysicalTime( | 1168 LayerTreeHostImplOverridePhysicalTime( |
| 1162 const LayerTreeSettings& settings, | 1169 const LayerTreeSettings& settings, |
| 1163 LayerTreeHostImplClient* client, | 1170 LayerTreeHostImplClient* client, |
| 1164 Proxy* proxy, | 1171 Proxy* proxy, |
| 1172 SharedBitmapManager* manager, | |
| 1165 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 1173 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 1166 : LayerTreeHostImpl(settings, | 1174 : LayerTreeHostImpl(settings, |
| 1167 client, | 1175 client, |
| 1168 proxy, | 1176 proxy, |
| 1169 rendering_stats_instrumentation, | 1177 rendering_stats_instrumentation, |
| 1170 NULL, | 1178 manager, |
| 1171 0) {} | 1179 0) {} |
| 1172 | 1180 |
| 1173 virtual base::TimeTicks CurrentPhysicalTimeTicks() const OVERRIDE { | 1181 virtual base::TimeTicks CurrentPhysicalTimeTicks() const OVERRIDE { |
| 1174 return fake_current_physical_time_; | 1182 return fake_current_physical_time_; |
| 1175 } | 1183 } |
| 1176 | 1184 |
| 1177 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 1185 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
| 1178 fake_current_physical_time_ = fake_now; | 1186 fake_current_physical_time_ = fake_now; |
| 1179 } | 1187 } |
| 1180 | 1188 |
| 1181 private: | 1189 private: |
| 1182 base::TimeTicks fake_current_physical_time_; | 1190 base::TimeTicks fake_current_physical_time_; |
| 1183 }; | 1191 }; |
| 1184 | 1192 |
| 1185 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1193 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
| 1186 LayerTreeSettings settings; | 1194 LayerTreeSettings settings; |
| 1187 settings.scrollbar_animator = LayerTreeSettings::LinearFade; | 1195 settings.scrollbar_animator = LayerTreeSettings::LinearFade; |
| 1188 settings.scrollbar_linear_fade_delay_ms = 20; | 1196 settings.scrollbar_linear_fade_delay_ms = 20; |
| 1189 settings.scrollbar_linear_fade_length_ms = 20; | 1197 settings.scrollbar_linear_fade_length_ms = 20; |
| 1190 | 1198 |
| 1191 gfx::Size viewport_size(10, 10); | 1199 gfx::Size viewport_size(10, 10); |
| 1192 gfx::Size content_size(100, 100); | 1200 gfx::Size content_size(100, 100); |
| 1193 | 1201 |
| 1202 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | |
| 1194 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = | 1203 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
| 1195 new LayerTreeHostImplOverridePhysicalTime( | 1204 new LayerTreeHostImplOverridePhysicalTime(settings, |
| 1196 settings, this, &proxy_, &stats_instrumentation_); | 1205 this, |
| 1206 &proxy_, | |
| 1207 shared_bitmap_manager_.get(), | |
| 1208 &stats_instrumentation_); | |
| 1197 host_impl_ = make_scoped_ptr(host_impl_override_time); | 1209 host_impl_ = make_scoped_ptr(host_impl_override_time); |
| 1198 host_impl_->InitializeRenderer(CreateOutputSurface()); | 1210 host_impl_->InitializeRenderer(CreateOutputSurface()); |
| 1199 host_impl_->SetViewportSize(viewport_size); | 1211 host_impl_->SetViewportSize(viewport_size); |
| 1200 | 1212 |
| 1201 scoped_ptr<LayerImpl> root = | 1213 scoped_ptr<LayerImpl> root = |
| 1202 LayerImpl::Create(host_impl_->active_tree(), 1); | 1214 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1203 root->SetBounds(viewport_size); | 1215 root->SetBounds(viewport_size); |
| 1204 | 1216 |
| 1205 scoped_ptr<LayerImpl> scroll = | 1217 scoped_ptr<LayerImpl> scroll = |
| 1206 LayerImpl::Create(host_impl_->active_tree(), 2); | 1218 LayerImpl::Create(host_impl_->active_tree(), 2); |
| (...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3840 context_provider->BindToCurrentThread(); | 3852 context_provider->BindToCurrentThread(); |
| 3841 context_provider->TestContext3d()->set_have_post_sub_buffer(true); | 3853 context_provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 3842 | 3854 |
| 3843 scoped_ptr<OutputSurface> output_surface( | 3855 scoped_ptr<OutputSurface> output_surface( |
| 3844 FakeOutputSurface::Create3d(context_provider)); | 3856 FakeOutputSurface::Create3d(context_provider)); |
| 3845 | 3857 |
| 3846 // This test creates its own LayerTreeHostImpl, so | 3858 // This test creates its own LayerTreeHostImpl, so |
| 3847 // that we can force partial swap enabled. | 3859 // that we can force partial swap enabled. |
| 3848 LayerTreeSettings settings; | 3860 LayerTreeSettings settings; |
| 3849 settings.partial_swap_enabled = true; | 3861 settings.partial_swap_enabled = true; |
| 3862 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | |
| 3863 new TestSharedBitmapManager()); | |
| 3850 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 3864 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
| 3851 LayerTreeHostImpl::Create( | 3865 LayerTreeHostImpl::Create(settings, |
| 3852 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 3866 this, |
| 3867 &proxy_, | |
| 3868 &stats_instrumentation_, | |
| 3869 shared_bitmap_manager.get(), | |
| 3870 0); | |
| 3853 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 3871 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3854 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 3872 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 3855 | 3873 |
| 3856 scoped_ptr<LayerImpl> root = | 3874 scoped_ptr<LayerImpl> root = |
| 3857 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 3875 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 3858 scoped_ptr<LayerImpl> child = | 3876 scoped_ptr<LayerImpl> child = |
| 3859 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 3877 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 3860 child->SetPosition(gfx::PointF(12.f, 13.f)); | 3878 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 3861 child->SetAnchorPoint(gfx::PointF()); | 3879 child->SetAnchorPoint(gfx::PointF()); |
| 3862 child->SetBounds(gfx::Size(14, 15)); | 3880 child->SetBounds(gfx::Size(14, 15)); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4134 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); | 4152 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4135 host_impl_->DidDrawAllLayers(frame); | 4153 host_impl_->DidDrawAllLayers(frame); |
| 4136 } | 4154 } |
| 4137 Mock::VerifyAndClearExpectations(&mock_context); | 4155 Mock::VerifyAndClearExpectations(&mock_context); |
| 4138 } | 4156 } |
| 4139 | 4157 |
| 4140 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 4158 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 4141 bool partial_swap, | 4159 bool partial_swap, |
| 4142 LayerTreeHostImplClient* client, | 4160 LayerTreeHostImplClient* client, |
| 4143 Proxy* proxy, | 4161 Proxy* proxy, |
| 4162 SharedBitmapManager* manager, | |
| 4144 RenderingStatsInstrumentation* stats_instrumentation) { | 4163 RenderingStatsInstrumentation* stats_instrumentation) { |
| 4145 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4164 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 4146 scoped_ptr<OutputSurface> output_surface( | 4165 scoped_ptr<OutputSurface> output_surface( |
| 4147 FakeOutputSurface::Create3d(provider)); | 4166 FakeOutputSurface::Create3d(provider)); |
| 4148 provider->BindToCurrentThread(); | 4167 provider->BindToCurrentThread(); |
| 4149 provider->TestContext3d()->set_have_post_sub_buffer(true); | 4168 provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 4150 | 4169 |
| 4151 LayerTreeSettings settings; | 4170 LayerTreeSettings settings; |
| 4152 settings.partial_swap_enabled = partial_swap; | 4171 settings.partial_swap_enabled = partial_swap; |
| 4153 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 4172 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
| 4154 settings, client, proxy, stats_instrumentation, NULL, 0); | 4173 settings, client, proxy, stats_instrumentation, manager, 0); |
| 4155 my_host_impl->InitializeRenderer(output_surface.Pass()); | 4174 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4156 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 4175 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
| 4157 | 4176 |
| 4158 /* | 4177 /* |
| 4159 Layers are created as follows: | 4178 Layers are created as follows: |
| 4160 | 4179 |
| 4161 +--------------------+ | 4180 +--------------------+ |
| 4162 | 1 | | 4181 | 1 | |
| 4163 | +-----------+ | | 4182 | +-----------+ | |
| 4164 | | 2 | | | 4183 | | 2 | | |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4210 grand_child->SetDrawsContent(true); | 4229 grand_child->SetDrawsContent(true); |
| 4211 | 4230 |
| 4212 child->AddChild(grand_child.Pass()); | 4231 child->AddChild(grand_child.Pass()); |
| 4213 root->AddChild(child.Pass()); | 4232 root->AddChild(child.Pass()); |
| 4214 | 4233 |
| 4215 my_host_impl->active_tree()->SetRootLayer(root.Pass()); | 4234 my_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 4216 return my_host_impl.Pass(); | 4235 return my_host_impl.Pass(); |
| 4217 } | 4236 } |
| 4218 | 4237 |
| 4219 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 4238 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
| 4239 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | |
| 4240 new TestSharedBitmapManager()); | |
| 4220 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 4241 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 4221 SetupLayersForOpacity(true, this, &proxy_, &stats_instrumentation_); | 4242 SetupLayersForOpacity(true, |
| 4243 this, | |
| 4244 &proxy_, | |
| 4245 shared_bitmap_manager.get(), | |
| 4246 &stats_instrumentation_); | |
| 4222 { | 4247 { |
| 4223 LayerTreeHostImpl::FrameData frame; | 4248 LayerTreeHostImpl::FrameData frame; |
| 4224 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, | 4249 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, |
| 4225 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 4250 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 4226 | 4251 |
| 4227 // Verify all quads have been computed | 4252 // Verify all quads have been computed |
| 4228 ASSERT_EQ(2U, frame.render_passes.size()); | 4253 ASSERT_EQ(2U, frame.render_passes.size()); |
| 4229 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 4254 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 4230 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 4255 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 4231 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 4256 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| 4232 frame.render_passes[0]->quad_list[0]->material); | 4257 frame.render_passes[0]->quad_list[0]->material); |
| 4233 EXPECT_EQ(DrawQuad::RENDER_PASS, | 4258 EXPECT_EQ(DrawQuad::RENDER_PASS, |
| 4234 frame.render_passes[1]->quad_list[0]->material); | 4259 frame.render_passes[1]->quad_list[0]->material); |
| 4235 | 4260 |
| 4236 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 4261 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
| 4237 my_host_impl->DidDrawAllLayers(frame); | 4262 my_host_impl->DidDrawAllLayers(frame); |
| 4238 } | 4263 } |
| 4239 } | 4264 } |
| 4240 | 4265 |
| 4241 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 4266 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
| 4267 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | |
| 4268 new TestSharedBitmapManager()); | |
| 4242 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 4269 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 4243 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); | 4270 SetupLayersForOpacity(false, |
| 4271 this, | |
| 4272 &proxy_, | |
| 4273 shared_bitmap_manager.get(), | |
| 4274 &stats_instrumentation_); | |
| 4244 { | 4275 { |
| 4245 LayerTreeHostImpl::FrameData frame; | 4276 LayerTreeHostImpl::FrameData frame; |
| 4246 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, | 4277 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, |
| 4247 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 4278 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
| 4248 | 4279 |
| 4249 // Verify all quads have been computed | 4280 // Verify all quads have been computed |
| 4250 ASSERT_EQ(2U, frame.render_passes.size()); | 4281 ASSERT_EQ(2U, frame.render_passes.size()); |
| 4251 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 4282 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
| 4252 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 4283 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
| 4253 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 4284 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5506 onscreen_context_provider_, offscreen_context_provider_)); | 5537 onscreen_context_provider_, offscreen_context_provider_)); |
| 5507 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 5538 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 5508 EXPECT_FALSE(host_impl_->offscreen_context_provider()); | 5539 EXPECT_FALSE(host_impl_->offscreen_context_provider()); |
| 5509 EXPECT_FALSE(did_update_renderer_capabilities_); | 5540 EXPECT_FALSE(did_update_renderer_capabilities_); |
| 5510 } | 5541 } |
| 5511 | 5542 |
| 5512 // Checks that we have a non-0 default allocation if we pass a context that | 5543 // Checks that we have a non-0 default allocation if we pass a context that |
| 5513 // doesn't support memory management extensions. | 5544 // doesn't support memory management extensions. |
| 5514 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 5545 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
| 5515 LayerTreeSettings settings; | 5546 LayerTreeSettings settings; |
| 5516 host_impl_ = LayerTreeHostImpl::Create( | 5547 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
|
danakj
2014/03/18 23:42:44
can use shared_bitmap_manager_ here since we're se
| |
| 5517 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 5548 new TestSharedBitmapManager()); |
| 5549 host_impl_ = LayerTreeHostImpl::Create(settings, | |
| 5550 this, | |
| 5551 &proxy_, | |
| 5552 &stats_instrumentation_, | |
| 5553 shared_bitmap_manager.get(), | |
| 5554 0); | |
| 5518 | 5555 |
| 5519 scoped_ptr<OutputSurface> output_surface( | 5556 scoped_ptr<OutputSurface> output_surface( |
| 5520 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); | 5557 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); |
| 5521 host_impl_->InitializeRenderer(output_surface.Pass()); | 5558 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 5522 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); | 5559 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); |
| 5523 } | 5560 } |
| 5524 | 5561 |
| 5525 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { | 5562 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { |
| 5526 ManagedMemoryPolicy policy1( | 5563 ManagedMemoryPolicy policy1( |
| 5527 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); | 5564 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6178 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6215 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
| 6179 300u * 1024u * 1024u); | 6216 300u * 1024u * 1024u); |
| 6180 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6217 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
| 6181 150u * 1024u * 1024u); | 6218 150u * 1024u * 1024u); |
| 6182 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, | 6219 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, |
| 6183 75u * 1024u * 1024u); | 6220 75u * 1024u * 1024u); |
| 6184 } | 6221 } |
| 6185 | 6222 |
| 6186 } // namespace | 6223 } // namespace |
| 6187 } // namespace cc | 6224 } // namespace cc |
| OLD | NEW |