Skip to content

Update SceneBuilder.pushOpacity and PaintingContext.pushOpacity #102888

@jonahwilliams

Description

@jonahwilliams

The Flutter framework and dart:ui has methods called PaintingContext.pushOpacity and SceneBuilder.pushOpacity (respectively) used to create opacity layers today. Unfortunately, these methods actually take an alpha. In order to support wider opacity values, we'd like to instead have methods which accept a float/double and avoid int truncation. We have a few advantages, namely that in the corpus of g3 code I've looked at, no one seems to use these methods directly.

  • We could roll a hard breaking change where we change the type of the engine APIs to accept a double, then do a similar change in the framework. This would be disruptive during the landing, but would lead us quickly to an ideal state. Code not in g3 or the SDK would not be migrated, though this could potentially be dart fix'd since the conversion from alpha to opacity is trivial.

  • Alternatively, we could introduce new APIs that do the right thing, and make the old APIs delegate to these new ones along with a deprecation period. Unfortunately its hard to get a better name than pushOpacity. We'd basically need to introduce pushOpacity2. I'm calling it pushOpacityValue right now which is just redundant.

This came up in #102687

Engine change would be: flutter/engine#33035

(We should consider similar changes for color to support wider gamuts )

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions