0

Use integer scale for k2DTransformWithCompositedDescendants

k2DTransformWithCompositedDescendants was introduced for cases when we
have parent div with scale transform and child composited elements that
are adjacent to each other. Normally that use case would produce seams
due to analytical AA overlap.

This CL changes content scale for such surfaces to be integer values,
so we will avoid seams.

k2DTransformWithCompositedDescendants is under feature flag right now,
so this CL doesn't need additional guarding.

Bug: 40084005
Change-Id: Ideacbca6145659f8aa7b7ef8ebcde9f9eff5950f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6288112
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1423379}
This commit is contained in:
Vasiliy Telezhnikov
2025-02-21 13:18:24 -08:00
committed by Chromium LUCI CQ
parent 2ef8ddc2ff
commit 4cccecedb2
2 changed files with 13 additions and 2 deletions

@ -72,8 +72,6 @@ const char* RenderSurfaceReasonToString(RenderSurfaceReason reason) {
return "2D transform with composited descendants";
case RenderSurfaceReason::kTest:
return "test";
default:
NOTREACHED() << static_cast<int>(reason);
}
}

@ -1069,6 +1069,19 @@ void EffectTree::UpdateSurfaceContentsScale(EffectNode* effect_node) {
effect_node->surface_contents_scale = gfx::ComputeTransform2dScaleComponents(
transform_tree.ToScreen(transform_node->id), layer_scale_factor);
// To avoid seams we apply only scale as draw transform instead of raster
// content transform.
if (effect_node->render_surface_reason ==
RenderSurfaceReason::k2DTransformWithCompositedDescendants) {
// We raster at closest positive integer scale and then apply the rest as
// the draw transform, e.g scale 3.5 will rastered at 4 and 0.875 (3.5/4)
// will be applied as draw transform.
effect_node->surface_contents_scale.set_x(
std::ceil(std::abs(effect_node->surface_contents_scale.x())));
effect_node->surface_contents_scale.set_y(
std::ceil(std::abs(effect_node->surface_contents_scale.y())));
}
// If surface contents scale changes, draw transforms are no longer valid.
// Invalidates the draw transform cache and updates the clip for the surface.
if (old_scale != effect_node->surface_contents_scale) {