Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@flar
Copy link
Contributor

@flar flar commented Dec 10, 2020

Fixes flutter/flutter#71871

Currently Skia supports a "decal" tile mode which defines "out of bounds" values of a gradient or image as transparency. Skia supports this in both Gradients and Blur filters, but we don't have the value in our TileMode enum. This PR adds that new value.

We also have no parameter on ImageFilter.blur() that allows the developer to specify a tile mode. The implementation currently defaults to clamp which is appropriate for opaque images, but it causes frustrating rendering anomalies for other uses (see flutter/flutter#57180). This PR adds a new TileMode parameter to ImageFilter.blur to enable developers to control this aspect of the blur operation. The default value is clamp for backwards compatibility.

I've updated the tests to include the new values and implemented this on web, with a few caveats:

  • Flutter web on HTML/CSS only supports a single radius and decal mode so the implementation of blur on this platform used to be "always wrong" and now it is "wrong unless a developer asks for decal mode and uses the same sigma for X and Y". Improvement, but this platform will likely never support all of the capabilities of the Flutter blur filter.

  • Flutter with CanvasKit supports all of the new decal modes for Gradients, and it should support all of the modes for blur filters, but for some reason the values supplied in the MakeBlur() constructor don't seem to have any effect. Is there a missing link in getting that value to the underlying implementation that I missed?

Finally, I took the name decal from the Skia enum. Is that a good name for Flutter developers?

@flar
Copy link
Contributor Author

flar commented Dec 10, 2020

@Hixie Is decal a good name for the new TileMode enum value? Would that name be recognizable or familiar to Flutter developers?

/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/tile_mode_mirror_radial.png)
mirror,

/// Edge is transparent black.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe "Extrapolates the source image with transparent black (0x00000000) pixels, when the image filter samples outside of the bounds of the source image"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the entries are documented as "Edge is ...". I agree that I don't like the way that is all phrased. I'll look for some better wording for all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates pushed...

/// 4.0 to 3.0, and so forth (and for linear gradients, similarly from in the
/// negative direction).
///
/// An image filter will treat the image as tiled in an alternating forwards and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "An image filter will treat the image ..." makes me think TileMode is a property of the image, not the filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"An image filter will treat its source as ..."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates pushed...

@chinmaygarde chinmaygarde added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Dec 10, 2020
@flar flar merged commit bb81b95 into flutter:master Dec 10, 2020
///
/// An image filter will substitute transparent black for any sample it must read from
/// outside its source image.
decal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess decal is as good a name for this as any, and has the advantage of matching Skia.

/// gradient.
///
/// An image filter will substitute transparent black for any sample it must read from
/// outside its source image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to add the new image, too. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan was to add that as soon as it propagates to the framework and I can modify the built assets. I also plan to add equivalent ImageFilter.blur example images to all of the TileMode values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I landed new assets today which included the assets for decal. (I forgot about ImageFilter.blur examples, sorry, so if they haven't been added yet they're still missing.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that just for the gradient? I have been waiting to update these assets until Skia fixes bugs in the tile mode handling for the ImageFilter.blur(). It was supposed to go in a few days after this PR, but the fix has been re-un-re-verted since then and still hasn't landed and rolled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking the blur/TileMode doc image issue in flutter/flutter#74367

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 11, 2020
dnfield pushed a commit to flutter/flutter that referenced this pull request Dec 11, 2020
* 3a30ae3 Fix ios voiceover (for safari >13.4) (flutter/engine#22965)

* 4338849 Replace g_object_weak_ref with g_object_add_weak_pointer

* 3b9937a Load macOS dart bundle by URL fallback (flutter/engine#22979)

* 96927bb add ffi_struct_patch.dart to libraries.yaml (flutter/engine#23000)

* 2efc7c1 Set SkPath::setIsVolatile based on whether the path survives at least two frames (flutter/engine#22620)

* bb81b95 Allow Tile mode for blur filter and add new decal TileMode (flutter/engine#22982)

* 9df2157 Load iOS dart bundle by URL fallback (flutter/engine#22997)

* 7647fdb Roll Skia from 22f80a60b17f to 6b07e0eb497c (26 revisions) (flutter/engine#23005)

* 062cbd8 Freiling warmup memory (flutter/engine#22984)

* 1646966 Revert "Freiling warmup memory (#22984)" (flutter/engine#23007)

* 50d830a [web] Do not reset 'cursor' in PersistedPlatformView. (flutter/engine#22977)

* 6ebf5c3 Roll Dart SDK from e4c9b06267d3 to a4e6fe145bf7 (2 revisions) (flutter/engine#23006)

* 14c8c24 [web] Fix regression in foreground style (flutter/engine#22999)

* 6678efa Implement SystemSound.play

* fb769a4 Roll Fuchsia Linux SDK from rnN_X2o75... to ESzmO-yOF... (flutter/engine#23010)

* b424356 Roll Skia from 6b07e0eb497c to f7cce2b243b2 (6 revisions) (flutter/engine#23018)

* 56035c7 Roll Fuchsia Linux SDK from ESzmO-yOF... to K4cPd0-Xd... (flutter/engine#23020)

* cb4a2ef Roll Skia from f7cce2b243b2 to b0cb8372c1ef (3 revisions) (flutter/engine#23021)

* cc8c9d4 Roll Skia from b0cb8372c1ef to 5284e96599a8 (2 revisions) (flutter/engine#23023)

* 8e9a943 Roll Dart SDK from a4e6fe145bf7 to c287db6bf232 (2 revisions) (flutter/engine#23024)

* 714b543 Roll Fuchsia Mac SDK from OUQEzH1oE... to a9yuHfriB... (flutter/engine#23025)

* d50cdda Roll Dart SDK from c287db6bf232 to 2553a84fe438 (1 revision) (flutter/engine#23026)

* 4794d04 Roll Skia from 5284e96599a8 to f7fdf1aa2911 (1 revision) (flutter/engine#23027)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 14, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 15, 2020
@Hixie Hixie mentioned this pull request May 28, 2021
9 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for TileMode and kDecal to ImageFilter.blur

5 participants