Add missing transform into DelegatedRendererLayerImpl::AppendRenderPassQuads.

We can miss applying a transform if we have a transformed, partially
occluded DelegatedRendererLayerImpl with a contributing RenderPass. This
causes the wrong transform to be sent into the occlusion tracker, so
occlusion gets applied incorrectly, which hides desired content.

BUG=379072,390873

Review URL: https://codereview.chromium.org/447193005

Cr-Commit-Position: refs/heads/master@{#288403}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288403 0039d316-1c4b-4281-b951-d872f2087c98
parent d383bd67
......@@ -397,13 +397,14 @@ void DelegatedRendererLayerImpl::AppendRenderPassQuads(
for (size_t i = 0; i < delegated_render_pass->quad_list.size(); ++i) {
const DrawQuad* delegated_quad = delegated_render_pass->quad_list[i];
bool is_root_delegated_render_pass =
delegated_render_pass == render_passes_in_draw_order_.back();
if (delegated_quad->shared_quad_state != delegated_shared_quad_state) {
delegated_shared_quad_state = delegated_quad->shared_quad_state;
output_shared_quad_state = render_pass->CreateAndAppendSharedQuadState();
output_shared_quad_state->CopyFrom(delegated_shared_quad_state);
bool is_root_delegated_render_pass =
delegated_render_pass == render_passes_in_draw_order_.back();
if (is_root_delegated_render_pass) {
gfx::Transform delegated_frame_to_target_transform = draw_transform();
delegated_frame_to_target_transform.Scale(inverse_device_scale_factor_,
......@@ -436,9 +437,17 @@ void DelegatedRendererLayerImpl::AppendRenderPassQuads(
}
DCHECK(output_shared_quad_state);
gfx::Transform quad_content_to_delegated_target_space =
output_shared_quad_state->content_to_target_transform;
if (!is_root_delegated_render_pass) {
quad_content_to_delegated_target_space.ConcatTransform(
render_pass->transform_to_root_target);
quad_content_to_delegated_target_space.ConcatTransform(draw_transform());
}
gfx::Rect quad_visible_rect = occlusion_tracker.UnoccludedContentRect(
delegated_quad->visible_rect,
output_shared_quad_state->content_to_target_transform);
delegated_quad->visible_rect, quad_content_to_delegated_target_space);
if (quad_visible_rect.IsEmpty())
continue;
......
......@@ -1507,6 +1507,33 @@ TEST_F(DelegatedRendererLayerImplTest, Occlusion) {
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);
SCOPED_TRACE("Contributing render pass with transformed root");
delegated_renderer_layer_impl->SetTransform(transform);
impl.CalcDrawProps(viewport_size);
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());
}
}
TEST_F(DelegatedRendererLayerImplTest, PushPropertiesTo) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment