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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 6707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6718 | 6718 |
6719 // There's a solid color quad under everything. | 6719 // There's a solid color quad under everything. |
6720 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); | 6720 EXPECT_EQ(DrawQuad::SOLID_COLOR, root_pass->quad_list.back()->material); |
6721 | 6721 |
6722 // The surface is clipped to 10x20. | 6722 // The surface is clipped to 10x20. |
6723 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); | 6723 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); |
6724 const RenderPassDrawQuad* render_pass_quad = | 6724 const RenderPassDrawQuad* render_pass_quad = |
6725 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6725 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
6726 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), | 6726 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), |
6727 render_pass_quad->rect.ToString()); | 6727 render_pass_quad->rect.ToString()); |
6728 // The masked layer is 50x50, but the surface size is 10x20. So the texture | 6728 // The mask layer is 100x100, but the surface size is 10x20. So the texture |
6729 // coords in the mask are scaled by 10/50 and 20/50. | 6729 // coords in the mask are scaled by 10/100 and 20/100. |
6730 // The surface is clipped to (20,10) so the mask texture coords are offset | 6730 // The surface is clipped to (20,10) so the mask texture coords are offset |
6731 // by 20/50 and 10/50 | 6731 // by 20/100 and 10/100 |
6732 if (host_impl->settings().enable_mask_tiling) { | 6732 if (host_impl->settings().enable_mask_tiling) { |
6733 PictureLayerImpl* mask_layer_impl = static_cast<PictureLayerImpl*>( | 6733 PictureLayerImpl* mask_layer_impl = static_cast<PictureLayerImpl*>( |
6734 host_impl->active_tree()->LayerById(mask_layer_id_)); | 6734 host_impl->active_tree()->LayerById(mask_layer_id_)); |
6735 gfx::SizeF texture_size( | 6735 gfx::SizeF texture_size( |
6736 mask_layer_impl->CalculateTileSize(mask_layer_impl->bounds())); | 6736 mask_layer_impl->CalculateTileSize(mask_layer_impl->bounds())); |
6737 EXPECT_EQ( | 6737 EXPECT_EQ( |
6738 gfx::RectF(20.f / texture_size.width(), 10.f / texture_size.height(), | 6738 gfx::RectF(20.f / texture_size.width(), 10.f / texture_size.height(), |
6739 10.f / texture_size.width(), 20.f / texture_size.height()) | 6739 10.f / texture_size.width(), 20.f / texture_size.height()) |
6740 .ToString(), | 6740 .ToString(), |
6741 render_pass_quad->mask_uv_rect.ToString()); | 6741 render_pass_quad->mask_uv_rect.ToString()); |
6742 } else { | 6742 } else { |
6743 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f) | 6743 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 100.f) |
6744 .ToString(), | 6744 .ToString(), |
6745 render_pass_quad->mask_uv_rect.ToString()); | 6745 render_pass_quad->mask_uv_rect.ToString()); |
6746 } | 6746 } |
6747 EndTest(); | 6747 EndTest(); |
6748 return draw_result; | 6748 return draw_result; |
6749 } | 6749 } |
6750 | 6750 |
6751 void AfterTest() override {} | 6751 void AfterTest() override {} |
6752 | 6752 |
6753 int mask_layer_id_; | 6753 int mask_layer_id_; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6939 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6939 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
6940 switch (host_impl->active_tree()->source_frame_number()) { | 6940 switch (host_impl->active_tree()->source_frame_number()) { |
6941 case 0: | 6941 case 0: |
6942 // Check that the mask fills the surface. | 6942 // Check that the mask fills the surface. |
6943 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 6943 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
6944 render_pass_quad->rect.ToString()); | 6944 render_pass_quad->rect.ToString()); |
6945 if (host_impl->settings().enable_mask_tiling) { | 6945 if (host_impl->settings().enable_mask_tiling) { |
6946 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(), | 6946 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(), |
6947 render_pass_quad->mask_uv_rect.ToString()); | 6947 render_pass_quad->mask_uv_rect.ToString()); |
6948 } else { | 6948 } else { |
6949 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6949 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 100.f, 50.f / 100.f).ToString(), |
6950 render_pass_quad->mask_uv_rect.ToString()); | 6950 render_pass_quad->mask_uv_rect.ToString()); |
6951 } | 6951 } |
6952 break; | 6952 break; |
6953 case 1: | 6953 case 1: |
6954 // Applying a DSF should change the render surface size, but won't | 6954 // Applying a DSF should change the render surface size, but won't |
6955 // affect which part of the mask is used. | 6955 // affect which part of the mask is used. |
6956 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 6956 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
6957 render_pass_quad->rect.ToString()); | 6957 render_pass_quad->rect.ToString()); |
6958 if (host_impl->settings().enable_mask_tiling) { | 6958 if (host_impl->settings().enable_mask_tiling) { |
6959 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(), | 6959 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 128.f, 50.f / 128.f).ToString(), |
6960 render_pass_quad->mask_uv_rect.ToString()); | 6960 render_pass_quad->mask_uv_rect.ToString()); |
6961 } else { | 6961 } else { |
6962 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6962 EXPECT_EQ(gfx::RectF(0.f, 0.f, 50.f / 100.f, 50.f / 100.f).ToString(), |
6963 render_pass_quad->mask_uv_rect.ToString()); | 6963 render_pass_quad->mask_uv_rect.ToString()); |
6964 } | 6964 } |
6965 EndTest(); | 6965 EndTest(); |
6966 break; | 6966 break; |
6967 } | 6967 } |
6968 return draw_result; | 6968 return draw_result; |
6969 } | 6969 } |
6970 | 6970 |
6971 void DidCommit() override { | 6971 void DidCommit() override { |
6972 switch (layer_tree_host()->SourceFrameNumber()) { | 6972 switch (layer_tree_host()->SourceFrameNumber()) { |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7497 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); | 7497 DCHECK_EQ(hud->scroll_tree_index(), root_layer->scroll_tree_index()); |
7498 } | 7498 } |
7499 | 7499 |
7500 void AfterTest() override {} | 7500 void AfterTest() override {} |
7501 }; | 7501 }; |
7502 | 7502 |
7503 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); | 7503 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestHudLayerWithLayerLists); |
7504 | 7504 |
7505 } // namespace | 7505 } // namespace |
7506 } // namespace cc | 7506 } // namespace cc |
OLD | NEW |