Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8176795

Wrong color drawn when painting translucent colors on volatile images using XRender.

    XMLWordPrintable

Details

    • 2d
    • 8
    • b01
    • x86_64
    • linux

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_121"
        Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
        Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)


        ADDITIONAL OS VERSION INFORMATION :
        Linux osboxes 4.8.0-41-generic #44-Ubuntu SMP Fri Mar 3 15:27:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
        Current version of Compiz installed.

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        VM running in VirtualBox.

        A DESCRIPTION OF THE PROBLEM :
        When painting translucent colors on a volatile image on Linux we get an unexpected result color value.
        Eg.:
        - first filling volatile image with solid black
        - then filling with 50% white (0x80ffffff)
        - we would expect medium gray ff808080
        Expected color is what we see on Windows OS but not on Linux with Java 8.
        There we get ff404040 (see test case).
        We could verify with jdk1.8.0_05, jdk1.8.0_60, jdk1.8.0_91, jdk1.8.0_92, jdk1.8.0_121.
        Bug does not seem to occur with Java 7, verified with jdk1.7.0_67.

        REGRESSION. Last worked in version 7u76

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.7.0_67"
        Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
        Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Please run the test case.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        ff808080
        ACTUAL -
        ff404040

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package de.centigrade.cezanne.bugs;

        import java.awt.Color;
        import java.awt.Graphics2D;
        import java.awt.GraphicsConfiguration;
        import java.awt.GraphicsDevice;
        import java.awt.GraphicsEnvironment;
        import java.awt.image.BufferedImage;
        import java.awt.image.VolatileImage;

        public class Bug0029487TestCase {

            public static void main(String[] args) throws Exception {

                System.out.println("Java " + System.getProperty("java.version"));
                GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
                GraphicsConfiguration translucentGC = null;
                SCREENS: for (GraphicsDevice screen : env.getScreenDevices()) {
                    for (GraphicsConfiguration gc : screen.getConfigurations()) {
                        if (gc.isTranslucencyCapable()) {
                            translucentGC = gc;
                            break SCREENS;
                        }
                    }
                }
                if (translucentGC == null) {
                    throw new Exception("No suitable gc found.");
                }
                int width = 10;
                int height = 10;
                VolatileImage image = translucentGC.createCompatibleVolatileImage(width, height);
                Graphics2D g = image.createGraphics();
                g.setColor(Color.BLACK);
                g.fillRect(0, 0, width, height);
                g.setColor(new Color(0x80ffffff, true));
                g.fillRect(0, 0, width, height);
                g.dispose();
                // You could also paint image here to verify color value printed below.
                BufferedImage snapshot = image.getSnapshot();
                int argb = snapshot.getRGB(width / 2, height / 2);
                System.out.println(Integer.toHexString(argb));
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        None known for translucent volatile images.

        Attachments

          Issue Links

            Activity

              People

                jdv Jayathirth D V
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: