jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java
changeset 31661 a5cb86f2253b
parent 30469 bac0a7ff7e1e
equal deleted inserted replaced
31660:1a4e2e5c15e1 31661:a5cb86f2253b
    41 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
    41 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
    42 import static sun.java2d.pipe.hw.AccelSurface.*;
    42 import static sun.java2d.pipe.hw.AccelSurface.*;
    43 import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
    43 import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
    44 import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
    44 import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
    45 
    45 
    46 public class WGLVolatileSurfaceManager
    46 public class WGLVolatileSurfaceManager extends VolatileSurfaceManager {
    47     extends VolatileSurfaceManager
    47 
    48 {
    48     private final boolean accelerationEnabled;
    49     private boolean accelerationEnabled;
       
    50 
    49 
    51     public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    50     public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
    52         super(vImg, context);
    51         super(vImg, context);
    53 
    52 
    54         /*
    53         /*
    55          * We will attempt to accelerate this image only under the
    54          * We will attempt to accelerate this image only under the
    56          * following conditions:
    55          * following conditions:
    57          *   - the image is opaque OR
    56          *   - the image is not bitmask AND the GraphicsConfig supports the FBO
    58          *   - the image is translucent AND
    57          *     extension
    59          *       - the GraphicsConfig supports the FBO extension OR
       
    60          *       - the GraphicsConfig has a stored alpha channel
       
    61          */
    58          */
    62         int transparency = vImg.getTransparency();
    59         int transparency = vImg.getTransparency();
    63         WGLGraphicsConfig gc = (WGLGraphicsConfig)vImg.getGraphicsConfig();
    60         WGLGraphicsConfig gc = (WGLGraphicsConfig) vImg.getGraphicsConfig();
    64         accelerationEnabled =
    61         accelerationEnabled = gc.isCapPresent(CAPS_EXT_FBOBJECT)
    65             (transparency == Transparency.OPAQUE) ||
    62                 && transparency != Transparency.BITMASK;
    66             ((transparency == Transparency.TRANSLUCENT) &&
       
    67              (gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
       
    68               gc.isCapPresent(CAPS_STORED_ALPHA)));
       
    69     }
    63     }
    70 
    64 
    71     protected boolean isAccelerationEnabled() {
    65     protected boolean isAccelerationEnabled() {
    72         return accelerationEnabled;
    66         return accelerationEnabled;
    73     }
    67     }
    74 
    68 
    75     /**
    69     /**
    76      * Create a pbuffer-based SurfaceData object (or init the backbuffer
    70      * Create a FBO-based SurfaceData object (or init the backbuffer
    77      * of an existing window if this is a double buffered GraphicsConfig).
    71      * of an existing window if this is a double buffered GraphicsConfig).
    78      */
    72      */
    79     protected SurfaceData initAcceleratedSurface() {
    73     protected SurfaceData initAcceleratedSurface() {
    80         SurfaceData sData;
    74         SurfaceData sData;
    81         Component comp = vImg.getComponent();
    75         Component comp = vImg.getComponent();
   109                 WGLGraphicsConfig gc =
   103                 WGLGraphicsConfig gc =
   110                     (WGLGraphicsConfig)vImg.getGraphicsConfig();
   104                     (WGLGraphicsConfig)vImg.getGraphicsConfig();
   111                 ColorModel cm = gc.getColorModel(vImg.getTransparency());
   105                 ColorModel cm = gc.getColorModel(vImg.getTransparency());
   112                 int type = vImg.getForcedAccelSurfaceType();
   106                 int type = vImg.getForcedAccelSurfaceType();
   113                 // if acceleration type is forced (type != UNDEFINED) then
   107                 // if acceleration type is forced (type != UNDEFINED) then
   114                 // use the forced type, otherwise choose one based on caps
   108                 // use the forced type, otherwise choose FBOBJECT
   115                 if (type == OGLSurfaceData.UNDEFINED) {
   109                 if (type == OGLSurfaceData.UNDEFINED) {
   116                     type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ?
   110                     type = OGLSurfaceData.FBOBJECT;
   117                         OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
       
   118                 }
   111                 }
   119                 if (createVSynced) {
   112                 if (createVSynced) {
   120                     sData = WGLSurfaceData.createData(peer, vImg, type);
   113                     sData = WGLSurfaceData.createData(peer, vImg, type);
   121                 } else {
   114                 } else {
   122                     sData = WGLSurfaceData.createData(gc,
   115                     sData = WGLSurfaceData.createData(gc,