RFR: 8377426: Adjust scene background to color scheme

Martin Fox mfox at openjdk.org
Wed Feb 11 17:07:43 UTC 2026


On Sun, 8 Feb 2026 03:30:51 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

> When a non-opaque scene fill color is used with a stage style other than `StageStyle.TRANSPARENT`, the actual fill color is always white. This doesn't work well when the scene uses a dark color scheme. A practical solution is to allow non-opaque scene fill colors, and blend them on top of a white or black background (depending on color scheme) to derive an opaque color that adapts intuitively to the color scheme.
> 
> To test this, simply create a scene that uses a non-opaque fill color and observe the scene background when the color scheme is changed.
> 
> This PR includes a system test, run it with:
> 
> ./gradlew -PFULL_TEST=true -PUSE_ROBOT=true :systemTests:test --tests test.robot.javafx.scene.SceneFillTest.testSceneFill

When writing a value to the screen and reading it back the components can shift a bit. There's a utility for comparing two colors (assertColorEquals) that allows for a tolerance when comparing the components. You can see sample code for this in SRGBTest.java.

JavaFX specifies colors in the sRGB space which employs a gamma (power) curve. For any given color component Prism presumably converts it to a linear space, performs blending operations, converts back to sRGB, then rounds the result to a byte to hand it off to the OS. Most Macs displays don't use sRGB natively so the byte then gets converted to the display's color space using more math and float <=> byte conversions. Then when the Robot reads the color back a bunch of this process is reversed.

This PR is blending two colors in the sRGB space instead of a linear space. That's a little odd but it seems that other parts of the system do this (I see the Color.interpolate method works in sRGB) so maybe we'll just let it pass.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2068#issuecomment-3885754039


More information about the openjfx-dev mailing list