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

Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr


  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 import sun.awt.util.ThreadGroupUtils;
  46 
  47 /**
  48  * This is an implementation of a GraphicsDevice object for a single
  49  * X11 screen.
  50  *
  51  * @see GraphicsEnvironment
  52  * @see GraphicsConfiguration
  53  */
  54 public class X11GraphicsDevice
  55     extends GraphicsDevice
  56     implements DisplayChangedListener
  57 {
  58     int screen;
  59     HashMap x11ProxyKeyMap = new HashMap();
  60 
  61     private static AWTPermission fullScreenExclusivePermission;
  62     private static Boolean xrandrExtSupported;
  63     private final Object configLock = new Object();
  64     private SunDisplayChanger topLevels = new SunDisplayChanger();
  65     private DisplayMode origDisplayMode;
  66     private boolean shutdownHookRegistered;
  67 
  68     public X11GraphicsDevice(int screennum) {
  69         this.screen = screennum;
  70     }
  71 
  72     /*
  73      * Initialize JNI field and method IDs for fields that may be
  74      * accessed from C.
  75      */
  76     private static native void initIDs();
  77 
  78     static {
  79         if (!GraphicsEnvironment.isHeadless()) {


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


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




  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 import sun.awt.util.ThreadGroupUtils;
  46 
  47 /**
  48  * This is an implementation of a GraphicsDevice object for a single
  49  * X11 screen.
  50  *
  51  * @see GraphicsEnvironment
  52  * @see GraphicsConfiguration
  53  */
  54 public class X11GraphicsDevice
  55     extends GraphicsDevice
  56     implements DisplayChangedListener
  57 {
  58     int screen;
  59     HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
  60 
  61     private static AWTPermission fullScreenExclusivePermission;
  62     private static Boolean xrandrExtSupported;
  63     private final Object configLock = new Object();
  64     private SunDisplayChanger topLevels = new SunDisplayChanger();
  65     private DisplayMode origDisplayMode;
  66     private boolean shutdownHookRegistered;
  67 
  68     public X11GraphicsDevice(int screennum) {
  69         this.screen = screennum;
  70     }
  71 
  72     /*
  73      * Initialize JNI field and method IDs for fields that may be
  74      * accessed from C.
  75      */
  76     private static native void initIDs();
  77 
  78     static {
  79         if (!GraphicsEnvironment.isHeadless()) {


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


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