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

Unified 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: review 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.cc ('k') | cc/layers/io_surface_layer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/delegated_renderer_layer_impl_unittest.cc
diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc
index 94ba6c7de5b889cde896ec033eec7f534b39f097..ee65ed3b82f5f83b3efb3a08004894c1cad1c80e 100644
--- a/cc/layers/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc
@@ -1374,10 +1374,10 @@ TEST_F(DelegatedRendererLayerImplTest, InvalidRenderPassDrawQuad) {
TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
gfx::Size layer_size(1000, 1000);
gfx::Size viewport_size(1000, 1000);
- gfx::Rect quad_rect(200, 300, 400, 500);
+ gfx::Rect quad_screen_rect(211, 300, 400, 500);
gfx::Transform transform;
- transform.Translate(11.0, 0.0);
+ transform.Translate(211.0, 300.0);
LayerTestCommon::LayerImplTest impl;
@@ -1387,14 +1387,18 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
delegated_renderer_layer_impl->SetContentBounds(layer_size);
delegated_renderer_layer_impl->SetDrawsContent(true);
+ // Contributing render pass is offset by a transform and holds a quad that
+ // covers it entirely.
RenderPassList delegated_render_passes;
// pass2 is just the size of the quad. It contributes to |pass1| with a
- // translation of (11,0).
+ // translation of (211,300).
RenderPassId pass2_id =
delegated_renderer_layer_impl->FirstContributingRenderPassId();
- TestRenderPass* pass2 =
- AddRenderPass(&delegated_render_passes, pass2_id, quad_rect, transform);
- AddQuad(pass2, gfx::Rect(quad_rect.size()), SK_ColorRED);
+ TestRenderPass* pass2 = AddRenderPass(&delegated_render_passes,
+ pass2_id,
+ gfx::Rect(quad_screen_rect.size()),
+ transform);
+ AddQuad(pass2, gfx::Rect(quad_screen_rect.size()), SK_ColorRED);
// |pass1| covers the whole layer.
RenderPassId pass1_id = RenderPassId(impl.root_layer()->id(), 0);
TestRenderPass* pass1 = AddRenderPass(&delegated_render_passes,
@@ -1407,9 +1411,6 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
impl.CalcDrawProps(viewport_size);
- // The |quad_rect| translated by the |transform|.
- gfx::Rect quad_screen_rect = quad_rect + gfx::Vector2d(11, 0);
-
{
SCOPED_TRACE("No occlusion");
gfx::Rect occluded;
@@ -1427,8 +1428,8 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
SCOPED_TRACE("Contributing render pass");
impl.AppendQuadsForPassWithOcclusion(
delegated_renderer_layer_impl, pass2_id, occluded);
- LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
- gfx::Rect(quad_rect.size()));
+ LayerTestCommon::VerifyQuadsExactlyCoverRect(
+ impl.quad_list(), gfx::Rect(quad_screen_rect.size()));
ASSERT_EQ(1u, impl.quad_list().size());
EXPECT_EQ(DrawQuad::SOLID_COLOR, impl.quad_list()[0]->material);
}
@@ -1448,8 +1449,6 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
}
{
gfx::Rect occluded(delegated_renderer_layer_impl->visible_content_rect());
- // Move the occlusion to where it is in the contributing surface.
- occluded -= quad_rect.OffsetFromOrigin();
SCOPED_TRACE("Contributing render pass");
impl.AppendQuadsForPassWithOcclusion(
@@ -1463,34 +1462,32 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
{
SCOPED_TRACE("Partial occlusion");
{
- gfx::Rect occluded(0, 0, 500, 1000);
+ gfx::Rect occlusion_in_root_target(0, 0, 500, 1000);
SCOPED_TRACE("Root render pass");
impl.AppendQuadsForPassWithOcclusion(
- delegated_renderer_layer_impl, pass1_id, occluded);
+ delegated_renderer_layer_impl, pass1_id, occlusion_in_root_target);
size_t partially_occluded_count = 0;
- LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
- impl.quad_list(),
- quad_screen_rect,
- occluded,
- &partially_occluded_count);
+ LayerTestCommon::VerifyQuadsAreOccluded(impl.quad_list(),
+ occlusion_in_root_target,
+ &partially_occluded_count);
// The layer outputs one quad, which is partially occluded.
EXPECT_EQ(1u, impl.quad_list().size());
EXPECT_EQ(1u, partially_occluded_count);
}
{
- gfx::Rect occluded(0, 0, 500, 1000);
+ gfx::Rect occlusion_in_root_target(0, 0, 500, 1000);
// Move the occlusion to where it is in the contributing surface.
- occluded -= quad_rect.OffsetFromOrigin() + gfx::Vector2d(11, 0);
+ gfx::Rect occlusion_in_target_of_delegated_quad =
+ occlusion_in_root_target - quad_screen_rect.OffsetFromOrigin();
SCOPED_TRACE("Contributing render pass");
impl.AppendQuadsForPassWithOcclusion(
- delegated_renderer_layer_impl, pass2_id, occluded);
+ delegated_renderer_layer_impl, pass2_id, occlusion_in_root_target);
size_t partially_occluded_count = 0;
- LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
+ LayerTestCommon::VerifyQuadsAreOccluded(
impl.quad_list(),
- gfx::Rect(quad_rect.size()),
- occluded,
+ occlusion_in_target_of_delegated_quad,
&partially_occluded_count);
// The layer outputs one quad, which is partially occluded.
EXPECT_EQ(1u, impl.quad_list().size());
@@ -1501,33 +1498,38 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
EXPECT_EQ(gfx::Rect(300 - 11, 0, 100 + 11, 500).ToString(),
impl.quad_list()[0]->visible_rect.ToString());
}
- }
- {
- gfx::Rect occluded(0, 0, 500, 1000);
- // Move the occlusion to where it is in the contributing surface.
- occluded -= quad_rect.OffsetFromOrigin() + gfx::Vector2d(11, 0);
+ {
+ gfx::Rect occlusion_in_root_target(0, 0, 500, 1000);
+ // Move the occlusion to where it is in the contributing surface.
+ gfx::Rect occlusion_in_target_of_delegated_quad =
+ occlusion_in_root_target - quad_screen_rect.OffsetFromOrigin();
- SCOPED_TRACE("Contributing render pass with transformed root");
+ SCOPED_TRACE("Contributing render pass with transformed root");
- delegated_renderer_layer_impl->SetTransform(transform);
- impl.CalcDrawProps(viewport_size);
+ gfx::Transform layer_transform;
+ layer_transform.Translate(11.0, 0.0);
+ delegated_renderer_layer_impl->SetTransform(layer_transform);
- impl.AppendQuadsForPassWithOcclusion(
- delegated_renderer_layer_impl, pass2_id, occluded);
- size_t partially_occluded_count = 0;
- LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
- impl.quad_list(),
- gfx::Rect(quad_rect.size()),
- occluded,
- &partially_occluded_count);
- // The layer outputs one quad, which is partially occluded.
- EXPECT_EQ(1u, impl.quad_list().size());
- EXPECT_EQ(1u, partially_occluded_count);
- // The quad in the contributing surface is at (222,300) in the transformed
- // root. The occlusion extends to 500 in the x-axis, pushing the left of the
- // visible part of the quad to 500 - 222 = 300 - 22 inside the quad.
- EXPECT_EQ(gfx::Rect(300 - 22, 0, 100 + 22, 500).ToString(),
- impl.quad_list()[0]->visible_rect.ToString());
+ occlusion_in_target_of_delegated_quad += gfx::Vector2d(11, 0);
+
+ impl.CalcDrawProps(viewport_size);
+
+ impl.AppendQuadsForPassWithOcclusion(
+ delegated_renderer_layer_impl, pass2_id, occlusion_in_root_target);
+ size_t partially_occluded_count = 0;
+ LayerTestCommon::VerifyQuadsAreOccluded(
+ impl.quad_list(),
+ occlusion_in_target_of_delegated_quad,
+ &partially_occluded_count);
+ // The layer outputs one quad, which is partially occluded.
+ EXPECT_EQ(1u, impl.quad_list().size());
+ EXPECT_EQ(1u, partially_occluded_count);
+ // The quad in the contributing surface is at (222,300) in the transformed
+ // root. The occlusion extends to 500 in the x-axis, pushing the left of
+ // the visible part of the quad to 500 - 222 = 300 - 22 inside the quad.
+ EXPECT_EQ(gfx::Rect(300 - 22, 0, 100 + 22, 500).ToString(),
+ impl.quad_list()[0]->visible_rect.ToString());
+ }
}
}
« no previous file with comments | « cc/layers/delegated_renderer_layer_impl.cc ('k') | cc/layers/io_surface_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698