-
Notifications
You must be signed in to change notification settings - Fork 113
Fix ComposePanel background
#2670
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
Conversation
| /** | ||
| * Asserts that the two colors are within the given tolerance of each other, on each component. | ||
| */ | ||
| fun assertColorsWithinTolerance(expected: java.awt.Color, actual: java.awt.Color, tolerance: Int = 5) { |
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.
Why do we need tolerance here? It should be a strict match in cases of Int values
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.
The pixel colors returned by java.awt.Robot don't exactly match the colors drawn by skia.
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.
It uses different color spaces, you need to convert it into equal instead of such comparison
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.
Couldn't find the right conversion after trying several things:
- The color space of the
java.awt.Colorreturned byRobot. - The color space of
frame.graphicsConfiguration.
Changed the way the test is performed. Compare to a known correct screen color value instead of using tolerance.
| get() = contentComponent.transparency | ||
| set(value) { | ||
| contentComponent.transparency = value | ||
| if (value && !windowContext.isWindowTransparent && renderApi == GraphicsApi.METAL) { |
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.
Where is this METAL check now?
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 think there a need for it anymore.
Before the change in skiko
contentComponent.transparency = true would set the background color to Color(0, 0, 0, 0) which was the wrong value for the case of !windowContext.isWindowTransparent && renderApi == GraphicsApi.METAL (it needed to be null in this case).
After the change in skiko
contentComponent.transparency = true no longer modifies the background; now the code here sets it by itself on the next line. For the case when !windowContext.isWindowTransparent it will set it to null, just like before.
The difference
The difference will only be when all 3 below are true:
transparency = true!windowContext.isWindowTransparentrenderApiis notMETAL.
Before the change the background was set toColor(0, 0, 0, 0)and now it will be set tonull.
But what is the correct value in this case? When does transparency && !windowContext.isWindowTransparent even happen?
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.
When does transparency && !windowContext.isWindowTransparent even happen?
Experimental interop on a regular (non transparent) window
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.
Can you give me a sample to try/test?
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.
Changed the code such that the background is null when !windowContext.isWindowTransparent && (renderApi == GraphicsApi.METAL), as before.
2ddf1c0 to
5a56a2f
Compare
compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/awt/ComposePanelTest.kt
Outdated
Show resolved
Hide resolved
…mate color comparison.
5a56a2f to
6e1b704
Compare
…en `!windowContext.isWindowTransparent && (renderApi == GraphicsApi.METAL)`
Fix
ComposePaneldrawing the background that was set on it.This follows Skiko's Fix SkiaLayer background drawing
Fixes https://youtrack.jetbrains.com/issue/CMP-8738
Testing
Added a unit test and tested manually.
This should be tested by QA
Release Notes
Fixes - Desktop
ComposePaneldrawing the background that was set on it.