| 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 16 matching lines...) Expand all Loading... |
| 27 #include "cc/output/compositor_frame_ack.h" | 27 #include "cc/output/compositor_frame_ack.h" |
| 28 #include "cc/output/compositor_frame_metadata.h" | 28 #include "cc/output/compositor_frame_metadata.h" |
| 29 #include "cc/output/gl_renderer.h" | 29 #include "cc/output/gl_renderer.h" |
| 30 #include "cc/quads/render_pass_draw_quad.h" | 30 #include "cc/quads/render_pass_draw_quad.h" |
| 31 #include "cc/quads/solid_color_draw_quad.h" | 31 #include "cc/quads/solid_color_draw_quad.h" |
| 32 #include "cc/quads/texture_draw_quad.h" | 32 #include "cc/quads/texture_draw_quad.h" |
| 33 #include "cc/quads/tile_draw_quad.h" | 33 #include "cc/quads/tile_draw_quad.h" |
| 34 #include "cc/resources/layer_tiling_data.h" | 34 #include "cc/resources/layer_tiling_data.h" |
| 35 #include "cc/test/animation_test_common.h" | 35 #include "cc/test/animation_test_common.h" |
| 36 #include "cc/test/fake_output_surface.h" | 36 #include "cc/test/fake_output_surface.h" |
| 37 #include "cc/test/fake_output_surface_client.h" |
| 37 #include "cc/test/fake_proxy.h" | 38 #include "cc/test/fake_proxy.h" |
| 38 #include "cc/test/fake_rendering_stats_instrumentation.h" | 39 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| 39 #include "cc/test/fake_video_frame_provider.h" | 40 #include "cc/test/fake_video_frame_provider.h" |
| 40 #include "cc/test/geometry_test_utils.h" | 41 #include "cc/test/geometry_test_utils.h" |
| 41 #include "cc/test/layer_test_common.h" | 42 #include "cc/test/layer_test_common.h" |
| 42 #include "cc/test/render_pass_test_common.h" | 43 #include "cc/test/render_pass_test_common.h" |
| 43 #include "cc/trees/layer_tree_impl.h" | 44 #include "cc/trees/layer_tree_impl.h" |
| 44 #include "cc/trees/single_thread_proxy.h" | 45 #include "cc/trees/single_thread_proxy.h" |
| 45 #include "media/base/media.h" | 46 #include "media/base/media.h" |
| 46 #include "testing/gmock/include/gmock/gmock.h" | 47 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 366 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
| 366 bool always_draw = false; | 367 bool always_draw = false; |
| 367 CheckNotifyCalledIfCanDrawChanged(always_draw); | 368 CheckNotifyCalledIfCanDrawChanged(always_draw); |
| 368 } | 369 } |
| 369 | 370 |
| 370 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { | 371 TEST_F(LayerTreeHostImplTest, CanDrawIncompleteFrames) { |
| 371 LayerTreeSettings settings; | 372 LayerTreeSettings settings; |
| 372 settings.impl_side_painting = true; | 373 settings.impl_side_painting = true; |
| 373 host_impl_ = LayerTreeHostImpl::Create( | 374 host_impl_ = LayerTreeHostImpl::Create( |
| 374 settings, this, &proxy_, &stats_instrumentation_); | 375 settings, this, &proxy_, &stats_instrumentation_); |
| 376 |
| 377 scoped_ptr<FakeOutputSurface> output_surface( |
| 378 FakeOutputSurface::CreateAlwaysDrawAndSwap3d()); |
| 379 |
| 375 host_impl_->InitializeRenderer( | 380 host_impl_->InitializeRenderer( |
| 376 FakeOutputSurface::CreateAlwaysDrawAndSwap3d().PassAs<OutputSurface>()); | 381 output_surface.PassAs<OutputSurface>()); |
| 377 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 382 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 378 | 383 |
| 379 bool always_draw = true; | 384 bool always_draw = true; |
| 380 CheckNotifyCalledIfCanDrawChanged(always_draw); | 385 CheckNotifyCalledIfCanDrawChanged(always_draw); |
| 381 } | 386 } |
| 382 | 387 |
| 383 class TestWebGraphicsContext3DMakeCurrentFails | |
| 384 : public TestWebGraphicsContext3D { | |
| 385 public: | |
| 386 virtual bool makeContextCurrent() OVERRIDE { return false; } | |
| 387 }; | |
| 388 | |
| 389 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { | 388 TEST_F(LayerTreeHostImplTest, ScrollDeltaNoLayers) { |
| 390 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); | 389 ASSERT_FALSE(host_impl_->active_tree()->root_layer()); |
| 391 | 390 |
| 392 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 391 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 393 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 392 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 394 } | 393 } |
| 395 | 394 |
| 396 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { | 395 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { |
| 397 { | 396 { |
| 398 scoped_ptr<LayerImpl> root = | 397 scoped_ptr<LayerImpl> root = |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 EXPECT_EQ(InputHandler::ScrollIgnored, | 472 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 474 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 473 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 475 } | 474 } |
| 476 | 475 |
| 477 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 476 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
| 478 LayerTreeSettings settings; | 477 LayerTreeSettings settings; |
| 479 host_impl_ = LayerTreeHostImpl::Create(settings, | 478 host_impl_ = LayerTreeHostImpl::Create(settings, |
| 480 this, | 479 this, |
| 481 &proxy_, | 480 &proxy_, |
| 482 &stats_instrumentation_); | 481 &stats_instrumentation_); |
| 482 scoped_ptr<TestWebGraphicsContext3D> context_owned = |
| 483 TestWebGraphicsContext3D::Create(); |
| 484 context_owned->set_times_make_current_succeeds(0); |
| 485 |
| 486 scoped_ptr<FakeOutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 487 context_owned.Pass())); |
| 483 | 488 |
| 484 // Initialization will fail here. | 489 // Initialization will fail here. |
| 485 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d( | 490 host_impl_->InitializeRenderer(output_surface.PassAs<OutputSurface>()); |
| 486 scoped_ptr<WebKit::WebGraphicsContext3D>( | |
| 487 new TestWebGraphicsContext3DMakeCurrentFails)) | |
| 488 .PassAs<OutputSurface>()); | |
| 489 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 491 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 490 | 492 |
| 491 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 493 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 492 | 494 |
| 493 // We should not crash when trying to scroll after the renderer initialization | 495 // We should not crash when trying to scroll after the renderer initialization |
| 494 // fails. | 496 // fails. |
| 495 EXPECT_EQ(InputHandler::ScrollIgnored, | 497 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 496 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 498 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 497 } | 499 } |
| 498 | 500 |
| (...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2843 } | 2845 } |
| 2844 | 2846 |
| 2845 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 2847 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 2846 public: | 2848 public: |
| 2847 void CreateLayerTreeHostImpl(bool always_draw) { | 2849 void CreateLayerTreeHostImpl(bool always_draw) { |
| 2848 LayerTreeSettings settings; | 2850 LayerTreeSettings settings; |
| 2849 settings.minimum_occlusion_tracking_size = gfx::Size(); | 2851 settings.minimum_occlusion_tracking_size = gfx::Size(); |
| 2850 settings.impl_side_painting = true; | 2852 settings.impl_side_painting = true; |
| 2851 host_impl_ = LayerTreeHostImpl::Create( | 2853 host_impl_ = LayerTreeHostImpl::Create( |
| 2852 settings, this, &proxy_, &stats_instrumentation_); | 2854 settings, this, &proxy_, &stats_instrumentation_); |
| 2853 scoped_ptr<OutputSurface> output_surface; | 2855 |
| 2854 if (always_draw) { | 2856 scoped_ptr<FakeOutputSurface> output_surface; |
| 2855 output_surface = FakeOutputSurface::CreateAlwaysDrawAndSwap3d() | 2857 if (always_draw) |
| 2856 .PassAs<OutputSurface>(); | 2858 output_surface = FakeOutputSurface::CreateAlwaysDrawAndSwap3d().Pass(); |
| 2857 } else { | 2859 else |
| 2858 output_surface = CreateFakeOutputSurface(); | 2860 output_surface = FakeOutputSurface::Create3d().Pass(); |
| 2859 } | 2861 |
| 2860 host_impl_->InitializeRenderer(output_surface.Pass()); | 2862 host_impl_->InitializeRenderer(output_surface.PassAs<OutputSurface>()); |
| 2861 viewport_size_ = gfx::Size(1000, 1000); | 2863 viewport_size_ = gfx::Size(1000, 1000); |
| 2862 } | 2864 } |
| 2863 | 2865 |
| 2864 void SetupActiveTreeLayers() { | 2866 void SetupActiveTreeLayers() { |
| 2865 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 2867 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| 2866 host_impl_->active_tree()->SetRootLayer( | 2868 host_impl_->active_tree()->SetRootLayer( |
| 2867 LayerImpl::Create(host_impl_->active_tree(), 1)); | 2869 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 2868 host_impl_->active_tree()->root_layer()->AddChild( | 2870 host_impl_->active_tree()->root_layer()->AddChild( |
| 2869 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 2871 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 2870 2, | 2872 2, |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3074 } | 3076 } |
| 3075 protected: | 3077 protected: |
| 3076 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 3078 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 3077 : LayerImpl(tree_impl, id) {} | 3079 : LayerImpl(tree_impl, id) {} |
| 3078 }; | 3080 }; |
| 3079 | 3081 |
| 3080 // Only reshape when we know we are going to draw. Otherwise, the reshape | 3082 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 3081 // can leave the window at the wrong size if we never draw and the proper | 3083 // can leave the window at the wrong size if we never draw and the proper |
| 3082 // viewport size is never set. | 3084 // viewport size is never set. |
| 3083 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | 3085 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { |
| 3084 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d( | 3086 scoped_ptr<ReshapeTrackerContext> owned_reshape_tracker( |
| 3085 scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)) | 3087 new ReshapeTrackerContext); |
| 3086 .PassAs<OutputSurface>(); | 3088 ReshapeTrackerContext* reshape_tracker = owned_reshape_tracker.get(); |
| 3087 ReshapeTrackerContext* reshape_tracker = | 3089 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3088 static_cast<ReshapeTrackerContext*>(output_surface->context3d()); | 3090 owned_reshape_tracker.PassAs<TestWebGraphicsContext3D>())); |
| 3089 host_impl_->InitializeRenderer(output_surface.Pass()); | 3091 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 3090 | 3092 |
| 3091 scoped_ptr<LayerImpl> root = | 3093 scoped_ptr<LayerImpl> root = |
| 3092 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 3094 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
| 3093 root->SetAnchorPoint(gfx::PointF()); | 3095 root->SetAnchorPoint(gfx::PointF()); |
| 3094 root->SetBounds(gfx::Size(10, 10)); | 3096 root->SetBounds(gfx::Size(10, 10)); |
| 3095 root->SetContentBounds(gfx::Size(10, 10)); | 3097 root->SetContentBounds(gfx::Size(10, 10)); |
| 3096 root->SetDrawsContent(true); | 3098 root->SetDrawsContent(true); |
| 3097 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3099 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3098 EXPECT_FALSE(reshape_tracker->reshape_called()); | 3100 EXPECT_FALSE(reshape_tracker->reshape_called()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 } | 3170 } |
| 3169 | 3171 |
| 3170 private: | 3172 private: |
| 3171 gfx::Rect update_rect_; | 3173 gfx::Rect update_rect_; |
| 3172 UpdateType last_update_type_; | 3174 UpdateType last_update_type_; |
| 3173 }; | 3175 }; |
| 3174 | 3176 |
| 3175 // Make sure damage tracking propagates all the way to the graphics context, | 3177 // Make sure damage tracking propagates all the way to the graphics context, |
| 3176 // where it should request to swap only the sub-buffer that is damaged. | 3178 // where it should request to swap only the sub-buffer that is damaged. |
| 3177 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { | 3179 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
| 3178 scoped_ptr<OutputSurface> output_surface = | 3180 scoped_ptr<SwapTrackerContext> context(new SwapTrackerContext); |
| 3179 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3181 SwapTrackerContext* swap_tracker = context.get(); |
| 3180 new SwapTrackerContext)).PassAs<OutputSurface>(); | 3182 |
| 3181 SwapTrackerContext* swap_tracker = | 3183 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3182 static_cast<SwapTrackerContext*>(output_surface->context3d()); | 3184 context.PassAs<TestWebGraphicsContext3D>())); |
| 3183 | 3185 |
| 3184 // This test creates its own LayerTreeHostImpl, so | 3186 // This test creates its own LayerTreeHostImpl, so |
| 3185 // that we can force partial swap enabled. | 3187 // that we can force partial swap enabled. |
| 3186 LayerTreeSettings settings; | 3188 LayerTreeSettings settings; |
| 3187 settings.partial_swap_enabled = true; | 3189 settings.partial_swap_enabled = true; |
| 3188 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 3190 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
| 3189 LayerTreeHostImpl::Create(settings, | 3191 LayerTreeHostImpl::Create(settings, |
| 3190 this, | 3192 this, |
| 3191 &proxy_, | 3193 &proxy_, |
| 3192 &stats_instrumentation_); | 3194 &stats_instrumentation_); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3407 | 3409 |
| 3408 EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST)) | 3410 EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST)) |
| 3409 .Times(0); | 3411 .Times(0); |
| 3410 | 3412 |
| 3411 EXPECT_CALL(*context_, scissor(_, _, _, _)) | 3413 EXPECT_CALL(*context_, scissor(_, _, _, _)) |
| 3412 .Times(0); | 3414 .Times(0); |
| 3413 } | 3415 } |
| 3414 }; | 3416 }; |
| 3415 | 3417 |
| 3416 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { | 3418 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { |
| 3417 scoped_ptr<OutputSurface> output_surface = | 3419 scoped_ptr<MockContext> mock_context_owned(new MockContext); |
| 3418 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3420 MockContext* mock_context = mock_context_owned.get(); |
| 3419 new MockContext)).PassAs<OutputSurface>(); | 3421 |
| 3420 MockContext* mock_context = | 3422 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3421 static_cast<MockContext*>(output_surface->context3d()); | 3423 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 3422 MockContextHarness harness(mock_context); | 3424 MockContextHarness harness(mock_context); |
| 3423 | 3425 |
| 3424 // Run test case | 3426 // Run test case |
| 3425 CreateLayerTreeHost(false, output_surface.Pass()); | 3427 CreateLayerTreeHost(false, output_surface.Pass()); |
| 3426 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 3428 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 3427 | 3429 |
| 3428 // Without partial swap, and no clipping, no scissor is set. | 3430 // Without partial swap, and no clipping, no scissor is set. |
| 3429 harness.MustDrawSolidQuad(); | 3431 harness.MustDrawSolidQuad(); |
| 3430 harness.MustSetNoScissor(); | 3432 harness.MustSetNoScissor(); |
| 3431 { | 3433 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3444 { | 3446 { |
| 3445 LayerTreeHostImpl::FrameData frame; | 3447 LayerTreeHostImpl::FrameData frame; |
| 3446 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); | 3448 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect())); |
| 3447 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); | 3449 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); |
| 3448 host_impl_->DidDrawAllLayers(frame); | 3450 host_impl_->DidDrawAllLayers(frame); |
| 3449 } | 3451 } |
| 3450 Mock::VerifyAndClearExpectations(&mock_context); | 3452 Mock::VerifyAndClearExpectations(&mock_context); |
| 3451 } | 3453 } |
| 3452 | 3454 |
| 3453 TEST_F(LayerTreeHostImplTest, PartialSwap) { | 3455 TEST_F(LayerTreeHostImplTest, PartialSwap) { |
| 3454 scoped_ptr<OutputSurface> output_surface = | 3456 scoped_ptr<MockContext> context_owned(new MockContext); |
| 3455 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3457 MockContext* mock_context = context_owned.get(); |
| 3456 new MockContext)).PassAs<OutputSurface>(); | 3458 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3457 MockContext* mock_context = | 3459 context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 3458 static_cast<MockContext*>(output_surface->context3d()); | |
| 3459 MockContextHarness harness(mock_context); | 3460 MockContextHarness harness(mock_context); |
| 3460 | 3461 |
| 3461 CreateLayerTreeHost(true, output_surface.Pass()); | 3462 CreateLayerTreeHost(true, output_surface.Pass()); |
| 3462 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | 3463 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); |
| 3463 | 3464 |
| 3464 // The first frame is not a partially-swapped one. | 3465 // The first frame is not a partially-swapped one. |
| 3465 harness.MustSetScissor(0, 0, 10, 10); | 3466 harness.MustSetScissor(0, 0, 10, 10); |
| 3466 harness.MustDrawSolidQuad(); | 3467 harness.MustDrawSolidQuad(); |
| 3467 { | 3468 { |
| 3468 LayerTreeHostImpl::FrameData frame; | 3469 LayerTreeHostImpl::FrameData frame; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3508 else if (pname == GL_ACTIVE_TEXTURE) | 3509 else if (pname == GL_ACTIVE_TEXTURE) |
| 3509 *value = GL_TEXTURE0; | 3510 *value = GL_TEXTURE0; |
| 3510 } | 3511 } |
| 3511 }; | 3512 }; |
| 3512 | 3513 |
| 3513 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 3514 static scoped_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 3514 bool partial_swap, | 3515 bool partial_swap, |
| 3515 LayerTreeHostImplClient* client, | 3516 LayerTreeHostImplClient* client, |
| 3516 Proxy* proxy, | 3517 Proxy* proxy, |
| 3517 RenderingStatsInstrumentation* stats_instrumentation) { | 3518 RenderingStatsInstrumentation* stats_instrumentation) { |
| 3518 scoped_ptr<OutputSurface> output_surface = | 3519 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3519 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3520 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 3520 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 3521 | 3521 |
| 3522 LayerTreeSettings settings; | 3522 LayerTreeSettings settings; |
| 3523 settings.partial_swap_enabled = partial_swap; | 3523 settings.partial_swap_enabled = partial_swap; |
| 3524 scoped_ptr<LayerTreeHostImpl> my_host_impl = | 3524 scoped_ptr<LayerTreeHostImpl> my_host_impl = |
| 3525 LayerTreeHostImpl::Create(settings, client, proxy, stats_instrumentation); | 3525 LayerTreeHostImpl::Create(settings, client, proxy, stats_instrumentation); |
| 3526 my_host_impl->InitializeRenderer(output_surface.Pass()); | 3526 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3527 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 3527 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
| 3528 | 3528 |
| 3529 /* | 3529 /* |
| 3530 Layers are created as follows: | 3530 Layers are created as follows: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3665 | 3665 |
| 3666 private: | 3666 private: |
| 3667 base::hash_map<WebKit::WebGLId, bool> textures_; | 3667 base::hash_map<WebKit::WebGLId, bool> textures_; |
| 3668 unsigned num_textures_; | 3668 unsigned num_textures_; |
| 3669 }; | 3669 }; |
| 3670 | 3670 |
| 3671 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 3671 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
| 3672 scoped_ptr<TestWebGraphicsContext3D> context = | 3672 scoped_ptr<TestWebGraphicsContext3D> context = |
| 3673 TestWebGraphicsContext3D::Create(); | 3673 TestWebGraphicsContext3D::Create(); |
| 3674 TestWebGraphicsContext3D* context3d = context.get(); | 3674 TestWebGraphicsContext3D* context3d = context.get(); |
| 3675 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d( | 3675 scoped_ptr<OutputSurface> output_surface( |
| 3676 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); | 3676 FakeOutputSurface::Create3d(context.Pass())); |
| 3677 host_impl_->InitializeRenderer(output_surface.Pass()); | 3677 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 3678 | 3678 |
| 3679 scoped_ptr<LayerImpl> root_layer = | 3679 scoped_ptr<LayerImpl> root_layer = |
| 3680 LayerImpl::Create(host_impl_->active_tree(), 1); | 3680 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3681 root_layer->SetBounds(gfx::Size(10, 10)); | 3681 root_layer->SetBounds(gfx::Size(10, 10)); |
| 3682 root_layer->SetAnchorPoint(gfx::PointF()); | 3682 root_layer->SetAnchorPoint(gfx::PointF()); |
| 3683 | 3683 |
| 3684 scoped_refptr<VideoFrame> softwareFrame = | 3684 scoped_refptr<VideoFrame> softwareFrame = |
| 3685 media::VideoFrame::CreateColorFrame( | 3685 media::VideoFrame::CreateColorFrame( |
| 3686 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 3686 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3725 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 3725 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
| 3726 public: | 3726 public: |
| 3727 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); | 3727 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); |
| 3728 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, | 3728 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, |
| 3729 WebKit::WGC3Dsizei count, | 3729 WebKit::WGC3Dsizei count, |
| 3730 WebKit::WGC3Denum type, | 3730 WebKit::WGC3Denum type, |
| 3731 WebKit::WGC3Dintptr offset)); | 3731 WebKit::WGC3Dintptr offset)); |
| 3732 }; | 3732 }; |
| 3733 | 3733 |
| 3734 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 3734 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
| 3735 scoped_ptr<OutputSurface> output_surface = | 3735 scoped_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( |
| 3736 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3736 new MockDrawQuadsToFillScreenContext); |
| 3737 new MockDrawQuadsToFillScreenContext)).PassAs<OutputSurface>(); | 3737 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); |
| 3738 MockDrawQuadsToFillScreenContext* mock_context = | 3738 |
| 3739 static_cast<MockDrawQuadsToFillScreenContext*>( | 3739 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3740 output_surface->context3d()); | 3740 mock_context_owned.PassAs<TestWebGraphicsContext3D>())); |
| 3741 | 3741 |
| 3742 // Run test case | 3742 // Run test case |
| 3743 CreateLayerTreeHost(false, output_surface.Pass()); | 3743 CreateLayerTreeHost(false, output_surface.Pass()); |
| 3744 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 3744 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 3745 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 3745 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 3746 | 3746 |
| 3747 // Verify one quad is drawn when transparent background set is not set. | 3747 // Verify one quad is drawn when transparent background set is not set. |
| 3748 host_impl_->active_tree()->set_has_transparent_background(false); | 3748 host_impl_->active_tree()->set_has_transparent_background(false); |
| 3749 EXPECT_CALL(*mock_context, useProgram(_)) | 3749 EXPECT_CALL(*mock_context, useProgram(_)) |
| 3750 .Times(1); | 3750 .Times(1); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3783 *result = layer_ptr; | 3783 *result = layer_ptr; |
| 3784 } | 3784 } |
| 3785 | 3785 |
| 3786 static void SetupLayersForTextureCaching( | 3786 static void SetupLayersForTextureCaching( |
| 3787 LayerTreeHostImpl* layer_tree_host_impl, | 3787 LayerTreeHostImpl* layer_tree_host_impl, |
| 3788 LayerImpl*& root_ptr, | 3788 LayerImpl*& root_ptr, |
| 3789 LayerImpl*& intermediate_layer_ptr, | 3789 LayerImpl*& intermediate_layer_ptr, |
| 3790 LayerImpl*& surface_layer_ptr, | 3790 LayerImpl*& surface_layer_ptr, |
| 3791 LayerImpl*& child_ptr, | 3791 LayerImpl*& child_ptr, |
| 3792 gfx::Size root_size) { | 3792 gfx::Size root_size) { |
| 3793 scoped_ptr<OutputSurface> output_surface = | 3793 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3794 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3794 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 3795 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 3796 | 3795 |
| 3797 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); | 3796 layer_tree_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3798 layer_tree_host_impl->SetViewportSize(root_size); | 3797 layer_tree_host_impl->SetViewportSize(root_size); |
| 3799 | 3798 |
| 3800 scoped_ptr<LayerImpl> root = | 3799 scoped_ptr<LayerImpl> root = |
| 3801 LayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 3800 LayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 3802 root_ptr = root.get(); | 3801 root_ptr = root.get(); |
| 3803 | 3802 |
| 3804 root->SetAnchorPoint(gfx::PointF()); | 3803 root->SetAnchorPoint(gfx::PointF()); |
| 3805 root->SetPosition(gfx::PointF()); | 3804 root->SetPosition(gfx::PointF()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3862 // | 3861 // |
| 3863 // Occlusion: | 3862 // Occlusion: |
| 3864 // L12 occludes L11 (internal) | 3863 // L12 occludes L11 (internal) |
| 3865 // L20 occludes L10 (external) | 3864 // L20 occludes L10 (external) |
| 3866 // L21 occludes L20 (internal) | 3865 // L21 occludes L20 (internal) |
| 3867 | 3866 |
| 3868 LayerImpl* root_ptr; | 3867 LayerImpl* root_ptr; |
| 3869 LayerImpl* layer_s1_ptr; | 3868 LayerImpl* layer_s1_ptr; |
| 3870 LayerImpl* layer_s2_ptr; | 3869 LayerImpl* layer_s2_ptr; |
| 3871 | 3870 |
| 3872 scoped_ptr<OutputSurface> output_surface = | 3871 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3873 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3872 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 3874 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 3875 | 3873 |
| 3876 gfx::Size root_size(1000, 1000); | 3874 gfx::Size root_size(1000, 1000); |
| 3877 | 3875 |
| 3878 my_host_impl->InitializeRenderer(output_surface.Pass()); | 3876 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3879 my_host_impl->SetViewportSize(root_size); | 3877 my_host_impl->SetViewportSize(root_size); |
| 3880 | 3878 |
| 3881 scoped_ptr<LayerImpl> root = | 3879 scoped_ptr<LayerImpl> root = |
| 3882 LayerImpl::Create(my_host_impl->active_tree(), 1); | 3880 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 3883 root_ptr = root.get(); | 3881 root_ptr = root.get(); |
| 3884 | 3882 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3981 // | +- L13 (corner, unoccluded) | 3979 // | +- L13 (corner, unoccluded) |
| 3982 // | +- L14 (corner, entirely occluded) | 3980 // | +- L14 (corner, entirely occluded) |
| 3983 // | | 3981 // | |
| 3984 // +-- S2 +- L20 (owning, drawing) | 3982 // +-- S2 +- L20 (owning, drawing) |
| 3985 // | 3983 // |
| 3986 | 3984 |
| 3987 LayerImpl* root_ptr; | 3985 LayerImpl* root_ptr; |
| 3988 LayerImpl* layer_s1_ptr; | 3986 LayerImpl* layer_s1_ptr; |
| 3989 LayerImpl* layer_s2_ptr; | 3987 LayerImpl* layer_s2_ptr; |
| 3990 | 3988 |
| 3991 scoped_ptr<OutputSurface> output_surface = | 3989 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 3992 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 3990 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 3993 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 3994 | 3991 |
| 3995 gfx::Size root_size(1000, 1000); | 3992 gfx::Size root_size(1000, 1000); |
| 3996 | 3993 |
| 3997 my_host_impl->InitializeRenderer(output_surface.Pass()); | 3994 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 3998 my_host_impl->SetViewportSize(root_size); | 3995 my_host_impl->SetViewportSize(root_size); |
| 3999 | 3996 |
| 4000 scoped_ptr<LayerImpl> root = | 3997 scoped_ptr<LayerImpl> root = |
| 4001 LayerImpl::Create(my_host_impl->active_tree(), 1); | 3998 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 4002 root_ptr = root.get(); | 3999 root_ptr = root.get(); |
| 4003 | 4000 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4102 // | +- L11 (corner, occluded by L12) | 4099 // | +- L11 (corner, occluded by L12) |
| 4103 // | +- L12 (opposite corner) | 4100 // | +- L12 (opposite corner) |
| 4104 // | | 4101 // | |
| 4105 // +-- S2 +- L20 (owning, drawing) | 4102 // +-- S2 +- L20 (owning, drawing) |
| 4106 // | 4103 // |
| 4107 | 4104 |
| 4108 LayerImpl* root_ptr; | 4105 LayerImpl* root_ptr; |
| 4109 LayerImpl* layer_s1_ptr; | 4106 LayerImpl* layer_s1_ptr; |
| 4110 LayerImpl* layer_s2_ptr; | 4107 LayerImpl* layer_s2_ptr; |
| 4111 | 4108 |
| 4112 scoped_ptr<OutputSurface> output_surface = | 4109 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4113 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 4110 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 4114 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 4115 | 4111 |
| 4116 gfx::Size root_size(1000, 1000); | 4112 gfx::Size root_size(1000, 1000); |
| 4117 | 4113 |
| 4118 my_host_impl->InitializeRenderer(output_surface.Pass()); | 4114 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4119 my_host_impl->SetViewportSize(root_size); | 4115 my_host_impl->SetViewportSize(root_size); |
| 4120 | 4116 |
| 4121 scoped_ptr<LayerImpl> root = | 4117 scoped_ptr<LayerImpl> root = |
| 4122 LayerImpl::Create(my_host_impl->active_tree(), 1); | 4118 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 4123 root_ptr = root.get(); | 4119 root_ptr = root.get(); |
| 4124 | 4120 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4192 &stats_instrumentation_); | 4188 &stats_instrumentation_); |
| 4193 | 4189 |
| 4194 // Layers are structured as follows: | 4190 // Layers are structured as follows: |
| 4195 // | 4191 // |
| 4196 // R +-- S1 +- L10 (rotated, drawing) | 4192 // R +-- S1 +- L10 (rotated, drawing) |
| 4197 // +- L11 (occupies half surface) | 4193 // +- L11 (occupies half surface) |
| 4198 | 4194 |
| 4199 LayerImpl* root_ptr; | 4195 LayerImpl* root_ptr; |
| 4200 LayerImpl* layer_s1_ptr; | 4196 LayerImpl* layer_s1_ptr; |
| 4201 | 4197 |
| 4202 scoped_ptr<OutputSurface> output_surface = | 4198 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4203 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 4199 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 4204 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 4205 | 4200 |
| 4206 gfx::Size root_size(1000, 1000); | 4201 gfx::Size root_size(1000, 1000); |
| 4207 | 4202 |
| 4208 my_host_impl->InitializeRenderer(output_surface.Pass()); | 4203 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4209 my_host_impl->SetViewportSize(root_size); | 4204 my_host_impl->SetViewportSize(root_size); |
| 4210 | 4205 |
| 4211 scoped_ptr<LayerImpl> root = | 4206 scoped_ptr<LayerImpl> root = |
| 4212 LayerImpl::Create(my_host_impl->active_tree(), 1); | 4207 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 4213 root_ptr = root.get(); | 4208 root_ptr = root.get(); |
| 4214 | 4209 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4283 // | 4278 // |
| 4284 // Occlusion: | 4279 // Occlusion: |
| 4285 // L12 occludes L11 (internal) | 4280 // L12 occludes L11 (internal) |
| 4286 // L20 occludes L10 (external) | 4281 // L20 occludes L10 (external) |
| 4287 // L21 occludes L20 (internal) | 4282 // L21 occludes L20 (internal) |
| 4288 | 4283 |
| 4289 LayerImpl* root_ptr; | 4284 LayerImpl* root_ptr; |
| 4290 LayerImpl* layer_s1_ptr; | 4285 LayerImpl* layer_s1_ptr; |
| 4291 LayerImpl* layer_s2_ptr; | 4286 LayerImpl* layer_s2_ptr; |
| 4292 | 4287 |
| 4293 scoped_ptr<OutputSurface> output_surface = | 4288 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4294 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 4289 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 4295 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 4296 | 4290 |
| 4297 gfx::Size root_size(1000, 1000); | 4291 gfx::Size root_size(1000, 1000); |
| 4298 | 4292 |
| 4299 my_host_impl->InitializeRenderer(output_surface.Pass()); | 4293 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4300 my_host_impl->SetViewportSize(root_size); | 4294 my_host_impl->SetViewportSize(root_size); |
| 4301 | 4295 |
| 4302 scoped_ptr<LayerImpl> root = | 4296 scoped_ptr<LayerImpl> root = |
| 4303 LayerImpl::Create(my_host_impl->active_tree(), 1); | 4297 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 4304 root_ptr = root.get(); | 4298 root_ptr = root.get(); |
| 4305 | 4299 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4413 LayerImpl::Create(my_host_impl->active_tree(), 1); | 4407 LayerImpl::Create(my_host_impl->active_tree(), 1); |
| 4414 scoped_ptr<TiledLayerImpl> child = | 4408 scoped_ptr<TiledLayerImpl> child = |
| 4415 TiledLayerImpl::Create(my_host_impl->active_tree(), 2); | 4409 TiledLayerImpl::Create(my_host_impl->active_tree(), 2); |
| 4416 scoped_ptr<LayerImpl> grand_child = | 4410 scoped_ptr<LayerImpl> grand_child = |
| 4417 LayerImpl::Create(my_host_impl->active_tree(), 3); | 4411 LayerImpl::Create(my_host_impl->active_tree(), 3); |
| 4418 | 4412 |
| 4419 gfx::Rect root_rect(0, 0, 100, 100); | 4413 gfx::Rect root_rect(0, 0, 100, 100); |
| 4420 gfx::Rect child_rect(10, 10, 50, 50); | 4414 gfx::Rect child_rect(10, 10, 50, 50); |
| 4421 gfx::Rect grand_child_rect(5, 5, 150, 150); | 4415 gfx::Rect grand_child_rect(5, 5, 150, 150); |
| 4422 | 4416 |
| 4423 scoped_ptr<OutputSurface> output_surface = | 4417 scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d( |
| 4424 FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext3D>( | 4418 scoped_ptr<TestWebGraphicsContext3D>(new PartialSwapContext))); |
| 4425 new PartialSwapContext)).PassAs<OutputSurface>(); | |
| 4426 my_host_impl->InitializeRenderer(output_surface.Pass()); | 4419 my_host_impl->InitializeRenderer(output_surface.Pass()); |
| 4427 | 4420 |
| 4428 root->SetAnchorPoint(gfx::PointF()); | 4421 root->SetAnchorPoint(gfx::PointF()); |
| 4429 root->SetPosition(gfx::PointF(root_rect.x(), root_rect.y())); | 4422 root->SetPosition(gfx::PointF(root_rect.x(), root_rect.y())); |
| 4430 root->SetBounds(gfx::Size(root_rect.width(), root_rect.height())); | 4423 root->SetBounds(gfx::Size(root_rect.width(), root_rect.height())); |
| 4431 root->SetContentBounds(root->bounds()); | 4424 root->SetContentBounds(root->bounds()); |
| 4432 root->SetDrawsContent(true); | 4425 root->SetDrawsContent(true); |
| 4433 root->SetMasksToBounds(true); | 4426 root->SetMasksToBounds(true); |
| 4434 | 4427 |
| 4435 child->SetAnchorPoint(gfx::PointF()); | 4428 child->SetAnchorPoint(gfx::PointF()); |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5289 static void VerifyRenderPassTestData( | 5282 static void VerifyRenderPassTestData( |
| 5290 const TestCase& test_case, | 5283 const TestCase& test_case, |
| 5291 const RenderPassRemovalTestData& test_data) { | 5284 const RenderPassRemovalTestData& test_data) { |
| 5292 char actual_result[1024]; | 5285 char actual_result[1024]; |
| 5293 DumpRenderPassTestData(test_data, actual_result); | 5286 DumpRenderPassTestData(test_data, actual_result); |
| 5294 EXPECT_STREQ(test_case.expected_result, actual_result) << "In test case: " << | 5287 EXPECT_STREQ(test_case.expected_result, actual_result) << "In test case: " << |
| 5295 test_case.name; | 5288 test_case.name; |
| 5296 } | 5289 } |
| 5297 | 5290 |
| 5298 TEST_F(LayerTreeHostImplTest, TestRemoveRenderPasses) { | 5291 TEST_F(LayerTreeHostImplTest, TestRemoveRenderPasses) { |
| 5292 FakeOutputSurfaceClient output_surface_client; |
| 5299 scoped_ptr<OutputSurface> output_surface(CreateOutputSurface()); | 5293 scoped_ptr<OutputSurface> output_surface(CreateOutputSurface()); |
| 5300 ASSERT_TRUE(output_surface->context3d()); | 5294 ASSERT_TRUE(output_surface->BindToClient(&output_surface_client)); |
| 5295 ASSERT_TRUE(output_surface->context_provider()); |
| 5296 |
| 5301 scoped_ptr<ResourceProvider> resource_provider = | 5297 scoped_ptr<ResourceProvider> resource_provider = |
| 5302 ResourceProvider::Create(output_surface.get(), 0); | 5298 ResourceProvider::Create(output_surface.get(), 0); |
| 5303 | 5299 |
| 5304 scoped_ptr<TestRenderer> renderer = | 5300 scoped_ptr<TestRenderer> renderer = |
| 5305 TestRenderer::Create(resource_provider.get(), | 5301 TestRenderer::Create(resource_provider.get(), |
| 5306 output_surface.get(), | 5302 output_surface.get(), |
| 5307 &proxy_); | 5303 &proxy_); |
| 5308 | 5304 |
| 5309 int test_case_index = 0; | 5305 int test_case_index = 0; |
| 5310 while (remove_render_passes_cases[test_case_index].name) { | 5306 while (remove_render_passes_cases[test_case_index].name) { |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6206 video_layer->SetContentBounds(gfx::Size(10, 10)); | 6202 video_layer->SetContentBounds(gfx::Size(10, 10)); |
| 6207 video_layer->SetDrawsContent(true); | 6203 video_layer->SetDrawsContent(true); |
| 6208 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); | 6204 root_layer->AddChild(video_layer.PassAs<LayerImpl>()); |
| 6209 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); | 6205 SetupRootLayerImpl(root_layer.PassAs<LayerImpl>()); |
| 6210 | 6206 |
| 6211 // Software draw. | 6207 // Software draw. |
| 6212 DrawFrame(); | 6208 DrawFrame(); |
| 6213 | 6209 |
| 6214 // DeferredInitialize and hardware draw. | 6210 // DeferredInitialize and hardware draw. |
| 6215 EXPECT_FALSE(did_try_initialize_renderer_); | 6211 EXPECT_FALSE(did_try_initialize_renderer_); |
| 6216 EXPECT_TRUE(output_surface_ptr->SetAndInitializeContext3D( | 6212 EXPECT_TRUE(output_surface_ptr->InitializeAndSetContext3d( |
| 6217 scoped_ptr<WebKit::WebGraphicsContext3D>( | 6213 TestContextProvider::Create(), NULL)); |
| 6218 TestWebGraphicsContext3D::Create()))); | |
| 6219 EXPECT_TRUE(did_try_initialize_renderer_); | 6214 EXPECT_TRUE(did_try_initialize_renderer_); |
| 6220 | 6215 |
| 6221 // Defer intialized GL draw. | 6216 // Defer intialized GL draw. |
| 6222 DrawFrame(); | 6217 DrawFrame(); |
| 6223 | 6218 |
| 6224 // Revert back to software. | 6219 // Revert back to software. |
| 6225 did_try_initialize_renderer_ = false; | 6220 did_try_initialize_renderer_ = false; |
| 6226 output_surface_ptr->ReleaseGL(); | 6221 output_surface_ptr->ReleaseGL(); |
| 6227 EXPECT_TRUE(did_try_initialize_renderer_); | 6222 EXPECT_TRUE(did_try_initialize_renderer_); |
| 6228 DrawFrame(); | 6223 DrawFrame(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6239 | 6234 |
| 6240 // Checks that we have a non-0 default allocation if we pass a context that | 6235 // Checks that we have a non-0 default allocation if we pass a context that |
| 6241 // doesn't support memory management extensions. | 6236 // doesn't support memory management extensions. |
| 6242 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 6237 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
| 6243 LayerTreeSettings settings; | 6238 LayerTreeSettings settings; |
| 6244 host_impl_ = LayerTreeHostImpl::Create(settings, | 6239 host_impl_ = LayerTreeHostImpl::Create(settings, |
| 6245 this, | 6240 this, |
| 6246 &proxy_, | 6241 &proxy_, |
| 6247 &stats_instrumentation_); | 6242 &stats_instrumentation_); |
| 6248 | 6243 |
| 6249 host_impl_->InitializeRenderer(FakeOutputSurface::Create3d( | 6244 scoped_ptr<OutputSurface> output_surface( |
| 6250 scoped_ptr<WebKit::WebGraphicsContext3D>( | 6245 FakeOutputSurface::Create3d(scoped_ptr<TestWebGraphicsContext3D>( |
| 6251 new ContextThatDoesNotSupportMemoryManagmentExtensions)) | 6246 new ContextThatDoesNotSupportMemoryManagmentExtensions))); |
| 6252 .PassAs<OutputSurface>()); | 6247 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6253 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); | 6248 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); |
| 6254 } | 6249 } |
| 6255 | 6250 |
| 6256 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { | 6251 TEST_F(LayerTreeHostImplTest, MemoryPolicy) { |
| 6257 ManagedMemoryPolicy policy1( | 6252 ManagedMemoryPolicy policy1( |
| 6258 456, ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, | 6253 456, ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
| 6259 123, ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, 1000); | 6254 123, ManagedMemoryPolicy::CUTOFF_ALLOW_NICE_TO_HAVE, 1000); |
| 6260 int visible_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( | 6255 int visible_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( |
| 6261 policy1.priority_cutoff_when_visible); | 6256 policy1.priority_cutoff_when_visible); |
| 6262 int not_visible_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( | 6257 int not_visible_cutoff_value = ManagedMemoryPolicy::PriorityCutoffToValue( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6273 | 6268 |
| 6274 host_impl_->SetVisible(true); | 6269 host_impl_->SetVisible(true); |
| 6275 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); | 6270 EXPECT_EQ(policy1.bytes_limit_when_visible, current_limit_bytes_); |
| 6276 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); | 6271 EXPECT_EQ(visible_cutoff_value, current_priority_cutoff_value_); |
| 6277 } | 6272 } |
| 6278 | 6273 |
| 6279 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 6274 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
| 6280 scoped_ptr<TestWebGraphicsContext3D> context = | 6275 scoped_ptr<TestWebGraphicsContext3D> context = |
| 6281 TestWebGraphicsContext3D::Create(); | 6276 TestWebGraphicsContext3D::Create(); |
| 6282 TestWebGraphicsContext3D* context3d = context.get(); | 6277 TestWebGraphicsContext3D* context3d = context.get(); |
| 6283 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d( | 6278 scoped_ptr<OutputSurface> output_surface = CreateFakeOutputSurface(); |
| 6284 context.PassAs<WebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>(); | |
| 6285 host_impl_->InitializeRenderer(output_surface.Pass()); | 6279 host_impl_->InitializeRenderer(output_surface.Pass()); |
| 6286 | 6280 |
| 6287 EXPECT_EQ(0u, context3d->NumTextures()); | 6281 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6288 | 6282 |
| 6289 UIResourceId ui_resource_id = 1; | 6283 UIResourceId ui_resource_id = 1; |
| 6290 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( | 6284 scoped_refptr<UIResourceBitmap> bitmap = UIResourceBitmap::Create( |
| 6291 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); | 6285 new uint8_t[1], UIResourceBitmap::RGBA8, gfx::Size(1, 1)); |
| 6292 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 6286 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
| 6293 EXPECT_EQ(1u, context3d->NumTextures()); | 6287 EXPECT_EQ(1u, context3d->NumTextures()); |
| 6294 ResourceProvider::ResourceId id1 = | 6288 ResourceProvider::ResourceId id1 = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6317 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); | 6311 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); |
| 6318 EXPECT_EQ(0u, context3d->NumTextures()); | 6312 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6319 | 6313 |
| 6320 // Should not change state for multiple deletion on one UIResourceId | 6314 // Should not change state for multiple deletion on one UIResourceId |
| 6321 host_impl_->DeleteUIResource(ui_resource_id); | 6315 host_impl_->DeleteUIResource(ui_resource_id); |
| 6322 EXPECT_EQ(0u, context3d->NumTextures()); | 6316 EXPECT_EQ(0u, context3d->NumTextures()); |
| 6323 } | 6317 } |
| 6324 | 6318 |
| 6325 } // namespace | 6319 } // namespace |
| 6326 } // namespace cc | 6320 } // namespace cc |
| OLD | NEW |