Commit 7ef34f45 authored by CJ Dimeglio's avatar CJ Dimeglio Committed by Commit Bot

Adds stretch_to_fit support for surface aggregation.

This CL makes it so that if |stretch_to_fit_bounds| is set on a surface,
damage calculation takes this into account and scales the damage quad
accordingly.

Bug: 799512
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I405ae815046d7ab51179bfceb0e54db9e5749725
Reviewed-on: https://chromium-review.googlesource.com/887789
Commit-Queue: CJ DiMeglio <lethalantidote@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533915}
parent 56419136
......@@ -880,13 +880,15 @@ gfx::Rect SurfaceAggregator::PrewalkTree(Surface* surface,
bool has_moved_pixels,
RenderPassId parent_pass_id,
const gfx::Transform& target_to_surface_transform,
const gfx::Rect& quad_rect)
const gfx::Rect& quad_rect,
bool stretch_content_to_fill_bounds)
: primary_id(primary_id),
fallback_id(fallback_id),
has_moved_pixels(has_moved_pixels),
parent_pass_id(parent_pass_id),
target_to_surface_transform(target_to_surface_transform),
quad_rect(quad_rect) {}
quad_rect(quad_rect),
stretch_content_to_fill_bounds(stretch_content_to_fill_bounds) {}
SurfaceId primary_id;
base::Optional<SurfaceId> fallback_id;
......@@ -894,6 +896,7 @@ gfx::Rect SurfaceAggregator::PrewalkTree(Surface* surface,
RenderPassId parent_pass_id;
gfx::Transform target_to_surface_transform;
gfx::Rect quad_rect;
bool stretch_content_to_fill_bounds;
};
std::vector<SurfaceInfo> child_surfaces;
......@@ -935,7 +938,7 @@ gfx::Rect SurfaceAggregator::PrewalkTree(Surface* surface,
child_surfaces.emplace_back(
surface_quad->primary_surface_id, surface_quad->fallback_surface_id,
in_moved_pixel_pass, remapped_pass_id, target_to_surface_transform,
surface_quad->rect);
surface_quad->rect, surface_quad->stretch_content_to_fill_bounds);
} else if (quad->material == DrawQuad::RENDER_PASS) {
const auto* render_pass_quad = RenderPassDrawQuad::MaterialCast(quad);
if (in_moved_pixel_pass) {
......@@ -1002,9 +1005,26 @@ gfx::Rect SurfaceAggregator::PrewalkTree(Surface* surface,
}
if (child_surface) {
surface_damage.Union(
PrewalkTree(child_surface, surface_info.has_moved_pixels,
surface_info.parent_pass_id, will_draw, result));
if (surface_info.stretch_content_to_fill_bounds) {
// Scale up the damage_quad generated by the child_surface to fit
// the containing quad_rect.
gfx::Rect child_rect =
PrewalkTree(child_surface, surface_info.has_moved_pixels,
surface_info.parent_pass_id, will_draw, result);
if (child_surface->size_in_pixels().GetCheckedArea().ValueOrDefault(0) >
0) {
float y_scale = static_cast<float>(surface_info.quad_rect.height()) /
child_surface->size_in_pixels().height();
float x_scale = static_cast<float>(surface_info.quad_rect.width()) /
child_surface->size_in_pixels().width();
surface_damage.Union(
gfx::ScaleToEnclosingRect(child_rect, x_scale, y_scale));
}
} else {
surface_damage.Union(
PrewalkTree(child_surface, surface_info.has_moved_pixels,
surface_info.parent_pass_id, will_draw, result));
}
}
if (surface_damage.IsEmpty())
......
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