< prev index next >

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

Print this page




  58 import sun.lwawt.macosx.CPlatformView;
  59 
  60 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_DOUBLEBUFFERED;
  61 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
  62 import static sun.java2d.opengl.OGLSurfaceData.FBOBJECT;
  63 import static sun.java2d.opengl.OGLSurfaceData.TEXTURE;
  64 
  65 public final class CGLGraphicsConfig extends CGraphicsConfig
  66     implements OGLGraphicsConfig
  67 {
  68     //private static final int kOpenGLSwapInterval =
  69     // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
  70     private static final int kOpenGLSwapInterval = 0; // TODO
  71     private static boolean cglAvailable;
  72     private static ImageCapabilities imageCaps = new CGLImageCaps();
  73 
  74     private int pixfmt;
  75     private BufferCapabilities bufferCaps;
  76     private long pConfigInfo;
  77     private ContextCapabilities oglCaps;
  78     private OGLContext context;
  79     private final Object disposerReferent = new Object();
  80     private final int maxTextureSize;
  81 
  82     private static native boolean initCGL();
  83     private static native long getCGLConfigInfo(int displayID, int visualnum,
  84                                                 int swapInterval);
  85     private static native int getOGLCapabilities(long configInfo);
  86 
  87     /**
  88      * Returns GL_MAX_TEXTURE_SIZE from the shared opengl context. Must be
  89      * called under OGLRQ lock, because this method change current context.
  90      *
  91      * @return GL_MAX_TEXTURE_SIZE
  92      */
  93     private static native int nativeGetMaxTextureSize();
  94 
  95     static {
  96         cglAvailable = initCGL();
  97     }
  98 
  99     private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
 100                               long configInfo, int maxTextureSize,
 101                               ContextCapabilities oglCaps) {
 102         super(device);
 103 
 104         this.pixfmt = pixfmt;
 105         this.pConfigInfo = configInfo;
 106         this.oglCaps = oglCaps;
 107         this.maxTextureSize = maxTextureSize;
 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 
 116     @Override
 117     public Object getProxyKey() {
 118         return this;
 119     }
 120 
 121     @Override
 122     public SurfaceData createManagedSurface(int w, int h, int transparency) {
 123         return CGLSurfaceData.createData(this, w, h,
 124                                          getColorModel(transparency),
 125                                          null,
 126                                          OGLSurfaceData.TEXTURE);
 127     }
 128 




  58 import sun.lwawt.macosx.CPlatformView;
  59 
  60 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_DOUBLEBUFFERED;
  61 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
  62 import static sun.java2d.opengl.OGLSurfaceData.FBOBJECT;
  63 import static sun.java2d.opengl.OGLSurfaceData.TEXTURE;
  64 
  65 public final class CGLGraphicsConfig extends CGraphicsConfig
  66     implements OGLGraphicsConfig
  67 {
  68     //private static final int kOpenGLSwapInterval =
  69     // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
  70     private static final int kOpenGLSwapInterval = 0; // TODO
  71     private static boolean cglAvailable;
  72     private static ImageCapabilities imageCaps = new CGLImageCaps();
  73 
  74     private int pixfmt;
  75     private BufferCapabilities bufferCaps;
  76     private long pConfigInfo;
  77     private ContextCapabilities oglCaps;
  78     private final OGLContext context;
  79     private final Object disposerReferent = new Object();
  80     private final int maxTextureSize;
  81 
  82     private static native boolean initCGL();
  83     private static native long getCGLConfigInfo(int displayID, int visualnum,
  84                                                 int swapInterval);
  85     private static native int getOGLCapabilities(long configInfo);
  86 
  87     /**
  88      * Returns GL_MAX_TEXTURE_SIZE from the shared opengl context. Must be
  89      * called under OGLRQ lock, because this method change current context.
  90      *
  91      * @return GL_MAX_TEXTURE_SIZE
  92      */
  93     private static native int nativeGetMaxTextureSize();
  94 
  95     static {
  96         cglAvailable = initCGL();
  97     }
  98 
  99     private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
 100                               long configInfo, int maxTextureSize,
 101                               ContextCapabilities oglCaps) {
 102         super(device);
 103 
 104         this.pixfmt = pixfmt;
 105         this.pConfigInfo = configInfo;
 106         this.oglCaps = oglCaps;
 107         this.maxTextureSize = maxTextureSize;
 108         context = new OGLContext(OGLRenderQueue.getInstance());
 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 
 116     @Override
 117     public Object getProxyKey() {
 118         return this;
 119     }
 120 
 121     @Override
 122     public SurfaceData createManagedSurface(int w, int h, int transparency) {
 123         return CGLSurfaceData.createData(this, w, h,
 124                                          getColorModel(transparency),
 125                                          null,
 126                                          OGLSurfaceData.TEXTURE);
 127     }
 128 


< prev index next >