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" |
62 #include "ui/gfx/vector2d_conversions.h" | 63 #include "ui/gfx/vector2d_conversions.h" |
63 | 64 |
64 using ::testing::Mock; | 65 using ::testing::Mock; |
65 using ::testing::Return; | 66 using ::testing::Return; |
66 using ::testing::AnyNumber; | 67 using ::testing::AnyNumber; |
67 using ::testing::AtLeast; | 68 using ::testing::AtLeast; |
68 using ::testing::_; | 69 using ::testing::_; |
69 using media::VideoFrame; | 70 using media::VideoFrame; |
70 | 71 |
71 namespace cc { | 72 namespace cc { |
72 namespace { | 73 namespace { |
73 | 74 |
74 class LayerTreeHostImplTest : public testing::Test, | 75 class LayerTreeHostImplTest : public testing::Test, |
75 public LayerTreeHostImplClient { | 76 public LayerTreeHostImplClient { |
76 public: | 77 public: |
77 LayerTreeHostImplTest() | 78 LayerTreeHostImplTest() |
78 : proxy_(base::MessageLoopProxy::current()), | 79 : proxy_(base::MessageLoopProxy::current()), |
79 always_impl_thread_(&proxy_), | 80 always_impl_thread_(&proxy_), |
80 always_main_thread_blocked_(&proxy_), | 81 always_main_thread_blocked_(&proxy_), |
| 82 shared_bitmap_manager_(new TestSharedBitmapManager()), |
81 on_can_draw_state_changed_called_(false), | 83 on_can_draw_state_changed_called_(false), |
82 did_notify_ready_to_activate_(false), | 84 did_notify_ready_to_activate_(false), |
83 did_request_commit_(false), | 85 did_request_commit_(false), |
84 did_request_redraw_(false), | 86 did_request_redraw_(false), |
85 did_request_manage_tiles_(false), | 87 did_request_manage_tiles_(false), |
86 did_upload_visible_tile_(false), | 88 did_upload_visible_tile_(false), |
87 reduce_memory_result_(true), | 89 reduce_memory_result_(true), |
88 current_limit_bytes_(0), | 90 current_limit_bytes_(0), |
89 current_priority_cutoff_value_(0) { | 91 current_priority_cutoff_value_(0) { |
90 media::InitializeMediaLibraryForTesting(); | 92 media::InitializeMediaLibraryForTesting(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 OVERRIDE { requested_scrollbar_animation_delay_ = delay; } | 149 OVERRIDE { requested_scrollbar_animation_delay_ = delay; } |
148 virtual void DidActivatePendingTree() OVERRIDE {} | 150 virtual void DidActivatePendingTree() OVERRIDE {} |
149 virtual void DidManageTiles() OVERRIDE {} | 151 virtual void DidManageTiles() OVERRIDE {} |
150 | 152 |
151 void set_reduce_memory_result(bool reduce_memory_result) { | 153 void set_reduce_memory_result(bool reduce_memory_result) { |
152 reduce_memory_result_ = reduce_memory_result; | 154 reduce_memory_result_ = reduce_memory_result; |
153 } | 155 } |
154 | 156 |
155 bool CreateHostImpl(const LayerTreeSettings& settings, | 157 bool CreateHostImpl(const LayerTreeSettings& settings, |
156 scoped_ptr<OutputSurface> output_surface) { | 158 scoped_ptr<OutputSurface> output_surface) { |
157 host_impl_ = LayerTreeHostImpl::Create( | 159 host_impl_ = LayerTreeHostImpl::Create(settings, |
158 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 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 |
1194 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = | 1202 LayerTreeHostImplOverridePhysicalTime* host_impl_override_time = |
1195 new LayerTreeHostImplOverridePhysicalTime( | 1203 new LayerTreeHostImplOverridePhysicalTime(settings, |
1196 settings, this, &proxy_, &stats_instrumentation_); | 1204 this, |
| 1205 &proxy_, |
| 1206 shared_bitmap_manager_.get(), |
| 1207 &stats_instrumentation_); |
1197 host_impl_ = make_scoped_ptr(host_impl_override_time); | 1208 host_impl_ = make_scoped_ptr(host_impl_override_time); |
1198 host_impl_->InitializeRenderer(CreateOutputSurface()); | 1209 host_impl_->InitializeRenderer(CreateOutputSurface()); |
1199 host_impl_->SetViewportSize(viewport_size); | 1210 host_impl_->SetViewportSize(viewport_size); |
1200 | 1211 |
1201 scoped_ptr<LayerImpl> root = | 1212 scoped_ptr<LayerImpl> root = |
1202 LayerImpl::Create(host_impl_->active_tree(), 1); | 1213 LayerImpl::Create(host_impl_->active_tree(), 1); |
1203 root->SetBounds(viewport_size); | 1214 root->SetBounds(viewport_size); |
1204 | 1215 |
1205 scoped_ptr<LayerImpl> scroll = | 1216 scoped_ptr<LayerImpl> scroll = |
1206 LayerImpl::Create(host_impl_->active_tree(), 2); | 1217 LayerImpl::Create(host_impl_->active_tree(), 2); |
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 context_provider->BindToCurrentThread(); | 3851 context_provider->BindToCurrentThread(); |
3841 context_provider->TestContext3d()->set_have_post_sub_buffer(true); | 3852 context_provider->TestContext3d()->set_have_post_sub_buffer(true); |
3842 | 3853 |
3843 scoped_ptr<OutputSurface> output_surface( | 3854 scoped_ptr<OutputSurface> output_surface( |
3844 FakeOutputSurface::Create3d(context_provider)); | 3855 FakeOutputSurface::Create3d(context_provider)); |
3845 | 3856 |
3846 // This test creates its own LayerTreeHostImpl, so | 3857 // This test creates its own LayerTreeHostImpl, so |
3847 // that we can force partial swap enabled. | 3858 // that we can force partial swap enabled. |
3848 LayerTreeSettings settings; | 3859 LayerTreeSettings settings; |
3849 settings.partial_swap_enabled = true; | 3860 settings.partial_swap_enabled = true; |
| 3861 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 3862 new TestSharedBitmapManager()); |
3850 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 3863 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
3851 LayerTreeHostImpl::Create( | 3864 LayerTreeHostImpl::Create(settings, |
3852 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 3865 this, |
| 3866 &proxy_, |
| 3867 &stats_instrumentation_, |
| 3868 shared_bitmap_manager.get(), |
| 3869 0); |
3853 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 3870 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
3854 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 3871 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
3855 | 3872 |
3856 scoped_ptr<LayerImpl> root = | 3873 scoped_ptr<LayerImpl> root = |
3857 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 3874 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
3858 scoped_ptr<LayerImpl> child = | 3875 scoped_ptr<LayerImpl> child = |
3859 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 3876 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
3860 child->SetPosition(gfx::PointF(12.f, 13.f)); | 3877 child->SetPosition(gfx::PointF(12.f, 13.f)); |
3861 child->SetAnchorPoint(gfx::PointF()); | 3878 child->SetAnchorPoint(gfx::PointF()); |
3862 child->SetBounds(gfx::Size(14, 15)); | 3879 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()); | 4151 host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); |
4135 host_impl_->DidDrawAllLayers(frame); | 4152 host_impl_->DidDrawAllLayers(frame); |
4136 } | 4153 } |
4137 Mock::VerifyAndClearExpectations(&mock_context); | 4154 Mock::VerifyAndClearExpectations(&mock_context); |
4138 } | 4155 } |
4139 | 4156 |
4140 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 4157 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
4141 bool partial_swap, | 4158 bool partial_swap, |
4142 LayerTreeHostImplClient* client, | 4159 LayerTreeHostImplClient* client, |
4143 Proxy* proxy, | 4160 Proxy* proxy, |
| 4161 SharedBitmapManager* manager, |
4144 RenderingStatsInstrumentation* stats_instrumentation) { | 4162 RenderingStatsInstrumentation* stats_instrumentation) { |
4145 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 4163 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
4146 scoped_ptr<OutputSurface> output_surface( | 4164 scoped_ptr<OutputSurface> output_surface( |
4147 FakeOutputSurface::Create3d(provider)); | 4165 FakeOutputSurface::Create3d(provider)); |
4148 provider->BindToCurrentThread(); | 4166 provider->BindToCurrentThread(); |
4149 provider->TestContext3d()->set_have_post_sub_buffer(true); | 4167 provider->TestContext3d()->set_have_post_sub_buffer(true); |
4150 | 4168 |
4151 LayerTreeSettings settings; | 4169 LayerTreeSettings settings; |
4152 settings.partial_swap_enabled = partial_swap; | 4170 settings.partial_swap_enabled = partial_swap; |
4153 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 4171 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
4154 settings, client, proxy, stats_instrumentation, NULL, 0); | 4172 settings, client, proxy, stats_instrumentation, manager, 0); |
4155 my_host_impl->InitializeRenderer(output_surface.Pass()); | 4173 my_host_impl->InitializeRenderer(output_surface.Pass()); |
4156 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 4174 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
4157 | 4175 |
4158 /* | 4176 /* |
4159 Layers are created as follows: | 4177 Layers are created as follows: |
4160 | 4178 |
4161 +--------------------+ | 4179 +--------------------+ |
4162 | 1 | | 4180 | 1 | |
4163 | +-----------+ | | 4181 | +-----------+ | |
4164 | | 2 | | | 4182 | | 2 | | |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4210 grand_child->SetDrawsContent(true); | 4228 grand_child->SetDrawsContent(true); |
4211 | 4229 |
4212 child->AddChild(grand_child.Pass()); | 4230 child->AddChild(grand_child.Pass()); |
4213 root->AddChild(child.Pass()); | 4231 root->AddChild(child.Pass()); |
4214 | 4232 |
4215 my_host_impl->active_tree()->SetRootLayer(root.Pass()); | 4233 my_host_impl->active_tree()->SetRootLayer(root.Pass()); |
4216 return my_host_impl.Pass(); | 4234 return my_host_impl.Pass(); |
4217 } | 4235 } |
4218 | 4236 |
4219 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 4237 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
| 4238 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 4239 new TestSharedBitmapManager()); |
4220 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 4240 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
4221 SetupLayersForOpacity(true, this, &proxy_, &stats_instrumentation_); | 4241 SetupLayersForOpacity(true, |
| 4242 this, |
| 4243 &proxy_, |
| 4244 shared_bitmap_manager.get(), |
| 4245 &stats_instrumentation_); |
4222 { | 4246 { |
4223 LayerTreeHostImpl::FrameData frame; | 4247 LayerTreeHostImpl::FrameData frame; |
4224 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, | 4248 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, |
4225 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 4249 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
4226 | 4250 |
4227 // Verify all quads have been computed | 4251 // Verify all quads have been computed |
4228 ASSERT_EQ(2U, frame.render_passes.size()); | 4252 ASSERT_EQ(2U, frame.render_passes.size()); |
4229 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 4253 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
4230 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 4254 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
4231 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 4255 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
4232 frame.render_passes[0]->quad_list[0]->material); | 4256 frame.render_passes[0]->quad_list[0]->material); |
4233 EXPECT_EQ(DrawQuad::RENDER_PASS, | 4257 EXPECT_EQ(DrawQuad::RENDER_PASS, |
4234 frame.render_passes[1]->quad_list[0]->material); | 4258 frame.render_passes[1]->quad_list[0]->material); |
4235 | 4259 |
4236 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); | 4260 my_host_impl->DrawLayers(&frame, gfx::FrameTime::Now()); |
4237 my_host_impl->DidDrawAllLayers(frame); | 4261 my_host_impl->DidDrawAllLayers(frame); |
4238 } | 4262 } |
4239 } | 4263 } |
4240 | 4264 |
4241 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 4265 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
| 4266 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 4267 new TestSharedBitmapManager()); |
4242 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 4268 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
4243 SetupLayersForOpacity(false, this, &proxy_, &stats_instrumentation_); | 4269 SetupLayersForOpacity(false, |
| 4270 this, |
| 4271 &proxy_, |
| 4272 shared_bitmap_manager.get(), |
| 4273 &stats_instrumentation_); |
4244 { | 4274 { |
4245 LayerTreeHostImpl::FrameData frame; | 4275 LayerTreeHostImpl::FrameData frame; |
4246 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, | 4276 EXPECT_EQ(DrawSwapReadbackResult::DRAW_SUCCESS, |
4247 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); | 4277 my_host_impl->PrepareToDraw(&frame, gfx::Rect())); |
4248 | 4278 |
4249 // Verify all quads have been computed | 4279 // Verify all quads have been computed |
4250 ASSERT_EQ(2U, frame.render_passes.size()); | 4280 ASSERT_EQ(2U, frame.render_passes.size()); |
4251 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 4281 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
4252 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 4282 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
4253 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 4283 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_)); | 5536 onscreen_context_provider_, offscreen_context_provider_)); |
5507 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 5537 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
5508 EXPECT_FALSE(host_impl_->offscreen_context_provider()); | 5538 EXPECT_FALSE(host_impl_->offscreen_context_provider()); |
5509 EXPECT_FALSE(did_update_renderer_capabilities_); | 5539 EXPECT_FALSE(did_update_renderer_capabilities_); |
5510 } | 5540 } |
5511 | 5541 |
5512 // Checks that we have a non-0 default allocation if we pass a context that | 5542 // Checks that we have a non-0 default allocation if we pass a context that |
5513 // doesn't support memory management extensions. | 5543 // doesn't support memory management extensions. |
5514 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 5544 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
5515 LayerTreeSettings settings; | 5545 LayerTreeSettings settings; |
5516 host_impl_ = LayerTreeHostImpl::Create( | 5546 host_impl_ = LayerTreeHostImpl::Create(settings, |
5517 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); | 5547 this, |
| 5548 &proxy_, |
| 5549 &stats_instrumentation_, |
| 5550 shared_bitmap_manager_.get(), |
| 5551 0); |
5518 | 5552 |
5519 scoped_ptr<OutputSurface> output_surface( | 5553 scoped_ptr<OutputSurface> output_surface( |
5520 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); | 5554 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); |
5521 host_impl_->InitializeRenderer(output_surface.Pass()); | 5555 host_impl_->InitializeRenderer(output_surface.Pass()); |
5522 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); | 5556 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); |
5523 } | 5557 } |
5524 | 5558 |
5525 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { | 5559 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { |
5526 ManagedMemoryPolicy policy1( | 5560 ManagedMemoryPolicy policy1( |
5527 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); | 5561 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5565 EXPECT_EQ(0u, current_limit_bytes_); | 5599 EXPECT_EQ(0u, current_limit_bytes_); |
5566 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); | 5600 EXPECT_EQ(nothing_cutoff_value, current_priority_cutoff_value_); |
5567 } | 5601 } |
5568 | 5602 |
5569 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest { | 5603 class LayerTreeHostImplTestManageTiles : public LayerTreeHostImplTest { |
5570 public: | 5604 public: |
5571 virtual void SetUp() OVERRIDE { | 5605 virtual void SetUp() OVERRIDE { |
5572 LayerTreeSettings settings; | 5606 LayerTreeSettings settings; |
5573 settings.impl_side_painting = true; | 5607 settings.impl_side_painting = true; |
5574 | 5608 |
5575 fake_host_impl_ = new FakeLayerTreeHostImpl(settings, &proxy_); | 5609 fake_host_impl_ = new FakeLayerTreeHostImpl( |
| 5610 settings, &proxy_, shared_bitmap_manager_.get()); |
5576 host_impl_.reset(fake_host_impl_); | 5611 host_impl_.reset(fake_host_impl_); |
5577 host_impl_->InitializeRenderer(CreateOutputSurface()); | 5612 host_impl_->InitializeRenderer(CreateOutputSurface()); |
5578 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 5613 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
5579 } | 5614 } |
5580 | 5615 |
5581 FakeLayerTreeHostImpl* fake_host_impl_; | 5616 FakeLayerTreeHostImpl* fake_host_impl_; |
5582 }; | 5617 }; |
5583 | 5618 |
5584 TEST_F(LayerTreeHostImplTestManageTiles, ManageTilesWhenInvisible) { | 5619 TEST_F(LayerTreeHostImplTestManageTiles, ManageTilesWhenInvisible) { |
5585 fake_host_impl_->DidModifyTilePriorities(); | 5620 fake_host_impl_->DidModifyTilePriorities(); |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6178 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6213 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
6179 300u * 1024u * 1024u); | 6214 300u * 1024u * 1024u); |
6180 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6215 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
6181 150u * 1024u * 1024u); | 6216 150u * 1024u * 1024u); |
6182 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, | 6217 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, |
6183 75u * 1024u * 1024u); | 6218 75u * 1024u * 1024u); |
6184 } | 6219 } |
6185 | 6220 |
6186 } // namespace | 6221 } // namespace |
6187 } // namespace cc | 6222 } // namespace cc |
OLD | NEW |