Skip to content

[RFC] Supporting local-space Pictures (and Picture caching across frames). #2533

@glennw

Description

@glennw

I've been thinking about #1542 (#1447 and #1371 are also relevant to this discussion).

Right now, as we recurse through the Picture tree, we take the concatenated transform for each primitive, and calculate the screen-space rect. This is used for culling, clip-mask generation etc. This doesn't work where we have chosen to rasterize the Picture in local-space (e.g. an animated Picture, for performance reasons).

When we encounter a Picture to be drawn in local space, we need to ensure that the transforms referenced in this Picture (by clips and primitives) are relative to the root transform for this Picture, to get correct output. In this case, what we now consider the "screen-rect" would actually become a rect that is in the space of the root transform of the Picture.

If we made it so that Pictures always operate off a local collection of transforms (and we store them with the Picture), rather than referencing the global clip-scroll tree, there's a number of additional potential benefits:

  • Support for Picture caching (across display lists!) becomes simpler and faster to add.
    • We can compare a limited number of transforms, and they are relative to the content of the Picture, rather than the global scene.
    • Many Pictures we will want to cache are effectively local-space rasterized (e.g. an image with complex filters on it), even if the calling code has requested screen-space rasterization. This will allow us to cache Pictures that are moving, but otherwise the same, for instance.
  • Existing specialized support for local-space Pictures (e.g. text-shadows) is no longer needed.
  • Culling can be supported in a wider range of circumstances (e.g. text-shadows).
  • Some more subtle benefits - supporting proper clip masks in local-space allows us to collapse brush_line into a clip source, for example.
  • This may be helpful when we start using the OS compositor interfaces.

This may sound like a lot of work, but most of it is in-place already. It's (hopefully) a medium-ish amount of refactoring, a bit of matrix math, and that's about it. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions