| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 media::InitializeMediaLibraryForTesting(); | 89 media::InitializeMediaLibraryForTesting(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual void SetUp() OVERRIDE { | 92 virtual void SetUp() OVERRIDE { |
| 93 LayerTreeSettings settings; | 93 LayerTreeSettings settings; |
| 94 settings.minimum_occlusion_tracking_size = gfx::Size(); | 94 settings.minimum_occlusion_tracking_size = gfx::Size(); |
| 95 settings.impl_side_painting = true; | 95 settings.impl_side_painting = true; |
| 96 settings.texture_id_allocation_chunk_size = 1; | 96 settings.texture_id_allocation_chunk_size = 1; |
| 97 | 97 |
| 98 host_impl_ = LayerTreeHostImpl::Create( | 98 host_impl_ = LayerTreeHostImpl::Create( |
| 99 settings, this, &proxy_, &stats_instrumentation_, NULL); | 99 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 100 host_impl_->InitializeRenderer(CreateOutputSurface()); | 100 host_impl_->InitializeRenderer(CreateOutputSurface()); |
| 101 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 101 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 virtual void TearDown() OVERRIDE {} | 104 virtual void TearDown() OVERRIDE {} |
| 105 | 105 |
| 106 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { | 106 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE { |
| 107 did_lose_output_surface_ = true; | 107 did_lose_output_surface_ = true; |
| 108 } | 108 } |
| 109 virtual void DidSwapBuffersOnImplThread() OVERRIDE {} | 109 virtual void DidSwapBuffersOnImplThread() OVERRIDE {} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 reduce_memory_result_ = reduce_memory_result; | 152 reduce_memory_result_ = reduce_memory_result; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void CreateLayerTreeHost(bool partial_swap, | 155 void CreateLayerTreeHost(bool partial_swap, |
| 156 scoped_ptr<OutputSurface> output_surface) { | 156 scoped_ptr<OutputSurface> output_surface) { |
| 157 LayerTreeSettings settings; | 157 LayerTreeSettings settings; |
| 158 settings.minimum_occlusion_tracking_size = gfx::Size(); | 158 settings.minimum_occlusion_tracking_size = gfx::Size(); |
| 159 settings.partial_swap_enabled = partial_swap; | 159 settings.partial_swap_enabled = partial_swap; |
| 160 | 160 |
| 161 host_impl_ = LayerTreeHostImpl::Create( | 161 host_impl_ = LayerTreeHostImpl::Create( |
| 162 settings, this, &proxy_, &stats_instrumentation_, NULL); | 162 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 163 | 163 |
| 164 host_impl_->InitializeRenderer(output_surface.Pass()); | 164 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 165 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 165 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { | 168 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { |
| 169 root->SetAnchorPoint(gfx::PointF()); | 169 root->SetAnchorPoint(gfx::PointF()); |
| 170 root->SetPosition(gfx::PointF()); | 170 root->SetPosition(gfx::PointF()); |
| 171 root->SetBounds(gfx::Size(10, 10)); | 171 root->SetBounds(gfx::Size(10, 10)); |
| 172 root->SetContentBounds(gfx::Size(10, 10)); | 172 root->SetContentBounds(gfx::Size(10, 10)); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 382 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
| 383 bool always_draw = false; | 383 bool always_draw = false; |
| 384 CheckNotifyCalledIfCanDrawChanged(always_draw); | 384 CheckNotifyCalledIfCanDrawChanged(always_draw); |
| 385 } | 385 } |
| 386 | 386 |
| 387 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { | 387 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { |
| 388 LayerTreeSettings settings; | 388 LayerTreeSettings settings; |
| 389 settings.impl_side_painting = true; | 389 settings.impl_side_painting = true; |
| 390 host_impl_ = LayerTreeHostImpl::Create( | 390 host_impl_ = LayerTreeHostImpl::Create( |
| 391 settings, this, &proxy_, &stats_instrumentation_, NULL); | 391 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 392 | 392 |
| 393 scoped_ptr<FakeOutputSurface> output_surface( | 393 scoped_ptr<FakeOutputSurface> output_surface( |
| 394 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); | 394 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); |
| 395 | 395 |
| 396 host_impl_->InitializeRenderer( | 396 host_impl_->InitializeRenderer( |
| 397 output_surface.PassAs<OutputSurface>()); | 397 output_surface.PassAs<OutputSurface>()); |
| 398 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 398 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 399 | 399 |
| 400 bool always_draw = true; | 400 bool always_draw = true; |
| 401 CheckNotifyCalledIfCanDrawChanged(always_draw); | 401 CheckNotifyCalledIfCanDrawChanged(always_draw); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 485 |
| 486 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { | 486 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { |
| 487 // We should not crash when trying to scroll an empty layer tree. | 487 // We should not crash when trying to scroll an empty layer tree. |
| 488 EXPECT_EQ(InputHandler::ScrollIgnored, | 488 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 489 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 489 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 490 } | 490 } |
| 491 | 491 |
| 492 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 492 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
| 493 LayerTreeSettings settings; | 493 LayerTreeSettings settings; |
| 494 host_impl_ = LayerTreeHostImpl::Create( | 494 host_impl_ = LayerTreeHostImpl::Create( |
| 495 settings, this, &proxy_, &stats_instrumentation_, NULL); | 495 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 496 scoped_ptr<TestWebGraphicsContext3D> context_owned = | 496 scoped_ptr<TestWebGraphicsContext3D> context_owned = |
| 497 TestWebGraphicsContext3D::Create(); | 497 TestWebGraphicsContext3D::Create(); |
| 498 context_owned->set_times_make_current_succeeds(0); | 498 context_owned->set_times_make_current_succeeds(0); |
| 499 | 499 |
| 500 scoped_ptr<FakeOutputSurface> output_surface(FakeOutputSurface::Create3d( | 500 scoped_ptr<FakeOutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 501 context_owned.Pass())); | 501 context_owned.Pass())); |
| 502 | 502 |
| 503 // Initialization will fail here. | 503 // Initialization will fail here. |
| 504 host_impl_->InitializeRenderer(output_surface.PassAs<OutputSurface>()); | 504 host_impl_->InitializeRenderer(output_surface.PassAs<OutputSurface>()); |
| 505 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 505 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 public: | 1141 public: |
| 1142 LayerTreeHostImplOverridePhysicalTime( | 1142 LayerTreeHostImplOverridePhysicalTime( |
| 1143 const LayerTreeSettings& settings, | 1143 const LayerTreeSettings& settings, |
| 1144 LayerTreeHostImplClient* client, | 1144 LayerTreeHostImplClient* client, |
| 1145 Proxy* proxy, | 1145 Proxy* proxy, |
| 1146 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 1146 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 1147 : LayerTreeHostImpl(settings, | 1147 : LayerTreeHostImpl(settings, |
| 1148 client, | 1148 client, |
| 1149 proxy, | 1149 proxy, |
| 1150 rendering_stats_instrumentation, | 1150 rendering_stats_instrumentation, |
| 1151 NULL) {} | 1151 NULL, |
| 1152 0) {} |
| 1152 | 1153 |
| 1153 virtual base::TimeTicks CurrentPhysicalTimeTicks() const OVERRIDE { | 1154 virtual base::TimeTicks CurrentPhysicalTimeTicks() const OVERRIDE { |
| 1154 return fake_current_physical_time_; | 1155 return fake_current_physical_time_; |
| 1155 } | 1156 } |
| 1156 | 1157 |
| 1157 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 1158 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
| 1158 fake_current_physical_time_ = fake_now; | 1159 fake_current_physical_time_ = fake_now; |
| 1159 } | 1160 } |
| 1160 | 1161 |
| 1161 private: | 1162 private: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 float device_scale_factor) { | 1275 float device_scale_factor) { |
| 1275 LayerTreeSettings settings; | 1276 LayerTreeSettings settings; |
| 1276 settings.scrollbar_animator = LayerTreeSettings::Thinning; | 1277 settings.scrollbar_animator = LayerTreeSettings::Thinning; |
| 1277 | 1278 |
| 1278 gfx::Size viewport_size(300, 200); | 1279 gfx::Size viewport_size(300, 200); |
| 1279 gfx::Size device_viewport_size = gfx::ToFlooredSize( | 1280 gfx::Size device_viewport_size = gfx::ToFlooredSize( |
| 1280 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1281 gfx::ScaleSize(viewport_size, device_scale_factor)); |
| 1281 gfx::Size content_size(1000, 1000); | 1282 gfx::Size content_size(1000, 1000); |
| 1282 | 1283 |
| 1283 host_impl_ = LayerTreeHostImpl::Create( | 1284 host_impl_ = LayerTreeHostImpl::Create( |
| 1284 settings, this, &proxy_, &stats_instrumentation_, NULL); | 1285 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 1285 host_impl_->InitializeRenderer(CreateOutputSurface()); | 1286 host_impl_->InitializeRenderer(CreateOutputSurface()); |
| 1286 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1287 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 1287 host_impl_->SetViewportSize(device_viewport_size); | 1288 host_impl_->SetViewportSize(device_viewport_size); |
| 1288 | 1289 |
| 1289 scoped_ptr<LayerImpl> root = | 1290 scoped_ptr<LayerImpl> root = |
| 1290 LayerImpl::Create(host_impl_->active_tree(), 1); | 1291 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1291 root->SetBounds(viewport_size); | 1292 root->SetBounds(viewport_size); |
| 1292 | 1293 |
| 1293 scoped_ptr<LayerImpl> scroll = | 1294 scoped_ptr<LayerImpl> scroll = |
| 1294 LayerImpl::Create(host_impl_->active_tree(), 2); | 1295 LayerImpl::Create(host_impl_->active_tree(), 2); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 EXPECT_FALSE(did_request_redraw_); | 1781 EXPECT_FALSE(did_request_redraw_); |
| 1781 EXPECT_FALSE(did_request_commit_); | 1782 EXPECT_FALSE(did_request_commit_); |
| 1782 } | 1783 } |
| 1783 | 1784 |
| 1784 TEST_F(LayerTreeHostImplTest, ScrollNonScrollableRootWithTopControls) { | 1785 TEST_F(LayerTreeHostImplTest, ScrollNonScrollableRootWithTopControls) { |
| 1785 LayerTreeSettings settings; | 1786 LayerTreeSettings settings; |
| 1786 settings.calculate_top_controls_position = true; | 1787 settings.calculate_top_controls_position = true; |
| 1787 settings.top_controls_height = 50; | 1788 settings.top_controls_height = 50; |
| 1788 | 1789 |
| 1789 host_impl_ = LayerTreeHostImpl::Create( | 1790 host_impl_ = LayerTreeHostImpl::Create( |
| 1790 settings, this, &proxy_, &stats_instrumentation_, NULL); | 1791 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 1791 host_impl_->InitializeRenderer(CreateOutputSurface()); | 1792 host_impl_->InitializeRenderer(CreateOutputSurface()); |
| 1792 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 1793 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 1793 | 1794 |
| 1794 gfx::Size layer_size(5, 5); | 1795 gfx::Size layer_size(5, 5); |
| 1795 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 1796 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1796 root->SetScrollable(true); | 1797 root->SetScrollable(true); |
| 1797 root->SetMaxScrollOffset(gfx::Vector2d(layer_size.width(), | 1798 root->SetMaxScrollOffset(gfx::Vector2d(layer_size.width(), |
| 1798 layer_size.height())); | 1799 layer_size.height())); |
| 1799 root->SetBounds(layer_size); | 1800 root->SetBounds(layer_size); |
| 1800 root->SetContentBounds(layer_size); | 1801 root->SetContentBounds(layer_size); |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2742 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2743 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2743 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); | 2744 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); |
| 2744 host_impl_->ScrollEnd(); | 2745 host_impl_->ScrollEnd(); |
| 2745 } | 2746 } |
| 2746 } | 2747 } |
| 2747 | 2748 |
| 2748 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 2749 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
| 2749 LayerTreeSettings settings; | 2750 LayerTreeSettings settings; |
| 2750 settings.always_overscroll = true; | 2751 settings.always_overscroll = true; |
| 2751 host_impl_ = LayerTreeHostImpl::Create( | 2752 host_impl_ = LayerTreeHostImpl::Create( |
| 2752 settings, this, &proxy_, &stats_instrumentation_, NULL); | 2753 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 2753 | 2754 |
| 2754 SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 2755 SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
| 2755 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2756 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2756 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); | 2757 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); |
| 2757 InitializeRendererAndDrawFrame(); | 2758 InitializeRendererAndDrawFrame(); |
| 2758 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 2759 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 2759 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 2760 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
| 2760 | 2761 |
| 2761 // Even though the layer can't scroll the overscroll still happens. | 2762 // Even though the layer can't scroll the overscroll still happens. |
| 2762 EXPECT_EQ(InputHandler::ScrollStarted, | 2763 EXPECT_EQ(InputHandler::ScrollStarted, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3075 LayerTreeHostImplViewportCoveredTest() : | 3076 LayerTreeHostImplViewportCoveredTest() : |
| 3076 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 3077 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 3077 child_(NULL), | 3078 child_(NULL), |
| 3078 did_activate_pending_tree_(false) {} | 3079 did_activate_pending_tree_(false) {} |
| 3079 | 3080 |
| 3080 void CreateLayerTreeHostImpl(bool always_draw) { | 3081 void CreateLayerTreeHostImpl(bool always_draw) { |
| 3081 LayerTreeSettings settings; | 3082 LayerTreeSettings settings; |
| 3082 settings.minimum_occlusion_tracking_size = gfx::Size(); | 3083 settings.minimum_occlusion_tracking_size = gfx::Size(); |
| 3083 settings.impl_side_painting = true; | 3084 settings.impl_side_painting = true; |
| 3084 host_impl_ = LayerTreeHostImpl::Create( | 3085 host_impl_ = LayerTreeHostImpl::Create( |
| 3085 settings, this, &proxy_, &stats_instrumentation_, NULL); | 3086 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 3086 | 3087 |
| 3087 scoped_ptr<FakeOutputSurface> output_surface; | 3088 scoped_ptr<FakeOutputSurface> output_surface; |
| 3088 if (always_draw) | 3089 if (always_draw) |
| 3089 output_surface = FakeOutputSurface::CreateAlwaysDrawAndSwap3d().Pass(); | 3090 output_surface = FakeOutputSurface::CreateAlwaysDrawAndSwap3d().Pass(); |
| 3090 else | 3091 else |
| 3091 output_surface = FakeOutputSurface::Create3d().Pass(); | 3092 output_surface = FakeOutputSurface::Create3d().Pass(); |
| 3092 | 3093 |
| 3093 host_impl_->InitializeRenderer(output_surface.PassAs<OutputSurface>()); | 3094 host_impl_->InitializeRenderer(output_surface.PassAs<OutputSurface>()); |
| 3094 viewport_size_ = gfx::Size(1000, 1000); | 3095 viewport_size_ = gfx::Size(1000, 1000); |
| 3095 } | 3096 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3432 provider->BindToCurrentThread(); | 3433 provider->BindToCurrentThread(); |
| 3433 TestWebGraphicsContext3D* context = provider->TestContext3d(); | 3434 TestWebGraphicsContext3D* context = provider->TestContext3d(); |
| 3434 context->set_have_post_sub_buffer(true); | 3435 context->set_have_post_sub_buffer(true); |
| 3435 | 3436 |
| 3436 // This test creates its own LayerTreeHostImpl, so | 3437 // This test creates its own LayerTreeHostImpl, so |
| 3437 // that we can force partial swap enabled. | 3438 // that we can force partial swap enabled. |
| 3438 LayerTreeSettings settings; | 3439 LayerTreeSettings settings; |
| 3439 settings.partial_swap_enabled = true; | 3440 settings.partial_swap_enabled = true; |
| 3440 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 3441 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
| 3441 LayerTreeHostImpl::Create( | 3442 LayerTreeHostImpl::Create( |
| 3442 settings, this, &proxy_, &stats_instrumentation_, NULL); | 3443 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 3443 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 3444 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3444 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 3445 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 3445 | 3446 |
| 3446 scoped_ptr<LayerImpl> root = | 3447 scoped_ptr<LayerImpl> root = |
| 3447 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 3448 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 3448 scoped_ptr<LayerImpl> child = | 3449 scoped_ptr<LayerImpl> child = |
| 3449 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 3450 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 3450 child->SetPosition(gfx::PointF(12.f, 13.f)); | 3451 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 3451 child->SetAnchorPoint(gfx::PointF()); | 3452 child->SetAnchorPoint(gfx::PointF()); |
| 3452 child->SetBounds(gfx::Size(14, 15)); | 3453 child->SetBounds(gfx::Size(14, 15)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3732 RenderingStatsInstrumentation* stats_instrumentation) { | 3733 RenderingStatsInstrumentation* stats_instrumentation) { |
| 3733 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 3734 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
| 3734 scoped_ptr<OutputSurface> output_surface( | 3735 scoped_ptr<OutputSurface> output_surface( |
| 3735 FakeOutputSurface::Create3d(provider)); | 3736 FakeOutputSurface::Create3d(provider)); |
| 3736 provider->BindToCurrentThread(); | 3737 provider->BindToCurrentThread(); |
| 3737 provider->TestContext3d()->set_have_post_sub_buffer(true); | 3738 provider->TestContext3d()->set_have_post_sub_buffer(true); |
| 3738 | 3739 |
| 3739 LayerTreeSettings settings; | 3740 LayerTreeSettings settings; |
| 3740 settings.partial_swap_enabled = partial_swap; | 3741 settings.partial_swap_enabled = partial_swap; |
| 3741 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 3742 scoped_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
| 3742 settings, client, proxy, stats_instrumentation, NULL); | 3743 settings, client, proxy, stats_instrumentation, NULL, 0); |
| 3743 my_host_impl->InitializeRenderer(output_surface.Pass()); | 3744 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3744 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 3745 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
| 3745 | 3746 |
| 3746 /* | 3747 /* |
| 3747 Layers are created as follows: | 3748 Layers are created as follows: |
| 3748 | 3749 |
| 3749 +--------------------+ | 3750 +--------------------+ |
| 3750 | 1 | | 3751 | 1 | |
| 3751 | +-----------+ | | 3752 | +-----------+ | |
| 3752 | | 2 | | | 3753 | | 2 | | |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4076 | 4077 |
| 4077 private: | 4078 private: |
| 4078 FakeMaskLayerImpl(LayerTreeImpl* tree_impl, int id) | 4079 FakeMaskLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 4079 : LayerImpl(tree_impl, id) {} | 4080 : LayerImpl(tree_impl, id) {} |
| 4080 }; | 4081 }; |
| 4081 | 4082 |
| 4082 TEST_F(LayerTreeHostImplTest, MaskLayerWithScaling) { | 4083 TEST_F(LayerTreeHostImplTest, MaskLayerWithScaling) { |
| 4083 LayerTreeSettings settings; | 4084 LayerTreeSettings settings; |
| 4084 settings.layer_transforms_should_scale_layer_contents = true; | 4085 settings.layer_transforms_should_scale_layer_contents = true; |
| 4085 host_impl_ = LayerTreeHostImpl::Create( | 4086 host_impl_ = LayerTreeHostImpl::Create( |
| 4086 settings, this, &proxy_, &stats_instrumentation_, NULL); | 4087 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 4087 host_impl_->InitializeRenderer(CreateOutputSurface()); | 4088 host_impl_->InitializeRenderer(CreateOutputSurface()); |
| 4088 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 4089 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 4089 | 4090 |
| 4090 // Root | 4091 // Root |
| 4091 // | | 4092 // | |
| 4092 // +-- Scaling Layer (adds a 2x scale) | 4093 // +-- Scaling Layer (adds a 2x scale) |
| 4093 // | | 4094 // | |
| 4094 // +-- Content Layer | 4095 // +-- Content Layer |
| 4095 // +--Mask | 4096 // +--Mask |
| 4096 scoped_ptr<LayerImpl> scoped_root = | 4097 scoped_ptr<LayerImpl> scoped_root = |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5065 | 5066 |
| 5066 // We lose the output surface. | 5067 // We lose the output surface. |
| 5067 EXPECT_TRUE(did_lose_output_surface_); | 5068 EXPECT_TRUE(did_lose_output_surface_); |
| 5068 } | 5069 } |
| 5069 | 5070 |
| 5070 // Checks that we have a non-0 default allocation if we pass a context that | 5071 // Checks that we have a non-0 default allocation if we pass a context that |
| 5071 // doesn't support memory management extensions. | 5072 // doesn't support memory management extensions. |
| 5072 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 5073 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
| 5073 LayerTreeSettings settings; | 5074 LayerTreeSettings settings; |
| 5074 host_impl_ = LayerTreeHostImpl::Create( | 5075 host_impl_ = LayerTreeHostImpl::Create( |
| 5075 settings, this, &proxy_, &stats_instrumentation_, NULL); | 5076 settings, this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 5076 | 5077 |
| 5077 scoped_ptr<OutputSurface> output_surface( | 5078 scoped_ptr<OutputSurface> output_surface( |
| 5078 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); | 5079 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create())); |
| 5079 host_impl_->InitializeRenderer(output_surface.Pass()); | 5080 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 5080 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); | 5081 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); |
| 5081 } | 5082 } |
| 5082 | 5083 |
| 5083 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { | 5084 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { |
| 5084 ManagedMemoryPolicy policy1( | 5085 ManagedMemoryPolicy policy1( |
| 5085 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); | 5086 456, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 1000); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5196 } | 5197 } |
| 5197 | 5198 |
| 5198 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { | 5199 void ShutdownReleasesContext_Callback(scoped_ptr<CopyOutputResult> result) { |
| 5199 } | 5200 } |
| 5200 | 5201 |
| 5201 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 5202 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
| 5202 scoped_refptr<TestContextProvider> context_provider = | 5203 scoped_refptr<TestContextProvider> context_provider = |
| 5203 TestContextProvider::Create(); | 5204 TestContextProvider::Create(); |
| 5204 | 5205 |
| 5205 host_impl_ = LayerTreeHostImpl::Create( | 5206 host_impl_ = LayerTreeHostImpl::Create( |
| 5206 LayerTreeSettings(), this, &proxy_, &stats_instrumentation_, NULL); | 5207 LayerTreeSettings(), this, &proxy_, &stats_instrumentation_, NULL, 0); |
| 5207 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d(context_provider) | 5208 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d(context_provider) |
| 5208 .PassAs<OutputSurface>()); | 5209 .PassAs<OutputSurface>()); |
| 5209 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 5210 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 5210 | 5211 |
| 5211 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 5212 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 5212 | 5213 |
| 5213 ScopedPtrVector<CopyOutputRequest> requests; | 5214 ScopedPtrVector<CopyOutputRequest> requests; |
| 5214 requests.push_back(CopyOutputRequest::CreateRequest( | 5215 requests.push_back(CopyOutputRequest::CreateRequest( |
| 5215 base::Bind(&ShutdownReleasesContext_Callback))); | 5216 base::Bind(&ShutdownReleasesContext_Callback))); |
| 5216 | 5217 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5353 // The root should have scrolled. | 5354 // The root should have scrolled. |
| 5354 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 5355 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
| 5355 ExpectContains(*scroll_info.get(), | 5356 ExpectContains(*scroll_info.get(), |
| 5356 host_impl_->active_tree()->root_layer()->id(), | 5357 host_impl_->active_tree()->root_layer()->id(), |
| 5357 gfx::Vector2d(0, 10)); | 5358 gfx::Vector2d(0, 10)); |
| 5358 } | 5359 } |
| 5359 } | 5360 } |
| 5360 | 5361 |
| 5361 } // namespace | 5362 } // namespace |
| 5362 } // namespace cc | 5363 } // namespace cc |
| OLD | NEW |