Skip to content

Make Canvas.drawShadow work on multiple views #130165

@dkwingsmt

Description

@dkwingsmt

Canvas.drawShadow requires DPR to calculate shadow length, and currently it gets the DPR implicitly from the first window:

// lib/ui/painting/canvas.cc
  SkScalar dpr = static_cast<float>(UIDartState::Current()
                                        ->platform_configuration()
                                        ->get_window(0)
                                        ->viewport_metrics()
                                        .device_pixel_ratio);

This is not compatible with multi-view, because in multi-view there might not be a window 0 if the platform disables implicit view. This DPR should come from the target view of this drawing command.

However, the drawShadow signature does not allow inserting a view ID or DPR anywhere. There's an elevation parameter, but it's a pre-DPR length.

  void drawShadow(Path path, Color color, double elevation, bool transparentOccluder);

To solve this in a non-breaking way, we can either

  • create a new drawShadowWithDpr that has an additional parameter float dpr, or
  • create a new drawShadowOnView that has an additional parameter int viewId.

Either way, we'll need to deprecate drawShadow afterwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: multi windowIssues related to multi window supportengineflutter/engine related. See also e: labels.team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions