src/macosx/classes/sun/awt/CGraphicsConfig.java

Print this page




  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
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.*;
  30 import java.awt.image.*;
  31 
  32 import sun.java2d.SurfaceData;
  33 import sun.java2d.opengl.CGLLayer;

  34 import sun.lwawt.macosx.CPlatformView;
  35 
  36 public class CGraphicsConfig extends GraphicsConfiguration {


  37     private final CGraphicsDevice device;
  38     private ColorModel colorModel;
  39 
  40     public CGraphicsConfig(CGraphicsDevice device) {
  41         this.device = device;
  42     }
  43 
  44     @Override
  45     public BufferedImage createCompatibleImage(int width, int height) {
  46         throw new UnsupportedOperationException("not implemented");
  47     }
  48 
  49     private static native Rectangle2D nativeGetBounds(int screen);
  50 
  51     @Override
  52     public Rectangle getBounds() {
  53         final Rectangle2D nativeBounds = nativeGetBounds(device.getCoreGraphicsScreen());
  54         return nativeBounds.getBounds(); // does integer rounding
  55     }
  56 
  57     @Override
  58     public ColorModel getColorModel() {
  59         if (colorModel == null) {
  60             colorModel = getColorModel(Transparency.OPAQUE);


  67         throw new UnsupportedOperationException("not implemented");
  68     }
  69 
  70     @Override
  71     public AffineTransform getDefaultTransform() {
  72         return new AffineTransform();
  73     }
  74 
  75     @Override
  76     public CGraphicsDevice getDevice() {
  77         return device;
  78     }
  79 
  80     @Override
  81     public AffineTransform getNormalizingTransform() {
  82         double xscale = device.getXResolution() / 72.0;
  83         double yscale = device.getYResolution() / 72.0;
  84         return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
  85     }
  86 
  87 
  88     /**
  89      * The following methods are invoked from CToolkit.java and
  90      * LWWindowPeer.java rather than having the native
  91      * implementations hardcoded in those classes.  This way the appropriate
  92      * actions are taken based on the peer's GraphicsConfig, whether it is
  93      * an CGLGraphicsConfig or something else.
  94      */
  95 
  96     /**
  97      * Creates a new SurfaceData that will be associated with the given
  98      * LWWindowPeer.
  99      */
 100     public SurfaceData createSurfaceData(CPlatformView pView) {
 101         throw new UnsupportedOperationException("not implemented");
 102     }
 103 
 104     /**
 105      * Creates a new SurfaceData that will be associated with the given
 106      * CGLLayer.
 107      */
 108     public SurfaceData createSurfaceData(CGLLayer layer) {
 109         throw new UnsupportedOperationException("not implemented");
 110     }
 111 
 112     /**
 113      * Creates a new hidden-acceleration image of the given width and height
 114      * that is associated with the target Component.
 115      */
 116     public Image createAcceleratedImage(Component target,
 117                                         int width, int height)
 118     {
 119         throw new UnsupportedOperationException("not implemented");
 120     }
 121 
 122     /**
 123      * The following methods correspond to the multibuffering methods in
 124      * LWWindowPeer.java...
 125      */
 126 
 127     /**
 128      * Attempts to create a native backbuffer for the given peer.  If
 129      * the requested configuration is not natively supported, an AWTException
 130      * is thrown.  Otherwise, if the backbuffer creation is successful, a
 131      * handle to the native backbuffer is returned.
 132      */
 133     public long createBackBuffer(CPlatformView pView,
 134                                  int numBuffers, BufferCapabilities caps)
 135         throws AWTException
 136     {
 137         throw new UnsupportedOperationException("not implemented");
 138     }
 139 
 140     public void destroyBackBuffer(long backBuffer)
 141         throws AWTException
 142     {
 143         throw new UnsupportedOperationException("not implemented");
 144     }
 145 
 146     /**
 147      * Creates a VolatileImage that essentially wraps the target Component's
 148      * backbuffer, using the provided backbuffer handle.
 149      */
 150     public VolatileImage createBackBufferImage(Component target,
 151                                                long backBuffer)
 152     {
 153         throw new UnsupportedOperationException("not implemented");
 154     }
 155 
 156     /**
 157      * Performs the native flip operation for the given target Component.
 158      */
 159     public void flip(CPlatformView delegate,
 160                      Component target, VolatileImage xBackBuffer,
 161                      int x1, int y1, int x2, int y2,
 162                      BufferCapabilities.FlipContents flipAction)
 163     {
 164         throw new UnsupportedOperationException("not implemented");
 165     }
 166 
 167     @Override
 168     public boolean isTranslucencyCapable() {
 169         //we know for sure we have capable config :)
 170         return true;
 171     }
 172 }


  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
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.*;
  29 import java.awt.geom.*;
  30 import java.awt.image.*;
  31 
  32 import sun.java2d.SurfaceData;
  33 import sun.java2d.opengl.CGLLayer;
  34 import sun.lwawt.LWGraphicsConfig;
  35 import sun.lwawt.macosx.CPlatformView;
  36 
  37 public abstract class CGraphicsConfig extends GraphicsConfiguration
  38         implements LWGraphicsConfig {
  39 
  40     private final CGraphicsDevice device;
  41     private ColorModel colorModel;
  42 
  43     protected CGraphicsConfig(CGraphicsDevice device) {
  44         this.device = device;
  45     }
  46 
  47     @Override
  48     public BufferedImage createCompatibleImage(int width, int height) {
  49         throw new UnsupportedOperationException("not implemented");
  50     }
  51 
  52     private static native Rectangle2D nativeGetBounds(int screen);
  53 
  54     @Override
  55     public Rectangle getBounds() {
  56         final Rectangle2D nativeBounds = nativeGetBounds(device.getCoreGraphicsScreen());
  57         return nativeBounds.getBounds(); // does integer rounding
  58     }
  59 
  60     @Override
  61     public ColorModel getColorModel() {
  62         if (colorModel == null) {
  63             colorModel = getColorModel(Transparency.OPAQUE);


  70         throw new UnsupportedOperationException("not implemented");
  71     }
  72 
  73     @Override
  74     public AffineTransform getDefaultTransform() {
  75         return new AffineTransform();
  76     }
  77 
  78     @Override
  79     public CGraphicsDevice getDevice() {
  80         return device;
  81     }
  82 
  83     @Override
  84     public AffineTransform getNormalizingTransform() {
  85         double xscale = device.getXResolution() / 72.0;
  86         double yscale = device.getYResolution() / 72.0;
  87         return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
  88     }
  89 









  90     /**
  91      * Creates a new SurfaceData that will be associated with the given
  92      * LWWindowPeer.
  93      */
  94     public abstract SurfaceData createSurfaceData(CPlatformView pView);


  95 
  96     /**
  97      * Creates a new SurfaceData that will be associated with the given
  98      * CGLLayer.
  99      */
 100     public abstract SurfaceData createSurfaceData(CGLLayer layer);

























































 101 
 102     @Override
 103     public final boolean isTranslucencyCapable() {
 104         //we know for sure we have capable config :)
 105         return true;
 106     }
 107 }