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/quad_sink.h" | 8 #include "cc/layers/quad_sink.h" |
9 #include "cc/layers/solid_color_layer_impl.h" | 9 #include "cc/layers/solid_color_layer_impl.h" |
10 #include "cc/quads/render_pass_draw_quad.h" | 10 #include "cc/quads/render_pass_draw_quad.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 LayerTreeHostImpl::FrameData frame; | 238 LayerTreeHostImpl::FrameData frame; |
239 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 239 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
240 | 240 |
241 // Each non-DelegatedRendererLayer added one RenderPass. The | 241 // Each non-DelegatedRendererLayer added one RenderPass. The |
242 // DelegatedRendererLayer added two contributing passes. | 242 // DelegatedRendererLayer added two contributing passes. |
243 ASSERT_EQ(5u, frame.render_passes.size()); | 243 ASSERT_EQ(5u, frame.render_passes.size()); |
244 | 244 |
245 // The DelegatedRendererLayer is at position 3,3 compared to its target, and | 245 // The DelegatedRendererLayer is at position 3,3 compared to its target, and |
246 // has a translation transform of 1,1. So its root RenderPass' quads should | 246 // has a translation transform of 1,1. So its root RenderPass' quads should |
247 // all be transformed by that combined amount. | 247 // all be transformed by that combined amount. |
248 // The DelegatedRendererLayer has a size of 10x10, but the root delegated | |
249 // RenderPass has a size of 8x8, so any quads should be scaled by 10/8. | |
250 gfx::Transform transform; | 248 gfx::Transform transform; |
251 transform.Translate(4.0, 4.0); | 249 transform.Translate(4.0, 4.0); |
252 transform.Scale(10.0 / 8.0, 10.0 / 8.0); | |
253 EXPECT_TRANSFORMATION_MATRIX_EQ( | 250 EXPECT_TRANSFORMATION_MATRIX_EQ( |
254 transform, frame.render_passes[3]->quad_list[0]->quadTransform()); | 251 transform, frame.render_passes[3]->quad_list[0]->quadTransform()); |
255 | 252 |
256 // Quads from non-root RenderPasses should not be shifted though. | 253 // Quads from non-root RenderPasses should not be shifted though. |
257 ASSERT_EQ(2u, frame.render_passes[2]->quad_list.size()); | 254 ASSERT_EQ(2u, frame.render_passes[2]->quad_list.size()); |
258 EXPECT_TRANSFORMATION_MATRIX_EQ( | 255 EXPECT_TRANSFORMATION_MATRIX_EQ( |
259 gfx::Transform(), frame.render_passes[2]->quad_list[0]->quadTransform()); | 256 gfx::Transform(), frame.render_passes[2]->quad_list[0]->quadTransform()); |
260 EXPECT_TRANSFORMATION_MATRIX_EQ( | 257 EXPECT_TRANSFORMATION_MATRIX_EQ( |
261 gfx::Transform(), frame.render_passes[2]->quad_list[1]->quadTransform()); | 258 gfx::Transform(), frame.render_passes[2]->quad_list[1]->quadTransform()); |
262 ASSERT_EQ(1u, frame.render_passes[1]->quad_list.size()); | 259 ASSERT_EQ(1u, frame.render_passes[1]->quad_list.size()); |
(...skipping 10 matching lines...) Expand all Loading... | |
273 | 270 |
274 // The delegated layer has a surface between it and the root. | 271 // The delegated layer has a surface between it and the root. |
275 EXPECT_TRUE(delegated_renderer_layer_->render_target()->parent()); | 272 EXPECT_TRUE(delegated_renderer_layer_->render_target()->parent()); |
276 | 273 |
277 // Each non-DelegatedRendererLayer added one RenderPass. The | 274 // Each non-DelegatedRendererLayer added one RenderPass. The |
278 // DelegatedRendererLayer added two contributing passes. | 275 // DelegatedRendererLayer added two contributing passes. |
279 ASSERT_EQ(5u, frame.render_passes.size()); | 276 ASSERT_EQ(5u, frame.render_passes.size()); |
280 | 277 |
281 // The DelegatedRendererLayer is at position 9,9 compared to the root, so all | 278 // The DelegatedRendererLayer is at position 9,9 compared to the root, so all |
282 // render pass' transforms to the root should be shifted by this amount. | 279 // render pass' transforms to the root should be shifted by this amount. |
283 // The DelegatedRendererLayer has a size of 10x10, but the root delegated | |
284 // RenderPass has a size of 8x8, so any render passes should be scaled by | |
285 // 10/8. | |
286 gfx::Transform transform; | 280 gfx::Transform transform; |
287 transform.Translate(9.0, 9.0); | 281 transform.Translate(9.0, 9.0); |
288 transform.Scale(10.0 / 8.0, 10.0 / 8.0); | |
289 | 282 |
290 // The first contributing surface has a translation of 5, 6. | 283 // The first contributing surface has a translation of 5, 6. |
291 gfx::Transform five_six(1, 0, 0, 1, 5, 6); | 284 gfx::Transform five_six(1, 0, 0, 1, 5, 6); |
292 | 285 |
293 // The second contributing surface has a translation of 7, 8. | 286 // The second contributing surface has a translation of 7, 8. |
294 gfx::Transform seven_eight(1, 0, 0, 1, 7, 8); | 287 gfx::Transform seven_eight(1, 0, 0, 1, 7, 8); |
295 | 288 |
296 EXPECT_TRANSFORMATION_MATRIX_EQ( | 289 EXPECT_TRANSFORMATION_MATRIX_EQ( |
297 transform * five_six, frame.render_passes[1]->transform_to_root_target); | 290 transform * five_six, frame.render_passes[1]->transform_to_root_target); |
298 EXPECT_TRANSFORMATION_MATRIX_EQ( | 291 EXPECT_TRANSFORMATION_MATRIX_EQ( |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 QuadsFromRootRenderPassAreNotModifiedForTheTarget) { | 454 QuadsFromRootRenderPassAreNotModifiedForTheTarget) { |
462 LayerTreeHostImpl::FrameData frame; | 455 LayerTreeHostImpl::FrameData frame; |
463 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 456 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
464 | 457 |
465 // Each non-DelegatedRendererLayer added one RenderPass. The | 458 // Each non-DelegatedRendererLayer added one RenderPass. The |
466 // DelegatedRendererLayer added two contributing passes and its owned surface | 459 // DelegatedRendererLayer added two contributing passes and its owned surface |
467 // added one pass. | 460 // added one pass. |
468 ASSERT_EQ(6u, frame.render_passes.size()); | 461 ASSERT_EQ(6u, frame.render_passes.size()); |
469 | 462 |
470 // Because the DelegatedRendererLayer owns a RenderSurfaceImpl, its root | 463 // Because the DelegatedRendererLayer owns a RenderSurfaceImpl, its root |
471 // RenderPass' quads do not need to be translated at all. However, they are | 464 // RenderPass' quads do not need to be translated at all. |
472 // scaled from the frame's size (8x8) to the layer's bounds (10x10). | |
473 gfx::Transform transform; | |
474 transform.Scale(10.0 / 8.0, 10.0 / 8.0); | |
475 EXPECT_TRANSFORMATION_MATRIX_EQ( | 465 EXPECT_TRANSFORMATION_MATRIX_EQ( |
476 transform, frame.render_passes[3]->quad_list[0]->quadTransform()); | 466 gfx::Transform(), frame.render_passes[3]->quad_list[0]->quadTransform()); |
477 | 467 |
478 // Quads from non-root RenderPasses should not be shifted either. | 468 // Quads from non-root RenderPasses should not be shifted either. |
479 ASSERT_EQ(2u, frame.render_passes[2]->quad_list.size()); | 469 ASSERT_EQ(2u, frame.render_passes[2]->quad_list.size()); |
480 EXPECT_TRANSFORMATION_MATRIX_EQ( | 470 EXPECT_TRANSFORMATION_MATRIX_EQ( |
481 gfx::Transform(), frame.render_passes[2]->quad_list[0]->quadTransform()); | 471 gfx::Transform(), frame.render_passes[2]->quad_list[0]->quadTransform()); |
482 EXPECT_TRANSFORMATION_MATRIX_EQ( | 472 EXPECT_TRANSFORMATION_MATRIX_EQ( |
483 gfx::Transform(), frame.render_passes[2]->quad_list[1]->quadTransform()); | 473 gfx::Transform(), frame.render_passes[2]->quad_list[1]->quadTransform()); |
484 ASSERT_EQ(1u, frame.render_passes[1]->quad_list.size()); | 474 ASSERT_EQ(1u, frame.render_passes[1]->quad_list.size()); |
485 EXPECT_TRANSFORMATION_MATRIX_EQ( | 475 EXPECT_TRANSFORMATION_MATRIX_EQ( |
486 gfx::Transform(), frame.render_passes[1]->quad_list[0]->quadTransform()); | 476 gfx::Transform(), frame.render_passes[1]->quad_list[0]->quadTransform()); |
(...skipping 17 matching lines...) Expand all Loading... | |
504 root_layer->SetBounds(gfx::Size(100, 100)); | 494 root_layer->SetBounds(gfx::Size(100, 100)); |
505 | 495 |
506 delegated_renderer_layer->SetPosition(gfx::Point(20, 20)); | 496 delegated_renderer_layer->SetPosition(gfx::Point(20, 20)); |
507 delegated_renderer_layer->SetBounds(gfx::Size(75, 75)); | 497 delegated_renderer_layer->SetBounds(gfx::Size(75, 75)); |
508 delegated_renderer_layer->SetContentBounds(gfx::Size(75, 75)); | 498 delegated_renderer_layer->SetContentBounds(gfx::Size(75, 75)); |
509 delegated_renderer_layer->SetDrawsContent(true); | 499 delegated_renderer_layer->SetDrawsContent(true); |
510 gfx::Transform transform; | 500 gfx::Transform transform; |
511 transform.Scale(2.0, 2.0); | 501 transform.Scale(2.0, 2.0); |
512 transform.Translate(8.0, 8.0); | 502 transform.Translate(8.0, 8.0); |
513 delegated_renderer_layer->SetTransform(transform); | 503 delegated_renderer_layer->SetTransform(transform); |
514 delegated_renderer_layer->SetTransformOrigin( | |
jamesr
2014/06/05 20:54:26
deleting this (which doesn't seem all that relevan
enne (OOO)
2014/06/05 23:02:14
Yeah, I don't think it's relevant to DRLI and make
| |
515 gfx::Point3F(75 * 0.5f, 75 * 0.5f, 0.0f)); | |
516 | 504 |
517 ScopedPtrVector<RenderPass> delegated_render_passes; | 505 ScopedPtrVector<RenderPass> delegated_render_passes; |
518 | 506 |
519 gfx::Size child_pass_content_bounds(7, 7); | 507 gfx::Size child_pass_content_bounds(7, 7); |
520 gfx::Rect child_pass_rect(20, 20, 7, 7); | 508 gfx::Rect child_pass_rect(20, 20, 7, 7); |
521 gfx::Transform child_pass_transform; | 509 gfx::Transform child_pass_transform; |
522 child_pass_transform.Scale(0.8f, 0.8f); | 510 child_pass_transform.Scale(0.8f, 0.8f); |
523 child_pass_transform.Translate(9.0, 9.0); | 511 child_pass_transform.Translate(9.0, 9.0); |
524 gfx::Rect child_pass_clip_rect(21, 21, 3, 3); | 512 gfx::Rect child_pass_clip_rect(21, 21, 3, 3); |
525 bool child_pass_clipped = false; | 513 bool child_pass_clipped = false; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 // the drawable_content_rect of the delegated renderer layer. | 696 // the drawable_content_rect of the delegated renderer layer. |
709 EXPECT_EQ(delegated_renderer_layer_->drawable_content_rect().ToString(), | 697 EXPECT_EQ(delegated_renderer_layer_->drawable_content_rect().ToString(), |
710 root_delegated_shared_quad_state->clip_rect.ToString()); | 698 root_delegated_shared_quad_state->clip_rect.ToString()); |
711 | 699 |
712 // Even though the quads in the root pass have no clip of their own, they | 700 // Even though the quads in the root pass have no clip of their own, they |
713 // inherit the clip rect from the delegated renderer layer if it does not | 701 // inherit the clip rect from the delegated renderer layer if it does not |
714 // own a surface. | 702 // own a surface. |
715 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); | 703 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); |
716 | 704 |
717 gfx::Transform expected; | 705 gfx::Transform expected; |
718 // Device scale factor is 2. | 706 // Device scale factor. |
719 expected.Scale(2.0, 2.0); | 707 expected.Scale(2.0, 2.0); |
720 // This is the transform from the layer's space to its target. | 708 // This is the transform from the layer's space to its target. |
721 // The position (20) - the width / scale (75 / 2) = 20 - 37.5 = -17.5 | 709 expected.Translate(20, 20); |
722 expected.Translate(-17.5, -17.5); | |
723 expected.Scale(2.0, 2.0); | 710 expected.Scale(2.0, 2.0); |
724 expected.Translate(8.0, 8.0); | 711 expected.Translate(8.0, 8.0); |
725 // The frame has size 100x100 but the layer's bounds are 75x75. | |
726 expected.Scale(75.0 / 100.0, 75.0 / 100.0); | |
727 // This is the transform within the source frame. | 712 // This is the transform within the source frame. |
713 // Inverse device scale factor to go from physical space to layer space. | |
714 expected.Scale(0.5, 0.5); | |
728 expected.Scale(1.5, 1.5); | 715 expected.Scale(1.5, 1.5); |
729 expected.Translate(7.0, 7.0); | 716 expected.Translate(7.0, 7.0); |
730 EXPECT_TRANSFORMATION_MATRIX_EQ( | 717 EXPECT_TRANSFORMATION_MATRIX_EQ( |
731 expected, root_delegated_shared_quad_state->content_to_target_transform); | 718 expected, root_delegated_shared_quad_state->content_to_target_transform); |
732 | 719 |
733 // The contributing render pass should not be transformed from its input. | 720 // The contributing render pass should not be transformed from its input. |
734 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), | 721 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), |
735 contrib_delegated_shared_quad_state->clip_rect.ToString()); | 722 contrib_delegated_shared_quad_state->clip_rect.ToString()); |
736 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); | 723 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); |
737 expected.MakeIdentity(); | 724 expected.MakeIdentity(); |
(...skipping 18 matching lines...) Expand all Loading... | |
756 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 743 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; |
757 VerifyRenderPasses( | 744 VerifyRenderPasses( |
758 frame, | 745 frame, |
759 2, | 746 2, |
760 &root_delegated_shared_quad_state, | 747 &root_delegated_shared_quad_state, |
761 &contrib_delegated_shared_quad_state); | 748 &contrib_delegated_shared_quad_state); |
762 | 749 |
763 // Since the quads have a clip_rect it should be modified by delegated | 750 // Since the quads have a clip_rect it should be modified by delegated |
764 // renderer layer's draw_transform. | 751 // renderer layer's draw_transform. |
765 // The position of the resulting clip_rect is: | 752 // The position of the resulting clip_rect is: |
766 // (clip rect position (10) * scale to layer (75/100) + translate (8)) * | 753 // (clip rect position (10) * inverse dsf (1/2) + translate (8)) * |
767 // layer scale (2) + layer position (20) = 51 | 754 // layer scale (2) + layer position (20) = 46 |
768 // But the layer is centered, so: 51 - (75 / 2) = 51 - 75 / 2 = 13.5 | 755 // The device scale is 2, so everything gets doubled, giving 92. |
769 // The device scale is 2, so everything gets doubled, giving 27. | |
770 // | 756 // |
771 // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from | 757 // The size is 35x35 scaled by the device scale. |
772 // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5. The device | 758 EXPECT_EQ(gfx::Rect(92, 92, 70, 70).ToString(), |
773 // scale doubles this to 105. | |
774 EXPECT_EQ(gfx::Rect(27, 27, 105, 105).ToString(), | |
775 root_delegated_shared_quad_state->clip_rect.ToString()); | 759 root_delegated_shared_quad_state->clip_rect.ToString()); |
776 | 760 |
777 // The quads had a clip and it should be preserved. | 761 // The quads had a clip and it should be preserved. |
778 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); | 762 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); |
779 | 763 |
780 gfx::Transform expected; | 764 gfx::Transform expected; |
781 // Device scale factor is 2. | 765 // Device scale factor. |
782 expected.Scale(2.0, 2.0); | 766 expected.Scale(2.0, 2.0); |
783 // This is the transform from the layer's space to its target. | 767 // This is the transform from the layer's space to its target. |
784 // The position (20) - the width / scale (75 / 2) = 20 - 37.5 = -17.5 | 768 expected.Translate(20, 20); |
785 expected.Translate(-17.5, -17.5); | |
786 expected.Scale(2.0, 2.0); | 769 expected.Scale(2.0, 2.0); |
787 expected.Translate(8.0, 8.0); | 770 expected.Translate(8.0, 8.0); |
788 // The frame has size 100x100 but the layer's bounds are 75x75. | |
789 expected.Scale(75.0 / 100.0, 75.0 / 100.0); | |
790 // This is the transform within the source frame. | 771 // This is the transform within the source frame. |
772 // Inverse device scale factor to go from physical space to layer space. | |
773 expected.Scale(0.5, 0.5); | |
791 expected.Scale(1.5, 1.5); | 774 expected.Scale(1.5, 1.5); |
792 expected.Translate(7.0, 7.0); | 775 expected.Translate(7.0, 7.0); |
793 EXPECT_TRANSFORMATION_MATRIX_EQ( | 776 EXPECT_TRANSFORMATION_MATRIX_EQ( |
794 expected, root_delegated_shared_quad_state->content_to_target_transform); | 777 expected, root_delegated_shared_quad_state->content_to_target_transform); |
795 | 778 |
796 // The contributing render pass should not be transformed from its input. | 779 // The contributing render pass should not be transformed from its input. |
797 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), | 780 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), |
798 contrib_delegated_shared_quad_state->clip_rect.ToString()); | 781 contrib_delegated_shared_quad_state->clip_rect.ToString()); |
799 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); | 782 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); |
800 expected.MakeIdentity(); | 783 expected.MakeIdentity(); |
(...skipping 19 matching lines...) Expand all Loading... | |
820 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 803 const SharedQuadState* root_delegated_shared_quad_state = NULL; |
821 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 804 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; |
822 VerifyRenderPasses( | 805 VerifyRenderPasses( |
823 frame, | 806 frame, |
824 3, | 807 3, |
825 &root_delegated_shared_quad_state, | 808 &root_delegated_shared_quad_state, |
826 &contrib_delegated_shared_quad_state); | 809 &contrib_delegated_shared_quad_state); |
827 | 810 |
828 // When the layer owns a surface, then its position and translation are not | 811 // When the layer owns a surface, then its position and translation are not |
829 // a part of its draw transform. | 812 // a part of its draw transform. |
830 // The position of the resulting clip_rect is: | 813 EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(), |
831 // (clip rect position (10) * scale to layer (75/100)) * device scale (2) = 15 | |
832 // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from | |
833 // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5. | |
834 EXPECT_EQ(gfx::Rect(15, 15, 53, 53).ToString(), | |
835 root_delegated_shared_quad_state->clip_rect.ToString()); | 814 root_delegated_shared_quad_state->clip_rect.ToString()); |
836 | 815 |
837 // Since the layer owns a surface it doesn't need to clip its quads, so | 816 // Since the layer owns a surface it doesn't need to clip its quads, so |
838 // unclipped quads remain unclipped. | 817 // unclipped quads remain unclipped. |
839 EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped); | 818 EXPECT_FALSE(root_delegated_shared_quad_state->is_clipped); |
840 | 819 |
841 gfx::Transform expected; | 820 gfx::Transform expected; |
842 // Device scale factor is 2. | |
843 expected.Scale(2.0, 2.0); | |
844 // The frame has size 100x100 but the layer's bounds are 75x75. | |
845 expected.Scale(75.0 / 100.0, 75.0 / 100.0); | |
846 // This is the transform within the source frame. | 821 // This is the transform within the source frame. |
847 expected.Scale(1.5, 1.5); | 822 expected.Scale(1.5, 1.5); |
848 expected.Translate(7.0, 7.0); | 823 expected.Translate(7.0, 7.0); |
849 EXPECT_TRANSFORMATION_MATRIX_EQ( | 824 EXPECT_TRANSFORMATION_MATRIX_EQ( |
850 expected, root_delegated_shared_quad_state->content_to_target_transform); | 825 expected, root_delegated_shared_quad_state->content_to_target_transform); |
851 | 826 |
852 // The contributing render pass should not be transformed from its input. | 827 // The contributing render pass should not be transformed from its input. |
853 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), | 828 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), |
854 contrib_delegated_shared_quad_state->clip_rect.ToString()); | 829 contrib_delegated_shared_quad_state->clip_rect.ToString()); |
855 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); | 830 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); |
(...skipping 19 matching lines...) Expand all Loading... | |
875 | 850 |
876 const SharedQuadState* root_delegated_shared_quad_state = NULL; | 851 const SharedQuadState* root_delegated_shared_quad_state = NULL; |
877 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; | 852 const SharedQuadState* contrib_delegated_shared_quad_state = NULL; |
878 VerifyRenderPasses( | 853 VerifyRenderPasses( |
879 frame, | 854 frame, |
880 3, | 855 3, |
881 &root_delegated_shared_quad_state, | 856 &root_delegated_shared_quad_state, |
882 &contrib_delegated_shared_quad_state); | 857 &contrib_delegated_shared_quad_state); |
883 | 858 |
884 // When the layer owns a surface, then its position and translation are not | 859 // When the layer owns a surface, then its position and translation are not |
885 // a part of its draw transform. | 860 // a part of its draw transform. The clip_rect should be preserved. |
886 // The position of the resulting clip_rect is: | 861 EXPECT_EQ(gfx::Rect(10, 10, 35, 35).ToString(), |
887 // (clip rect position (10) * scale to layer (75/100)) * device scale (2) = 15 | |
888 // The size is 35x35 scaled to fit inside the layer's bounds at 75x75 from | |
889 // a frame at 100x100: 35 * 2 (device scale) * 75 / 100 = 52.5. | |
890 EXPECT_EQ(gfx::Rect(15, 15, 53, 53).ToString(), | |
891 root_delegated_shared_quad_state->clip_rect.ToString()); | 862 root_delegated_shared_quad_state->clip_rect.ToString()); |
892 | 863 |
893 // The quads had a clip and it should be preserved. | 864 // The quads had a clip and it should be preserved. |
894 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); | 865 EXPECT_TRUE(root_delegated_shared_quad_state->is_clipped); |
895 | 866 |
896 gfx::Transform expected; | 867 gfx::Transform expected; |
897 // Device scale factor is 2. | |
898 expected.Scale(2.0, 2.0); | |
899 // The frame has size 100x100 but the layer's bounds are 75x75. | |
900 expected.Scale(75.0 / 100.0, 75.0 / 100.0); | |
901 // This is the transform within the source frame. | 868 // This is the transform within the source frame. |
902 expected.Scale(1.5, 1.5); | 869 expected.Scale(1.5, 1.5); |
903 expected.Translate(7.0, 7.0); | 870 expected.Translate(7.0, 7.0); |
904 EXPECT_TRANSFORMATION_MATRIX_EQ( | 871 EXPECT_TRANSFORMATION_MATRIX_EQ( |
905 expected, root_delegated_shared_quad_state->content_to_target_transform); | 872 expected, root_delegated_shared_quad_state->content_to_target_transform); |
906 | 873 |
907 // The contributing render pass should not be transformed from its input. | 874 // The contributing render pass should not be transformed from its input. |
908 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), | 875 EXPECT_EQ(gfx::Rect(21, 21, 3, 3).ToString(), |
909 contrib_delegated_shared_quad_state->clip_rect.ToString()); | 876 contrib_delegated_shared_quad_state->clip_rect.ToString()); |
910 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); | 877 EXPECT_FALSE(contrib_delegated_shared_quad_state->is_clipped); |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1504 // The occlusion extends to 500 in the x-axis, pushing the left of the | 1471 // The occlusion extends to 500 in the x-axis, pushing the left of the |
1505 // visible part of the quad to 500 - 211 = 300 - 11 inside the quad. | 1472 // visible part of the quad to 500 - 211 = 300 - 11 inside the quad. |
1506 EXPECT_EQ(gfx::Rect(300 - 11, 0, 100 + 11, 500).ToString(), | 1473 EXPECT_EQ(gfx::Rect(300 - 11, 0, 100 + 11, 500).ToString(), |
1507 impl.quad_list()[0]->visible_rect.ToString()); | 1474 impl.quad_list()[0]->visible_rect.ToString()); |
1508 } | 1475 } |
1509 } | 1476 } |
1510 } | 1477 } |
1511 | 1478 |
1512 } // namespace | 1479 } // namespace |
1513 } // namespace cc | 1480 } // namespace cc |
OLD | NEW |