-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Let pushColorFilter accept all types of ColorFilters #9641
Conversation
This has at least one bug in it right now that I'm working on... crashes when you pass it a matrix. |
This should be good now. Will have tests upstream in framework. |
lib/ui/compositing.dart
Outdated
default: | ||
assert(false); | ||
} | ||
final ColorFilterEngineLayer layer = ColorFilterEngineLayer._(engineLayer); | ||
assert(_debugPushLayer(layer)); | ||
return layer; | ||
} | ||
EngineLayer _pushColorFilter(int color, int blendMode) native 'SceneBuilder_pushColorFilter'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of implementing 4 pushColorFilter variants, maybe it's cleaner to define a single pushColorFilter
that takes a sk_sp<SkColorFilter>
, and expose ExtractColorFilter
from paint.cc
to generate the SkColorFilter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with that is the Paint version is a bit hacky and was mainly done to maintain backwards compatibility.
Paint can afford to do this because it already encodes/serializes this data to the engine side. Doing that is not free. I'd rather use this approach because it avoids allocating unnecessary typed data (which is demonstrably slow), and avoids sending data over to thenative side that we don't need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out! I didn't realize that ColorFilter
doesn't have a corresponding native SkColorFilter
object. Is it possible to create such a native object during the construction of ColorFilter
, so Paint
can just store it inside _objects
(like how Shader
is stored), and pushColorFilter
can also directly use it without triggering additional Dart to native conversion costs?
I guess that I'm Ok with having 4 pushColorFilter***
in scene_builder.cc
but it just feels a little weird as every previous push***
in scene_builder.cc
has a one-to-one relationship with the SceneBuilder.push***
in compositing.dart
. I'll consult @chinmaygarde and @yjbanov to see how they feel about 4 pushColorFilter***
variants in scene_builder.cc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may be a better way to go - just make ColorFilter a NativeFieldWrapper2
class. Do you want that to be part of this pull request or should we split it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have it here if it's not complicating this PR too much :) (I was hoping that it could even simplify this PR a little bit.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I split that effort out into #9668 which has landed and been merged into this PR. PTAL.
testing/dart/compositing_test.dart
Outdated
@@ -274,7 +274,13 @@ void main() { | |||
return builder.pushOpacity(100, oldLayer: oldLayer); | |||
}); | |||
testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { | |||
return builder.pushColorFilter(const Color.fromARGB(0, 0, 0, 0), BlendMode.color, oldLayer: oldLayer); | |||
return builder.pushColorFilter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add test coverage for all 4 types of ColorFilter
s. I think they don't have to be put in the SceneBuilder does not share a layer between addRetained and push*
test. Maybe just add a new test pushColorFilter handles all 4 types
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
a226e13
to
882ca85
Compare
882ca85
to
75a88a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
flutter/engine@75387db...49445ce git log 75387db..49445ce --no-merges --oneline 49445ce FLEViewController/Engine API changes (flutter/engine#9750) 2a79462 Add Fuchsia build CI presubmit steps (flutter/engine#9736) 67cebdb Roll fuchsia/sdk/core/linux-amd64 from KGmm_RIJoXS19zTm2crjM3RYpmp5Y03-fLUeVdylbTYC to ehWVT9QJbC-vFMM6SkkQM9HJ9oITFCws7FC9JnrFq2gC (flutter/engine#9765) 089c740 Roll fuchsia/sdk/core/mac-amd64 from lCQWEeR_Ert7t_qAbMRycwrRyZC-dIprYPyPJzwPmg4C to EYnRdXFT9l-d8Qkz4zeTRXnqfV3KQzpQhoPs1r0-740C (flutter/engine#9759) b22410e Include SkParagraph headers only when the enable-skshaper flag is on (flutter/engine#9758) 2cd650d Minimal integration with the Skia text shaper module (flutter/engine#9556) f775f5e Re-enable the Wuffs GIF decoder (flutter/engine#9466) aca0482 Make all shell unit tests use the OpenGL rasterizer. (flutter/engine#9746) bc57291 Make FLEViewController's view an internal detail (flutter/engine#9741) 9776043 Synchronize main thread and gpu thread for first render frame (flutter/engine#9506) f600ae8 Use libc++ variant of string view and remove the FML variant. (flutter/engine#9737) 564f53f Revert "Improve caching limits for Skia (#9503)" (flutter/engine#9740) b453d3c libtxt: fix reference counting of SkFontStyleSets held by font asset providers (flutter/engine#9561) fa7627d Fix backspace crash on Chinese devices (flutter/engine#9734) 56885f7 Let pushColorFilter accept all types of ColorFilters (flutter/engine#9641) 6dccb21 Roll src/third_party/skia 96fdfe0fe88e..af4e7b6cf616 (1 commits) (flutter/engine#9735) 8511d9b Roll fuchsia/sdk/core/mac-amd64 from byM-kyxL4bemlTYNqhKUfJfZoIUrCSzS6XzsFr4n9-MC to lCQWEeR_Ert7t_qAbMRycwrRyZC-dIprYPyPJzwPmg4C (flutter/engine#9742) b3bf0a1 Roll fuchsia/sdk/core/linux-amd64 from I2Qe1zxgckzIzMBTztvzeWYsDgcb9Fw-idSI16oIlx8C to KGmm_RIJoXS19zTm2crjM3RYpmp5Y03-fLUeVdylbTYC (flutter/engine#9743) 7e56823 Fix windows test by not attempting to open a directory as a file. (flutter/engine#9745) 6cf0d13 Roll src/third_party/skia a3ffaabcc4f2..96fdfe0fe88e (5 commits) (flutter/engine#9731) 49a00ae Fix Fuchsia build. (flutter/engine#9730) b3bb39b Roll src/third_party/dart 06c3d7ad3a...09fc76bc51 (flutter/engine#9728) 2284210 Make the license script compatible with recently changed Dart I/O stream APIs (flutter/engine#9725) ad582b5 Rework image & texture management to use concurrent message queues. (flutter/engine#9486) 1dcd5f5 Roll src/third_party/skia 6b82cf638682..a3ffaabcc4f2 (24 commits) (flutter/engine#9726) 129979c Revert "Roll src/third_party/dart 06c3d7ad3a..7acecda2cc (12 commits)" (flutter/engine#9724) 8020d7e Roll src/third_party/skia 56065d9b875f..6b82cf638682 (3 commits) (flutter/engine#9718) e24bd78 Roll src/third_party/dart 06c3d7ad3a..7acecda2cc (12 commits) 3d2668c Reland isolate group changes 802bd15 iOS platform view opacity (flutter/engine#9667) 3b6265b Roll src/third_party/dart b5aeaa6796..06c3d7ad3a (44 commits) 887e052 Refactor ColorFilter to have a native wrapper (flutter/engine#9668) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff ([email protected]), and stop the roller if necessary.
flutter/engine@75387db...49445ce git log 75387db..49445ce --no-merges --oneline 49445ce FLEViewController/Engine API changes (flutter/engine#9750) 2a79462 Add Fuchsia build CI presubmit steps (flutter/engine#9736) 67cebdb Roll fuchsia/sdk/core/linux-amd64 from KGmm_RIJoXS19zTm2crjM3RYpmp5Y03-fLUeVdylbTYC to ehWVT9QJbC-vFMM6SkkQM9HJ9oITFCws7FC9JnrFq2gC (flutter/engine#9765) 089c740 Roll fuchsia/sdk/core/mac-amd64 from lCQWEeR_Ert7t_qAbMRycwrRyZC-dIprYPyPJzwPmg4C to EYnRdXFT9l-d8Qkz4zeTRXnqfV3KQzpQhoPs1r0-740C (flutter/engine#9759) b22410e Include SkParagraph headers only when the enable-skshaper flag is on (flutter/engine#9758) 2cd650d Minimal integration with the Skia text shaper module (flutter/engine#9556) f775f5e Re-enable the Wuffs GIF decoder (flutter/engine#9466) aca0482 Make all shell unit tests use the OpenGL rasterizer. (flutter/engine#9746) bc57291 Make FLEViewController&flutter#39;s view an internal detail (flutter/engine#9741) 9776043 Synchronize main thread and gpu thread for first render frame (flutter/engine#9506) f600ae8 Use libc&flutter#43;&flutter#43; variant of string view and remove the FML variant. (flutter/engine#9737) 564f53f Revert &flutter#34;Improve caching limits for Skia (flutter#9503)&flutter#34; (flutter/engine#9740) b453d3c libtxt: fix reference counting of SkFontStyleSets held by font asset providers (flutter/engine#9561) fa7627d Fix backspace crash on Chinese devices (flutter/engine#9734) 56885f7 Let pushColorFilter accept all types of ColorFilters (flutter/engine#9641) 6dccb21 Roll src/third_party/skia 96fdfe0fe88e..af4e7b6cf616 (1 commits) (flutter/engine#9735) 8511d9b Roll fuchsia/sdk/core/mac-amd64 from byM-kyxL4bemlTYNqhKUfJfZoIUrCSzS6XzsFr4n9-MC to lCQWEeR_Ert7t_qAbMRycwrRyZC-dIprYPyPJzwPmg4C (flutter/engine#9742) b3bf0a1 Roll fuchsia/sdk/core/linux-amd64 from I2Qe1zxgckzIzMBTztvzeWYsDgcb9Fw-idSI16oIlx8C to KGmm_RIJoXS19zTm2crjM3RYpmp5Y03-fLUeVdylbTYC (flutter/engine#9743) 7e56823 Fix windows test by not attempting to open a directory as a file. (flutter/engine#9745) 6cf0d13 Roll src/third_party/skia a3ffaabcc4f2..96fdfe0fe88e (5 commits) (flutter/engine#9731) 49a00ae Fix Fuchsia build. (flutter/engine#9730) b3bb39b Roll src/third_party/dart 06c3d7ad3a...09fc76bc51 (flutter/engine#9728) 2284210 Make the license script compatible with recently changed Dart I/O stream APIs (flutter/engine#9725) ad582b5 Rework image & texture management to use concurrent message queues. (flutter/engine#9486) 1dcd5f5 Roll src/third_party/skia 6b82cf638682..a3ffaabcc4f2 (24 commits) (flutter/engine#9726) 129979c Revert &flutter#34;Roll src/third_party/dart 06c3d7ad3a..7acecda2cc (12 commits)&flutter#34; (flutter/engine#9724) 8020d7e Roll src/third_party/skia 56065d9b875f..6b82cf638682 (3 commits) (flutter/engine#9718) e24bd78 Roll src/third_party/dart 06c3d7ad3a..7acecda2cc (12 commits) 3d2668c Reland isolate group changes 802bd15 iOS platform view opacity (flutter/engine#9667) 3b6265b Roll src/third_party/dart b5aeaa6796..06c3d7ad3a (44 commits) 887e052 Refactor ColorFilter to have a native wrapper (flutter/engine#9668) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff ([email protected]), and stop the roller if necessary.
Fixes flutter/flutter#35415
This allows consumers to apply all supported types of color filters to a scene.
This is a breaking change, but we don't actually use this code anywhere in the framework so I expect this code to pass.
Breaking change announcement: https://groups.google.com/forum/#!topic/flutter-announce/bdhRbfwg6jA