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

Colors with alpha are painted incorrectly on Linux

    Details

    • Subcomponent:
      2d
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      A DESCRIPTION OF THE PROBLEM :
      It seems that on Linux colors with an alpha transparency are painted incorrectly:

      https://imgur.com/N1XuWCp

      It may be related to this existing issue,
      but I decided to report another bug just in case:
      https://bugs.openjdk.java.net/browse/JDK-8204931

      Painting off-screen is not affected (e.g. drawing to BufferedImage)

      REGRESSION : Last worked in version 10.0.1

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Colors like in previous versions
      ACTUAL -
      Glitched colors

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class Test extends JFrame {

      Test() {
      JPanel p = new JPanel() {
      @Override
      protected void paintComponent(Graphics graphics) {
      Graphics2D g = (Graphics2D)graphics.create();

      g.setColor(Color.WHITE);
      g.fillRect(0, 0, getWidth(), getHeight());

      g.setColor(Color.RED);
      g.fillRect(200, 200, 200, 200);

      g.setComposite(AlphaComposite.SrcOver.derive(0.5f));

      g.setColor(new Color(133, 156, 178));
      g.fillRect(100, 100, 200, 200);

      g.setColor(Color.BLACK);
      g.fillRect(300, 300, 200, 200);

      g.setColor(Color.GREEN);
      g.fillRect(300, 100, 200, 200);

      g.dispose();
      }
      };
      add(p);

      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setSize(800, 600);
      setVisible(true);
      }

      public static void main(String... args) {
      SwingUtilities.invokeLater(Test::new);
      }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Works OK with -Dsun.java2d.xrender=false option

      FREQUENCY : always


        Attachments

        1. 10.0.1.PNG
          10.0.1.PNG
          7 kB
        2. 11.PNG
          11.PNG
          8 kB
        3. Test.java
          0.8 kB

          Issue Links

            Activity

              People

              • Assignee:
                prr Philip Race
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: