< prev index next >

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

Print this page




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.java2d.opengl;
  27 
  28 import java.awt.Graphics;
  29 import java.awt.GraphicsConfiguration;
  30 import java.awt.GraphicsDevice;
  31 import java.awt.GraphicsEnvironment;
  32 import java.awt.Image;
  33 import java.awt.Rectangle;
  34 import java.awt.image.ColorModel;
  35 
  36 import sun.java2d.SunGraphics2D;
  37 import sun.java2d.SurfaceData;
  38 
  39 import sun.lwawt.macosx.CPlatformView;
  40 


  41 public abstract class CGLSurfaceData extends OGLSurfaceData {
  42 
  43     protected final int scale;
  44     protected final int width;
  45     protected final int height;
  46     protected CPlatformView pView;
  47     private CGLGraphicsConfig graphicsConfig;
  48 
  49     native void validate(int xoff, int yoff, int width, int height, boolean isOpaque);
  50 
  51     private native void initOps(long pConfigInfo, long pPeerData, long layerPtr,
  52                                 int xoff, int yoff, boolean isOpaque);
  53 
  54     protected native boolean initPbuffer(long pData, long pConfigInfo,
  55             boolean isOpaque, int width, int height);
  56 
  57     protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
  58                              int width, int height) {
  59         super(gc, cm, type);
  60         // TEXTURE shouldn't be scaled, it is used for managed BufferedImages.


  84                              ColorModel cm, int type,int width, int height)
  85     {
  86         this(gc, cm, type, width, height);
  87         this.graphicsConfig = gc;
  88 
  89         long pConfigInfo = gc.getNativeConfigInfo();
  90         long layerPtr = 0L;
  91         boolean isOpaque = true;
  92         if (layer != null) {
  93             layerPtr = layer.getPointer();
  94             isOpaque = layer.isOpaque();
  95         }
  96         initOps(pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
  97     }
  98 
  99     @Override //SurfaceData
 100     public GraphicsConfiguration getDeviceConfiguration() {
 101         return graphicsConfig;
 102     }
 103 












 104     /**
 105      * Creates a SurfaceData object representing the primary (front) buffer of
 106      * an on-screen Window.
 107      */
 108     public static CGLWindowSurfaceData createData(CPlatformView pView) {
 109         CGLGraphicsConfig gc = getGC(pView);
 110         return new CGLWindowSurfaceData(pView, gc);
 111     }
 112 
 113     /**
 114      * Creates a SurfaceData object representing the intermediate buffer
 115      * between the Java2D flusher thread and the AppKit thread.
 116      */
 117     public static CGLLayerSurfaceData createData(CGLLayer layer) {
 118         CGLGraphicsConfig gc = getGC(layer);
 119         Rectangle r = layer.getBounds();
 120         return new CGLLayerSurfaceData(layer, gc, r.width, r.height);
 121     }
 122 
 123     /**




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.java2d.opengl;
  27 
  28 import java.awt.Graphics;
  29 import java.awt.GraphicsConfiguration;
  30 import java.awt.GraphicsDevice;
  31 import java.awt.GraphicsEnvironment;
  32 import java.awt.Image;
  33 import java.awt.Rectangle;
  34 import java.awt.image.ColorModel;
  35 
  36 import sun.java2d.SunGraphics2D;
  37 import sun.java2d.SurfaceData;
  38 
  39 import sun.lwawt.macosx.CPlatformView;
  40 
  41 import static sun.java2d.opengl.OGLContext.OGLContextCaps.CAPS_EXT_LCD_SHADER;
  42 
  43 public abstract class CGLSurfaceData extends OGLSurfaceData {
  44 
  45     protected final int scale;
  46     protected final int width;
  47     protected final int height;
  48     protected CPlatformView pView;
  49     private CGLGraphicsConfig graphicsConfig;
  50 
  51     native void validate(int xoff, int yoff, int width, int height, boolean isOpaque);
  52 
  53     private native void initOps(long pConfigInfo, long pPeerData, long layerPtr,
  54                                 int xoff, int yoff, boolean isOpaque);
  55 
  56     protected native boolean initPbuffer(long pData, long pConfigInfo,
  57             boolean isOpaque, int width, int height);
  58 
  59     protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
  60                              int width, int height) {
  61         super(gc, cm, type);
  62         // TEXTURE shouldn't be scaled, it is used for managed BufferedImages.


  86                              ColorModel cm, int type,int width, int height)
  87     {
  88         this(gc, cm, type, width, height);
  89         this.graphicsConfig = gc;
  90 
  91         long pConfigInfo = gc.getNativeConfigInfo();
  92         long layerPtr = 0L;
  93         boolean isOpaque = true;
  94         if (layer != null) {
  95             layerPtr = layer.getPointer();
  96             isOpaque = layer.isOpaque();
  97         }
  98         initOps(pConfigInfo, 0, layerPtr, 0, 0, isOpaque);
  99     }
 100 
 101     @Override //SurfaceData
 102     public GraphicsConfiguration getDeviceConfiguration() {
 103         return graphicsConfig;
 104     }
 105 
 106     @Override
 107     public boolean canRenderLCDText(SunGraphics2D sg2d) {
 108         // relax the condition to render the lcd text
 109         // by removal the transparency check, because
 110         // we have to create translucent buffers due to
 111         // shaped windows support on macosx.
 112         return getOGLGraphicsConfig().isCapPresent(CAPS_EXT_LCD_SHADER) &&
 113                sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
 114                sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR;
 115     }
 116 
 117 
 118     /**
 119      * Creates a SurfaceData object representing the primary (front) buffer of
 120      * an on-screen Window.
 121      */
 122     public static CGLWindowSurfaceData createData(CPlatformView pView) {
 123         CGLGraphicsConfig gc = getGC(pView);
 124         return new CGLWindowSurfaceData(pView, gc);
 125     }
 126 
 127     /**
 128      * Creates a SurfaceData object representing the intermediate buffer
 129      * between the Java2D flusher thread and the AppKit thread.
 130      */
 131     public static CGLLayerSurfaceData createData(CGLLayer layer) {
 132         CGLGraphicsConfig gc = getGC(layer);
 133         Rectangle r = layer.getBounds();
 134         return new CGLLayerSurfaceData(layer, gc, r.width, r.height);
 135     }
 136 
 137     /**


< prev index next >