< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/TranslucentWindowPainter.java

Print this page




  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
  23  * questions.
  24  */
  25 package sun.awt.windows;
  26 
  27 import java.awt.AlphaComposite;
  28 import java.awt.Color;
  29 import java.awt.Graphics2D;
  30 import java.awt.GraphicsConfiguration;
  31 import java.awt.Image;
  32 import java.awt.Window;

  33 import java.awt.image.BufferedImage;
  34 import java.awt.image.DataBufferInt;
  35 import java.awt.image.VolatileImage;
  36 import java.security.AccessController;
  37 import sun.awt.image.BufImgSurfaceData;
  38 import sun.java2d.DestSurfaceProvider;
  39 import sun.java2d.InvalidPipeException;
  40 import sun.java2d.Surface;
  41 import sun.java2d.pipe.RenderQueue;
  42 import sun.java2d.pipe.BufferedContext;
  43 import sun.java2d.pipe.hw.AccelGraphicsConfig;
  44 import sun.java2d.pipe.hw.AccelSurface;
  45 import sun.security.action.GetPropertyAction;
  46 
  47 import static java.awt.image.VolatileImage.*;

  48 import static sun.java2d.pipe.hw.AccelSurface.*;
  49 import static sun.java2d.pipe.hw.ContextCapabilities.*;
  50 
  51 /**
  52  * This class handles the updates of the non-opaque windows.
  53  * The window associated with the peer is updated either given an image or
  54  * the window is repainted to an internal buffer which is then used to update
  55  * the window.
  56  *
  57  * Note: this class does not attempt to be thread safe, it is expected to be
  58  * called from a single thread (EDT).
  59  */
  60 abstract class TranslucentWindowPainter {
  61 
  62     protected Window window;
  63     protected WWindowPeer peer;
  64 
  65     // REMIND: we probably would want to remove this later
  66     private static final boolean forceOpt  =
  67         Boolean.valueOf(AccessController.doPrivileged(


 235                 backBuffer.flush();
 236                 backBuffer = null;
 237             }
 238         }
 239     }
 240 
 241     /**
 242      * A version of the painter which uses VolatileImage as the internal buffer.
 243      * The window is painted into this VI and then copied into the parent's
 244      * Java heap-based buffer (which is then uploaded to the layered window)
 245      */
 246     private static class VIWindowPainter extends BIWindowPainter {
 247         private VolatileImage viBB;
 248 
 249         protected VIWindowPainter(WWindowPeer peer) {
 250             super(peer);
 251         }
 252 
 253         @Override
 254         protected Image getBackBuffer(boolean clear) {
 255             int w = window.getWidth();
 256             int h = window.getHeight();
 257             GraphicsConfiguration gc = peer.getGraphicsConfiguration();
 258 




 259             if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
 260                 viBB.validate(gc) == IMAGE_INCOMPATIBLE)
 261             {
 262                 flush();
 263 
 264                 if (gc instanceof AccelGraphicsConfig) {
 265                     AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
 266                     viBB = agc.createCompatibleVolatileImage(w, h,
 267                                                              TRANSLUCENT,
 268                                                              RT_PLAIN);
 269                 }
 270                 if (viBB == null) {
 271                     viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
 272                 }
 273                 viBB.validate(gc);
 274             }
 275 
 276             return clear ? clearImage(viBB) : viBB;
 277         }
 278 




  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
  23  * questions.
  24  */
  25 package sun.awt.windows;
  26 
  27 import java.awt.AlphaComposite;
  28 import java.awt.Color;
  29 import java.awt.Graphics2D;
  30 import java.awt.GraphicsConfiguration;
  31 import java.awt.Image;
  32 import java.awt.Window;
  33 import java.awt.geom.AffineTransform;
  34 import java.awt.image.BufferedImage;
  35 import java.awt.image.DataBufferInt;
  36 import java.awt.image.VolatileImage;
  37 import java.security.AccessController;
  38 import sun.awt.image.BufImgSurfaceData;
  39 import sun.java2d.DestSurfaceProvider;
  40 import sun.java2d.InvalidPipeException;
  41 import sun.java2d.Surface;
  42 import sun.java2d.pipe.RenderQueue;
  43 import sun.java2d.pipe.BufferedContext;
  44 import sun.java2d.pipe.hw.AccelGraphicsConfig;
  45 import sun.java2d.pipe.hw.AccelSurface;
  46 import sun.security.action.GetPropertyAction;
  47 
  48 import static java.awt.image.VolatileImage.*;
  49 import sun.java2d.pipe.Region;
  50 import static sun.java2d.pipe.hw.AccelSurface.*;
  51 import static sun.java2d.pipe.hw.ContextCapabilities.*;
  52 
  53 /**
  54  * This class handles the updates of the non-opaque windows.
  55  * The window associated with the peer is updated either given an image or
  56  * the window is repainted to an internal buffer which is then used to update
  57  * the window.
  58  *
  59  * Note: this class does not attempt to be thread safe, it is expected to be
  60  * called from a single thread (EDT).
  61  */
  62 abstract class TranslucentWindowPainter {
  63 
  64     protected Window window;
  65     protected WWindowPeer peer;
  66 
  67     // REMIND: we probably would want to remove this later
  68     private static final boolean forceOpt  =
  69         Boolean.valueOf(AccessController.doPrivileged(


 237                 backBuffer.flush();
 238                 backBuffer = null;
 239             }
 240         }
 241     }
 242 
 243     /**
 244      * A version of the painter which uses VolatileImage as the internal buffer.
 245      * The window is painted into this VI and then copied into the parent's
 246      * Java heap-based buffer (which is then uploaded to the layered window)
 247      */
 248     private static class VIWindowPainter extends BIWindowPainter {
 249         private VolatileImage viBB;
 250 
 251         protected VIWindowPainter(WWindowPeer peer) {
 252             super(peer);
 253         }
 254 
 255         @Override
 256         protected Image getBackBuffer(boolean clear) {
 257             

 258             GraphicsConfiguration gc = peer.getGraphicsConfiguration();
 259          
 260             AffineTransform tx = gc.getDefaultTransform();
 261             int w = Region.clipScale(window.getWidth(), tx.getScaleX());
 262             int h = Region.clipScale(window.getHeight(), tx.getScaleY());
 263             
 264             if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
 265                 viBB.validate(gc) == IMAGE_INCOMPATIBLE)
 266             {
 267                 flush();
 268 
 269                 if (gc instanceof AccelGraphicsConfig) {
 270                     AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
 271                     viBB = agc.createCompatibleVolatileImage(w, h,
 272                                                              TRANSLUCENT,
 273                                                              RT_PLAIN);
 274                 }
 275                 if (viBB == null) {
 276                     viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
 277                 }
 278                 viBB.validate(gc);
 279             }
 280 
 281             return clear ? clearImage(viBB) : viBB;
 282         }
 283 


< prev index next >