Skip to content

Commit

Permalink
Render Pass overlay uv rects with scaling transform
Browse files Browse the repository at this point in the history
(cherry picked from commit e2da11e)

Bug: 1368798,1368798
Change-Id: I9d46074722cb2ea3bbb7d6d4668553f33bd71cdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3926261
Reviewed-by: Kramer Ge <fangzhoug@chromium.org>
Commit-Queue: Peter McNeeley <petermcneeley@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1053039}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3929351
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
Owners-Override: Srinivas Sista <srinivassista@chromium.org>
Reviewed-by: Srinivas Sista <srinivassista@chromium.org>
Cr-Commit-Position: refs/branch-heads/5326@{#7}
Cr-Branched-From: 1f40050-refs/heads/main@{#1051738}
  • Loading branch information
petermcneeleychromium authored and Chromium LUCI CQ committed Sep 29, 2022
1 parent c73e699 commit 1d3c56f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 10 additions & 6 deletions components/viz/service/display/skia_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3573,15 +3573,19 @@ void SkiaRenderer::PrepareRenderPassOverlay(
overlay->display_rect = gfx::RectF(filter_bounds);
quad->shared_quad_state->quad_to_target_transform.TransformRect(
&overlay->display_rect);
// TODO(petermcneeley): This clipping is only correct for translation and
// scale. For other transforms we will need to send the rect over as a
// separate parameter.
auto unclipped_display_rect = overlay->display_rect;
overlay->display_rect.Intersect(
gfx::RectF(gfx::SizeF(current_frame()->device_viewport_size)));
auto buffer_rect =
gfx::RectF(overlay->display_rect.origin(), gfx::SizeF(buffer_size));
// Set |uv_rect| to reflect clipping from |buffer_size| to |filter_bounds|.
overlay->uv_rect = gfx::RectF{1.f, 1.f};
if (buffer_rect != overlay->display_rect) {
// Set |uv_rect| to reflect rounding from |filter_bounds| to |buffer_size|.
overlay->uv_rect = gfx::RectF{
static_cast<float>(filter_bounds.width()) / buffer_size.width(),
static_cast<float>(filter_bounds.height()) / buffer_size.height()};
if (unclipped_display_rect != overlay->display_rect) {
overlay->uv_rect = cc::MathUtil::ScaleRectProportional(
overlay->uv_rect, buffer_rect, overlay->display_rect);
overlay->uv_rect, unclipped_display_rect, overlay->display_rect);
}
#endif // BUILDFLAG(IS_APPLE)
}
Expand Down
10 changes: 7 additions & 3 deletions ui/ozone/platform/wayland/host/wayland_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,11 @@ void WaylandSurface::ApplyPendingState() {
gfx::ScaleRect(crop_transformed, bounds.width(), bounds.height());
DCHECK(viewport());
if (wl_fixed_from_double(viewport_src_dip.width()) == 0 ||
wl_fixed_from_double(viewport_src_dip.height()) == 0) {
LOG(ERROR) << "Sending viewport src with width/height zero will result "
"in wayland disconnection";
wl_fixed_from_double(viewport_src_dip.height()) == 0 ||
wl_fixed_from_double(viewport_src_dip.x()) < 0 ||
wl_fixed_from_double(viewport_src_dip.y()) < 0) {
LOG(ERROR) << "Sending viewport src with width/height zero or negative "
"origin will result in wayland disconnection";
// TODO(crbug.com/1325344): Resolve why this viewport size ends up being
// zero and remove the fix below.
LOG(ERROR) << "viewport_src_dip=" << viewport_src_dip.ToString()
Expand All @@ -580,6 +582,8 @@ void WaylandSurface::ApplyPendingState() {
std::max(viewport_src_dip.width(), kViewPortSizeMinFloat));
viewport_src_dip.set_height(
std::max(viewport_src_dip.height(), kViewPortSizeMinFloat));
viewport_src_dip.set_x(std::max(viewport_src_dip.x(), 0.f));
viewport_src_dip.set_y(std::max(viewport_src_dip.y(), 0.f));
}
src_to_set[0] = wl_fixed_from_double(viewport_src_dip.x()),
src_to_set[1] = wl_fixed_from_double(viewport_src_dip.y());
Expand Down

0 comments on commit 1d3c56f

Please sign in to comment.