< prev index next >

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

Print this page




  34 import java.awt.ImageCapabilities;
  35 import java.awt.Rectangle;
  36 import java.awt.Transparency;
  37 import java.awt.color.ColorSpace;
  38 import java.awt.image.BufferedImage;
  39 import java.awt.image.ColorModel;
  40 import java.awt.image.DataBuffer;
  41 import java.awt.image.DirectColorModel;
  42 import java.awt.image.VolatileImage;
  43 import java.awt.image.WritableRaster;
  44 
  45 import sun.awt.CGraphicsConfig;
  46 import sun.awt.CGraphicsDevice;
  47 import sun.awt.image.OffScreenImage;
  48 import sun.awt.image.SunVolatileImage;
  49 import sun.java2d.Disposer;
  50 import sun.java2d.DisposerRecord;
  51 import sun.java2d.Surface;
  52 import sun.java2d.SurfaceData;
  53 import sun.java2d.opengl.OGLContext.OGLContextCaps;
  54 import sun.java2d.metal.MetalLayer;
  55 import sun.java2d.pipe.hw.AccelSurface;
  56 import sun.java2d.pipe.hw.AccelTypedVolatileImage;
  57 import sun.java2d.pipe.hw.ContextCapabilities;
  58 import sun.lwawt.LWComponentPeer;

  59 import sun.lwawt.macosx.CPlatformView;
  60 
  61 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_DOUBLEBUFFERED;
  62 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
  63 import static sun.java2d.opengl.OGLSurfaceData.FBOBJECT;
  64 import static sun.java2d.opengl.OGLSurfaceData.TEXTURE;
  65 
  66 public final class CGLGraphicsConfig extends CGraphicsConfig
  67     implements OGLGraphicsConfig
  68 {
  69     //private static final int kOpenGLSwapInterval =
  70     // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
  71     private static final int kOpenGLSwapInterval = 0; // TODO
  72     private static boolean cglAvailable;
  73     private static ImageCapabilities imageCaps = new CGLImageCaps();
  74 
  75     private int pixfmt;
  76     private BufferCapabilities bufferCaps;
  77     private long pConfigInfo;
  78     private ContextCapabilities oglCaps;


 248         rq.lock();
 249         try {
 250             OGLContext.invalidateCurrentContext();
 251         } finally {
 252             rq.unlock();
 253         }
 254     }
 255 
 256     @Override
 257     public String toString() {
 258         String display = getDevice().getIDstring();
 259         return ("CGLGraphicsConfig[" + display + ", pixfmt=" + pixfmt + "]");
 260     }
 261 
 262     @Override
 263     public SurfaceData createSurfaceData(CPlatformView pView) {
 264         return CGLSurfaceData.createData(pView);
 265     }
 266 
 267     @Override
 268     public SurfaceData createSurfaceData(CGLLayer layer) {
 269         return CGLSurfaceData.createData(layer);
 270     }
 271 
 272     @Override
 273     public SurfaceData createSurfaceData(MetalLayer layer) {
 274         return null;
 275     }
 276 
 277     @Override
 278     public Image createAcceleratedImage(Component target,
 279                                         int width, int height)
 280     {
 281         ColorModel model = getColorModel(Transparency.OPAQUE);
 282         WritableRaster wr = model.createCompatibleWritableRaster(width, height);
 283         return new OffScreenImage(target, model, wr,
 284                                   model.isAlphaPremultiplied());
 285     }
 286 
 287     @Override
 288     public void assertOperationSupported(final int numBuffers,
 289                                          final BufferCapabilities caps)
 290             throws AWTException {
 291         // Assume this method is never called with numBuffers != 2, as 0 is
 292         // unsupported, and 1 corresponds to a SingleBufferStrategy which
 293         // doesn't depend on the peer. Screen is considered as a separate
 294         // "buffer".




  34 import java.awt.ImageCapabilities;
  35 import java.awt.Rectangle;
  36 import java.awt.Transparency;
  37 import java.awt.color.ColorSpace;
  38 import java.awt.image.BufferedImage;
  39 import java.awt.image.ColorModel;
  40 import java.awt.image.DataBuffer;
  41 import java.awt.image.DirectColorModel;
  42 import java.awt.image.VolatileImage;
  43 import java.awt.image.WritableRaster;
  44 
  45 import sun.awt.CGraphicsConfig;
  46 import sun.awt.CGraphicsDevice;
  47 import sun.awt.image.OffScreenImage;
  48 import sun.awt.image.SunVolatileImage;
  49 import sun.java2d.Disposer;
  50 import sun.java2d.DisposerRecord;
  51 import sun.java2d.Surface;
  52 import sun.java2d.SurfaceData;
  53 import sun.java2d.opengl.OGLContext.OGLContextCaps;

  54 import sun.java2d.pipe.hw.AccelSurface;
  55 import sun.java2d.pipe.hw.AccelTypedVolatileImage;
  56 import sun.java2d.pipe.hw.ContextCapabilities;
  57 import sun.lwawt.LWComponentPeer;
  58 import sun.lwawt.macosx.CFRetainedResource;
  59 import sun.lwawt.macosx.CPlatformView;
  60 
  61 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_DOUBLEBUFFERED;
  62 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_FBOBJECT;
  63 import static sun.java2d.opengl.OGLSurfaceData.FBOBJECT;
  64 import static sun.java2d.opengl.OGLSurfaceData.TEXTURE;
  65 
  66 public final class CGLGraphicsConfig extends CGraphicsConfig
  67         implements OGLGraphicsConfig
  68 {
  69     //private static final int kOpenGLSwapInterval =
  70     // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
  71     private static final int kOpenGLSwapInterval = 0; // TODO
  72     private static boolean cglAvailable;
  73     private static ImageCapabilities imageCaps = new CGLImageCaps();
  74 
  75     private int pixfmt;
  76     private BufferCapabilities bufferCaps;
  77     private long pConfigInfo;
  78     private ContextCapabilities oglCaps;


 248         rq.lock();
 249         try {
 250             OGLContext.invalidateCurrentContext();
 251         } finally {
 252             rq.unlock();
 253         }
 254     }
 255 
 256     @Override
 257     public String toString() {
 258         String display = getDevice().getIDstring();
 259         return ("CGLGraphicsConfig[" + display + ", pixfmt=" + pixfmt + "]");
 260     }
 261 
 262     @Override
 263     public SurfaceData createSurfaceData(CPlatformView pView) {
 264         return CGLSurfaceData.createData(pView);
 265     }
 266 
 267     @Override
 268     public SurfaceData createSurfaceData(CFRetainedResource layer) {
 269         return CGLSurfaceData.createData((CGLLayer) layer);





 270     }
 271 
 272     @Override
 273     public Image createAcceleratedImage(Component target,
 274                                         int width, int height)
 275     {
 276         ColorModel model = getColorModel(Transparency.OPAQUE);
 277         WritableRaster wr = model.createCompatibleWritableRaster(width, height);
 278         return new OffScreenImage(target, model, wr,
 279                 model.isAlphaPremultiplied());
 280     }
 281 
 282     @Override
 283     public void assertOperationSupported(final int numBuffers,
 284                                          final BufferCapabilities caps)
 285             throws AWTException {
 286         // Assume this method is never called with numBuffers != 2, as 0 is
 287         // unsupported, and 1 corresponds to a SingleBufferStrategy which
 288         // doesn't depend on the peer. Screen is considered as a separate
 289         // "buffer".


< prev index next >