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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 #include "cc/test/fake_mask_layer_impl.h" | 50 #include "cc/test/fake_mask_layer_impl.h" |
51 #include "cc/test/fake_output_surface.h" | 51 #include "cc/test/fake_output_surface.h" |
52 #include "cc/test/fake_output_surface_client.h" | 52 #include "cc/test/fake_output_surface_client.h" |
53 #include "cc/test/fake_picture_layer_impl.h" | 53 #include "cc/test/fake_picture_layer_impl.h" |
54 #include "cc/test/fake_raster_source.h" | 54 #include "cc/test/fake_raster_source.h" |
55 #include "cc/test/fake_video_frame_provider.h" | 55 #include "cc/test/fake_video_frame_provider.h" |
56 #include "cc/test/geometry_test_utils.h" | 56 #include "cc/test/geometry_test_utils.h" |
57 #include "cc/test/gpu_rasterization_enabled_settings.h" | 57 #include "cc/test/gpu_rasterization_enabled_settings.h" |
58 #include "cc/test/layer_test_common.h" | 58 #include "cc/test/layer_test_common.h" |
59 #include "cc/test/layer_tree_test.h" | 59 #include "cc/test/layer_tree_test.h" |
60 #include "cc/test/test_delegating_output_surface.h" | |
60 #include "cc/test/test_gpu_memory_buffer_manager.h" | 61 #include "cc/test/test_gpu_memory_buffer_manager.h" |
61 #include "cc/test/test_shared_bitmap_manager.h" | 62 #include "cc/test/test_shared_bitmap_manager.h" |
62 #include "cc/test/test_task_graph_runner.h" | 63 #include "cc/test/test_task_graph_runner.h" |
63 #include "cc/test/test_web_graphics_context_3d.h" | 64 #include "cc/test/test_web_graphics_context_3d.h" |
64 #include "cc/trees/effect_node.h" | 65 #include "cc/trees/effect_node.h" |
66 #include "cc/trees/layer_tree_host_common.h" | |
65 #include "cc/trees/layer_tree_impl.h" | 67 #include "cc/trees/layer_tree_impl.h" |
66 #include "cc/trees/single_thread_proxy.h" | 68 #include "cc/trees/single_thread_proxy.h" |
67 #include "cc/trees/transform_node.h" | 69 #include "cc/trees/transform_node.h" |
68 #include "media/base/media.h" | 70 #include "media/base/media.h" |
69 #include "testing/gmock/include/gmock/gmock.h" | 71 #include "testing/gmock/include/gmock/gmock.h" |
70 #include "testing/gtest/include/gtest/gtest.h" | 72 #include "testing/gtest/include/gtest/gtest.h" |
71 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 73 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
72 #include "ui/gfx/geometry/rect_conversions.h" | 74 #include "ui/gfx/geometry/rect_conversions.h" |
73 #include "ui/gfx/geometry/size_conversions.h" | 75 #include "ui/gfx/geometry/size_conversions.h" |
74 #include "ui/gfx/geometry/vector2d_conversions.h" | 76 #include "ui/gfx/geometry/vector2d_conversions.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 std::unique_ptr<ScrollState> scroll_state( | 451 std::unique_ptr<ScrollState> scroll_state( |
450 new ScrollState(scroll_state_data)); | 452 new ScrollState(scroll_state_data)); |
451 return scroll_state; | 453 return scroll_state; |
452 } | 454 } |
453 | 455 |
454 void DrawFrame() { | 456 void DrawFrame() { |
455 LayerTreeHostImpl::FrameData frame; | 457 LayerTreeHostImpl::FrameData frame; |
456 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 458 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
457 host_impl_->DrawLayers(&frame); | 459 host_impl_->DrawLayers(&frame); |
458 host_impl_->DidDrawAllLayers(frame); | 460 host_impl_->DidDrawAllLayers(frame); |
461 host_impl_->SwapBuffers(frame); | |
459 } | 462 } |
460 | 463 |
461 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); | 464 void pinch_zoom_pan_viewport_forces_commit_redraw(float device_scale_factor); |
462 void pinch_zoom_pan_viewport_test(float device_scale_factor); | 465 void pinch_zoom_pan_viewport_test(float device_scale_factor); |
463 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); | 466 void pinch_zoom_pan_viewport_and_scroll_test(float device_scale_factor); |
464 void pinch_zoom_pan_viewport_and_scroll_boundary_test( | 467 void pinch_zoom_pan_viewport_and_scroll_boundary_test( |
465 float device_scale_factor); | 468 float device_scale_factor); |
466 | 469 |
467 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); | 470 void SetupMouseMoveAtWithDeviceScale(float device_scale_factor); |
468 | 471 |
469 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 472 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
470 | 473 |
471 protected: | 474 protected: |
472 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { | 475 virtual std::unique_ptr<OutputSurface> CreateOutputSurface() { |
473 return FakeOutputSurface::Create3d(); | 476 return FakeOutputSurface::CreateDelegating3d(); |
474 } | 477 } |
475 | 478 |
476 void DrawOneFrame() { | 479 void DrawOneFrame() { |
477 LayerTreeHostImpl::FrameData frame_data; | 480 LayerTreeHostImpl::FrameData frame_data; |
478 host_impl_->PrepareToDraw(&frame_data); | 481 host_impl_->PrepareToDraw(&frame_data); |
479 host_impl_->DidDrawAllLayers(frame_data); | 482 host_impl_->DidDrawAllLayers(frame_data); |
480 } | 483 } |
481 | 484 |
482 static void SetScrollOffsetDelta(LayerImpl* layer_impl, | 485 static void SetScrollOffsetDelta(LayerImpl* layer_impl, |
483 const gfx::Vector2dF& delta) { | 486 const gfx::Vector2dF& delta) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 on_can_draw_state_changed_called_ = false; | 566 on_can_draw_state_changed_called_ = false; |
564 | 567 |
565 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 568 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
566 EXPECT_TRUE(host_impl_->CanDraw()); | 569 EXPECT_TRUE(host_impl_->CanDraw()); |
567 EXPECT_TRUE(on_can_draw_state_changed_called_); | 570 EXPECT_TRUE(on_can_draw_state_changed_called_); |
568 on_can_draw_state_changed_called_ = false; | 571 on_can_draw_state_changed_called_ = false; |
569 } | 572 } |
570 | 573 |
571 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { | 574 TEST_F(LayerTreeHostImplTest, ResourcelessDrawWithEmptyViewport) { |
572 CreateHostImpl(DefaultSettings(), | 575 CreateHostImpl(DefaultSettings(), |
573 FakeOutputSurface::CreateSoftware( | 576 FakeOutputSurface::CreateDelegatingSoftware( |
574 base::WrapUnique(new SoftwareOutputDevice()))); | 577 base::WrapUnique(new SoftwareOutputDevice()))); |
575 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 578 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
576 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 579 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
577 | 580 |
578 EXPECT_TRUE(host_impl_->CanDraw()); | 581 EXPECT_TRUE(host_impl_->CanDraw()); |
579 host_impl_->SetViewportSize(gfx::Size()); | 582 host_impl_->SetViewportSize(gfx::Size()); |
580 EXPECT_FALSE(host_impl_->CanDraw()); | 583 EXPECT_FALSE(host_impl_->CanDraw()); |
581 | 584 |
582 FakeOutputSurface* fake_output_surface = | 585 FakeOutputSurface* fake_output_surface = |
583 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); | 586 static_cast<FakeOutputSurface*>(host_impl_->output_surface()); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, | 729 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer, |
727 status.main_thread_scrolling_reasons); | 730 status.main_thread_scrolling_reasons); |
728 } | 731 } |
729 | 732 |
730 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 733 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
731 std::unique_ptr<TestWebGraphicsContext3D> context_owned = | 734 std::unique_ptr<TestWebGraphicsContext3D> context_owned = |
732 TestWebGraphicsContext3D::Create(); | 735 TestWebGraphicsContext3D::Create(); |
733 context_owned->set_context_lost(true); | 736 context_owned->set_context_lost(true); |
734 | 737 |
735 // Initialization will fail. | 738 // Initialization will fail. |
736 EXPECT_FALSE( | 739 EXPECT_FALSE(CreateHostImpl( |
737 CreateHostImpl(DefaultSettings(), | 740 DefaultSettings(), |
738 FakeOutputSurface::Create3d(std::move(context_owned)))); | 741 FakeOutputSurface::CreateDelegating3d(std::move(context_owned)))); |
739 | 742 |
740 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 743 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
741 | 744 |
742 // We should not crash when trying to scroll after the renderer initialization | 745 // We should not crash when trying to scroll after the renderer initialization |
743 // fails. | 746 // fails. |
744 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 747 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
745 BeginState(gfx::Point()).get(), InputHandler::WHEEL); | 748 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
746 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 749 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
747 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 750 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
748 status.main_thread_scrolling_reasons); | 751 status.main_thread_scrolling_reasons); |
(...skipping 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3421 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3424 DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
3422 root->test_properties()->force_render_surface = true; | 3425 root->test_properties()->force_render_surface = true; |
3423 DidDrawCheckLayer* layer = | 3426 DidDrawCheckLayer* layer = |
3424 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); | 3427 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
3425 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3428 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
3426 | 3429 |
3427 { | 3430 { |
3428 LayerTreeHostImpl::FrameData frame; | 3431 LayerTreeHostImpl::FrameData frame; |
3429 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3432 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3430 host_impl_->DrawLayers(&frame); | 3433 host_impl_->DrawLayers(&frame); |
3434 host_impl_->SwapBuffers(frame); | |
3431 host_impl_->DidDrawAllLayers(frame); | 3435 host_impl_->DidDrawAllLayers(frame); |
3432 | 3436 |
3433 EXPECT_TRUE(layer->will_draw_called()); | 3437 EXPECT_TRUE(layer->will_draw_called()); |
3434 EXPECT_TRUE(layer->append_quads_called()); | 3438 EXPECT_TRUE(layer->append_quads_called()); |
3435 EXPECT_TRUE(layer->did_draw_called()); | 3439 EXPECT_TRUE(layer->did_draw_called()); |
3436 } | 3440 } |
3437 | 3441 |
3438 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); | 3442 host_impl_->SetViewportDamage(gfx::Rect(10, 10)); |
3439 | 3443 |
3440 { | 3444 { |
3441 LayerTreeHostImpl::FrameData frame; | 3445 LayerTreeHostImpl::FrameData frame; |
3442 | 3446 |
3443 layer->set_will_draw_returns_false(); | 3447 layer->set_will_draw_returns_false(); |
3444 layer->ClearDidDrawCheck(); | 3448 layer->ClearDidDrawCheck(); |
3445 | 3449 |
3446 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3450 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3447 host_impl_->DrawLayers(&frame); | 3451 host_impl_->DrawLayers(&frame); |
3452 host_impl_->SwapBuffers(frame); | |
3448 host_impl_->DidDrawAllLayers(frame); | 3453 host_impl_->DidDrawAllLayers(frame); |
3449 | 3454 |
3450 EXPECT_TRUE(layer->will_draw_called()); | 3455 EXPECT_TRUE(layer->will_draw_called()); |
3451 EXPECT_FALSE(layer->append_quads_called()); | 3456 EXPECT_FALSE(layer->append_quads_called()); |
3452 EXPECT_FALSE(layer->did_draw_called()); | 3457 EXPECT_FALSE(layer->did_draw_called()); |
3453 } | 3458 } |
3454 } | 3459 } |
3455 | 3460 |
3456 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { | 3461 TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { |
3457 // The root layer is always drawn, so run this test on a child layer that | 3462 // The root layer is always drawn, so run this test on a child layer that |
(...skipping 13 matching lines...) Expand all Loading... | |
3471 layer->SetBounds(gfx::Size(10, 10)); | 3476 layer->SetBounds(gfx::Size(10, 10)); |
3472 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3477 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
3473 | 3478 |
3474 LayerTreeHostImpl::FrameData frame; | 3479 LayerTreeHostImpl::FrameData frame; |
3475 | 3480 |
3476 EXPECT_FALSE(layer->will_draw_called()); | 3481 EXPECT_FALSE(layer->will_draw_called()); |
3477 EXPECT_FALSE(layer->did_draw_called()); | 3482 EXPECT_FALSE(layer->did_draw_called()); |
3478 | 3483 |
3479 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3484 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3480 host_impl_->DrawLayers(&frame); | 3485 host_impl_->DrawLayers(&frame); |
3486 host_impl_->SwapBuffers(frame); | |
3481 host_impl_->DidDrawAllLayers(frame); | 3487 host_impl_->DidDrawAllLayers(frame); |
3482 | 3488 |
3483 EXPECT_FALSE(layer->will_draw_called()); | 3489 EXPECT_FALSE(layer->will_draw_called()); |
3484 EXPECT_FALSE(layer->did_draw_called()); | 3490 EXPECT_FALSE(layer->did_draw_called()); |
3485 | 3491 |
3486 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); | 3492 EXPECT_TRUE(layer->visible_layer_rect().IsEmpty()); |
3487 | 3493 |
3488 // Ensure visible_layer_rect for layer is not empty | 3494 // Ensure visible_layer_rect for layer is not empty |
3489 layer->SetPosition(gfx::PointF()); | 3495 layer->SetPosition(gfx::PointF()); |
3490 layer->NoteLayerPropertyChanged(); | 3496 layer->NoteLayerPropertyChanged(); |
3491 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 3497 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
3492 | 3498 |
3493 EXPECT_FALSE(layer->will_draw_called()); | 3499 EXPECT_FALSE(layer->will_draw_called()); |
3494 EXPECT_FALSE(layer->did_draw_called()); | 3500 EXPECT_FALSE(layer->did_draw_called()); |
3495 | 3501 |
3496 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3502 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3497 host_impl_->DrawLayers(&frame); | 3503 host_impl_->DrawLayers(&frame); |
3504 host_impl_->SwapBuffers(frame); | |
3498 host_impl_->DidDrawAllLayers(frame); | 3505 host_impl_->DidDrawAllLayers(frame); |
3499 | 3506 |
3500 EXPECT_TRUE(layer->will_draw_called()); | 3507 EXPECT_TRUE(layer->will_draw_called()); |
3501 EXPECT_TRUE(layer->did_draw_called()); | 3508 EXPECT_TRUE(layer->did_draw_called()); |
3502 | 3509 |
3503 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); | 3510 EXPECT_FALSE(layer->visible_layer_rect().IsEmpty()); |
3504 } | 3511 } |
3505 | 3512 |
3506 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { | 3513 TEST_F(LayerTreeHostImplTest, WillDrawNotCalledOnOccludedLayer) { |
3507 gfx::Size big_size(1000, 1000); | 3514 gfx::Size big_size(1000, 1000); |
(...skipping 22 matching lines...) Expand all Loading... | |
3530 | 3537 |
3531 LayerTreeHostImpl::FrameData frame; | 3538 LayerTreeHostImpl::FrameData frame; |
3532 | 3539 |
3533 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3540 EXPECT_FALSE(occluded_layer->will_draw_called()); |
3534 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3541 EXPECT_FALSE(occluded_layer->did_draw_called()); |
3535 EXPECT_FALSE(top_layer->will_draw_called()); | 3542 EXPECT_FALSE(top_layer->will_draw_called()); |
3536 EXPECT_FALSE(top_layer->did_draw_called()); | 3543 EXPECT_FALSE(top_layer->did_draw_called()); |
3537 | 3544 |
3538 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3545 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3539 host_impl_->DrawLayers(&frame); | 3546 host_impl_->DrawLayers(&frame); |
3547 host_impl_->SwapBuffers(frame); | |
3540 host_impl_->DidDrawAllLayers(frame); | 3548 host_impl_->DidDrawAllLayers(frame); |
3541 | 3549 |
3542 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3550 EXPECT_FALSE(occluded_layer->will_draw_called()); |
3543 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3551 EXPECT_FALSE(occluded_layer->did_draw_called()); |
3544 EXPECT_TRUE(top_layer->will_draw_called()); | 3552 EXPECT_TRUE(top_layer->will_draw_called()); |
3545 EXPECT_TRUE(top_layer->did_draw_called()); | 3553 EXPECT_TRUE(top_layer->did_draw_called()); |
3546 } | 3554 } |
3547 | 3555 |
3548 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3556 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
3549 host_impl_->active_tree()->SetRootLayerForTesting( | 3557 host_impl_->active_tree()->SetRootLayerForTesting( |
(...skipping 18 matching lines...) Expand all Loading... | |
3568 | 3576 |
3569 EXPECT_FALSE(root->did_draw_called()); | 3577 EXPECT_FALSE(root->did_draw_called()); |
3570 EXPECT_FALSE(layer1->did_draw_called()); | 3578 EXPECT_FALSE(layer1->did_draw_called()); |
3571 EXPECT_FALSE(layer2->did_draw_called()); | 3579 EXPECT_FALSE(layer2->did_draw_called()); |
3572 | 3580 |
3573 LayerTreeHostImpl::FrameData frame; | 3581 LayerTreeHostImpl::FrameData frame; |
3574 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3582 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
3575 *host_impl_->active_tree()->begin()); | 3583 *host_impl_->active_tree()->begin()); |
3576 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 3584 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
3577 host_impl_->DrawLayers(&frame); | 3585 host_impl_->DrawLayers(&frame); |
3586 host_impl_->SwapBuffers(frame); | |
3578 host_impl_->DidDrawAllLayers(frame); | 3587 host_impl_->DidDrawAllLayers(frame); |
3579 | 3588 |
3580 EXPECT_TRUE(root->did_draw_called()); | 3589 EXPECT_TRUE(root->did_draw_called()); |
3581 EXPECT_TRUE(layer1->did_draw_called()); | 3590 EXPECT_TRUE(layer1->did_draw_called()); |
3582 EXPECT_TRUE(layer2->did_draw_called()); | 3591 EXPECT_TRUE(layer2->did_draw_called()); |
3583 | 3592 |
3584 EXPECT_NE(root->render_surface(), layer1->render_surface()); | 3593 EXPECT_NE(root->render_surface(), layer1->render_surface()); |
3585 EXPECT_TRUE(layer1->render_surface()); | 3594 EXPECT_TRUE(layer1->render_surface()); |
3586 } | 3595 } |
3587 | 3596 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3784 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); | 3793 EXPECT_EQ(testcase.expected_result, host_impl_->PrepareToDraw(&frame)); |
3785 host_impl_->DrawLayers(&frame); | 3794 host_impl_->DrawLayers(&frame); |
3786 host_impl_->DidDrawAllLayers(frame); | 3795 host_impl_->DidDrawAllLayers(frame); |
3787 host_impl_->SwapBuffers(frame); | 3796 host_impl_->SwapBuffers(frame); |
3788 } | 3797 } |
3789 } | 3798 } |
3790 | 3799 |
3791 TEST_F(LayerTreeHostImplTest, | 3800 TEST_F(LayerTreeHostImplTest, |
3792 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { | 3801 PrepareToDrawWhenDrawAndSwapFullViewportEveryFrame) { |
3793 CreateHostImpl(DefaultSettings(), | 3802 CreateHostImpl(DefaultSettings(), |
3794 FakeOutputSurface::CreateSoftware( | 3803 FakeOutputSurface::CreateDelegatingSoftware( |
3795 base::WrapUnique(new SoftwareOutputDevice()))); | 3804 base::WrapUnique(new SoftwareOutputDevice()))); |
3796 | 3805 |
3797 const gfx::Transform external_transform; | 3806 const gfx::Transform external_transform; |
3798 const gfx::Rect external_viewport; | 3807 const gfx::Rect external_viewport; |
3799 const gfx::Rect external_clip; | 3808 const gfx::Rect external_clip; |
3800 const bool resourceless_software_draw = true; | 3809 const bool resourceless_software_draw = true; |
3801 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 3810 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
3802 external_transform); | 3811 external_transform); |
3803 | 3812 |
3804 std::vector<PrepareToDrawSuccessTestCase> cases; | 3813 std::vector<PrepareToDrawSuccessTestCase> cases; |
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6466 | 6475 |
6467 // Opaque layer, drawn without blending. | 6476 // Opaque layer, drawn without blending. |
6468 layer1->SetContentsOpaque(true); | 6477 layer1->SetContentsOpaque(true); |
6469 layer1->SetExpectation(false, false); | 6478 layer1->SetExpectation(false, false); |
6470 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6479 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6471 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6480 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6472 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6481 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6473 host_impl_->DrawLayers(&frame); | 6482 host_impl_->DrawLayers(&frame); |
6474 EXPECT_TRUE(layer1->quads_appended()); | 6483 EXPECT_TRUE(layer1->quads_appended()); |
6475 host_impl_->DidDrawAllLayers(frame); | 6484 host_impl_->DidDrawAllLayers(frame); |
6485 host_impl_->SwapBuffers(frame); | |
6476 | 6486 |
6477 // Layer with translucent content and painting, so drawn with blending. | 6487 // Layer with translucent content and painting, so drawn with blending. |
6478 layer1->SetContentsOpaque(false); | 6488 layer1->SetContentsOpaque(false); |
6479 layer1->SetExpectation(true, false); | 6489 layer1->SetExpectation(true, false); |
6480 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6490 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6481 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6491 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6482 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6492 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6483 host_impl_->DrawLayers(&frame); | 6493 host_impl_->DrawLayers(&frame); |
6494 host_impl_->SwapBuffers(frame); | |
6484 EXPECT_TRUE(layer1->quads_appended()); | 6495 EXPECT_TRUE(layer1->quads_appended()); |
6485 host_impl_->DidDrawAllLayers(frame); | 6496 host_impl_->DidDrawAllLayers(frame); |
6486 | 6497 |
6487 // Layer with translucent opacity, drawn with blending. | 6498 // Layer with translucent opacity, drawn with blending. |
6488 layer1->SetContentsOpaque(true); | 6499 layer1->SetContentsOpaque(true); |
6489 layer1->test_properties()->opacity = 0.5f; | 6500 layer1->test_properties()->opacity = 0.5f; |
6490 layer1->NoteLayerPropertyChanged(); | 6501 layer1->NoteLayerPropertyChanged(); |
6491 layer1->SetExpectation(true, false); | 6502 layer1->SetExpectation(true, false); |
6492 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6503 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6493 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6504 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6494 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6505 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6495 host_impl_->DrawLayers(&frame); | 6506 host_impl_->DrawLayers(&frame); |
6507 host_impl_->SwapBuffers(frame); | |
6496 EXPECT_TRUE(layer1->quads_appended()); | 6508 EXPECT_TRUE(layer1->quads_appended()); |
6497 host_impl_->DidDrawAllLayers(frame); | 6509 host_impl_->DidDrawAllLayers(frame); |
6498 | 6510 |
6499 // Layer with translucent opacity and painting, drawn with blending. | 6511 // Layer with translucent opacity and painting, drawn with blending. |
6500 layer1->SetContentsOpaque(true); | 6512 layer1->SetContentsOpaque(true); |
6501 layer1->test_properties()->opacity = 0.5f; | 6513 layer1->test_properties()->opacity = 0.5f; |
6502 layer1->NoteLayerPropertyChanged(); | 6514 layer1->NoteLayerPropertyChanged(); |
6503 layer1->SetExpectation(true, false); | 6515 layer1->SetExpectation(true, false); |
6504 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6516 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6505 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6517 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6506 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6518 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6507 host_impl_->DrawLayers(&frame); | 6519 host_impl_->DrawLayers(&frame); |
6520 host_impl_->SwapBuffers(frame); | |
6508 EXPECT_TRUE(layer1->quads_appended()); | 6521 EXPECT_TRUE(layer1->quads_appended()); |
6509 host_impl_->DidDrawAllLayers(frame); | 6522 host_impl_->DidDrawAllLayers(frame); |
6510 | 6523 |
6511 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( | 6524 layer1->test_properties()->AddChild(BlendStateCheckLayer::Create( |
6512 host_impl_->active_tree(), 3, host_impl_->resource_provider())); | 6525 host_impl_->active_tree(), 3, host_impl_->resource_provider())); |
6513 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( | 6526 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( |
6514 layer1->test_properties()->children[0]); | 6527 layer1->test_properties()->children[0]); |
6515 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 6528 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
6516 | 6529 |
6517 // 2 opaque layers, drawn without blending. | 6530 // 2 opaque layers, drawn without blending. |
6518 layer1->SetContentsOpaque(true); | 6531 layer1->SetContentsOpaque(true); |
6519 layer1->test_properties()->opacity = 1.f; | 6532 layer1->test_properties()->opacity = 1.f; |
6520 layer1->NoteLayerPropertyChanged(); | 6533 layer1->NoteLayerPropertyChanged(); |
6521 layer1->SetExpectation(false, false); | 6534 layer1->SetExpectation(false, false); |
6522 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6535 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6523 layer2->SetContentsOpaque(true); | 6536 layer2->SetContentsOpaque(true); |
6524 layer2->test_properties()->opacity = 1.f; | 6537 layer2->test_properties()->opacity = 1.f; |
6525 layer2->NoteLayerPropertyChanged(); | 6538 layer2->NoteLayerPropertyChanged(); |
6526 layer2->SetExpectation(false, false); | 6539 layer2->SetExpectation(false, false); |
6527 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6540 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6528 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6541 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6529 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6542 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6530 host_impl_->DrawLayers(&frame); | 6543 host_impl_->DrawLayers(&frame); |
6544 host_impl_->SwapBuffers(frame); | |
6531 EXPECT_TRUE(layer1->quads_appended()); | 6545 EXPECT_TRUE(layer1->quads_appended()); |
6532 EXPECT_TRUE(layer2->quads_appended()); | 6546 EXPECT_TRUE(layer2->quads_appended()); |
6533 host_impl_->DidDrawAllLayers(frame); | 6547 host_impl_->DidDrawAllLayers(frame); |
6534 | 6548 |
6535 // Parent layer with translucent content, drawn with blending. | 6549 // Parent layer with translucent content, drawn with blending. |
6536 // Child layer with opaque content, drawn without blending. | 6550 // Child layer with opaque content, drawn without blending. |
6537 layer1->SetContentsOpaque(false); | 6551 layer1->SetContentsOpaque(false); |
6538 layer1->SetExpectation(true, false); | 6552 layer1->SetExpectation(true, false); |
6539 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6553 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6540 layer2->SetExpectation(false, false); | 6554 layer2->SetExpectation(false, false); |
6541 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6555 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6542 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6556 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6543 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6557 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6544 host_impl_->DrawLayers(&frame); | 6558 host_impl_->DrawLayers(&frame); |
6559 host_impl_->SwapBuffers(frame); | |
6545 EXPECT_TRUE(layer1->quads_appended()); | 6560 EXPECT_TRUE(layer1->quads_appended()); |
6546 EXPECT_TRUE(layer2->quads_appended()); | 6561 EXPECT_TRUE(layer2->quads_appended()); |
6547 host_impl_->DidDrawAllLayers(frame); | 6562 host_impl_->DidDrawAllLayers(frame); |
6548 | 6563 |
6549 // Parent layer with translucent content but opaque painting, drawn without | 6564 // Parent layer with translucent content but opaque painting, drawn without |
6550 // blending. | 6565 // blending. |
6551 // Child layer with opaque content, drawn without blending. | 6566 // Child layer with opaque content, drawn without blending. |
6552 layer1->SetContentsOpaque(true); | 6567 layer1->SetContentsOpaque(true); |
6553 layer1->SetExpectation(false, false); | 6568 layer1->SetExpectation(false, false); |
6554 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6569 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6555 layer2->SetExpectation(false, false); | 6570 layer2->SetExpectation(false, false); |
6556 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6571 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6557 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6572 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6558 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6573 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6559 host_impl_->DrawLayers(&frame); | 6574 host_impl_->DrawLayers(&frame); |
6575 host_impl_->SwapBuffers(frame); | |
6560 EXPECT_TRUE(layer1->quads_appended()); | 6576 EXPECT_TRUE(layer1->quads_appended()); |
6561 EXPECT_TRUE(layer2->quads_appended()); | 6577 EXPECT_TRUE(layer2->quads_appended()); |
6562 host_impl_->DidDrawAllLayers(frame); | 6578 host_impl_->DidDrawAllLayers(frame); |
6563 | 6579 |
6564 // Parent layer with translucent opacity and opaque content. Since it has a | 6580 // Parent layer with translucent opacity and opaque content. Since it has a |
6565 // drawing child, it's drawn to a render surface which carries the opacity, | 6581 // drawing child, it's drawn to a render surface which carries the opacity, |
6566 // so it's itself drawn without blending. | 6582 // so it's itself drawn without blending. |
6567 // Child layer with opaque content, drawn without blending (parent surface | 6583 // Child layer with opaque content, drawn without blending (parent surface |
6568 // carries the inherited opacity). | 6584 // carries the inherited opacity). |
6569 layer1->SetContentsOpaque(true); | 6585 layer1->SetContentsOpaque(true); |
6570 layer1->test_properties()->opacity = 0.5f; | 6586 layer1->test_properties()->opacity = 0.5f; |
6571 layer1->NoteLayerPropertyChanged(); | 6587 layer1->NoteLayerPropertyChanged(); |
6572 layer1->test_properties()->force_render_surface = true; | 6588 layer1->test_properties()->force_render_surface = true; |
6573 layer1->SetExpectation(false, true); | 6589 layer1->SetExpectation(false, true); |
6574 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6590 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6575 layer2->SetExpectation(false, false); | 6591 layer2->SetExpectation(false, false); |
6576 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6592 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6577 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 6593 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
6578 host_impl_->active_tree()->root_layer_for_testing()); | 6594 host_impl_->active_tree()->root_layer_for_testing()); |
6579 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6595 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6580 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6596 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6581 host_impl_->DrawLayers(&frame); | 6597 host_impl_->DrawLayers(&frame); |
6598 host_impl_->SwapBuffers(frame); | |
6582 EXPECT_TRUE(layer1->quads_appended()); | 6599 EXPECT_TRUE(layer1->quads_appended()); |
6583 EXPECT_TRUE(layer2->quads_appended()); | 6600 EXPECT_TRUE(layer2->quads_appended()); |
6584 host_impl_->DidDrawAllLayers(frame); | 6601 host_impl_->DidDrawAllLayers(frame); |
6585 layer1->test_properties()->force_render_surface = false; | 6602 layer1->test_properties()->force_render_surface = false; |
6586 | 6603 |
6587 // Draw again, but with child non-opaque, to make sure | 6604 // Draw again, but with child non-opaque, to make sure |
6588 // layer1 not culled. | 6605 // layer1 not culled. |
6589 layer1->SetContentsOpaque(true); | 6606 layer1->SetContentsOpaque(true); |
6590 layer1->test_properties()->opacity = 1.f; | 6607 layer1->test_properties()->opacity = 1.f; |
6591 layer1->NoteLayerPropertyChanged(); | 6608 layer1->NoteLayerPropertyChanged(); |
6592 layer1->SetExpectation(false, false); | 6609 layer1->SetExpectation(false, false); |
6593 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6610 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6594 layer2->SetContentsOpaque(true); | 6611 layer2->SetContentsOpaque(true); |
6595 layer2->test_properties()->opacity = 0.5f; | 6612 layer2->test_properties()->opacity = 0.5f; |
6596 layer2->NoteLayerPropertyChanged(); | 6613 layer2->NoteLayerPropertyChanged(); |
6597 layer2->SetExpectation(true, false); | 6614 layer2->SetExpectation(true, false); |
6598 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6615 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6599 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6616 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6600 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6617 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6601 host_impl_->DrawLayers(&frame); | 6618 host_impl_->DrawLayers(&frame); |
6619 host_impl_->SwapBuffers(frame); | |
6602 EXPECT_TRUE(layer1->quads_appended()); | 6620 EXPECT_TRUE(layer1->quads_appended()); |
6603 EXPECT_TRUE(layer2->quads_appended()); | 6621 EXPECT_TRUE(layer2->quads_appended()); |
6604 host_impl_->DidDrawAllLayers(frame); | 6622 host_impl_->DidDrawAllLayers(frame); |
6605 | 6623 |
6606 // A second way of making the child non-opaque. | 6624 // A second way of making the child non-opaque. |
6607 layer1->SetContentsOpaque(true); | 6625 layer1->SetContentsOpaque(true); |
6608 layer1->test_properties()->opacity = 1.f; | 6626 layer1->test_properties()->opacity = 1.f; |
6609 layer1->NoteLayerPropertyChanged(); | 6627 layer1->NoteLayerPropertyChanged(); |
6610 layer1->SetExpectation(false, false); | 6628 layer1->SetExpectation(false, false); |
6611 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6629 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6612 layer2->SetContentsOpaque(false); | 6630 layer2->SetContentsOpaque(false); |
6613 layer2->test_properties()->opacity = 1.f; | 6631 layer2->test_properties()->opacity = 1.f; |
6614 layer2->NoteLayerPropertyChanged(); | 6632 layer2->NoteLayerPropertyChanged(); |
6615 layer2->SetExpectation(true, false); | 6633 layer2->SetExpectation(true, false); |
6616 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6634 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6617 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6635 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6618 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6636 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6619 host_impl_->DrawLayers(&frame); | 6637 host_impl_->DrawLayers(&frame); |
6638 host_impl_->SwapBuffers(frame); | |
6620 EXPECT_TRUE(layer1->quads_appended()); | 6639 EXPECT_TRUE(layer1->quads_appended()); |
6621 EXPECT_TRUE(layer2->quads_appended()); | 6640 EXPECT_TRUE(layer2->quads_appended()); |
6622 host_impl_->DidDrawAllLayers(frame); | 6641 host_impl_->DidDrawAllLayers(frame); |
6623 | 6642 |
6624 // And when the layer says its not opaque but is painted opaque, it is not | 6643 // And when the layer says its not opaque but is painted opaque, it is not |
6625 // blended. | 6644 // blended. |
6626 layer1->SetContentsOpaque(true); | 6645 layer1->SetContentsOpaque(true); |
6627 layer1->test_properties()->opacity = 1.f; | 6646 layer1->test_properties()->opacity = 1.f; |
6628 layer1->NoteLayerPropertyChanged(); | 6647 layer1->NoteLayerPropertyChanged(); |
6629 layer1->SetExpectation(false, false); | 6648 layer1->SetExpectation(false, false); |
6630 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6649 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6631 layer2->SetContentsOpaque(true); | 6650 layer2->SetContentsOpaque(true); |
6632 layer2->test_properties()->opacity = 1.f; | 6651 layer2->test_properties()->opacity = 1.f; |
6633 layer2->NoteLayerPropertyChanged(); | 6652 layer2->NoteLayerPropertyChanged(); |
6634 layer2->SetExpectation(false, false); | 6653 layer2->SetExpectation(false, false); |
6635 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6654 layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6636 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6655 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6637 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6656 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6638 host_impl_->DrawLayers(&frame); | 6657 host_impl_->DrawLayers(&frame); |
6658 host_impl_->SwapBuffers(frame); | |
6639 EXPECT_TRUE(layer1->quads_appended()); | 6659 EXPECT_TRUE(layer1->quads_appended()); |
6640 EXPECT_TRUE(layer2->quads_appended()); | 6660 EXPECT_TRUE(layer2->quads_appended()); |
6641 host_impl_->DidDrawAllLayers(frame); | 6661 host_impl_->DidDrawAllLayers(frame); |
6642 | 6662 |
6643 // Layer with partially opaque contents, drawn with blending. | 6663 // Layer with partially opaque contents, drawn with blending. |
6644 layer1->SetContentsOpaque(false); | 6664 layer1->SetContentsOpaque(false); |
6645 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6665 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6646 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); | 6666 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); |
6647 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6667 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6648 layer1->SetExpectation(true, false); | 6668 layer1->SetExpectation(true, false); |
6649 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6669 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6650 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6670 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6651 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6671 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6652 host_impl_->DrawLayers(&frame); | 6672 host_impl_->DrawLayers(&frame); |
6673 host_impl_->SwapBuffers(frame); | |
6653 EXPECT_TRUE(layer1->quads_appended()); | 6674 EXPECT_TRUE(layer1->quads_appended()); |
6654 host_impl_->DidDrawAllLayers(frame); | 6675 host_impl_->DidDrawAllLayers(frame); |
6655 | 6676 |
6656 // Layer with partially opaque contents partially culled, drawn with blending. | 6677 // Layer with partially opaque contents partially culled, drawn with blending. |
6657 layer1->SetContentsOpaque(false); | 6678 layer1->SetContentsOpaque(false); |
6658 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6679 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6659 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); | 6680 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); |
6660 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6681 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6661 layer1->SetExpectation(true, false); | 6682 layer1->SetExpectation(true, false); |
6662 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6683 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6663 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6684 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6664 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6685 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6665 host_impl_->DrawLayers(&frame); | 6686 host_impl_->DrawLayers(&frame); |
6687 host_impl_->SwapBuffers(frame); | |
6666 EXPECT_TRUE(layer1->quads_appended()); | 6688 EXPECT_TRUE(layer1->quads_appended()); |
6667 host_impl_->DidDrawAllLayers(frame); | 6689 host_impl_->DidDrawAllLayers(frame); |
6668 | 6690 |
6669 // Layer with partially opaque contents culled, drawn with blending. | 6691 // Layer with partially opaque contents culled, drawn with blending. |
6670 layer1->SetContentsOpaque(false); | 6692 layer1->SetContentsOpaque(false); |
6671 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6693 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6672 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); | 6694 layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); |
6673 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6695 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6674 layer1->SetExpectation(true, false); | 6696 layer1->SetExpectation(true, false); |
6675 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6697 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6676 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6698 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6677 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6699 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6678 host_impl_->DrawLayers(&frame); | 6700 host_impl_->DrawLayers(&frame); |
6701 host_impl_->SwapBuffers(frame); | |
6679 EXPECT_TRUE(layer1->quads_appended()); | 6702 EXPECT_TRUE(layer1->quads_appended()); |
6680 host_impl_->DidDrawAllLayers(frame); | 6703 host_impl_->DidDrawAllLayers(frame); |
6681 | 6704 |
6682 // Layer with partially opaque contents and translucent contents culled, drawn | 6705 // Layer with partially opaque contents and translucent contents culled, drawn |
6683 // without blending. | 6706 // without blending. |
6684 layer1->SetContentsOpaque(false); | 6707 layer1->SetContentsOpaque(false); |
6685 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); | 6708 layer1->SetQuadRect(gfx::Rect(5, 5, 5, 5)); |
6686 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); | 6709 layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); |
6687 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); | 6710 layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); |
6688 layer1->SetExpectation(false, false); | 6711 layer1->SetExpectation(false, false); |
6689 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6712 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
6690 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6713 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
6691 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6714 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6692 host_impl_->DrawLayers(&frame); | 6715 host_impl_->DrawLayers(&frame); |
6716 host_impl_->SwapBuffers(frame); | |
6693 EXPECT_TRUE(layer1->quads_appended()); | 6717 EXPECT_TRUE(layer1->quads_appended()); |
6694 host_impl_->DidDrawAllLayers(frame); | 6718 host_impl_->DidDrawAllLayers(frame); |
6695 } | 6719 } |
6696 | 6720 |
6697 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 6721 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
6698 protected: | 6722 protected: |
6699 LayerTreeHostImplViewportCoveredTest() : | 6723 LayerTreeHostImplViewportCoveredTest() : |
6700 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 6724 gutter_quad_material_(DrawQuad::SOLID_COLOR), |
6701 child_(NULL), | 6725 child_(NULL), |
6702 did_activate_pending_tree_(false) {} | 6726 did_activate_pending_tree_(false) {} |
6703 | 6727 |
6704 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { | 6728 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { |
6705 if (software) { | 6729 if (software) { |
6706 return FakeOutputSurface::CreateSoftware( | 6730 return FakeOutputSurface::CreateDelegatingSoftware( |
6707 base::WrapUnique(new SoftwareOutputDevice())); | 6731 base::WrapUnique(new SoftwareOutputDevice())); |
6708 } | 6732 } |
6709 return FakeOutputSurface::Create3d(); | 6733 return FakeOutputSurface::CreateDelegating3d(); |
6710 } | 6734 } |
6711 | 6735 |
6712 void SetupActiveTreeLayers() { | 6736 void SetupActiveTreeLayers() { |
6713 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 6737 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
6714 host_impl_->active_tree()->SetRootLayerForTesting( | 6738 host_impl_->active_tree()->SetRootLayerForTesting( |
6715 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6739 LayerImpl::Create(host_impl_->active_tree(), 1)); |
6716 host_impl_->active_tree() | 6740 host_impl_->active_tree() |
6717 ->root_layer_for_testing() | 6741 ->root_layer_for_testing() |
6718 ->test_properties() | 6742 ->test_properties() |
6719 ->force_render_surface = true; | 6743 ->force_render_surface = true; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6999 class FakeDrawableLayerImpl: public LayerImpl { | 7023 class FakeDrawableLayerImpl: public LayerImpl { |
7000 public: | 7024 public: |
7001 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 7025 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
7002 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); | 7026 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); |
7003 } | 7027 } |
7004 protected: | 7028 protected: |
7005 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 7029 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
7006 : LayerImpl(tree_impl, id) {} | 7030 : LayerImpl(tree_impl, id) {} |
7007 }; | 7031 }; |
7008 | 7032 |
7009 // Only reshape when we know we are going to draw. Otherwise, the reshape | |
7010 // can leave the window at the wrong size if we never draw and the proper | |
7011 // viewport size is never set. | |
7012 TEST_F(LayerTreeHostImplTest, ReshapeNotCalledUntilDraw) { | |
enne (OOO)
2016/07/19 23:00:50
I think this is fine to delete as preparing to dra
| |
7013 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | |
7014 std::unique_ptr<OutputSurface> output_surface( | |
7015 FakeOutputSurface::Create3d(provider)); | |
7016 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | |
7017 | |
7018 std::unique_ptr<LayerImpl> root = | |
7019 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | |
7020 root->SetBounds(gfx::Size(10, 10)); | |
7021 root->SetDrawsContent(true); | |
7022 root->test_properties()->force_render_surface = true; | |
7023 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | |
7024 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
7025 | |
7026 EXPECT_FALSE(provider->TestContext3d()->reshape_called()); | |
7027 provider->TestContext3d()->clear_reshape_called(); | |
7028 | |
7029 LayerTreeHostImpl::FrameData frame; | |
7030 host_impl_->SetViewportSize(gfx::Size(10, 10)); | |
7031 host_impl_->active_tree()->SetDeviceScaleFactor(1.f); | |
7032 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7033 host_impl_->DrawLayers(&frame); | |
7034 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | |
7035 EXPECT_EQ(provider->TestContext3d()->width(), 10); | |
7036 EXPECT_EQ(provider->TestContext3d()->height(), 10); | |
7037 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | |
7038 host_impl_->DidDrawAllLayers(frame); | |
7039 provider->TestContext3d()->clear_reshape_called(); | |
7040 | |
7041 host_impl_->SetViewportSize(gfx::Size(20, 30)); | |
7042 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7043 host_impl_->DrawLayers(&frame); | |
7044 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | |
7045 EXPECT_EQ(provider->TestContext3d()->width(), 20); | |
7046 EXPECT_EQ(provider->TestContext3d()->height(), 30); | |
7047 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 1.f); | |
7048 host_impl_->DidDrawAllLayers(frame); | |
7049 provider->TestContext3d()->clear_reshape_called(); | |
7050 | |
7051 host_impl_->active_tree()->SetDeviceScaleFactor(2.f); | |
7052 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7053 host_impl_->DrawLayers(&frame); | |
7054 EXPECT_TRUE(provider->TestContext3d()->reshape_called()); | |
7055 EXPECT_EQ(provider->TestContext3d()->width(), 20); | |
7056 EXPECT_EQ(provider->TestContext3d()->height(), 30); | |
7057 EXPECT_EQ(provider->TestContext3d()->scale_factor(), 2.f); | |
7058 host_impl_->DidDrawAllLayers(frame); | |
7059 provider->TestContext3d()->clear_reshape_called(); | |
7060 } | |
7061 | |
7062 // Make sure damage tracking propagates all the way to the graphics context, | 7033 // Make sure damage tracking propagates all the way to the graphics context, |
7063 // where it should request to swap only the sub-buffer that is damaged. | 7034 // where it should request to swap only the sub-buffer that is damaged. |
7064 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { | 7035 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
7065 scoped_refptr<TestContextProvider> context_provider( | 7036 scoped_refptr<TestContextProvider> context_provider( |
7066 TestContextProvider::Create()); | 7037 TestContextProvider::Create()); |
7067 context_provider->BindToCurrentThread(); | 7038 context_provider->BindToCurrentThread(); |
7068 context_provider->TestContext3d()->set_have_post_sub_buffer(true); | 7039 context_provider->TestContext3d()->set_have_post_sub_buffer(true); |
7069 | 7040 |
7070 std::unique_ptr<FakeOutputSurface> output_surface( | 7041 std::unique_ptr<FakeOutputSurface> output_surface( |
7071 FakeOutputSurface::Create3d(context_provider)); | 7042 FakeOutputSurface::CreateDelegating3d(context_provider)); |
7072 FakeOutputSurface* fake_output_surface = output_surface.get(); | 7043 FakeOutputSurface* fake_output_surface = output_surface.get(); |
7073 | 7044 |
7074 // This test creates its own LayerTreeHostImpl, so | 7045 // This test creates its own LayerTreeHostImpl, so |
7075 // that we can force partial swap enabled. | 7046 // that we can force partial swap enabled. |
7076 LayerTreeSettings settings = DefaultSettings(); | 7047 LayerTreeSettings settings = DefaultSettings(); |
7077 settings.renderer_settings.partial_swap_enabled = true; | 7048 settings.renderer_settings.partial_swap_enabled = true; |
7078 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7049 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
7079 LayerTreeHostImpl::Create( | 7050 LayerTreeHostImpl::Create( |
7080 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7051 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7081 &shared_bitmap_manager_, NULL, &task_graph_runner_, | 7052 &shared_bitmap_manager_, NULL, &task_graph_runner_, |
(...skipping 18 matching lines...) Expand all Loading... | |
7100 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); | 7071 layer_tree_host_impl->active_tree()->SetRootLayerForTesting(std::move(root)); |
7101 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7072 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
7102 | 7073 |
7103 LayerTreeHostImpl::FrameData frame; | 7074 LayerTreeHostImpl::FrameData frame; |
7104 | 7075 |
7105 // First frame, the entire screen should get swapped. | 7076 // First frame, the entire screen should get swapped. |
7106 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7077 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
7107 layer_tree_host_impl->DrawLayers(&frame); | 7078 layer_tree_host_impl->DrawLayers(&frame); |
7108 layer_tree_host_impl->DidDrawAllLayers(frame); | 7079 layer_tree_host_impl->DidDrawAllLayers(frame); |
7109 layer_tree_host_impl->SwapBuffers(frame); | 7080 layer_tree_host_impl->SwapBuffers(frame); |
7110 gfx::Rect expected_swap_rect(0, 0, 500, 500); | 7081 gfx::Rect expected_swap_rect(500, 500); |
7111 EXPECT_EQ(expected_swap_rect.ToString(), | 7082 EXPECT_EQ(expected_swap_rect.ToString(), |
7112 fake_output_surface->last_swap_rect().ToString()); | 7083 fake_output_surface->last_swap_rect().ToString()); |
7113 | 7084 |
7114 // Second frame, only the damaged area should get swapped. Damage should be | 7085 // Second frame, only the damaged area should get swapped. Damage should be |
7115 // the union of old and new child rects. | 7086 // the union of old and new child rects: gfx::Rect(26, 28). |
7116 // expected damage rect: gfx::Rect(26, 28); | |
7117 // expected swap rect: vertically flipped, with origin at bottom left corner. | |
7118 layer_tree_host_impl->active_tree() | 7087 layer_tree_host_impl->active_tree() |
7119 ->root_layer_for_testing() | 7088 ->root_layer_for_testing() |
7120 ->test_properties() | 7089 ->test_properties() |
7121 ->children[0] | 7090 ->children[0] |
7122 ->SetPosition(gfx::PointF()); | 7091 ->SetPosition(gfx::PointF()); |
7123 layer_tree_host_impl->active_tree() | 7092 layer_tree_host_impl->active_tree() |
7124 ->root_layer_for_testing() | 7093 ->root_layer_for_testing() |
7125 ->test_properties() | 7094 ->test_properties() |
7126 ->children[0] | 7095 ->children[0] |
7127 ->NoteLayerPropertyChanged(); | 7096 ->NoteLayerPropertyChanged(); |
7128 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); | 7097 layer_tree_host_impl->active_tree()->BuildPropertyTreesForTesting(); |
7129 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7098 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
7130 layer_tree_host_impl->DrawLayers(&frame); | 7099 layer_tree_host_impl->DrawLayers(&frame); |
7131 host_impl_->DidDrawAllLayers(frame); | 7100 host_impl_->DidDrawAllLayers(frame); |
7132 layer_tree_host_impl->SwapBuffers(frame); | 7101 layer_tree_host_impl->SwapBuffers(frame); |
7133 | 7102 |
7134 // Make sure that partial swap is constrained to the viewport dimensions | 7103 expected_swap_rect = gfx::Rect(26, 28); |
7135 // expected damage rect: gfx::Rect(500, 500); | |
7136 // expected swap rect: flipped damage rect, but also clamped to viewport | |
7137 expected_swap_rect = gfx::Rect(0, 500-28, 26, 28); | |
7138 EXPECT_EQ(expected_swap_rect.ToString(), | 7104 EXPECT_EQ(expected_swap_rect.ToString(), |
7139 fake_output_surface->last_swap_rect().ToString()); | 7105 fake_output_surface->last_swap_rect().ToString()); |
7140 | 7106 |
7141 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); | 7107 layer_tree_host_impl->SetViewportSize(gfx::Size(10, 10)); |
7142 // This will damage everything. | 7108 // This will damage everything. |
7143 layer_tree_host_impl->active_tree() | 7109 layer_tree_host_impl->active_tree() |
7144 ->root_layer_for_testing() | 7110 ->root_layer_for_testing() |
7145 ->SetBackgroundColor(SK_ColorBLACK); | 7111 ->SetBackgroundColor(SK_ColorBLACK); |
7146 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 7112 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
7147 layer_tree_host_impl->DrawLayers(&frame); | 7113 layer_tree_host_impl->DrawLayers(&frame); |
7148 host_impl_->DidDrawAllLayers(frame); | 7114 host_impl_->DidDrawAllLayers(frame); |
7149 layer_tree_host_impl->SwapBuffers(frame); | 7115 layer_tree_host_impl->SwapBuffers(frame); |
7150 | 7116 |
7151 expected_swap_rect = gfx::Rect(0, 0, 10, 10); | 7117 expected_swap_rect = gfx::Rect(10, 10); |
7152 EXPECT_EQ(expected_swap_rect.ToString(), | 7118 EXPECT_EQ(expected_swap_rect.ToString(), |
7153 fake_output_surface->last_swap_rect().ToString()); | 7119 fake_output_surface->last_swap_rect().ToString()); |
7154 | 7120 |
7155 layer_tree_host_impl->ReleaseOutputSurface(); | 7121 layer_tree_host_impl->ReleaseOutputSurface(); |
7156 } | 7122 } |
7157 | 7123 |
7158 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { | 7124 TEST_F(LayerTreeHostImplTest, RootLayerDoesntCreateExtraSurface) { |
7159 std::unique_ptr<LayerImpl> root = | 7125 std::unique_ptr<LayerImpl> root = |
7160 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); | 7126 FakeDrawableLayerImpl::Create(host_impl_->active_tree(), 1); |
7161 std::unique_ptr<LayerImpl> child = | 7127 std::unique_ptr<LayerImpl> child = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7197 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 7163 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
7198 my_quad->SetNew( | 7164 my_quad->SetNew( |
7199 shared_quad_state, quad_rect, visible_quad_rect, gray, false); | 7165 shared_quad_state, quad_rect, visible_quad_rect, gray, false); |
7200 } | 7166 } |
7201 | 7167 |
7202 private: | 7168 private: |
7203 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) | 7169 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) |
7204 : LayerImpl(tree_impl, id) {} | 7170 : LayerImpl(tree_impl, id) {} |
7205 }; | 7171 }; |
7206 | 7172 |
7207 class MockContext : public TestWebGraphicsContext3D { | |
enne (OOO)
2016/07/19 23:00:50
I do think these should probably be display unit t
danakj
2016/07/20 01:03:25
I added GLRenderer unittests. Will do some softwar
| |
7208 public: | |
7209 MOCK_METHOD1(useProgram, void(GLuint program)); | |
7210 MOCK_METHOD5(uniform4f, void(GLint location, | |
7211 GLfloat x, | |
7212 GLfloat y, | |
7213 GLfloat z, | |
7214 GLfloat w)); | |
7215 MOCK_METHOD4(uniformMatrix4fv, void(GLint location, | |
7216 GLsizei count, | |
7217 GLboolean transpose, | |
7218 const GLfloat* value)); | |
7219 MOCK_METHOD4(drawElements, void(GLenum mode, | |
7220 GLsizei count, | |
7221 GLenum type, | |
7222 GLintptr offset)); | |
7223 MOCK_METHOD1(enable, void(GLenum cap)); | |
7224 MOCK_METHOD1(disable, void(GLenum cap)); | |
7225 MOCK_METHOD4(scissor, void(GLint x, | |
7226 GLint y, | |
7227 GLsizei width, | |
7228 GLsizei height)); | |
7229 }; | |
7230 | |
7231 class MockContextHarness { | |
7232 private: | |
7233 MockContext* context_; | |
7234 | |
7235 public: | |
7236 explicit MockContextHarness(MockContext* context) | |
7237 : context_(context) { | |
7238 context_->set_have_post_sub_buffer(true); | |
7239 | |
7240 // Catch "uninteresting" calls | |
7241 EXPECT_CALL(*context_, useProgram(_)) | |
7242 .Times(0); | |
7243 | |
7244 EXPECT_CALL(*context_, drawElements(_, _, _, _)) | |
7245 .Times(0); | |
7246 | |
7247 // These are not asserted | |
7248 EXPECT_CALL(*context_, uniformMatrix4fv(_, _, _, _)) | |
7249 .WillRepeatedly(Return()); | |
7250 | |
7251 EXPECT_CALL(*context_, uniform4f(_, _, _, _, _)) | |
7252 .WillRepeatedly(Return()); | |
7253 | |
7254 // Any un-sanctioned calls to enable() are OK | |
7255 EXPECT_CALL(*context_, enable(_)) | |
7256 .WillRepeatedly(Return()); | |
7257 | |
7258 // Any un-sanctioned calls to disable() are OK | |
7259 EXPECT_CALL(*context_, disable(_)) | |
7260 .WillRepeatedly(Return()); | |
7261 } | |
7262 | |
7263 void MustDrawSolidQuad() { | |
7264 EXPECT_CALL(*context_, drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)) | |
7265 .WillOnce(Return()) | |
7266 .RetiresOnSaturation(); | |
7267 | |
7268 EXPECT_CALL(*context_, useProgram(_)) | |
7269 .WillOnce(Return()) | |
7270 .RetiresOnSaturation(); | |
7271 } | |
7272 | |
7273 void MustSetScissor(int x, int y, int width, int height) { | |
7274 EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST)) | |
7275 .WillRepeatedly(Return()); | |
7276 | |
7277 EXPECT_CALL(*context_, scissor(x, y, width, height)) | |
7278 .Times(AtLeast(1)) | |
7279 .WillRepeatedly(Return()); | |
7280 } | |
7281 | |
7282 void MustSetNoScissor() { | |
7283 EXPECT_CALL(*context_, disable(GL_SCISSOR_TEST)) | |
7284 .WillRepeatedly(Return()); | |
7285 | |
7286 EXPECT_CALL(*context_, enable(GL_SCISSOR_TEST)) | |
7287 .Times(0); | |
7288 | |
7289 EXPECT_CALL(*context_, scissor(_, _, _, _)) | |
7290 .Times(0); | |
7291 } | |
7292 }; | |
7293 | |
7294 TEST_F(LayerTreeHostImplTest, NoPartialSwap) { | |
7295 std::unique_ptr<MockContext> mock_context_owned(new MockContext); | |
7296 MockContext* mock_context = mock_context_owned.get(); | |
7297 MockContextHarness harness(mock_context); | |
7298 | |
7299 // Run test case | |
7300 LayerTreeSettings settings = DefaultSettings(); | |
7301 settings.renderer_settings.partial_swap_enabled = false; | |
7302 CreateHostImpl(settings, | |
7303 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | |
7304 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | |
7305 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
7306 | |
7307 // Without partial swap, and no clipping, no scissor is set. | |
7308 harness.MustDrawSolidQuad(); | |
7309 harness.MustSetNoScissor(); | |
7310 { | |
7311 LayerTreeHostImpl::FrameData frame; | |
7312 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7313 host_impl_->DrawLayers(&frame); | |
7314 host_impl_->DidDrawAllLayers(frame); | |
7315 } | |
7316 Mock::VerifyAndClearExpectations(&mock_context); | |
7317 | |
7318 // Without partial swap, but a layer does clip its subtree, one scissor is | |
7319 // set. | |
7320 auto* root = host_impl_->active_tree()->root_layer_for_testing(); | |
7321 root->SetMasksToBounds(true); | |
7322 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
7323 root->NoteLayerPropertyChanged(); | |
7324 harness.MustDrawSolidQuad(); | |
7325 harness.MustSetScissor(0, 0, 10, 10); | |
7326 { | |
7327 LayerTreeHostImpl::FrameData frame; | |
7328 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7329 host_impl_->DrawLayers(&frame); | |
7330 host_impl_->DidDrawAllLayers(frame); | |
7331 } | |
7332 Mock::VerifyAndClearExpectations(&mock_context); | |
7333 } | |
7334 | |
7335 TEST_F(LayerTreeHostImplTest, PartialSwap) { | |
7336 std::unique_ptr<MockContext> context_owned(new MockContext); | |
7337 MockContext* mock_context = context_owned.get(); | |
7338 MockContextHarness harness(mock_context); | |
7339 | |
7340 LayerTreeSettings settings = DefaultSettings(); | |
7341 settings.renderer_settings.partial_swap_enabled = true; | |
7342 CreateHostImpl(settings, | |
7343 FakeOutputSurface::Create3d(std::move(context_owned))); | |
7344 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1)); | |
7345 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
7346 | |
7347 // The first frame is not a partially-swapped one. No scissor should be set. | |
7348 harness.MustSetNoScissor(); | |
7349 harness.MustDrawSolidQuad(); | |
7350 { | |
7351 LayerTreeHostImpl::FrameData frame; | |
7352 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7353 host_impl_->DrawLayers(&frame); | |
7354 host_impl_->DidDrawAllLayers(frame); | |
7355 } | |
7356 Mock::VerifyAndClearExpectations(&mock_context); | |
7357 | |
7358 // Damage a portion of the frame. | |
7359 auto* root = host_impl_->active_tree()->root_layer_for_testing(); | |
7360 root->SetUpdateRect(gfx::Rect(0, 0, 2, 3)); | |
7361 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | |
7362 | |
7363 // The second frame will be partially-swapped (the y coordinates are flipped). | |
7364 harness.MustSetScissor(0, 7, 2, 3); | |
7365 harness.MustDrawSolidQuad(); | |
7366 { | |
7367 LayerTreeHostImpl::FrameData frame; | |
7368 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | |
7369 host_impl_->DrawLayers(&frame); | |
7370 host_impl_->DidDrawAllLayers(frame); | |
7371 } | |
7372 Mock::VerifyAndClearExpectations(&mock_context); | |
7373 } | |
7374 | |
7375 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7173 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
7376 LayerTreeSettings settings, | 7174 LayerTreeSettings settings, |
7377 bool partial_swap, | 7175 bool partial_swap, |
7378 LayerTreeHostImplClient* client, | 7176 LayerTreeHostImplClient* client, |
7379 TaskRunnerProvider* task_runner_provider, | 7177 TaskRunnerProvider* task_runner_provider, |
7380 SharedBitmapManager* manager, | 7178 SharedBitmapManager* manager, |
7381 TaskGraphRunner* task_graph_runner, | 7179 TaskGraphRunner* task_graph_runner, |
7382 RenderingStatsInstrumentation* stats_instrumentation, | 7180 RenderingStatsInstrumentation* stats_instrumentation, |
7383 OutputSurface* output_surface) { | 7181 OutputSurface* output_surface) { |
7384 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7182 settings.renderer_settings.partial_swap_enabled = partial_swap; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7447 return my_host_impl; | 7245 return my_host_impl; |
7448 } | 7246 } |
7449 | 7247 |
7450 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { | 7248 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorPartialSwap) { |
7451 TestSharedBitmapManager shared_bitmap_manager; | 7249 TestSharedBitmapManager shared_bitmap_manager; |
7452 TestTaskGraphRunner task_graph_runner; | 7250 TestTaskGraphRunner task_graph_runner; |
7453 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7251 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7454 provider->BindToCurrentThread(); | 7252 provider->BindToCurrentThread(); |
7455 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7253 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7456 std::unique_ptr<OutputSurface> output_surface( | 7254 std::unique_ptr<OutputSurface> output_surface( |
7457 FakeOutputSurface::Create3d(provider)); | 7255 FakeOutputSurface::CreateDelegating3d(provider)); |
7458 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7256 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7459 DefaultSettings(), true, this, &task_runner_provider_, | 7257 DefaultSettings(), true, this, &task_runner_provider_, |
7460 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7258 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, |
7461 output_surface.get()); | 7259 output_surface.get()); |
7462 { | 7260 { |
7463 LayerTreeHostImpl::FrameData frame; | 7261 LayerTreeHostImpl::FrameData frame; |
7464 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7262 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7465 | 7263 |
7466 // Verify all quads have been computed | 7264 // Verify all quads have been computed |
7467 ASSERT_EQ(2U, frame.render_passes.size()); | 7265 ASSERT_EQ(2U, frame.render_passes.size()); |
(...skipping 10 matching lines...) Expand all Loading... | |
7478 my_host_impl->ReleaseOutputSurface(); | 7276 my_host_impl->ReleaseOutputSurface(); |
7479 } | 7277 } |
7480 | 7278 |
7481 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { | 7279 TEST_F(LayerTreeHostImplTest, ContributingLayerEmptyScissorNoPartialSwap) { |
7482 TestSharedBitmapManager shared_bitmap_manager; | 7280 TestSharedBitmapManager shared_bitmap_manager; |
7483 TestTaskGraphRunner task_graph_runner; | 7281 TestTaskGraphRunner task_graph_runner; |
7484 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); | 7282 scoped_refptr<TestContextProvider> provider(TestContextProvider::Create()); |
7485 provider->BindToCurrentThread(); | 7283 provider->BindToCurrentThread(); |
7486 provider->TestContext3d()->set_have_post_sub_buffer(true); | 7284 provider->TestContext3d()->set_have_post_sub_buffer(true); |
7487 std::unique_ptr<OutputSurface> output_surface( | 7285 std::unique_ptr<OutputSurface> output_surface( |
7488 FakeOutputSurface::Create3d(provider)); | 7286 FakeOutputSurface::CreateDelegating3d(provider)); |
7489 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( | 7287 std::unique_ptr<LayerTreeHostImpl> my_host_impl = SetupLayersForOpacity( |
7490 DefaultSettings(), false, this, &task_runner_provider_, | 7288 DefaultSettings(), false, this, &task_runner_provider_, |
7491 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, | 7289 &shared_bitmap_manager, &task_graph_runner, &stats_instrumentation_, |
7492 output_surface.get()); | 7290 output_surface.get()); |
7493 { | 7291 { |
7494 LayerTreeHostImpl::FrameData frame; | 7292 LayerTreeHostImpl::FrameData frame; |
7495 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); | 7293 EXPECT_EQ(DRAW_SUCCESS, my_host_impl->PrepareToDraw(&frame)); |
7496 | 7294 |
7497 // Verify all quads have been computed | 7295 // Verify all quads have been computed |
7498 ASSERT_EQ(2U, frame.render_passes.size()); | 7296 ASSERT_EQ(2U, frame.render_passes.size()); |
7499 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); | 7297 ASSERT_EQ(1U, frame.render_passes[0]->quad_list.size()); |
7500 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); | 7298 ASSERT_EQ(1U, frame.render_passes[1]->quad_list.size()); |
7501 EXPECT_EQ(DrawQuad::SOLID_COLOR, | 7299 EXPECT_EQ(DrawQuad::SOLID_COLOR, |
7502 frame.render_passes[0]->quad_list.front()->material); | 7300 frame.render_passes[0]->quad_list.front()->material); |
7503 EXPECT_EQ(DrawQuad::RENDER_PASS, | 7301 EXPECT_EQ(DrawQuad::RENDER_PASS, |
7504 frame.render_passes[1]->quad_list.front()->material); | 7302 frame.render_passes[1]->quad_list.front()->material); |
7505 | 7303 |
7506 my_host_impl->DrawLayers(&frame); | 7304 my_host_impl->DrawLayers(&frame); |
7507 my_host_impl->DidDrawAllLayers(frame); | 7305 my_host_impl->DidDrawAllLayers(frame); |
7508 } | 7306 } |
7509 my_host_impl->ReleaseOutputSurface(); | 7307 my_host_impl->ReleaseOutputSurface(); |
7510 } | 7308 } |
7511 | 7309 |
7512 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { | 7310 TEST_F(LayerTreeHostImplTest, LayersFreeTextures) { |
7513 std::unique_ptr<TestWebGraphicsContext3D> context = | 7311 std::unique_ptr<TestWebGraphicsContext3D> context = |
7514 TestWebGraphicsContext3D::Create(); | 7312 TestWebGraphicsContext3D::Create(); |
7515 TestWebGraphicsContext3D* context3d = context.get(); | 7313 TestWebGraphicsContext3D* context3d = context.get(); |
7516 std::unique_ptr<OutputSurface> output_surface( | 7314 std::unique_ptr<OutputSurface> output_surface( |
7517 FakeOutputSurface::Create3d(std::move(context))); | 7315 FakeOutputSurface::CreateDelegating3d(std::move(context))); |
7518 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7316 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
7519 | 7317 |
7520 std::unique_ptr<LayerImpl> root_layer = | 7318 std::unique_ptr<LayerImpl> root_layer = |
7521 LayerImpl::Create(host_impl_->active_tree(), 1); | 7319 LayerImpl::Create(host_impl_->active_tree(), 1); |
7522 root_layer->SetBounds(gfx::Size(10, 10)); | 7320 root_layer->SetBounds(gfx::Size(10, 10)); |
7523 root_layer->test_properties()->force_render_surface = true; | 7321 root_layer->test_properties()->force_render_surface = true; |
7524 | 7322 |
7525 scoped_refptr<VideoFrame> softwareFrame = | 7323 scoped_refptr<VideoFrame> softwareFrame = |
7526 media::VideoFrame::CreateColorFrame( | 7324 media::VideoFrame::CreateColorFrame( |
7527 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | 7325 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
(...skipping 27 matching lines...) Expand all Loading... | |
7555 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 7353 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
7556 public: | 7354 public: |
7557 MOCK_METHOD1(useProgram, void(GLuint program)); | 7355 MOCK_METHOD1(useProgram, void(GLuint program)); |
7558 MOCK_METHOD4(drawElements, void(GLenum mode, | 7356 MOCK_METHOD4(drawElements, void(GLenum mode, |
7559 GLsizei count, | 7357 GLsizei count, |
7560 GLenum type, | 7358 GLenum type, |
7561 GLintptr offset)); | 7359 GLintptr offset)); |
7562 }; | 7360 }; |
7563 | 7361 |
7564 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 7362 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
7565 std::unique_ptr<MockDrawQuadsToFillScreenContext> mock_context_owned( | |
7566 new MockDrawQuadsToFillScreenContext); | |
7567 MockDrawQuadsToFillScreenContext* mock_context = mock_context_owned.get(); | |
7568 | |
7569 // Run test case | |
7570 LayerTreeSettings settings = DefaultSettings(); | |
7571 settings.renderer_settings.partial_swap_enabled = false; | |
7572 CreateHostImpl(settings, | |
7573 FakeOutputSurface::Create3d(std::move(mock_context_owned))); | |
7574 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7363 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
7575 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7364 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
7576 | 7365 |
7577 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7366 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
7578 | 7367 |
7579 // Verify one quad is drawn when transparent background set is not set. | 7368 // Verify one quad is drawn when transparent background set is not set. |
7580 host_impl_->active_tree()->set_has_transparent_background(false); | 7369 host_impl_->active_tree()->set_has_transparent_background(false); |
7581 EXPECT_CALL(*mock_context, useProgram(_)) | |
7582 .Times(1); | |
7583 EXPECT_CALL(*mock_context, drawElements(_, _, _, _)) | |
7584 .Times(1); | |
7585 LayerTreeHostImpl::FrameData frame; | 7370 LayerTreeHostImpl::FrameData frame; |
7586 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7371 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7372 { | |
7373 const auto& root_pass = frame.render_passes.back(); | |
7374 ASSERT_EQ(1u, root_pass->quad_list.size()); | |
7375 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.front()->material); | |
7376 } | |
7587 host_impl_->DrawLayers(&frame); | 7377 host_impl_->DrawLayers(&frame); |
7588 host_impl_->DidDrawAllLayers(frame); | 7378 host_impl_->DidDrawAllLayers(frame); |
7589 Mock::VerifyAndClearExpectations(&mock_context); | 7379 host_impl_->SwapBuffers(frame); |
7380 | |
7381 // Cause damage so we would draw something if possible. | |
7382 host_impl_->SetFullRootLayerDamage(); | |
7590 | 7383 |
7591 // Verify no quads are drawn when transparent background is set. | 7384 // Verify no quads are drawn when transparent background is set. |
7592 host_impl_->active_tree()->set_has_transparent_background(true); | 7385 host_impl_->active_tree()->set_has_transparent_background(true); |
7593 host_impl_->SetFullRootLayerDamage(); | 7386 host_impl_->SetFullRootLayerDamage(); |
7594 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7387 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
7388 { | |
7389 const auto& root_pass = frame.render_passes.back(); | |
7390 ASSERT_EQ(0u, root_pass->quad_list.size()); | |
7391 } | |
7595 host_impl_->DrawLayers(&frame); | 7392 host_impl_->DrawLayers(&frame); |
7596 host_impl_->DidDrawAllLayers(frame); | 7393 host_impl_->DidDrawAllLayers(frame); |
7597 Mock::VerifyAndClearExpectations(&mock_context); | 7394 host_impl_->SwapBuffers(frame); |
7598 } | 7395 } |
7599 | 7396 |
7600 class LayerTreeHostImplTestWithDelegatingRenderer | 7397 class LayerTreeHostImplTestWithDelegatingRenderer |
7601 : public LayerTreeHostImplTest { | 7398 : public LayerTreeHostImplTest { |
7602 protected: | 7399 protected: |
7603 std::unique_ptr<OutputSurface> CreateOutputSurface() override { | 7400 std::unique_ptr<OutputSurface> CreateOutputSurface() override { |
7604 return FakeOutputSurface::CreateDelegating3d(); | 7401 return FakeOutputSurface::CreateDelegating3d(); |
7605 } | 7402 } |
7606 | 7403 |
7607 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { | 7404 void DrawFrameAndTestDamage(const gfx::Rect& expected_damage) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7803 return SoftwareOutputDevice::BeginPaint(damage_rect); | 7600 return SoftwareOutputDevice::BeginPaint(damage_rect); |
7804 } | 7601 } |
7805 void EndPaint() override { | 7602 void EndPaint() override { |
7806 SoftwareOutputDevice::EndPaint(); | 7603 SoftwareOutputDevice::EndPaint(); |
7807 ++frames_ended_; | 7604 ++frames_ended_; |
7808 } | 7605 } |
7809 | 7606 |
7810 int frames_began_, frames_ended_; | 7607 int frames_began_, frames_ended_; |
7811 }; | 7608 }; |
7812 | 7609 |
7813 TEST_F(LayerTreeHostImplTest, ForcedDrawToSoftwareDeviceBasicRender) { | |
enne (OOO)
2016/07/19 23:00:50
Do we have a resourceless software draw test somew
danakj
2016/07/20 01:03:25
LayerTreeHostTestResourcelessSoftwareDraw:
https:/
| |
7814 // No main thread evictions in resourceless software mode. | |
7815 set_reduce_memory_result(false); | |
7816 CountingSoftwareDevice* software_device = new CountingSoftwareDevice(); | |
7817 EXPECT_TRUE(CreateHostImpl( | |
7818 DefaultSettings(), | |
7819 FakeOutputSurface::CreateSoftware(base::WrapUnique(software_device)))); | |
7820 host_impl_->SetViewportSize(gfx::Size(50, 50)); | |
7821 | |
7822 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
7823 | |
7824 const gfx::Transform external_transform; | |
7825 const gfx::Rect external_viewport; | |
7826 const gfx::Rect external_clip; | |
7827 const bool resourceless_software_draw = true; | |
7828 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | |
7829 external_transform); | |
7830 | |
7831 EXPECT_EQ(0, software_device->frames_began_); | |
7832 EXPECT_EQ(0, software_device->frames_ended_); | |
7833 | |
7834 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | |
7835 resourceless_software_draw); | |
7836 | |
7837 EXPECT_EQ(1, software_device->frames_began_); | |
7838 EXPECT_EQ(1, software_device->frames_ended_); | |
7839 | |
7840 // Call another API method that is likely to hit nullptr in this mode. | |
7841 std::unique_ptr<base::trace_event::TracedValue> state( | |
7842 new base::trace_event::TracedValue()); | |
7843 host_impl_->ActivationStateAsValueInto(state.get()); | |
7844 } | |
7845 | |
7846 TEST_F(LayerTreeHostImplTest, | 7610 TEST_F(LayerTreeHostImplTest, |
7847 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { | 7611 ForcedDrawToSoftwareDeviceSkipsUnsupportedLayers) { |
7848 set_reduce_memory_result(false); | 7612 set_reduce_memory_result(false); |
7849 EXPECT_TRUE(CreateHostImpl( | 7613 EXPECT_TRUE(CreateHostImpl( |
7850 DefaultSettings(), FakeOutputSurface::CreateSoftware( | 7614 DefaultSettings(), FakeOutputSurface::CreateDelegatingSoftware( |
7851 base::WrapUnique(new CountingSoftwareDevice)))); | 7615 base::WrapUnique(new CountingSoftwareDevice)))); |
7852 | 7616 |
7853 const gfx::Transform external_transform; | 7617 const gfx::Transform external_transform; |
7854 const gfx::Rect external_viewport; | 7618 const gfx::Rect external_viewport; |
7855 const gfx::Rect external_clip; | 7619 const gfx::Rect external_clip; |
7856 const bool resourceless_software_draw = true; | 7620 const bool resourceless_software_draw = true; |
7857 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 7621 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
7858 external_transform); | 7622 external_transform); |
7859 | 7623 |
7860 // SolidColorLayerImpl will be drawn. | 7624 // SolidColorLayerImpl will be drawn. |
(...skipping 24 matching lines...) Expand all Loading... | |
7885 host_impl_->ReleaseOutputSurface(); | 7649 host_impl_->ReleaseOutputSurface(); |
7886 host_impl_ = nullptr; | 7650 host_impl_ = nullptr; |
7887 | 7651 |
7888 LayerTreeSettings settings = DefaultSettings(); | 7652 LayerTreeSettings settings = DefaultSettings(); |
7889 host_impl_ = LayerTreeHostImpl::Create( | 7653 host_impl_ = LayerTreeHostImpl::Create( |
7890 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7654 settings, this, &task_runner_provider_, &stats_instrumentation_, |
7891 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 7655 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, |
7892 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7656 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
7893 | 7657 |
7894 output_surface_ = | 7658 output_surface_ = |
7895 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); | 7659 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); |
7896 host_impl_->SetVisible(true); | 7660 host_impl_->SetVisible(true); |
7897 host_impl_->InitializeRenderer(output_surface_.get()); | 7661 host_impl_->InitializeRenderer(output_surface_.get()); |
7898 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); | 7662 EXPECT_LT(0ul, host_impl_->memory_allocation_limit_bytes()); |
7899 } | 7663 } |
7900 | 7664 |
7901 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { | 7665 TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { |
7902 ASSERT_TRUE(host_impl_->active_tree()); | 7666 ASSERT_TRUE(host_impl_->active_tree()); |
7903 | 7667 |
7904 // RequiresHighResToDraw is set when new output surface is used. | 7668 // RequiresHighResToDraw is set when new output surface is used. |
7905 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); | 7669 EXPECT_TRUE(host_impl_->RequiresHighResToDraw()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7970 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); | 7734 EXPECT_FALSE(fake_host_impl_->prepare_tiles_needed()); |
7971 host_impl_->SetVisible(true); | 7735 host_impl_->SetVisible(true); |
7972 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); | 7736 EXPECT_TRUE(fake_host_impl_->prepare_tiles_needed()); |
7973 } | 7737 } |
7974 | 7738 |
7975 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { | 7739 TEST_F(LayerTreeHostImplTest, UIResourceManagement) { |
7976 std::unique_ptr<TestWebGraphicsContext3D> context = | 7740 std::unique_ptr<TestWebGraphicsContext3D> context = |
7977 TestWebGraphicsContext3D::Create(); | 7741 TestWebGraphicsContext3D::Create(); |
7978 TestWebGraphicsContext3D* context3d = context.get(); | 7742 TestWebGraphicsContext3D* context3d = context.get(); |
7979 std::unique_ptr<FakeOutputSurface> output_surface = | 7743 std::unique_ptr<FakeOutputSurface> output_surface = |
7980 FakeOutputSurface::Create3d(); | 7744 FakeOutputSurface::CreateDelegating3d(); |
7981 CreateHostImpl(DefaultSettings(), std::move(output_surface)); | 7745 CreateHostImpl(DefaultSettings(), std::move(output_surface)); |
7982 | 7746 |
7983 EXPECT_EQ(0u, context3d->NumTextures()); | 7747 EXPECT_EQ(0u, context3d->NumTextures()); |
7984 | 7748 |
7985 UIResourceId ui_resource_id = 1; | 7749 UIResourceId ui_resource_id = 1; |
7986 bool is_opaque = false; | 7750 bool is_opaque = false; |
7987 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); | 7751 UIResourceBitmap bitmap(gfx::Size(1, 1), is_opaque); |
7988 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 7752 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
7989 EXPECT_EQ(1u, context3d->NumTextures()); | 7753 EXPECT_EQ(1u, context3d->NumTextures()); |
7990 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 7754 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
(...skipping 22 matching lines...) Expand all Loading... | |
8013 | 7777 |
8014 // Should not change state for multiple deletion on one UIResourceId | 7778 // Should not change state for multiple deletion on one UIResourceId |
8015 host_impl_->DeleteUIResource(ui_resource_id); | 7779 host_impl_->DeleteUIResource(ui_resource_id); |
8016 EXPECT_EQ(0u, context3d->NumTextures()); | 7780 EXPECT_EQ(0u, context3d->NumTextures()); |
8017 } | 7781 } |
8018 | 7782 |
8019 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { | 7783 TEST_F(LayerTreeHostImplTest, CreateETC1UIResource) { |
8020 std::unique_ptr<TestWebGraphicsContext3D> context = | 7784 std::unique_ptr<TestWebGraphicsContext3D> context = |
8021 TestWebGraphicsContext3D::Create(); | 7785 TestWebGraphicsContext3D::Create(); |
8022 TestWebGraphicsContext3D* context3d = context.get(); | 7786 TestWebGraphicsContext3D* context3d = context.get(); |
8023 CreateHostImpl(DefaultSettings(), FakeOutputSurface::Create3d()); | 7787 CreateHostImpl(DefaultSettings(), FakeOutputSurface::CreateDelegating3d()); |
8024 | 7788 |
8025 EXPECT_EQ(0u, context3d->NumTextures()); | 7789 EXPECT_EQ(0u, context3d->NumTextures()); |
8026 | 7790 |
8027 gfx::Size size(4, 4); | 7791 gfx::Size size(4, 4); |
8028 // SkImageInfo has no support for ETC1. The |info| below contains the right | 7792 // SkImageInfo has no support for ETC1. The |info| below contains the right |
8029 // total pixel size for the bitmap but not the right height and width. The | 7793 // total pixel size for the bitmap but not the right height and width. The |
8030 // correct width/height are passed directly to UIResourceBitmap. | 7794 // correct width/height are passed directly to UIResourceBitmap. |
8031 SkImageInfo info = | 7795 SkImageInfo info = |
8032 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); | 7796 SkImageInfo::Make(4, 2, kAlpha_8_SkColorType, kPremul_SkAlphaType); |
8033 sk_sp<SkPixelRef> pixel_ref(SkMallocPixelRef::NewAllocate(info, 0, 0)); | 7797 sk_sp<SkPixelRef> pixel_ref(SkMallocPixelRef::NewAllocate(info, 0, 0)); |
8034 pixel_ref->setImmutable(); | 7798 pixel_ref->setImmutable(); |
8035 UIResourceBitmap bitmap(std::move(pixel_ref), size); | 7799 UIResourceBitmap bitmap(std::move(pixel_ref), size); |
8036 UIResourceId ui_resource_id = 1; | 7800 UIResourceId ui_resource_id = 1; |
8037 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 7801 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
8038 EXPECT_EQ(1u, context3d->NumTextures()); | 7802 EXPECT_EQ(1u, context3d->NumTextures()); |
8039 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 7803 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
8040 EXPECT_NE(0u, id1); | 7804 EXPECT_NE(0u, id1); |
8041 } | 7805 } |
8042 | 7806 |
8043 void ShutdownReleasesContext_Callback( | 7807 void ShutdownReleasesContext_Callback( |
8044 std::unique_ptr<CopyOutputResult> result) {} | 7808 std::unique_ptr<CopyOutputResult> result) {} |
8045 | 7809 |
8046 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 7810 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
8047 scoped_refptr<TestContextProvider> context_provider = | 7811 scoped_refptr<TestContextProvider> context_provider = |
8048 TestContextProvider::Create(); | 7812 TestContextProvider::Create(); |
8049 | 7813 |
8050 CreateHostImpl(DefaultSettings(), | 7814 CreateHostImpl( |
8051 FakeOutputSurface::Create3d(context_provider)); | 7815 DefaultSettings(), |
7816 base::MakeUnique<TestDelegatingOutputSurface>( | |
7817 context_provider, TestContextProvider::CreateWorker(), | |
7818 FakeOutputSurface::Create3d(context_provider), nullptr, nullptr, | |
7819 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | |
7820 true /* synchronous_composite */)); | |
8052 | 7821 |
8053 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7822 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
8054 | 7823 |
8055 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 7824 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
8056 root->test_properties()->copy_requests.push_back( | 7825 root->test_properties()->copy_requests.push_back( |
8057 CopyOutputRequest::CreateRequest( | 7826 CopyOutputRequest::CreateRequest( |
8058 base::Bind(&ShutdownReleasesContext_Callback))); | 7827 base::Bind(&ShutdownReleasesContext_Callback))); |
8059 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7828 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8060 | 7829 |
8061 LayerTreeHostImpl::FrameData frame; | 7830 LayerTreeHostImpl::FrameData frame; |
8062 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7831 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
8063 host_impl_->DrawLayers(&frame); | 7832 host_impl_->DrawLayers(&frame); |
8064 host_impl_->DidDrawAllLayers(frame); | 7833 host_impl_->DidDrawAllLayers(frame); |
7834 host_impl_->SwapBuffers(frame); | |
8065 | 7835 |
8066 // The CopyOutputResult's callback has a ref on the ContextProvider and a | 7836 // The CopyOutputResult's callback has a ref on the ContextProvider and a |
8067 // texture in a texture mailbox. | 7837 // texture in a texture mailbox. |
8068 EXPECT_FALSE(context_provider->HasOneRef()); | 7838 EXPECT_FALSE(context_provider->HasOneRef()); |
8069 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); | 7839 EXPECT_EQ(1u, context_provider->TestContext3d()->NumTextures()); |
8070 | 7840 |
8071 host_impl_->ReleaseOutputSurface(); | 7841 host_impl_->ReleaseOutputSurface(); |
8072 host_impl_ = nullptr; | 7842 host_impl_ = nullptr; |
8073 | 7843 |
8074 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 7844 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10780 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10550 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10781 EXPECT_FALSE(host_impl_->use_msaa()); | 10551 EXPECT_FALSE(host_impl_->use_msaa()); |
10782 | 10552 |
10783 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = | 10553 std::unique_ptr<TestWebGraphicsContext3D> context_with_msaa = |
10784 TestWebGraphicsContext3D::Create(); | 10554 TestWebGraphicsContext3D::Create(); |
10785 context_with_msaa->SetMaxSamples(8); | 10555 context_with_msaa->SetMaxSamples(8); |
10786 | 10556 |
10787 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); | 10557 LayerTreeSettings msaaSettings = GpuRasterizationEnabledSettings(); |
10788 msaaSettings.gpu_rasterization_msaa_sample_count = 4; | 10558 msaaSettings.gpu_rasterization_msaa_sample_count = 4; |
10789 EXPECT_TRUE(CreateHostImpl( | 10559 EXPECT_TRUE(CreateHostImpl( |
10790 msaaSettings, FakeOutputSurface::Create3d(std::move(context_with_msaa)))); | 10560 msaaSettings, |
10561 FakeOutputSurface::CreateDelegating3d(std::move(context_with_msaa)))); | |
10791 host_impl_->SetHasGpuRasterizationTrigger(true); | 10562 host_impl_->SetHasGpuRasterizationTrigger(true); |
10792 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 10563 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
10793 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, | 10564 EXPECT_EQ(GpuRasterizationStatus::MSAA_CONTENT, |
10794 host_impl_->gpu_rasterization_status()); | 10565 host_impl_->gpu_rasterization_status()); |
10795 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 10566 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
10796 EXPECT_TRUE(host_impl_->use_msaa()); | 10567 EXPECT_TRUE(host_impl_->use_msaa()); |
10797 | 10568 |
10798 LayerTreeSettings settings = DefaultSettings(); | 10569 LayerTreeSettings settings = DefaultSettings(); |
10799 settings.gpu_rasterization_enabled = false; | 10570 settings.gpu_rasterization_enabled = false; |
10800 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 10571 EXPECT_TRUE( |
10572 CreateHostImpl(settings, FakeOutputSurface::CreateDelegating3d())); | |
10801 host_impl_->SetHasGpuRasterizationTrigger(true); | 10573 host_impl_->SetHasGpuRasterizationTrigger(true); |
10802 host_impl_->SetContentIsSuitableForGpuRasterization(true); | 10574 host_impl_->SetContentIsSuitableForGpuRasterization(true); |
10803 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, | 10575 EXPECT_EQ(GpuRasterizationStatus::OFF_DEVICE, |
10804 host_impl_->gpu_rasterization_status()); | 10576 host_impl_->gpu_rasterization_status()); |
10805 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10577 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10806 | 10578 |
10807 settings.gpu_rasterization_forced = true; | 10579 settings.gpu_rasterization_forced = true; |
10808 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 10580 EXPECT_TRUE( |
10581 CreateHostImpl(settings, FakeOutputSurface::CreateDelegating3d())); | |
10809 | 10582 |
10810 host_impl_->SetHasGpuRasterizationTrigger(false); | 10583 host_impl_->SetHasGpuRasterizationTrigger(false); |
10811 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 10584 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
10812 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 10585 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
10813 host_impl_->gpu_rasterization_status()); | 10586 host_impl_->gpu_rasterization_status()); |
10814 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 10587 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
10815 } | 10588 } |
10816 | 10589 |
10817 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { | 10590 class MsaaIsSlowLayerTreeHostImplTest : public LayerTreeHostImplTest { |
10818 public: | 10591 public: |
10819 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { | 10592 void CreateHostImplWithMsaaIsSlow(bool msaa_is_slow) { |
10820 LayerTreeSettings settings = DefaultSettings(); | 10593 LayerTreeSettings settings = DefaultSettings(); |
10821 settings.gpu_rasterization_enabled = true; | 10594 settings.gpu_rasterization_enabled = true; |
10822 settings.gpu_rasterization_msaa_sample_count = 4; | 10595 settings.gpu_rasterization_msaa_sample_count = 4; |
10823 auto context_provider = TestContextProvider::Create(); | 10596 auto context_provider = TestContextProvider::Create(); |
10824 context_provider->UnboundTestContext3d()->SetMaxSamples(4); | 10597 context_provider->UnboundTestContext3d()->SetMaxSamples(4); |
10825 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); | 10598 context_provider->UnboundTestContext3d()->set_msaa_is_slow(msaa_is_slow); |
10826 auto msaa_is_normal_output_surface = | 10599 auto msaa_is_normal_output_surface = |
10827 FakeOutputSurface::Create3d(context_provider); | 10600 FakeOutputSurface::CreateDelegating3d(context_provider); |
10828 EXPECT_TRUE( | 10601 EXPECT_TRUE( |
10829 CreateHostImpl(settings, std::move(msaa_is_normal_output_surface))); | 10602 CreateHostImpl(settings, std::move(msaa_is_normal_output_surface))); |
10830 } | 10603 } |
10831 }; | 10604 }; |
10832 | 10605 |
10833 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { | 10606 TEST_F(MsaaIsSlowLayerTreeHostImplTest, GpuRasterizationStatusMsaaIsSlow) { |
10834 // Ensure that without the msaa_is_slow cap we raster unsuitable content with | 10607 // Ensure that without the msaa_is_slow cap we raster unsuitable content with |
10835 // msaa. | 10608 // msaa. |
10836 CreateHostImplWithMsaaIsSlow(false); | 10609 CreateHostImplWithMsaaIsSlow(false); |
10837 host_impl_->SetHasGpuRasterizationTrigger(true); | 10610 host_impl_->SetHasGpuRasterizationTrigger(true); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11039 settings.gpu_rasterization_forced = true; | 10812 settings.gpu_rasterization_forced = true; |
11040 | 10813 |
11041 host_impl_ = LayerTreeHostImpl::Create( | 10814 host_impl_ = LayerTreeHostImpl::Create( |
11042 settings, this, &task_runner_provider_, &stats_instrumentation_, | 10815 settings, this, &task_runner_provider_, &stats_instrumentation_, |
11043 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, | 10816 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, &task_graph_runner_, |
11044 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 10817 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
11045 host_impl_->SetVisible(true); | 10818 host_impl_->SetVisible(true); |
11046 | 10819 |
11047 // InitializeRenderer with a gpu-raster enabled output surface. | 10820 // InitializeRenderer with a gpu-raster enabled output surface. |
11048 auto gpu_raster_output_surface = | 10821 auto gpu_raster_output_surface = |
11049 FakeOutputSurface::Create3d(TestWebGraphicsContext3D::Create()); | 10822 FakeOutputSurface::CreateDelegating3d(TestWebGraphicsContext3D::Create()); |
11050 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); | 10823 host_impl_->InitializeRenderer(gpu_raster_output_surface.get()); |
11051 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 10824 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11052 | 10825 |
11053 // Re-initialize with a software output surface. | 10826 // Re-initialize with a software output surface. |
11054 output_surface_ = FakeOutputSurface::CreateSoftware( | 10827 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware( |
11055 base::WrapUnique(new SoftwareOutputDevice)); | 10828 base::WrapUnique(new SoftwareOutputDevice)); |
11056 host_impl_->InitializeRenderer(output_surface_.get()); | 10829 host_impl_->InitializeRenderer(output_surface_.get()); |
11057 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10830 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11058 } | 10831 } |
11059 | 10832 |
11060 } // namespace | 10833 } // namespace |
11061 } // namespace cc | 10834 } // namespace cc |
OLD | NEW |