< 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.


 325 
 326         @Override
 327         public void flush() {
 328             flipSurface.flush();
 329             super.flush();
 330         }
 331     }
 332 
 333     public static class CGLOffScreenSurfaceData extends CGLSurfaceData {
 334         private Image offscreenImage;
 335 
 336         public CGLOffScreenSurfaceData(CPlatformView pView,
 337                                        CGLGraphicsConfig gc, int width, int height, Image image,
 338                                        ColorModel cm, int type) {
 339             super(pView, gc, cm, type, width, height);
 340             offscreenImage = image;
 341             initSurface(this.width, this.height);
 342         }
 343 
 344         @Override












 345         public SurfaceData getReplacement() {
 346             return restoreContents(offscreenImage);
 347         }
 348 
 349         @Override
 350         public Rectangle getBounds() {
 351             if (type == FLIP_BACKBUFFER) {
 352                 Rectangle r = pView.getBounds();
 353                 return new Rectangle(0, 0, r.width, r.height);
 354             } else {
 355                 return new Rectangle(width, height);
 356             }
 357         }
 358 
 359         /**
 360          * Returns destination Image associated with this SurfaceData.
 361          */
 362         @Override
 363         public Object getDestination() {
 364             return offscreenImage;




  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.


 327 
 328         @Override
 329         public void flush() {
 330             flipSurface.flush();
 331             super.flush();
 332         }
 333     }
 334 
 335     public static class CGLOffScreenSurfaceData extends CGLSurfaceData {
 336         private Image offscreenImage;
 337 
 338         public CGLOffScreenSurfaceData(CPlatformView pView,
 339                                        CGLGraphicsConfig gc, int width, int height, Image image,
 340                                        ColorModel cm, int type) {
 341             super(pView, gc, cm, type, width, height);
 342             offscreenImage = image;
 343             initSurface(this.width, this.height);
 344         }
 345 
 346         @Override
 347         public boolean canRenderLCDText(SunGraphics2D sg2d) {
 348             // relax the condition to render the lcd text
 349             // by removal the transparency check, because
 350             // we have to create translucent buffers due to
 351             // shaped windows support on macosx.
 352             return
 353                 getOGLGraphicsConfig().isCapPresent(CAPS_EXT_LCD_SHADER) &&
 354                 sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
 355                 sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR;
 356         }
 357 
 358         @Override
 359         public SurfaceData getReplacement() {
 360             return restoreContents(offscreenImage);
 361         }
 362 
 363         @Override
 364         public Rectangle getBounds() {
 365             if (type == FLIP_BACKBUFFER) {
 366                 Rectangle r = pView.getBounds();
 367                 return new Rectangle(0, 0, r.width, r.height);
 368             } else {
 369                 return new Rectangle(width, height);
 370             }
 371         }
 372 
 373         /**
 374          * Returns destination Image associated with this SurfaceData.
 375          */
 376         @Override
 377         public Object getDestination() {
 378             return offscreenImage;


< prev index next >