OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/delegated_renderer_layer_impl.h" | 5 #include "cc/layers/delegated_renderer_layer_impl.h" |
6 | 6 |
7 #include "cc/base/scoped_ptr_vector.h" | 7 #include "cc/base/scoped_ptr_vector.h" |
8 #include "cc/layers/solid_color_layer_impl.h" | 8 #include "cc/layers/solid_color_layer_impl.h" |
9 #include "cc/quads/render_pass_draw_quad.h" | 9 #include "cc/quads/render_pass_draw_quad.h" |
10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 float delegated_device_scale_factor_; | 685 float delegated_device_scale_factor_; |
686 }; | 686 }; |
687 | 687 |
688 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_NoSurface) { | 688 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_NoSurface) { |
689 root_delegated_render_pass_is_clipped_ = false; | 689 root_delegated_render_pass_is_clipped_ = false; |
690 SetUpTest(); | 690 SetUpTest(); |
691 | 691 |
692 LayerTreeHostImpl::FrameData frame; | 692 LayerTreeHostImpl::FrameData frame; |
693 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 693 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
694 | 694 |
695 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 695 const SharedQuadState* root_delegated_shared_quad_state = nullptr; |
696 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 696 const SharedQuadState* contrib_delegated_shared_quad_state = nullptr; |
697 VerifyRenderPasses( | 697 VerifyRenderPasses( |
698 frame, | 698 frame, |
699 2, | 699 2, |
700 &root_delegated_shared_quad_state, | 700 &root_delegated_shared_quad_state, |
701 &contrib_delegated_shared_quad_state); | 701 &contrib_delegated_shared_quad_state); |
702 | 702 |
703 // When the quads don't have a clip of their own, the clip rect is set to | 703 // When the quads don't have a clip of their own, the clip rect is set to |
704 // the drawable_content_rect of the delegated renderer layer. | 704 // the drawable_content_rect of the delegated renderer layer. |
705 EXPECT_EQ(delegated_renderer_layer_->drawable_content_rect().ToString(), | 705 EXPECT_EQ(delegated_renderer_layer_->drawable_content_rect().ToString(), |
706 root_delegated_shared_quad_state->clip_rect.ToString()); | 706 root_delegated_shared_quad_state->clip_rect.ToString()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 host_impl_->DidDrawAllLayers(frame); | 740 host_impl_->DidDrawAllLayers(frame); |
741 } | 741 } |
742 | 742 |
743 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_NoSurface) { | 743 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_NoSurface) { |
744 root_delegated_render_pass_is_clipped_ = true; | 744 root_delegated_render_pass_is_clipped_ = true; |
745 SetUpTest(); | 745 SetUpTest(); |
746 | 746 |
747 LayerTreeHostImpl::FrameData frame; | 747 LayerTreeHostImpl::FrameData frame; |
748 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 748 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
749 | 749 |
750 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 750 const SharedQuadState* root_delegated_shared_quad_state = nullptr; |
751 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 751 const SharedQuadState* contrib_delegated_shared_quad_state = nullptr; |
752 VerifyRenderPasses( | 752 VerifyRenderPasses( |
753 frame, | 753 frame, |
754 2, | 754 2, |
755 &root_delegated_shared_quad_state, | 755 &root_delegated_shared_quad_state, |
756 &contrib_delegated_shared_quad_state); | 756 &contrib_delegated_shared_quad_state); |
757 | 757 |
758 // Since the quads have a clip_rect it should be modified by delegated | 758 // Since the quads have a clip_rect it should be modified by delegated |
759 // renderer layer's draw_transform. | 759 // renderer layer's draw_transform. |
760 // The position of the resulting clip_rect is: | 760 // The position of the resulting clip_rect is: |
761 // (clip rect position (10) * inverse dsf (1/2) + translate (8)) * | 761 // (clip rect position (10) * inverse dsf (1/2) + translate (8)) * |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 | 801 |
802 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) { | 802 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsUnclipped_Surface) { |
803 root_delegated_render_pass_is_clipped_ = false; | 803 root_delegated_render_pass_is_clipped_ = false; |
804 SetUpTest(); | 804 SetUpTest(); |
805 | 805 |
806 delegated_renderer_layer_->SetForceRenderSurface(true); | 806 delegated_renderer_layer_->SetForceRenderSurface(true); |
807 | 807 |
808 LayerTreeHostImpl::FrameData frame; | 808 LayerTreeHostImpl::FrameData frame; |
809 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 809 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
810 | 810 |
811 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 811 const SharedQuadState* root_delegated_shared_quad_state = nullptr; |
812 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 812 const SharedQuadState* contrib_delegated_shared_quad_state = nullptr; |
813 VerifyRenderPasses( | 813 VerifyRenderPasses( |
814 frame, | 814 frame, |
815 3, | 815 3, |
816 &root_delegated_shared_quad_state, | 816 &root_delegated_shared_quad_state, |
817 &contrib_delegated_shared_quad_state); | 817 &contrib_delegated_shared_quad_state); |
818 | 818 |
819 // When the layer owns a surface, then its position and translation are not | 819 // When the layer owns a surface, then its position and translation are not |
820 // a part of its draw transform. | 820 // a part of its draw transform. |
821 EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(), | 821 EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(), |
822 root_delegated_shared_quad_state->clip_rect.ToString()); | 822 root_delegated_shared_quad_state->clip_rect.ToString()); |
(...skipping 26 matching lines...) Expand all Loading... |
849 | 849 |
850 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_Surface) { | 850 TEST_F(DelegatedRendererLayerImplTestTransform, QuadsClipped_Surface) { |
851 root_delegated_render_pass_is_clipped_ = true; | 851 root_delegated_render_pass_is_clipped_ = true; |
852 SetUpTest(); | 852 SetUpTest(); |
853 | 853 |
854 delegated_renderer_layer_->SetForceRenderSurface(true); | 854 delegated_renderer_layer_->SetForceRenderSurface(true); |
855 | 855 |
856 LayerTreeHostImpl::FrameData frame; | 856 LayerTreeHostImpl::FrameData frame; |
857 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 857 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
858 | 858 |
859 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 859 const SharedQuadState* root_delegated_shared_quad_state = nullptr; |
860 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 860 const SharedQuadState* contrib_delegated_shared_quad_state = nullptr; |
861 VerifyRenderPasses( | 861 VerifyRenderPasses( |
862 frame, | 862 frame, |
863 3, | 863 3, |
864 &root_delegated_shared_quad_state, | 864 &root_delegated_shared_quad_state, |
865 &contrib_delegated_shared_quad_state); | 865 &contrib_delegated_shared_quad_state); |
866 | 866 |
867 // When the layer owns a surface, then its position and translation are not | 867 // When the layer owns a surface, then its position and translation are not |
868 // a part of its draw transform. The clip_rect should be preserved. | 868 // a part of its draw transform. The clip_rect should be preserved. |
869 EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(), | 869 EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(), |
870 root_delegated_shared_quad_state->clip_rect.ToString()); | 870 root_delegated_shared_quad_state->clip_rect.ToString()); |
(...skipping 25 matching lines...) Expand all Loading... |
896 | 896 |
897 TEST_F(DelegatedRendererLayerImplTestTransform, MismatchedDeviceScaleFactor) { | 897 TEST_F(DelegatedRendererLayerImplTestTransform, MismatchedDeviceScaleFactor) { |
898 root_delegated_render_pass_is_clipped_ = true; | 898 root_delegated_render_pass_is_clipped_ = true; |
899 delegated_device_scale_factor_ = 1.3f; | 899 delegated_device_scale_factor_ = 1.3f; |
900 | 900 |
901 SetUpTest(); | 901 SetUpTest(); |
902 | 902 |
903 LayerTreeHostImpl::FrameData frame; | 903 LayerTreeHostImpl::FrameData frame; |
904 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 904 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
905 | 905 |
906 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 906 const SharedQuadState* root_delegated_shared_quad_state = nullptr; |
907 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 907 const SharedQuadState* contrib_delegated_shared_quad_state = nullptr; |
908 VerifyRenderPasses(frame, | 908 VerifyRenderPasses(frame, |
909 2, | 909 2, |
910 &root_delegated_shared_quad_state, | 910 &root_delegated_shared_quad_state, |
911 &contrib_delegated_shared_quad_state); | 911 &contrib_delegated_shared_quad_state); |
912 | 912 |
913 // The parent tree's device scale factor is 2.0, but the child has submitted a | 913 // The parent tree's device scale factor is 2.0, but the child has submitted a |
914 // frame with a device scale factor of 1.3. Absent any better option, the | 914 // frame with a device scale factor of 1.3. Absent any better option, the |
915 // only thing we can do is scale from 1.3 -> 2.0. | 915 // only thing we can do is scale from 1.3 -> 2.0. |
916 | 916 |
917 gfx::Transform expected; | 917 gfx::Transform expected; |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 scoped_ptr<DelegatedRendererLayerImpl> other_layer = | 1565 scoped_ptr<DelegatedRendererLayerImpl> other_layer = |
1566 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6); | 1566 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6); |
1567 | 1567 |
1568 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get()); | 1568 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get()); |
1569 | 1569 |
1570 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor()); | 1570 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor()); |
1571 } | 1571 } |
1572 | 1572 |
1573 } // namespace | 1573 } // namespace |
1574 } // namespace cc | 1574 } // namespace cc |
OLD | NEW |