-
Notifications
You must be signed in to change notification settings - Fork 6k
Imagefilter wrapper object #13711
Imagefilter wrapper object #13711
Conversation
Some comments on the implementation... This is based on the implementation of ColorFilter which immediately precedes ImageFilter in painting.dart. As I was following that template, a few issues struck me, but I wanted to remain true to following the template. In particular:
|
ceebd3a
to
60bc5d1
Compare
I consolidated my commits into a single commit to avoid a nasty merge with the ongoing changes to the web_ui version of the ImageFilter implementation. I will submit an issue for them to implement the necessary ==/hashcode/toString methods and enable the tests when this PR is landed. |
The non-web change LGTM. @yjbanov : what should we do about the web_ui test failure? Adding some dummy ==/hashcode/toString implementation so this PR can merge with passing tests? |
Why add a dummy implementation and not a real one? |
@yjbanov : Of course real ones are better. I got an impression that the real ones are currently blocked by something else (#13711 (comment)):
@flar : can you please specify who are "them", and what need to be implemented by "them"? My previous experience is that I just copied the real implementation to |
I've implemented ==/hashcode/toString in lib/ui for ImageFilter. I have some potential solutions, but right now I cannot even run a web test on my local engine and I have other things on my plate that are in the way of figuring that out. |
One question arises as to why the API comparison test is complaining that the web_ui versions of ImageFilter don't implement ==/hashcode/toString since those are implemented by default on all objects. What it really means is that lib/ui overrides them, but lib/web_ui does not. Is that really a concern? |
If I modify api_conform_test.dart to exclude ==/hashCode/toString from requiring matching methods then that check passes. The tests I wrote for those methods are marked TestOn('!chrome') as per other tests that shouldn't run on web, so they won't cause problems until web_ui decides to implement those methods. The question is, should api_conform_test.dart exclude these standard methods? |
Hmmm. We learned something new about Dart today. I can simply add abstract declarations of ==/hashCode/toString to the web_ui version of ImageFilter and the compiler accepts them without question and you can even call them and they just defer to the base implementations. This means I can get the code to pass the tests with 3 lines and then web_ui can come back and worry about their implementations on their own schedule. |
4e909c6
to
9362e23
Compare
For completeness I implemented the 3 methods for web_ui:ImageFilter.blur... |
I would like feedback from @yjbanov about what I did with the web_ui classes before I push this. |
/cc @jonahwilliams - the author of the API check. Was checking for |
We should relax it for toString,hashCode,and operator == but I thought I already did that... |
I've pushed most of @yjbanov 's suggestions, but left a couple of questions on the table from his previous review... |
The api_conform check is relaxed in #13907 (comment) |
Fix handling of null values for ImageFilter.blur(sigma[XY]). Add ImageFilter tests. Fix lint issues and remove misleading cut-and-paste comment. Added tests for ImageFilter.hashCode. Rename constants and explicit equals() Matchers in expect statements.
to web_ui version of ImageFilter.
655a003
to
cd76f71
Compare
* f240462 Implement basic text rendering support in CanvasKit backend (flutter/engine#13903) * ffcd856 Imagefilter wrapper object (flutter/engine#13711) * 176f563 Roll src/third_party/dart eeca3fb1cb..1f933abcee (7 commits) (flutter/engine#13931)
This PR creates a Dart wrapper object around the NativeFieldWrapper object which allows us to compare ImageFilter objects in the framework (and also print their values in a human readable form).
The main value for comparing their values is in the various objects which hold an ImageFilter (mainly BackdropFilter, but potentially an ImageFilterWidget in the future). Such objects will avoid marking themselves as requiring an update in the various levels of tree building if they can determine that the filter hasn't changed - but currently filters are only comparable via their identity rather than their values.
Tests are also added to check on the various construction, comparison and assignment operations (in particular Paint.imageFilter = ImageFilter...() where the image is not stored in its framework format).
There is a potential breaking change in that the external-facing ImageFilter used to implement the NativeFieldWrapper2 interface and now that interface is only implemented by an internally maintained engine-accessible value (see the new ImageFilter._nativeFilter field and the new _ImageFilter hidden class that it stores).