Skip to content

ImageFilter widget #13489

Closed
Closed

Description

@MichaelRFairhurst

I want to implement a blur, not of the layer below my widget, but of a current widget.

Is there a widget that looks something like:

build() =>
  new FilteredWidget(
    filter: new ImageFilter.blur(...),
    child: ...
  );

or should I copy RenderProxy from https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/rendering/proxy_box.dart to create one?

I also want to stack these layers, which I'm assuming requires compositing:

build() =>
  new Stack(
    children: [
      new FilteredWidget(
        filter: new ImageFilter.blur(...),
        child: ...
      ),
      new FilteredWidget(
        filter: new ImageFilter.blur(...),
        child: ...
      ),
      ...
  );

They will be blurred different amounts, so while I can use BackdropFilter, I have to order the most blurred before the least blurred, and calculate the proper blur amount to do on the first one such that blurring the second one results in the desired actual blur amount on the first. Would be much better to treat each widget as a blurred widget and composite them, than to treat each widget as blurring its prior paint.

Not sure if solving the first one gets me the second one for free, or if they are separate issues.

Activity

  1. Hixie commented on Dec 11, 2017

    @Hixie
    Contributor

    Looks like you want a widget similar to ShaderMask.

  2. added
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Dec 11, 2017
  3. added this to the milestone on Dec 11, 2017
  4. changed the title [-]Question: How to do compositing with ImageFilter directly?[/-] [+]ImageFilter widget[/+] on Dec 11, 2017
  5. MichaelRFairhurst commented on Dec 11, 2017

    @MichaelRFairhurst
    ContributorAuthor

    I realized I gave very little practical context: I'm doing a blur in an animation. That's why its not a backdrop, really.

  6. sroddy commented on Mar 18, 2018

    @sroddy
    Contributor

    @jonahwilliams I saw that you self-assigned this issue. Do you have a (tentative) ETA for this?
    This is a road blocker for one of our projects as the performances of Backdrop Fliter are not satisfying (and we just really need to blur a static background). I need to understand if it's worth to wait for this feature or if we work around this issue pre-processing the images on the server

  7. jonahwilliams commented on Mar 18, 2018

    @jonahwilliams
    Contributor

    @sroddy No ETA at this time, though it would be great if you could share any perf issues you are having with Backdrop Filter.

  8. sroddy commented on Mar 18, 2018

    @sroddy
    Contributor

    I'm just applying a backdrop filter on top of a static background image to obtain a blur effect of the background. Something very similar to this example: https://github.com/FlutterRocks/blurry_artist_details_page/blob/master/lib/artist_details_page.dart#L104

    on top of the blurred background there is a ListView that displays paragraphs of text. Scrolling it is extremely laggy (<30 fps) on Nexus 5 and Nexus 5x and far from usable. My guess is that everything behind the backdrop filter gets rasterized on every frame even if it doesn't change instead of being rasterized just once when something changes.

    Even in the example above you will notice that scrolling the horizontal listview is laggy on these devices, while if you remove the filter everything becomes smooth again.

  9. sroddy commented on Mar 18, 2018

    @sroddy
    Contributor
  10. jonahwilliams commented on Mar 18, 2018

    @jonahwilliams
    Contributor

    @sroddy Thanks for the report, I'll take a look on a real device.

  11. jonahwilliams commented on Mar 20, 2018

    @jonahwilliams
    Contributor

    @sroddy I have reproduced the issue on a Nexus 5, using a filtered image within a list view. SkCanvas::Flush and AndroidContextGL::SwapBuffers are each taking > 15ms a frame here. I'm going to drilldown into these more. Ideally we could just apply the filter to the image once and save that new image, I'm going to look into an implementation that does just that

    Image Filter: Blur

    image_filter_timeline

    No Image Filter

    without_image_filter

  12. sroddy commented on Mar 21, 2018

    @sroddy
    Contributor

    thanks @jonahwilliams, that would be really appreciated. Please keep me posted!

  13. 12 remaining items

  14. maryx commented on Feb 22, 2019

    @maryx
    Contributor

    I have a sample app that demonstrates the performance issues once blur is turned on. You can check it out at https://github.com/maryx/confetti and maybe it can help with debugging/resolving this issue.

  15. self-assigned this
    on Sep 16, 2019
  16. cmkweber commented on Jan 10, 2020

    @cmkweber

    An additional use case of this widget is now realtime supersampling can be performed. This can be beneficial when doing canvas operations that do not support antialiasing (such as drawVertices). I have provided an example gist here: https://gist.github.com/cmkweber/c17aae8fa48a4853a87f242835cb65cb

  17. flar commented on Oct 8, 2020

    @flar
  18. dnfield commented on Oct 8, 2020

    @dnfield
  19. github-actions commented on Aug 11, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  20. locked as resolved and limited conversation to collaborators on Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: new featureNothing broken; request for a new capabilityframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions