A question about CompositorRenderPassDrawQuad::tex_coord_rect

36 views
Skip to first unread message

Xianzhu Wang

unread,
Nov 22, 2024, 6:48:22 PM11/22/24
to graphics-dev
Hi,

I'm trying to fix crbug.com/40892376. This is a minimized test case:
  <div style="will-change: transform,filter; transform:translate(0.4px, 0.6px); width: 100px; height: 100px">
   Text
  </div>
which currently produces the following render passes and quads:
  RenderPass
   CompositorRenderPassDrawQuad (transform=translate(8.4,8.6) tex_coord_rect=(0,0 100x100))
    RenderPass
     TileDrawQuad (transform=identity, tex_coord_rect=(0,0 100x100))
      tile texture
The text is blurry due to the fractional transform.

I tried two methods:
1. (CL) Exclude subpixel fraction from RenderSurface::draw_transform(), and apply that fraction to contributing layers and render surfaces, then the fraction will be applied to the texture as a raster translation (an existing mechanism to make the text clear in a PictureLayerImpl under fractional transform).
  RenderPass
   CompositorRenderPassDrawQuad (transform=translate(8,8) text_coord_rect=(0,0 100x100))
    RenderPass
     TileDrawQuad (transform=translate(0.4,0.6), text_coord_rect=(0.4,0.6 100x100)
      texture drawn under translate(0.4,0.6)

2. (CL) Set the offset of CompositorRenderPassDrawQuad::text_coord_rect to the subpixel fraction of the transform of the render surface, and apply the fraction to the draw operations in the contributing layers as a translation.
  RenderPass
   CompositorRenderPassDrawQuad (transform=translate(8.4,8.6)  text_coord_rect=(0.4,0.6 100x100))
    RenderPass
     TileDrawQuad (transform=identity, text_coord_rect=(0,0 100x100))
      texture drawn under translate(0.4,0.6)

Both basically work, with problems. #1 will introduce inconsistency between the render surface draw properties and the property trees, which is error-prone, so I'm inclined to abandon it.

However, #2 seems to work with the software renderer only. The text is sharp on Linux cloudtop by default, but is blurry otherwise (e.g. with -use-gl=angle --use-angle=swiftshader). My question is: Is the RenderPass tree in #2 supposed to align texels and screen pixels? If yes, there seems to be a bug in SkiaRenderer. If not, is there a way to align pixels without changing the render surface transform?

Thanks,
Xianzhu

Vasiliy Telezhnikov

unread,
Nov 27, 2024, 3:28:30 PM11/27/24
to Xianzhu Wang, graphics-dev
I believe the second code should be equivalent of:

  RenderPass
   TileDrawQuad (transform=translate(8.4,8.6) tex_coord_rect=(0.4,0.6 100x100))
      texture drawn under translate(0.4,0.6)

Because RenderPass would be just a copy of a Tile. Which I guess should be equivalent to the [1], because the difference is an integer translation.
If you'd always return nullptr from here, does it change anything?

- Vasiliy

Xianzhu Wang

unread,
Nov 27, 2024, 5:15:15 PM11/27/24
to Vasiliy Telezhnikov, graphics-dev
On Wed, Nov 27, 2024 at 12:28 PM Vasiliy Telezhnikov <vas...@chromium.org> wrote:
I believe the second code should be equivalent of:

  RenderPass
   TileDrawQuad (transform=translate(8.4,8.6) tex_coord_rect=(0.4,0.6 100x100))
      texture drawn under translate(0.4,0.6)

I also expected the equivalence. This is actually how the current raster translation for PictureLayerImpl works.

Because RenderPass would be just a copy of a Tile. Which I guess should be equivalent to the [1], because the difference is an integer translation.
If you'd always return nullptr from here, does it change anything?

Yes, the text is no longer blurry with the change. It seems that the offset of RPDQ::tex_coord_rect is lost during the bypass?

I have another question: Does RPDQ::tex_coord_rect affect contributing draw quads that don't have tex_coord_rect, e.g. SolidColorDrawQuad and TextureDrawQuad?

Vasiliy Telezhnikov

unread,
Dec 3, 2024, 2:16:50 PM12/3/24
to Xianzhu Wang, graphics-dev
> Yes, the text is no longer blurry with the change. It seems that the offset of RPDQ::tex_coord_rect is lost during the bypass?

I think so, yeah. We should either apply tex_coord_rect during bypass or not bypass.

> I have another question: Does RPDQ::tex_coord_rect affect contributing draw quads that don't have tex_coord_rect, e.g. SolidColorDrawQuad and TextureDrawQuad?

tex_coord_rect defines the area that will be read from the render pass. Ignoring bypass case, all quads will be rendered to a separate texture and these coords specify which portion of the texture we want to display, e.g if render pass is 100x100, but coords are (50, 50)x(50, 50) only top bottom quadrant will be drawn. So it does affect all quads in this sense.

- Vasiliy
Reply all
Reply to author
Forward
0 new messages