Commit 5170e012 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Fix a rendering issue in meet.google.com

The meet.google.com rendering issue is because
shared_quad_state->mask_filter_info is not transformed correctly. Fix the
problem by transform it into the new allocated overlay backing's
coordinates.

Bug: 1148477
Change-Id: I016c0c01c4e60262d197c7b24f37f1df522859c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542949
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828297}
parent df21f3a2
...@@ -2648,17 +2648,33 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) { ...@@ -2648,17 +2648,33 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) {
auto* shared_quad_state = auto* shared_quad_state =
const_cast<SharedQuadState*>(quad->shared_quad_state); const_cast<SharedQuadState*>(quad->shared_quad_state);
gfx::Transform quad_to_target_transform_inverse(
gfx::Transform::kSkipInitialization);
if (shared_quad_state->is_clipped ||
!shared_quad_state->mask_filter_info.IsEmpty()) {
bool result = shared_quad_state->quad_to_target_transform.GetInverse(
&quad_to_target_transform_inverse);
DCHECK(result) << "quad_to_target_transform.GetInverse() failed";
}
// The |clip_rect| is in the device coordinate and with all transforms // The |clip_rect| is in the device coordinate and with all transforms
// (translation, scaling, rotation, etc), so remove them. // (translation, scaling, rotation, etc), so remove them.
base::Optional<base::AutoReset<gfx::Rect>> auto_reset_clip_rect; base::Optional<base::AutoReset<gfx::Rect>> auto_reset_clip_rect;
if (shared_quad_state->is_clipped) { if (shared_quad_state->is_clipped) {
gfx::RectF clip_rect(shared_quad_state->clip_rect); gfx::RectF clip_rect(shared_quad_state->clip_rect);
shared_quad_state->quad_to_target_transform.TransformRectReverse( quad_to_target_transform_inverse.TransformRect(&clip_rect);
&clip_rect);
auto_reset_clip_rect.emplace(&shared_quad_state->clip_rect, auto_reset_clip_rect.emplace(&shared_quad_state->clip_rect,
gfx::ToEnclosedRect(clip_rect)); gfx::ToEnclosedRect(clip_rect));
} }
// The |mask_filter_info| is in the device coordinate and with all transforms
// (translation, scaling, rotation, etc), so remove them.
if (!shared_quad_state->mask_filter_info.IsEmpty()) {
auto result = shared_quad_state->mask_filter_info.Transform(
quad_to_target_transform_inverse);
DCHECK(result) << "shared_quad_state->mask_filter_info.Transform() failed.";
}
// Reset |quad_to_target_transform|, so the quad will be rendered at the // Reset |quad_to_target_transform|, so the quad will be rendered at the
// origin (0,0) without all transforms (translation, scaling, rotation, etc) // origin (0,0) without all transforms (translation, scaling, rotation, etc)
// and then we will use OS compositor to do those transforms. // and then we will use OS compositor to do those transforms.
...@@ -2684,9 +2700,11 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) { ...@@ -2684,9 +2700,11 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) {
target_to_device, /*scissor=*/nullptr, quad, /*draw_region=*/nullptr); target_to_device, /*scissor=*/nullptr, quad, /*draw_region=*/nullptr);
DrawRPDQParams rpdq_params = CalculateRPDQParams(quad, &params); DrawRPDQParams rpdq_params = CalculateRPDQParams(quad, &params);
const auto& filter_bounds = rpdq_params.filter_bounds;
// |filter_bounds| is the content space bounds that includes any filtered // |filter_bounds| is the content space bounds that includes any filtered
// extents. If empty, the draw can be skipped. // extents. If empty, the draw can be skipped.
if (rpdq_params.filter_bounds.IsEmpty()) if (filter_bounds.IsEmpty())
return; return;
ResourceFormat buffer_format{}; ResourceFormat buffer_format{};
...@@ -2715,7 +2733,6 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) { ...@@ -2715,7 +2733,6 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) {
color_space = backing->color_space; color_space = backing->color_space;
} }
const auto filter_bounds = rpdq_params.filter_bounds;
// Adjust the overlay |buffer_size| to reduce memory fragmentation. It also // Adjust the overlay |buffer_size| to reduce memory fragmentation. It also
// increases buffer reusing possibilities. // increases buffer reusing possibilities.
...@@ -2735,15 +2752,17 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) { ...@@ -2735,15 +2752,17 @@ void SkiaRenderer::PrepareRenderPassOverlay(CALayerOverlay* overlay) {
// Clear the backing to ARGB(0,0,0,0). // Clear the backing to ARGB(0,0,0,0).
current_canvas_->clear(SkColorSetARGB(0, 0, 0, 0)); current_canvas_->clear(SkColorSetARGB(0, 0, 0, 0));
// Calculate visible_rect's origin in output device coordinates. // Adjust the |content_device_transform| to make sure filter extends are drawn
auto dst_visible_rect_origin = params.visible_rect.origin();
params.content_device_transform.TransformPoint(&dst_visible_rect_origin);
// Adjust the content_device_transform to make sure filter extends are drawn
// inside of the buffer. // inside of the buffer.
params.content_device_transform.Translate(-filter_bounds.x(), params.content_device_transform.Translate(-filter_bounds.x(),
-filter_bounds.y()); -filter_bounds.y());
// Also adjust the |rounded_corner_bounds| to the new location.
if (params.rounded_corner_bounds) {
params.rounded_corner_bounds->Offset(-filter_bounds.x(),
-filter_bounds.y());
}
// When Render Pass has a single quad inside we would draw that directly. // When Render Pass has a single quad inside we would draw that directly.
if (bypass != render_pass_bypass_quads_.end()) { if (bypass != render_pass_bypass_quads_.end()) {
if (bypass_mode == BypassMode::kDrawTransparentQuad) { if (bypass_mode == BypassMode::kDrawTransparentQuad) {
......
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