src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java

Print this page




  67 import sun.java2d.pipe.hw.AccelDeviceEventListener;
  68 import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
  69 
  70 import sun.lwawt.macosx.CPlatformView;
  71 
  72 public class CGLGraphicsConfig extends CGraphicsConfig
  73     implements OGLGraphicsConfig, TextureSizeConstraining
  74 {
  75     //private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
  76     private static final int kOpenGLSwapInterval = 0; // TODO
  77     protected static boolean cglAvailable;
  78     private static ImageCapabilities imageCaps = new CGLImageCaps();
  79 
  80     private int pixfmt;
  81     private BufferCapabilities bufferCaps;
  82     private long pConfigInfo;
  83     private ContextCapabilities oglCaps;
  84     private OGLContext context;
  85     private Object disposerReferent = new Object();
  86 


  87     public static native int getDefaultPixFmt(int screennum);
  88     private static native boolean initCGL();
  89     private static native long getCGLConfigInfo(int screennum, int visualnum,
  90                                                 int swapInterval);
  91     private static native int getOGLCapabilities(long configInfo);

  92 
  93     static {
  94         cglAvailable = initCGL();
  95     }
  96 
  97     protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
  98                                 long configInfo, ContextCapabilities oglCaps)
  99     {
 100         super(device);
 101 
 102         this.pixfmt = pixfmt;
 103         this.pConfigInfo = configInfo;
 104         this.oglCaps = oglCaps;
 105         context = new OGLContext(OGLRenderQueue.getInstance(), this);
 106 
 107         // add a record to the Disposer so that we destroy the native
 108         // CGLGraphicsConfigInfo data when this object goes away
 109         Disposer.addRecord(disposerReferent,
 110                            new CGLGCDisposerRecord(pConfigInfo));




 111     }
 112 
 113     @Override
 114     public Object getProxyKey() {
 115         return this;
 116     }
 117 
 118     @Override
 119     public SurfaceData createManagedSurface(int w, int h, int transparency) {
 120         return CGLSurfaceData.createData(this, w, h,
 121                                          getColorModel(transparency),
 122                                          null,
 123                                          OGLSurfaceData.TEXTURE);
 124     }
 125 
 126     public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
 127                                               int pixfmt)
 128     {
 129         if (!cglAvailable) {
 130             return null;


 483     }
 484 
 485     public void removeDeviceEventListener(AccelDeviceEventListener l) {
 486         AccelDeviceEventNotifier.removeListener(l);
 487     }
 488 
 489     private static final Rectangle totalDisplayBounds = new Rectangle();
 490 
 491     private static void updateTotalDisplayBounds() {
 492         synchronized (totalDisplayBounds) {
 493             Rectangle virtualBounds = new Rectangle();
 494             for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
 495                 for (GraphicsConfiguration gc : gd.getConfigurations()) {
 496                     virtualBounds = virtualBounds.union(gc.getBounds());
 497                 }
 498             }
 499             totalDisplayBounds.setBounds(virtualBounds);
 500         }
 501     }
 502 

 503     // 7160609: GL still fails to create a square texture of this size,
 504     //          so we use this value to cap the total display bounds.
 505     native private static int getMaxTextureSize();


 506 
 507     @Override
 508     public int getMaxTextureWidth() {
 509         int width;
 510 
 511         synchronized (totalDisplayBounds) {
 512             if (totalDisplayBounds.width == 0) {
 513                 updateTotalDisplayBounds();
 514             }
 515             width = totalDisplayBounds.width;
 516         }
 517 
 518         return Math.min(width, getMaxTextureSize());
 519     }
 520 
 521     @Override
 522     public int getMaxTextureHeight() {
 523         int height;
 524 
 525         synchronized (totalDisplayBounds) {


  67 import sun.java2d.pipe.hw.AccelDeviceEventListener;
  68 import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
  69 
  70 import sun.lwawt.macosx.CPlatformView;
  71 
  72 public class CGLGraphicsConfig extends CGraphicsConfig
  73     implements OGLGraphicsConfig, TextureSizeConstraining
  74 {
  75     //private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
  76     private static final int kOpenGLSwapInterval = 0; // TODO
  77     protected static boolean cglAvailable;
  78     private static ImageCapabilities imageCaps = new CGLImageCaps();
  79 
  80     private int pixfmt;
  81     private BufferCapabilities bufferCaps;
  82     private long pConfigInfo;
  83     private ContextCapabilities oglCaps;
  84     private OGLContext context;
  85     private Object disposerReferent = new Object();
  86 
  87     private final int cachedMaxTextureSize;
  88 
  89     public static native int getDefaultPixFmt(int screennum);
  90     private static native boolean initCGL();
  91     private static native long getCGLConfigInfo(int screennum, int visualnum,
  92                                                 int swapInterval);
  93     private static native int getOGLCapabilities(long configInfo);
  94     private static native int _getMaxTextureSize();
  95 
  96     static {
  97         cglAvailable = initCGL();
  98     }
  99 
 100     protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
 101                                 long configInfo, ContextCapabilities oglCaps)
 102     {
 103         super(device);
 104 
 105         this.pixfmt = pixfmt;
 106         this.pConfigInfo = configInfo;
 107         this.oglCaps = oglCaps;
 108         context = new OGLContext(OGLRenderQueue.getInstance(), this);
 109 
 110         // add a record to the Disposer so that we destroy the native
 111         // CGLGraphicsConfigInfo data when this object goes away
 112         Disposer.addRecord(disposerReferent,
 113                            new CGLGCDisposerRecord(pConfigInfo));
 114 
 115         // 7200762: Workaround a deadlock by caching the value
 116         //          A fix for JDK 8 will remove the workaround
 117         this.cachedMaxTextureSize = _getMaxTextureSize();
 118     }
 119 
 120     @Override
 121     public Object getProxyKey() {
 122         return this;
 123     }
 124 
 125     @Override
 126     public SurfaceData createManagedSurface(int w, int h, int transparency) {
 127         return CGLSurfaceData.createData(this, w, h,
 128                                          getColorModel(transparency),
 129                                          null,
 130                                          OGLSurfaceData.TEXTURE);
 131     }
 132 
 133     public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
 134                                               int pixfmt)
 135     {
 136         if (!cglAvailable) {
 137             return null;


 490     }
 491 
 492     public void removeDeviceEventListener(AccelDeviceEventListener l) {
 493         AccelDeviceEventNotifier.removeListener(l);
 494     }
 495 
 496     private static final Rectangle totalDisplayBounds = new Rectangle();
 497 
 498     private static void updateTotalDisplayBounds() {
 499         synchronized (totalDisplayBounds) {
 500             Rectangle virtualBounds = new Rectangle();
 501             for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
 502                 for (GraphicsConfiguration gc : gd.getConfigurations()) {
 503                     virtualBounds = virtualBounds.union(gc.getBounds());
 504                 }
 505             }
 506             totalDisplayBounds.setBounds(virtualBounds);
 507         }
 508     }
 509 
 510 
 511     // 7160609: GL still fails to create a square texture of this size,
 512     //          so we use this value to cap the total display bounds.
 513     private int getMaxTextureSize() {
 514         return cachedMaxTextureSize;
 515     }
 516 
 517     @Override
 518     public int getMaxTextureWidth() {
 519         int width;
 520 
 521         synchronized (totalDisplayBounds) {
 522             if (totalDisplayBounds.width == 0) {
 523                 updateTotalDisplayBounds();
 524             }
 525             width = totalDisplayBounds.width;
 526         }
 527 
 528         return Math.min(width, getMaxTextureSize());
 529     }
 530 
 531     @Override
 532     public int getMaxTextureHeight() {
 533         int height;
 534 
 535         synchronized (totalDisplayBounds) {