| 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 6001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6012 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6012 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 6013 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), | 6013 EXPECT_EQ(gfx::Rect(20, 10, 10, 20).ToString(), |
| 6014 render_pass_quad->rect.ToString()); | 6014 render_pass_quad->rect.ToString()); |
| 6015 // The masked layer is 50x50, but the surface size is 10x20. So the texture | 6015 // The masked layer is 50x50, but the surface size is 10x20. So the texture |
| 6016 // coords in the mask are scaled by 10/50 and 20/50. | 6016 // coords in the mask are scaled by 10/50 and 20/50. |
| 6017 // The surface is clipped to (20,10) so the mask texture coords are offset | 6017 // The surface is clipped to (20,10) so the mask texture coords are offset |
| 6018 // by 20/50 and 10/50 | 6018 // by 20/50 and 10/50 |
| 6019 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f) | 6019 EXPECT_EQ(gfx::ScaleRect(gfx::RectF(20.f, 10.f, 10.f, 20.f), 1.f / 50.f) |
| 6020 .ToString(), | 6020 .ToString(), |
| 6021 render_pass_quad->MaskUVRect().ToString()); | 6021 render_pass_quad->MaskUVRect().ToString()); |
| 6022 EXPECT_EQ(gfx::Vector2dF(10.f / 50.f, 20.f / 50.f).ToString(), | 6022 EXPECT_EQ(gfx::Vector2dF(1.f / 50.f, 1.f / 50.f).ToString(), |
| 6023 render_pass_quad->mask_uv_scale.ToString()); | 6023 render_pass_quad->mask_uv_scale.ToString()); |
| 6024 EndTest(); | 6024 EndTest(); |
| 6025 return draw_result; | 6025 return draw_result; |
| 6026 } | 6026 } |
| 6027 | 6027 |
| 6028 void AfterTest() override {} | 6028 void AfterTest() override {} |
| 6029 | 6029 |
| 6030 FakeContentLayerClient client_; | 6030 FakeContentLayerClient client_; |
| 6031 }; | 6031 }; |
| 6032 | 6032 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6095 const RenderPassDrawQuad* render_pass_quad = | 6095 const RenderPassDrawQuad* render_pass_quad = |
| 6096 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6096 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 6097 switch (host_impl->active_tree()->source_frame_number()) { | 6097 switch (host_impl->active_tree()->source_frame_number()) { |
| 6098 case 0: | 6098 case 0: |
| 6099 // Check that the tree scaling is correctly taken into account for the | 6099 // Check that the tree scaling is correctly taken into account for the |
| 6100 // mask, that should fully map onto the quad. | 6100 // mask, that should fully map onto the quad. |
| 6101 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 6101 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 6102 render_pass_quad->rect.ToString()); | 6102 render_pass_quad->rect.ToString()); |
| 6103 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6103 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6104 render_pass_quad->MaskUVRect().ToString()); | 6104 render_pass_quad->MaskUVRect().ToString()); |
| 6105 EXPECT_EQ(gfx::Vector2dF(1.f, 1.f).ToString(), | 6105 EXPECT_EQ(gfx::Vector2dF(0.01f, 0.01f).ToString(), |
| 6106 render_pass_quad->mask_uv_scale.ToString()); | 6106 render_pass_quad->mask_uv_scale.ToString()); |
| 6107 break; | 6107 break; |
| 6108 case 1: | 6108 case 1: |
| 6109 // Applying a DSF should change the render surface size, but won't | 6109 // Applying a DSF should change the render surface size, but won't |
| 6110 // affect which part of the mask is used. | 6110 // affect which part of the mask is used. |
| 6111 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), | 6111 EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(), |
| 6112 render_pass_quad->rect.ToString()); | 6112 render_pass_quad->rect.ToString()); |
| 6113 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6113 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6114 render_pass_quad->MaskUVRect().ToString()); | 6114 render_pass_quad->MaskUVRect().ToString()); |
| 6115 EXPECT_EQ(gfx::Vector2dF(1.f, 1.f).ToString(), | 6115 EXPECT_EQ(gfx::Vector2dF(0.005f, 0.005f).ToString(), |
| 6116 render_pass_quad->mask_uv_scale.ToString()); | 6116 render_pass_quad->mask_uv_scale.ToString()); |
| 6117 EndTest(); | 6117 EndTest(); |
| 6118 break; | 6118 break; |
| 6119 } | 6119 } |
| 6120 return draw_result; | 6120 return draw_result; |
| 6121 } | 6121 } |
| 6122 | 6122 |
| 6123 void DidCommit() override { | 6123 void DidCommit() override { |
| 6124 switch (layer_tree_host()->source_frame_number()) { | 6124 switch (layer_tree_host()->source_frame_number()) { |
| 6125 case 1: | 6125 case 1: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6183 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); | 6183 EXPECT_EQ(DrawQuad::RENDER_PASS, root_pass->quad_list.front()->material); |
| 6184 const RenderPassDrawQuad* render_pass_quad = | 6184 const RenderPassDrawQuad* render_pass_quad = |
| 6185 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); | 6185 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.front()); |
| 6186 switch (host_impl->active_tree()->source_frame_number()) { | 6186 switch (host_impl->active_tree()->source_frame_number()) { |
| 6187 case 0: | 6187 case 0: |
| 6188 // Check that the mask fills the surface. | 6188 // Check that the mask fills the surface. |
| 6189 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 6189 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 6190 render_pass_quad->rect.ToString()); | 6190 render_pass_quad->rect.ToString()); |
| 6191 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6191 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6192 render_pass_quad->MaskUVRect().ToString()); | 6192 render_pass_quad->MaskUVRect().ToString()); |
| 6193 EXPECT_EQ(gfx::Vector2dF(1.f, 1.f).ToString(), | 6193 EXPECT_EQ(gfx::Vector2dF(0.02f, 0.02f).ToString(), |
| 6194 render_pass_quad->mask_uv_scale.ToString()); | 6194 render_pass_quad->mask_uv_scale.ToString()); |
| 6195 break; | 6195 break; |
| 6196 case 1: | 6196 case 1: |
| 6197 // Applying a DSF should change the render surface size, but won't | 6197 // Applying a DSF should change the render surface size, but won't |
| 6198 // affect which part of the mask is used. | 6198 // affect which part of the mask is used. |
| 6199 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 6199 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 6200 render_pass_quad->rect.ToString()); | 6200 render_pass_quad->rect.ToString()); |
| 6201 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6201 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6202 render_pass_quad->MaskUVRect().ToString()); | 6202 render_pass_quad->MaskUVRect().ToString()); |
| 6203 EXPECT_EQ(gfx::Vector2dF(1.f, 1.f).ToString(), | 6203 EXPECT_EQ(gfx::Vector2dF(0.01f, 0.01f).ToString(), |
| 6204 render_pass_quad->mask_uv_scale.ToString()); | 6204 render_pass_quad->mask_uv_scale.ToString()); |
| 6205 EndTest(); | 6205 EndTest(); |
| 6206 break; | 6206 break; |
| 6207 } | 6207 } |
| 6208 return draw_result; | 6208 return draw_result; |
| 6209 } | 6209 } |
| 6210 | 6210 |
| 6211 void DidCommit() override { | 6211 void DidCommit() override { |
| 6212 switch (layer_tree_host()->source_frame_number()) { | 6212 switch (layer_tree_host()->source_frame_number()) { |
| 6213 case 1: | 6213 case 1: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6276 root_pass->quad_list.ElementAt(1)->material); | 6276 root_pass->quad_list.ElementAt(1)->material); |
| 6277 const RenderPassDrawQuad* render_pass_quad = | 6277 const RenderPassDrawQuad* render_pass_quad = |
| 6278 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.ElementAt(1)); | 6278 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.ElementAt(1)); |
| 6279 switch (host_impl->active_tree()->source_frame_number()) { | 6279 switch (host_impl->active_tree()->source_frame_number()) { |
| 6280 case 0: | 6280 case 0: |
| 6281 // Check that the mask fills the surface. | 6281 // Check that the mask fills the surface. |
| 6282 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 6282 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 6283 render_pass_quad->rect.ToString()); | 6283 render_pass_quad->rect.ToString()); |
| 6284 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6284 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6285 render_pass_quad->MaskUVRect().ToString()); | 6285 render_pass_quad->MaskUVRect().ToString()); |
| 6286 EXPECT_EQ(gfx::Vector2dF(1.f, 1.f).ToString(), | 6286 EXPECT_EQ(gfx::Vector2dF(0.02f, 0.02f).ToString(), |
| 6287 render_pass_quad->mask_uv_scale.ToString()); | 6287 render_pass_quad->mask_uv_scale.ToString()); |
| 6288 break; | 6288 break; |
| 6289 case 1: | 6289 case 1: |
| 6290 // Applying a DSF should change the render surface size, but won't | 6290 // Applying a DSF should change the render surface size, but won't |
| 6291 // affect which part of the mask is used. | 6291 // affect which part of the mask is used. |
| 6292 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 6292 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 6293 render_pass_quad->rect.ToString()); | 6293 render_pass_quad->rect.ToString()); |
| 6294 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), | 6294 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), |
| 6295 render_pass_quad->MaskUVRect().ToString()); | 6295 render_pass_quad->MaskUVRect().ToString()); |
| 6296 EXPECT_EQ(gfx::Vector2dF(1.f, 1.f).ToString(), | 6296 EXPECT_EQ(gfx::Vector2dF(0.01f, 0.01f).ToString(), |
| 6297 render_pass_quad->mask_uv_scale.ToString()); | 6297 render_pass_quad->mask_uv_scale.ToString()); |
| 6298 EndTest(); | 6298 EndTest(); |
| 6299 break; | 6299 break; |
| 6300 } | 6300 } |
| 6301 return draw_result; | 6301 return draw_result; |
| 6302 } | 6302 } |
| 6303 | 6303 |
| 6304 void DidCommit() override { | 6304 void DidCommit() override { |
| 6305 switch (layer_tree_host()->source_frame_number()) { | 6305 switch (layer_tree_host()->source_frame_number()) { |
| 6306 case 1: | 6306 case 1: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6376 const RenderPassDrawQuad* replica_quad = | 6376 const RenderPassDrawQuad* replica_quad = |
| 6377 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.ElementAt(1)); | 6377 RenderPassDrawQuad::MaterialCast(root_pass->quad_list.ElementAt(1)); |
| 6378 switch (host_impl->active_tree()->source_frame_number()) { | 6378 switch (host_impl->active_tree()->source_frame_number()) { |
| 6379 case 0: | 6379 case 0: |
| 6380 // The surface is 100x50. | 6380 // The surface is 100x50. |
| 6381 // The mask covers the owning layer only. | 6381 // The mask covers the owning layer only. |
| 6382 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | 6382 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 6383 replica_quad->rect.ToString()); | 6383 replica_quad->rect.ToString()); |
| 6384 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), | 6384 EXPECT_EQ(gfx::RectF(0.f, 0.f, 2.f, 1.f).ToString(), |
| 6385 replica_quad->MaskUVRect().ToString()); | 6385 replica_quad->MaskUVRect().ToString()); |
| 6386 EXPECT_EQ(gfx::Vector2dF(2.f, 1.f).ToString(), | 6386 EXPECT_EQ(gfx::Vector2dF(0.02f, 0.02f).ToString(), |
| 6387 replica_quad->mask_uv_scale.ToString()); | 6387 replica_quad->mask_uv_scale.ToString()); |
| 6388 break; | 6388 break; |
| 6389 case 1: | 6389 case 1: |
| 6390 // The surface is 100x50 with its origin at (-50, 0). | 6390 // The surface is 100x50 with its origin at (-50, 0). |
| 6391 // The mask covers the owning layer only. | 6391 // The mask covers the owning layer only. |
| 6392 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), | 6392 EXPECT_EQ(gfx::Rect(-50, 0, 100, 50).ToString(), |
| 6393 replica_quad->rect.ToString()); | 6393 replica_quad->rect.ToString()); |
| 6394 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), | 6394 EXPECT_EQ(gfx::RectF(-1.f, 0.f, 2.f, 1.f).ToString(), |
| 6395 replica_quad->MaskUVRect().ToString()); | 6395 replica_quad->MaskUVRect().ToString()); |
| 6396 EXPECT_EQ(gfx::Vector2dF(2.f, 1.f).ToString(), | 6396 EXPECT_EQ(gfx::Vector2dF(0.02f, 0.02f).ToString(), |
| 6397 replica_quad->mask_uv_scale.ToString()); | 6397 replica_quad->mask_uv_scale.ToString()); |
| 6398 EndTest(); | 6398 EndTest(); |
| 6399 break; | 6399 break; |
| 6400 } | 6400 } |
| 6401 return draw_result; | 6401 return draw_result; |
| 6402 } | 6402 } |
| 6403 | 6403 |
| 6404 void DidCommit() override { | 6404 void DidCommit() override { |
| 6405 switch (layer_tree_host()->source_frame_number()) { | 6405 switch (layer_tree_host()->source_frame_number()) { |
| 6406 case 1: | 6406 case 1: |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6592 EndTest(); | 6592 EndTest(); |
| 6593 } | 6593 } |
| 6594 | 6594 |
| 6595 void AfterTest() override {} | 6595 void AfterTest() override {} |
| 6596 }; | 6596 }; |
| 6597 | 6597 |
| 6598 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6598 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6599 | 6599 |
| 6600 } // namespace | 6600 } // namespace |
| 6601 } // namespace cc | 6601 } // namespace cc |
| OLD | NEW |