Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Side by Side Diff: cc/layers/delegated_renderer_layer_impl_unittest.cc

Issue 546993002: Apply the correct transform_to_root_target DelegatedRendererLayerImpl::AppendRenderPassQuads(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 delegated_renderer_layer_impl->SetBounds(layer_size); 1386 delegated_renderer_layer_impl->SetBounds(layer_size);
1387 delegated_renderer_layer_impl->SetContentBounds(layer_size); 1387 delegated_renderer_layer_impl->SetContentBounds(layer_size);
1388 delegated_renderer_layer_impl->SetDrawsContent(true); 1388 delegated_renderer_layer_impl->SetDrawsContent(true);
1389 1389
1390 RenderPassList delegated_render_passes; 1390 RenderPassList delegated_render_passes;
1391 // pass2 is just the size of the quad. It contributes to |pass1| with a 1391 // pass2 is just the size of the quad. It contributes to |pass1| with a
1392 // translation of (11,0). 1392 // translation of (11,0).
1393 RenderPassId pass2_id = 1393 RenderPassId pass2_id =
1394 delegated_renderer_layer_impl->FirstContributingRenderPassId(); 1394 delegated_renderer_layer_impl->FirstContributingRenderPassId();
1395 TestRenderPass* pass2 = 1395 TestRenderPass* pass2 =
1396 AddRenderPass(&delegated_render_passes, pass2_id, quad_rect, transform); 1396 AddRenderPass(&delegated_render_passes, pass2_id, quad_rect, transform);
danakj 2014/09/09 19:16:34 and this should be gfx::Rect(11, 0, 899, 1000) ins
1397 AddQuad(pass2, gfx::Rect(quad_rect.size()), SK_ColorRED); 1397 AddQuad(pass2, gfx::Rect(quad_rect.size()), SK_ColorRED);
danakj 2014/09/09 19:16:34 i think this should be quad_rect instead of droppi
1398 // |pass1| covers the whole layer. 1398 // |pass1| covers the whole layer.
1399 RenderPassId pass1_id = RenderPassId(impl.root_layer()->id(), 0); 1399 RenderPassId pass1_id = RenderPassId(impl.root_layer()->id(), 0);
1400 TestRenderPass* pass1 = AddRenderPass(&delegated_render_passes, 1400 TestRenderPass* pass1 = AddRenderPass(&delegated_render_passes,
1401 pass1_id, 1401 pass1_id,
1402 gfx::Rect(layer_size), 1402 gfx::Rect(layer_size),
1403 gfx::Transform()); 1403 gfx::Transform());
1404 AddRenderPassQuad(pass1, pass2, 0, FilterOperations(), transform); 1404 AddRenderPassQuad(pass1, pass2, 0, FilterOperations(), transform);
1405 delegated_renderer_layer_impl->SetFrameDataForRenderPasses( 1405 delegated_renderer_layer_impl->SetFrameDataForRenderPasses(
1406 1.f, &delegated_render_passes); 1406 1.f, &delegated_render_passes);
1407 1407
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 quad_screen_rect, 1474 quad_screen_rect,
1475 occluded, 1475 occluded,
1476 &partially_occluded_count); 1476 &partially_occluded_count);
1477 // The layer outputs one quad, which is partially occluded. 1477 // The layer outputs one quad, which is partially occluded.
1478 EXPECT_EQ(1u, impl.quad_list().size()); 1478 EXPECT_EQ(1u, impl.quad_list().size());
1479 EXPECT_EQ(1u, partially_occluded_count); 1479 EXPECT_EQ(1u, partially_occluded_count);
1480 } 1480 }
1481 { 1481 {
1482 gfx::Rect occluded(0, 0, 500, 1000); 1482 gfx::Rect occluded(0, 0, 500, 1000);
1483 // Move the occlusion to where it is in the contributing surface. 1483 // Move the occlusion to where it is in the contributing surface.
1484 occluded -= quad_rect.OffsetFromOrigin() + gfx::Vector2d(11, 0); 1484 occluded -= quad_screen_rect.OffsetFromOrigin();
1485 1485
1486 SCOPED_TRACE("Contributing render pass"); 1486 SCOPED_TRACE("Contributing render pass");
1487 impl.AppendQuadsForPassWithOcclusion( 1487 impl.AppendQuadsForPassWithOcclusion(
1488 delegated_renderer_layer_impl, pass2_id, occluded); 1488 delegated_renderer_layer_impl, pass2_id, occluded);
1489 size_t partially_occluded_count = 0; 1489 size_t partially_occluded_count = 0;
1490 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( 1490 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
1491 impl.quad_list(), 1491 impl.quad_list(),
1492 gfx::Rect(quad_rect.size()), 1492 gfx::Rect(quad_rect.size()),
1493 occluded, 1493 occluded,
1494 &partially_occluded_count); 1494 &partially_occluded_count);
1495 // The layer outputs one quad, which is partially occluded. 1495 // The layer outputs one quad, which is partially occluded.
1496 EXPECT_EQ(1u, impl.quad_list().size()); 1496 EXPECT_EQ(1u, impl.quad_list().size());
1497 EXPECT_EQ(1u, partially_occluded_count); 1497 EXPECT_EQ(1u, partially_occluded_count);
1498 // The quad in the contributing surface is at (211,300) in the root. 1498 // The quad in the contributing surface is at (222,300) in the root.
1499 // The occlusion extends to 500 in the x-axis, pushing the left of the 1499 // The occlusion extends to 500 in the x-axis, pushing the left of the
1500 // visible part of the quad to 500 - 211 = 300 - 11 inside the quad. 1500 // visible part of the quad to 500 - 222 = 300 - 22 inside the quad.
1501 EXPECT_EQ(gfx::Rect(300 - 11, 0, 100 + 11, 500).ToString(), 1501 EXPECT_EQ(gfx::Rect(300 - 22, 0, 100 + 22, 500).ToString(),
1502 impl.quad_list()[0]->visible_rect.ToString()); 1502 impl.quad_list()[0]->visible_rect.ToString());
1503 } 1503 }
1504 } 1504 }
1505 { 1505 {
1506 gfx::Rect occluded(0, 0, 500, 1000); 1506 gfx::Rect occluded(0, 0, 500, 1000);
1507 // Move the occlusion to where it is in the contributing surface. 1507 // Move the occlusion to where it is in the contributing surface.
1508 occluded -= quad_rect.OffsetFromOrigin() + gfx::Vector2d(11, 0); 1508 occluded -= quad_rect.OffsetFromOrigin() + gfx::Vector2d(11, 0);
1509 1509
1510 SCOPED_TRACE("Contributing render pass with transformed root"); 1510 SCOPED_TRACE("Contributing render pass with transformed root");
1511 1511
1512 delegated_renderer_layer_impl->SetTransform(transform); 1512 delegated_renderer_layer_impl->SetTransform(transform);
1513 impl.CalcDrawProps(viewport_size); 1513 impl.CalcDrawProps(viewport_size);
1514 1514
1515 impl.AppendQuadsForPassWithOcclusion( 1515 impl.AppendQuadsForPassWithOcclusion(
1516 delegated_renderer_layer_impl, pass2_id, occluded); 1516 delegated_renderer_layer_impl, pass2_id, occluded);
1517 size_t partially_occluded_count = 0; 1517 size_t partially_occluded_count = 0;
1518 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion( 1518 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
1519 impl.quad_list(), 1519 impl.quad_list(),
1520 gfx::Rect(quad_rect.size()), 1520 gfx::Rect(quad_rect.size()),
1521 occluded, 1521 occluded,
1522 &partially_occluded_count); 1522 &partially_occluded_count);
1523 // The layer outputs one quad, which is partially occluded. 1523 // The layer outputs one quad, which is partially occluded.
1524 EXPECT_EQ(1u, impl.quad_list().size()); 1524 EXPECT_EQ(1u, impl.quad_list().size());
1525 EXPECT_EQ(1u, partially_occluded_count); 1525 EXPECT_EQ(1u, partially_occluded_count);
1526 // The quad in the contributing surface is at (222,300) in the transformed 1526 // The quad in the contributing surface is at (233,300) in the transformed
1527 // root. The occlusion extends to 500 in the x-axis, pushing the left of the 1527 // root. The occlusion extends to 500 in the x-axis, pushing the left of the
1528 // visible part of the quad to 500 - 222 = 300 - 22 inside the quad. 1528 // visible part of the quad to 500 - 233 = 300 - 33 inside the quad.
1529 EXPECT_EQ(gfx::Rect(300 - 22, 0, 100 + 22, 500).ToString(), 1529 EXPECT_EQ(gfx::Rect(300 - 33, 0, 100 + 33, 500).ToString(),
1530 impl.quad_list()[0]->visible_rect.ToString()); 1530 impl.quad_list()[0]->visible_rect.ToString());
1531 } 1531 }
1532 } 1532 }
1533 1533
1534 TEST_F(DelegatedRendererLayerImplTest, PushPropertiesTo) { 1534 TEST_F(DelegatedRendererLayerImplTest, PushPropertiesTo) {
1535 gfx::Size layer_size(1000, 1000); 1535 gfx::Size layer_size(1000, 1000);
1536 1536
1537 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer_impl = 1537 scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer_impl =
1538 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 5); 1538 FakeDelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 5);
1539 delegated_renderer_layer_impl->SetBounds(layer_size); 1539 delegated_renderer_layer_impl->SetBounds(layer_size);
(...skipping 14 matching lines...) Expand all
1554 scoped_ptr<DelegatedRendererLayerImpl> other_layer = 1554 scoped_ptr<DelegatedRendererLayerImpl> other_layer =
1555 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6); 1555 DelegatedRendererLayerImpl::Create(host_impl_->active_tree(), 6);
1556 1556
1557 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get()); 1557 delegated_renderer_layer_impl->PushPropertiesTo(other_layer.get());
1558 1558
1559 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor()); 1559 EXPECT_EQ(0.5f, other_layer->inverse_device_scale_factor());
1560 } 1560 }
1561 1561
1562 } // namespace 1562 } // namespace
1563 } // namespace cc 1563 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698