-
Notifications
You must be signed in to change notification settings - Fork 187
Prepare the implementation of dynamically sized image file-formats #1828
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
Prepare the implementation of dynamically sized image file-formats #1828
Conversation
b959e54 to
edca23e
Compare
HeikoKlare
left a comment
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.
Thank you for this preparation, @HannesWell!
Overall, the changes look sound to me. I only have minor comments regarding naming/formatting and one comment regarding behavior.
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
Outdated
Show resolved
Hide resolved
For me, it would be fine to bring this into the upcoming release. I do not see any risk in it (give the adaptation I have mentioned in the review) and it would make preparation for the next release cycle in terms of follow-up PRs regarding SVG support easier. |
|
I would postpone this to 4.36, given that we've just shipped M3, we are in RC phase and the change is not trivial. |
226d63f to
5174223
Compare
I second that.
It's right that this is not trivial, but in the end it's just moving around some small parts of the code. And the only really new code-path, i.e. the path in |
|
I also see no risk in the change since, as you explained, it is just some renaming and simple refactoring and new code paths are not executed at all. Still, I understand the concerns, in particular since we are beyond M3 and even though the change is unrisky, it does not look like that when only taking a quick look. So I am not sure what to do. We should not push this through despite raised concerns. It's not worth to ask PMC for an advise/decision either (and you are part of that anyway 😉 ). |
|
@HeikoKlare as far as I understand the only reason is "make PRs happen earlier", what I usually do in this situation is:
This also will give some more confidence that what is done here is actually the right thing, and as Once master is open we can merge this right away and maybe even then more PRs. |
While I agree with you that this change should be save, I think we should postpone it if others would be uncomfortable with having it, as it's not that important. As we had discussed already privately with Michael and as Christoph has described it the other PRs can include this PR's change temporarily. |
|
Sure, I am completely fine with everything said. Just one remark on:
For me, that's not what it is about for me. It is rather two other reasons:
That does not outweigh accepting any risk, so don't take this as an argumentation for merging. It's just to explain why for me it's not only about getting things into a specific release but about efficiently using the time we have with (and without) freeze periods :-) |
45f5b9c to
b87670d
Compare
| super(device); | ||
| if (imageFileNameProvider == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); | ||
| this.imageFileNameProvider = imageFileNameProvider; | ||
| //TODO: implement fine-grained zoom handling here as well? |
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.
For Mac the implementation seems to be completely different than for the other platforms and it even looks to me that anything else than 100% and 200% is not considered?
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.
From my understanding, MacOS/Cocoa is only capable of 100% and 200% displays and thus everything in the SWT implementation for MacOS is to 100/200 as well.
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 have now implemented something that seemed suitable just from looking at the code on a Windows computer (no way to try it out), but I'm absolutely not sure if that's reasonable. And I have the impression that code should also be enhanced, because currently it loads the image twice in some cases which might be unnecessary and could be avoided.
In any case it would be good to get support from somebody who has a Mac at hand to try this out and to get some details.
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.
Unfortunately, MacOS has no on-demand loading for image data at different zooms implemented yet. Thus, whenever possible, two representations of each image are created upon image instantiation. We need to implement this here as well, which is why the changes are generally fine.
I still have enhanced the changes with support for the constructors taking InputStream and String to also render multiple sizes of SVGs in case they refer to an SVG. In addition, I have revised the constructor accepting an ImageFileNameProvider to not unnecessary try to rescale the 200% image but just add a representation for it as is, like done in other constructors as well.
| ImageData[] imgDataArray = getImageDataArrayFromStream(stream); | ||
| data = imgDataArray; |
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.
We have to discuss when we use the native implementation, which is not capable (currently) to render SVGs for different zooms and when to use the software implementations of the file-format.
At the moment I would say that for SVGs the software solution should be used if fileZoom!=targetZoom and for all other formats the currently used native impl should be used?
Alternatively one could always use the software SVG-renderer for consistency or we could make it configurable by a flag for the case fileZoom==targetZoom?
Deciding in advance if the stream is an SVG or not is possible (the stream is read into a byte-array below anyways) but not trivial.
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 don't have a strong opinion here. I would be in favor the following:
- Use the SVG software solution as default. Why? We then have consistent behavior across the operating systems and will not run into Linux-specific issues because of the native rendering, thus reducing maintenance efforts.
- Make the native implementation (either for fileZoom==targetZoom or even for every zoom) optional. Maybe having a system property for SVG rendering with arguments "native" and "nativeAtDefault" or the like would suffice to capture every desired use case. On the other hand, every valid argument for system properties need to be maintained and considered everywhere necessary, so introducing another maintenance overhead which maybe no one ever needs. So maybe when setting a property to use native SVG support (on Linux), only rendering at 100% is supported to exactly cover the case is supported right now (and other resolutions are done by auto-scaling), unless someone implements anything additionally?
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.
* Use the SVG software solution as default. Why? We then have consistent behavior across the operating systems and will not run into Linux-specific issues because of the native rendering, thus reducing maintenance efforts.
Agree.
* Make the native implementation (either for fileZoom==targetZoom or even for every zoom) optional. Maybe having a system property for SVG rendering with arguments "native" and "nativeAtDefault" or the like would suffice to capture every desired use case. On the other hand, every valid argument for system properties need to be maintained and considered everywhere necessary, so introducing another maintenance overhead which maybe no one ever needs. So maybe when setting a property to use native SVG support (on Linux), only rendering at 100% is supported to exactly cover the case is supported right now (and other resolutions are done by auto-scaling), unless someone implements anything additionally?
As far as I know the native implementation is used for performance reasons. And since only SVG is (currently) able to natively scale the image dynamically I think we should continue using the native implementation for all other file formats as is. And only for SVGs we should always render in software, scaling 'natively'.
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 really like the way how it is implemented now. Using the native file format implementations wherever possible and only using the software rendering for SVGs on Linux is fine as implemented in this PR.
I am in favor of doing it like proposed and in case we see need for more configuration options on this, we can still adapt.
9d0d9a8 to
e7c2b98
Compare
|
After a session with Heiko last week I have now updated this PR to further prepare implementation of dynamically sized image file-formats like SVGs in #1638 without the need to add any new API for that. The basic idea is to apply the concept of the Besides the
For Windows this looks already good to me, but for Mac and Linux I think the implementation is not complete or needs some clarification. |
e7c2b98 to
96bf079
Compare
96bf079 to
11cf125
Compare
|
Info: with the latest push, I have rebased the PR on top of master, in particular including an update of the ImageLoader implementation as that has been refactored into ImageLoader and InternalImageLoader on master. |
29397ec to
81b4f30
Compare
81b4f30 to
a0fb534
Compare
|
Info: with the recent pushed I haved rebased the change onto preparation work in #1886 and restructured the commits to the following two:
The former would completely works without the latter. |
9bf151f to
eba0710
Compare
Co-authored-by: Heiko Klare <[email protected]>
f8649f7 to
27fa1a4
Compare
|
I have extracted the second commit out of this PR to keep this preparatory work separated from the adoption in the OS-specific |
Required for
This is a purely internal change that also reduces the number of places where
IOExceptionsare handled (all int the same way) inFileFormat.isFileFormat()implementations.@HeikoKlare do you want to review this? Should we aim to land this for this release?
CC @Michael5601