[OpenJDK 2D-Dev]  RFR JDK-8176795: Wrong color drawn when painting translucent colors on volatile images using XRender.
Jayathirth D V
jayathirth.d.v at oracle.com
Thu Dec 7 15:16:56 UTC 2017
Please review the following fix in JDK10 :
Bug : https://bugs.openjdk.java.net/browse/JDK-8176795
Webrev : http://cr.openjdk.java.net/~jdv/8176795/webrev.00/
Issue : When we draw translucent color over an opaque color in Unix from JDK 8 we get different color after composition compared to any other platform.
Root cause : From JDK 8, X Rendering extension is enabled in Unix and we see this problem only when we use XRender in Unix if we use GLX or X11 we don't see any issue. Also X Rendering extension expects pre-multiplied alpha color values, so we need to convert the non-premultiplied alpha color values to pre-multiplied alpha color values before give pixel value to XRender for drawing. The main problem is we do this operation of conversion twice:
1) When we call Graphics2D.setColor() it uses ArgbPre PixelConverter based on SurfaceData(here it is XRenderPixMap ArgbPre surface) and converts the color to pre-multiplied values.
2) When we call Graphics2D.fillRect() internally before we compose the destination(opaque color) and source(translucent color) we prepare source render rectangle for X Render extension. Here again we convert the already converted color values to premultiplied values.
Solution : There is no need for us to do non-pre to pre color conversion again at XRender level so it should be removed. Also this logic of non-pre to pre color conversion at XRender was only used when source is Solid color and not Texture/Gradient. So I have completely removed this logic itself as it not needed anywhere else.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the 2d-dev