Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a layer and filter interface in the 2D canvas #9537

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Commits on Nov 14, 2024

  1. Add a layer and filter interface in the 2D canvas

    This adds new beginLayer and endLayer functions to open and close layers
    in the canvas. While layers are active, draw calls operate on a separate
    texture that gets composited to the parent output bitmap when the layer
    is closed. An optional filter can be specified in beginLayer, allowing
    effects to be applied to the layer's texture when it's composited its
    parent.
    
    Tests:
     https://github.com/web-platform-tests/wpt/tree/master/html/canvas/element/layers
     https://github.com/web-platform-tests/wpt/tree/master/html/canvas/offscreen/layers
    
    Fixes whatwg#8476
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    7f411fd View commit details
    Browse the repository at this point in the history
  2. Added CCS filter, fixed unclosed layers and replied to review comments

    This update addresses 3 main things:
    - Support for CSS filter strings was added to the beginLayer API
    - Unclosed layers are now never rasterized when the canvas is presented
      to the user. Instead, the content of the layer is preserved and will
      be rasterized in a later frame, if/when the layer is closed.
    - Replied to the first round of review comments.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    aa10da3 View commit details
    Browse the repository at this point in the history
  3. Fix <ref> syntax

    domenic authored and graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    9d4d816 View commit details
    Browse the repository at this point in the history
  4. Fixed editorial issues

    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    5caa39a View commit details
    Browse the repository at this point in the history
  5. Remove XML CanvasFilter from initial layer spec

    This will be moved to a separate pull request.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    7a74000 View commit details
    Browse the repository at this point in the history
  6. Add ctx.filter to the layer rendering states

    With this change, the context filters now applies to the layer's output
    bitmap and is resetted to "none" when entering layers.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    9dafd05 View commit details
    Browse the repository at this point in the history
  7. Remove BeginLayerOptions

    This removes the filter argument of the beginLayer API.
    BeginLayerOptions can possibliy be added to the specification as a
    follow-up.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    809c650 View commit details
    Browse the repository at this point in the history
  8. Clarify what type of bitmaps are used across the canvas spec

    The HTMLCanvasElement's bitmap was linkified to clarify to which bitmap
    each uses of the word "bitmap" refers to (either the element's bitmap,
    the context's top level output bitmap or the context's current output
    bitmap).
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    1630ffa View commit details
    Browse the repository at this point in the history
  9. Add the current transform to the layer rendering states

    This means that when entering a layer, the current transform now is
    reset to the identity matrix. setTransform and getTransform are now
    local to the current layer, meaning that calling setTransform sets a
    matrix relative to the parent layer.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    8a626cf View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    3f3cc52 View commit details
    Browse the repository at this point in the history
  11. Rewrote the note describing how the state stack stores the output bitmap

    With how the spec is written now, the context always has a top level and
    a current output bitmap, irrespective of how the context's bitmap is
    bound or used by an HTMLCanvasElement or OffscreenCanvas. Thus, the
    paragraph modified by this commit wasn't correct. It's more useful to
    describe how the state stack as a whole relates with the context's
    state.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    c8b18a1 View commit details
    Browse the repository at this point in the history
  12. Make all instances of "drawing states" plural

    Most uses were plural already. Making them all plural is more consistent
    and allows to remove the data-x that was needed to reconcile the
    differences.
    graveljp committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    1db7673 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2024

  1. Reply to review comment

    Main changes include clarifications in the `drawing state` definition
    and renaming `current transformation matrix` to `layer transformation
    matrix`.
    graveljp committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    3378c5d View commit details
    Browse the repository at this point in the history