< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  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


  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.
  61         scale = type == TEXTURE ? 1 : gc.getDevice().getScaleFactor();
  62         this.width = width * scale;
  63         this.height = height * scale;
  64     }
  65 
  66     protected CGLSurfaceData(CPlatformView pView, CGLGraphicsConfig gc,
  67                              ColorModel cm, int type,int width, int height)
  68     {
  69         this(gc, cm, type, width, height);
  70         this.pView = pView;
  71         this.graphicsConfig = gc;
  72 
  73         long pConfigInfo = gc.getNativeConfigInfo();
  74         long pPeerData = 0L;
  75         boolean isOpaque = true;
  76         if (pView != null) {


 122 
 123     /**
 124      * Creates a SurfaceData object representing the back buffer of a
 125      * double-buffered on-screen Window.
 126      */
 127     public static CGLOffScreenSurfaceData createData(CPlatformView pView,
 128             Image image, int type) {
 129         CGLGraphicsConfig gc = getGC(pView);
 130         Rectangle r = pView.getBounds();
 131         if (type == FLIP_BACKBUFFER) {
 132             return new CGLOffScreenSurfaceData(pView, gc, r.width, r.height,
 133                     image, gc.getColorModel(), FLIP_BACKBUFFER);
 134         } else {
 135             return new CGLVSyncOffScreenSurfaceData(pView, gc, r.width,
 136                     r.height, image, gc.getColorModel(), type);
 137         }
 138     }
 139 
 140     /**
 141      * Creates a SurfaceData object representing an off-screen buffer (either a
 142      * Pbuffer or Texture).
 143      */
 144     public static CGLOffScreenSurfaceData createData(CGLGraphicsConfig gc,
 145             int width, int height, ColorModel cm, Image image, int type) {
 146         return new CGLOffScreenSurfaceData(null, gc, width, height, image, cm,
 147                 type);
 148     }
 149 
 150     public static CGLGraphicsConfig getGC(CPlatformView pView) {
 151         if (pView != null) {
 152             return (CGLGraphicsConfig)pView.getGraphicsConfiguration();
 153         } else {
 154             // REMIND: this should rarely (never?) happen, but what if
 155             // default config is not CGL?
 156             GraphicsEnvironment env = GraphicsEnvironment
 157                 .getLocalGraphicsEnvironment();
 158             GraphicsDevice gd = env.getDefaultScreenDevice();
 159             return (CGLGraphicsConfig) gd.getDefaultConfiguration();
 160         }
 161     }
 162 


   1 /*
   2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  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


  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 CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
  55                              int width, int height) {
  56         super(gc, cm, type);
  57         // TEXTURE shouldn't be scaled, it is used for managed BufferedImages.
  58         scale = type == TEXTURE ? 1 : gc.getDevice().getScaleFactor();
  59         this.width = width * scale;
  60         this.height = height * scale;
  61     }
  62 
  63     protected CGLSurfaceData(CPlatformView pView, CGLGraphicsConfig gc,
  64                              ColorModel cm, int type,int width, int height)
  65     {
  66         this(gc, cm, type, width, height);
  67         this.pView = pView;
  68         this.graphicsConfig = gc;
  69 
  70         long pConfigInfo = gc.getNativeConfigInfo();
  71         long pPeerData = 0L;
  72         boolean isOpaque = true;
  73         if (pView != null) {


 119 
 120     /**
 121      * Creates a SurfaceData object representing the back buffer of a
 122      * double-buffered on-screen Window.
 123      */
 124     public static CGLOffScreenSurfaceData createData(CPlatformView pView,
 125             Image image, int type) {
 126         CGLGraphicsConfig gc = getGC(pView);
 127         Rectangle r = pView.getBounds();
 128         if (type == FLIP_BACKBUFFER) {
 129             return new CGLOffScreenSurfaceData(pView, gc, r.width, r.height,
 130                     image, gc.getColorModel(), FLIP_BACKBUFFER);
 131         } else {
 132             return new CGLVSyncOffScreenSurfaceData(pView, gc, r.width,
 133                     r.height, image, gc.getColorModel(), type);
 134         }
 135     }
 136 
 137     /**
 138      * Creates a SurfaceData object representing an off-screen buffer (either a
 139      * FBO or Texture).
 140      */
 141     public static CGLOffScreenSurfaceData createData(CGLGraphicsConfig gc,
 142             int width, int height, ColorModel cm, Image image, int type) {
 143         return new CGLOffScreenSurfaceData(null, gc, width, height, image, cm,
 144                 type);
 145     }
 146 
 147     public static CGLGraphicsConfig getGC(CPlatformView pView) {
 148         if (pView != null) {
 149             return (CGLGraphicsConfig)pView.getGraphicsConfiguration();
 150         } else {
 151             // REMIND: this should rarely (never?) happen, but what if
 152             // default config is not CGL?
 153             GraphicsEnvironment env = GraphicsEnvironment
 154                 .getLocalGraphicsEnvironment();
 155             GraphicsDevice gd = env.getDefaultScreenDevice();
 156             return (CGLGraphicsConfig) gd.getDefaultConfiguration();
 157         }
 158     }
 159 


< prev index next >