src/solaris/classes/sun/awt/X11GraphicsDevice.java

Print this page
rev 9717 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by:


  37 import java.util.ArrayList;
  38 import java.util.HashSet;
  39 import java.util.HashMap;
  40 
  41 import sun.java2d.opengl.GLXGraphicsConfig;
  42 import sun.java2d.xr.XRGraphicsConfig;
  43 import sun.java2d.loops.SurfaceType;
  44 
  45 /**
  46  * This is an implementation of a GraphicsDevice object for a single
  47  * X11 screen.
  48  *
  49  * @see GraphicsEnvironment
  50  * @see GraphicsConfiguration
  51  */
  52 public class X11GraphicsDevice
  53     extends GraphicsDevice
  54     implements DisplayChangedListener
  55 {
  56     int screen;
  57     HashMap x11ProxyKeyMap = new HashMap();
  58 
  59     private static AWTPermission fullScreenExclusivePermission;
  60     private static Boolean xrandrExtSupported;
  61     private final Object configLock = new Object();
  62     private SunDisplayChanger topLevels = new SunDisplayChanger();
  63     private DisplayMode origDisplayMode;
  64     private boolean shutdownHookRegistered;
  65 
  66     public X11GraphicsDevice(int screennum) {
  67         this.screen = screennum;
  68     }
  69 
  70     /*
  71      * Initialize JNI field and method IDs for fields that may be
  72      * accessed from C.
  73      */
  74     private static native void initIDs();
  75 
  76     static {
  77         if (!GraphicsEnvironment.isHeadless()) {


 108      * Returns the type of the graphics device.
 109      * @see #TYPE_RASTER_SCREEN
 110      * @see #TYPE_PRINTER
 111      * @see #TYPE_IMAGE_BUFFER
 112      */
 113     public int getType() {
 114         return TYPE_RASTER_SCREEN;
 115     }
 116 
 117     /**
 118      * Returns the identification string associated with this graphics
 119      * device.
 120      */
 121     public String getIDstring() {
 122         return ":0."+screen;
 123     }
 124 
 125 
 126     GraphicsConfiguration[] configs;
 127     GraphicsConfiguration defaultConfig;
 128     HashSet doubleBufferVisuals;
 129 
 130     /**
 131      * Returns all of the graphics
 132      * configurations associated with this graphics device.
 133      */
 134     public GraphicsConfiguration[] getConfigurations() {
 135         if (configs == null) {
 136             synchronized (configLock) {
 137                 makeConfigurations();
 138             }
 139         }
 140         return configs.clone();
 141     }
 142 
 143     private void makeConfigurations() {
 144         if (configs == null) {
 145             int i = 1;  // Index 0 is always the default config
 146             int num = getNumConfigs(screen);
 147             GraphicsConfiguration[] ret = new GraphicsConfiguration[num];
 148             if (defaultConfig == null) {
 149                 ret [0] = getDefaultConfiguration();
 150             }
 151             else {
 152                 ret [0] = defaultConfig;
 153             }
 154 
 155             boolean glxSupported = X11GraphicsEnvironment.isGLXAvailable();
 156             boolean xrenderSupported = X11GraphicsEnvironment.isXRenderAvailable();
 157 
 158             boolean dbeSupported = isDBESupported();
 159             if (dbeSupported && doubleBufferVisuals == null) {
 160                 doubleBufferVisuals = new HashSet();
 161                 getDoubleBufferVisuals(screen);
 162             }
 163             for ( ; i < num; i++) {
 164                 int visNum = getConfigVisualId(i, screen);
 165                 int depth = getConfigDepth (i, screen);
 166                 if (glxSupported) {
 167                     ret[i] = GLXGraphicsConfig.getConfig(this, visNum);
 168                 }
 169                 if (ret[i] == null) {
 170                     boolean doubleBuffer =
 171                         (dbeSupported &&
 172                          doubleBufferVisuals.contains(Integer.valueOf(visNum)));
 173 
 174                     if (xrenderSupported) {
 175                         ret[i] = XRGraphicsConfig.getConfig(this, visNum, depth,                                getConfigColormap(i, screen),
 176                                 doubleBuffer);
 177                     } else {
 178                        ret[i] = X11GraphicsConfig.getConfig(this, visNum, depth,
 179                               getConfigColormap(i, screen),
 180                               doubleBuffer);


 230 
 231     private void makeDefaultConfiguration() {
 232         if (defaultConfig == null) {
 233             int visNum = getConfigVisualId(0, screen);
 234             if (X11GraphicsEnvironment.isGLXAvailable()) {
 235                 defaultConfig = GLXGraphicsConfig.getConfig(this, visNum);
 236                 if (X11GraphicsEnvironment.isGLXVerbose()) {
 237                     if (defaultConfig != null) {
 238                         System.out.print("OpenGL pipeline enabled");
 239                     } else {
 240                         System.out.print("Could not enable OpenGL pipeline");
 241                     }
 242                     System.out.println(" for default config on screen " +
 243                                        screen);
 244                 }
 245             }
 246             if (defaultConfig == null) {
 247                 int depth = getConfigDepth(0, screen);
 248                 boolean doubleBuffer = false;
 249                 if (isDBESupported() && doubleBufferVisuals == null) {
 250                     doubleBufferVisuals = new HashSet();
 251                     getDoubleBufferVisuals(screen);
 252                     doubleBuffer =
 253                         doubleBufferVisuals.contains(Integer.valueOf(visNum));
 254                 }
 255 
 256                 if (X11GraphicsEnvironment.isXRenderAvailable()) {
 257                     if (X11GraphicsEnvironment.isXRenderVerbose()) {
 258                         System.out.println("XRender pipeline enabled");
 259                     }
 260                     defaultConfig = XRGraphicsConfig.getConfig(this, visNum,
 261                             depth, getConfigColormap(0, screen),
 262                             doubleBuffer);
 263                 } else {
 264                     defaultConfig = X11GraphicsConfig.getConfig(this, visNum,
 265                                         depth, getConfigColormap(0, screen),
 266                                         doubleBuffer);
 267                 }
 268             }
 269         }
 270     }




  37 import java.util.ArrayList;
  38 import java.util.HashSet;
  39 import java.util.HashMap;
  40 
  41 import sun.java2d.opengl.GLXGraphicsConfig;
  42 import sun.java2d.xr.XRGraphicsConfig;
  43 import sun.java2d.loops.SurfaceType;
  44 
  45 /**
  46  * This is an implementation of a GraphicsDevice object for a single
  47  * X11 screen.
  48  *
  49  * @see GraphicsEnvironment
  50  * @see GraphicsConfiguration
  51  */
  52 public class X11GraphicsDevice
  53     extends GraphicsDevice
  54     implements DisplayChangedListener
  55 {
  56     int screen;
  57     HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
  58 
  59     private static AWTPermission fullScreenExclusivePermission;
  60     private static Boolean xrandrExtSupported;
  61     private final Object configLock = new Object();
  62     private SunDisplayChanger topLevels = new SunDisplayChanger();
  63     private DisplayMode origDisplayMode;
  64     private boolean shutdownHookRegistered;
  65 
  66     public X11GraphicsDevice(int screennum) {
  67         this.screen = screennum;
  68     }
  69 
  70     /*
  71      * Initialize JNI field and method IDs for fields that may be
  72      * accessed from C.
  73      */
  74     private static native void initIDs();
  75 
  76     static {
  77         if (!GraphicsEnvironment.isHeadless()) {


 108      * Returns the type of the graphics device.
 109      * @see #TYPE_RASTER_SCREEN
 110      * @see #TYPE_PRINTER
 111      * @see #TYPE_IMAGE_BUFFER
 112      */
 113     public int getType() {
 114         return TYPE_RASTER_SCREEN;
 115     }
 116 
 117     /**
 118      * Returns the identification string associated with this graphics
 119      * device.
 120      */
 121     public String getIDstring() {
 122         return ":0."+screen;
 123     }
 124 
 125 
 126     GraphicsConfiguration[] configs;
 127     GraphicsConfiguration defaultConfig;
 128     HashSet<Integer> doubleBufferVisuals;
 129 
 130     /**
 131      * Returns all of the graphics
 132      * configurations associated with this graphics device.
 133      */
 134     public GraphicsConfiguration[] getConfigurations() {
 135         if (configs == null) {
 136             synchronized (configLock) {
 137                 makeConfigurations();
 138             }
 139         }
 140         return configs.clone();
 141     }
 142 
 143     private void makeConfigurations() {
 144         if (configs == null) {
 145             int i = 1;  // Index 0 is always the default config
 146             int num = getNumConfigs(screen);
 147             GraphicsConfiguration[] ret = new GraphicsConfiguration[num];
 148             if (defaultConfig == null) {
 149                 ret [0] = getDefaultConfiguration();
 150             }
 151             else {
 152                 ret [0] = defaultConfig;
 153             }
 154 
 155             boolean glxSupported = X11GraphicsEnvironment.isGLXAvailable();
 156             boolean xrenderSupported = X11GraphicsEnvironment.isXRenderAvailable();
 157 
 158             boolean dbeSupported = isDBESupported();
 159             if (dbeSupported && doubleBufferVisuals == null) {
 160                 doubleBufferVisuals = new HashSet<>();
 161                 getDoubleBufferVisuals(screen);
 162             }
 163             for ( ; i < num; i++) {
 164                 int visNum = getConfigVisualId(i, screen);
 165                 int depth = getConfigDepth (i, screen);
 166                 if (glxSupported) {
 167                     ret[i] = GLXGraphicsConfig.getConfig(this, visNum);
 168                 }
 169                 if (ret[i] == null) {
 170                     boolean doubleBuffer =
 171                         (dbeSupported &&
 172                          doubleBufferVisuals.contains(Integer.valueOf(visNum)));
 173 
 174                     if (xrenderSupported) {
 175                         ret[i] = XRGraphicsConfig.getConfig(this, visNum, depth,                                getConfigColormap(i, screen),
 176                                 doubleBuffer);
 177                     } else {
 178                        ret[i] = X11GraphicsConfig.getConfig(this, visNum, depth,
 179                               getConfigColormap(i, screen),
 180                               doubleBuffer);


 230 
 231     private void makeDefaultConfiguration() {
 232         if (defaultConfig == null) {
 233             int visNum = getConfigVisualId(0, screen);
 234             if (X11GraphicsEnvironment.isGLXAvailable()) {
 235                 defaultConfig = GLXGraphicsConfig.getConfig(this, visNum);
 236                 if (X11GraphicsEnvironment.isGLXVerbose()) {
 237                     if (defaultConfig != null) {
 238                         System.out.print("OpenGL pipeline enabled");
 239                     } else {
 240                         System.out.print("Could not enable OpenGL pipeline");
 241                     }
 242                     System.out.println(" for default config on screen " +
 243                                        screen);
 244                 }
 245             }
 246             if (defaultConfig == null) {
 247                 int depth = getConfigDepth(0, screen);
 248                 boolean doubleBuffer = false;
 249                 if (isDBESupported() && doubleBufferVisuals == null) {
 250                     doubleBufferVisuals = new HashSet<>();
 251                     getDoubleBufferVisuals(screen);
 252                     doubleBuffer =
 253                         doubleBufferVisuals.contains(Integer.valueOf(visNum));
 254                 }
 255 
 256                 if (X11GraphicsEnvironment.isXRenderAvailable()) {
 257                     if (X11GraphicsEnvironment.isXRenderVerbose()) {
 258                         System.out.println("XRender pipeline enabled");
 259                     }
 260                     defaultConfig = XRGraphicsConfig.getConfig(this, visNum,
 261                             depth, getConfigColormap(0, screen),
 262                             doubleBuffer);
 263                 } else {
 264                     defaultConfig = X11GraphicsConfig.getConfig(this, visNum,
 265                                         depth, getConfigColormap(0, screen),
 266                                         doubleBuffer);
 267                 }
 268             }
 269         }
 270     }