< prev index next >

src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java

Print this page




  41 import java.awt.image.SampleModel;
  42 import java.awt.image.SinglePixelPackedSampleModel;
  43 import sun.awt.SunHints;
  44 import sun.awt.image.DataBufferNative;
  45 import sun.awt.image.PixelConverter;
  46 import sun.awt.image.SurfaceManager;
  47 import sun.awt.image.WritableRasterNative;
  48 import sun.awt.windows.WComponentPeer;
  49 import sun.java2d.pipe.hw.AccelSurface;
  50 import sun.java2d.InvalidPipeException;
  51 import sun.java2d.SunGraphics2D;
  52 import sun.java2d.SurfaceData;
  53 import sun.java2d.loops.GraphicsPrimitive;
  54 import sun.java2d.loops.MaskFill;
  55 import sun.java2d.loops.SurfaceType;
  56 import sun.java2d.loops.CompositeType;
  57 import sun.java2d.pipe.ParallelogramPipe;
  58 import sun.java2d.pipe.PixelToParallelogramConverter;
  59 import sun.java2d.pipe.RenderBuffer;
  60 import sun.java2d.pipe.TextPipe;

  61 import static sun.java2d.pipe.BufferedOpCodes.*;
  62 import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
  63 import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
  64 import sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType;
  65 import java.awt.BufferCapabilities.FlipContents;
  66 import java.awt.Dimension;
  67 import java.awt.Window;
  68 import java.awt.geom.AffineTransform;
  69 import sun.awt.SunToolkit;
  70 import sun.awt.image.SunVolatileImage;
  71 import sun.awt.windows.WWindowPeer;
  72 import sun.java2d.ScreenUpdateManager;
  73 import sun.java2d.StateTracker;
  74 import sun.java2d.SurfaceDataProxy;
  75 import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
  76 
  77 /**
  78  * This class describes a D3D "surface", that is, a region of pixels
  79  * managed via D3D.  An D3DSurfaceData can be tagged with one of three
  80  * different SurfaceType objects for the purpose of registering loops, etc.


 219                              int width, int height, Image image,
 220                              ColorModel cm, int numBackBuffers,
 221                              int swapEffect, VSyncType vSyncType,
 222                              int type)
 223     {
 224         super(getCustomSurfaceType(type), cm);
 225         this.graphicsDevice = gc.getD3DDevice();
 226         this.scaleX = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleX();
 227         this.scaleY = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleY();
 228         this.peer = peer;
 229         this.type = type;
 230 
 231         if (scaleX == 1 && scaleY == 1) {
 232             this.width = width;
 233             this.height = height;
 234         } else if (peer instanceof WWindowPeer) {
 235             Dimension scaledSize = ((WWindowPeer) peer).getScaledWindowSize();
 236             this.width = scaledSize.width;
 237             this.height = scaledSize.height;
 238         } else {
 239             this.width = (int) Math.ceil(width * scaleX);
 240             this.height = (int) Math.ceil(height * scaleY);
 241         }
 242 
 243         this.offscreenImage = image;
 244         this.backBuffersNum = numBackBuffers;
 245         this.swapEffect = swapEffect;
 246         this.syncType = vSyncType;
 247 
 248         initOps(graphicsDevice.getScreen(), this.width, this.height);
 249         if (type == WINDOW) {
 250             // we put the surface into the "lost"
 251             // state; it will be restored by the D3DScreenUpdateManager
 252             // prior to rendering to it for the first time. This is done
 253             // so that vram is not wasted for surfaces never rendered to
 254             setSurfaceLost(true);
 255         } else {
 256             initSurface();
 257         }
 258         setBlitProxyKey(gc.getProxyKey());
 259     }
 260 


 795             buf.putInt(y2);
 796             rq.flushNow();
 797         } finally {
 798             rq.unlock();
 799         }
 800     }
 801 
 802     /**
 803      * Returns destination Image associated with this SurfaceData.
 804      */
 805     public Object getDestination() {
 806         return offscreenImage;
 807     }
 808 
 809     public Rectangle getBounds() {
 810         if (type == FLIP_BACKBUFFER || type == WINDOW) {
 811             double scaleX = getDefaultScaleX();
 812             double scaleY = getDefaultScaleY();
 813             Rectangle r = peer.getBounds();
 814             r.x = r.y = 0;
 815             r.width = (int) Math.ceil(r.width * scaleX);
 816             r.height = (int) Math.ceil(r.height * scaleY);
 817             return r;
 818         } else {
 819             return new Rectangle(width, height);
 820         }
 821     }
 822 
 823     public Rectangle getNativeBounds() {
 824         D3DRenderQueue rq = D3DRenderQueue.getInstance();
 825         // need to lock to make sure nativeWidth and Height are consistent
 826         // since they are set from the render thread from the native
 827         // level
 828         rq.lock();
 829         try {
 830             // REMIND: use xyoffsets?
 831             return new Rectangle(nativeWidth, nativeHeight);
 832         } finally {
 833             rq.unlock();
 834         }
 835     }
 836 




  41 import java.awt.image.SampleModel;
  42 import java.awt.image.SinglePixelPackedSampleModel;
  43 import sun.awt.SunHints;
  44 import sun.awt.image.DataBufferNative;
  45 import sun.awt.image.PixelConverter;
  46 import sun.awt.image.SurfaceManager;
  47 import sun.awt.image.WritableRasterNative;
  48 import sun.awt.windows.WComponentPeer;
  49 import sun.java2d.pipe.hw.AccelSurface;
  50 import sun.java2d.InvalidPipeException;
  51 import sun.java2d.SunGraphics2D;
  52 import sun.java2d.SurfaceData;
  53 import sun.java2d.loops.GraphicsPrimitive;
  54 import sun.java2d.loops.MaskFill;
  55 import sun.java2d.loops.SurfaceType;
  56 import sun.java2d.loops.CompositeType;
  57 import sun.java2d.pipe.ParallelogramPipe;
  58 import sun.java2d.pipe.PixelToParallelogramConverter;
  59 import sun.java2d.pipe.RenderBuffer;
  60 import sun.java2d.pipe.TextPipe;
  61 import sun.java2d.pipe.Region;
  62 import static sun.java2d.pipe.BufferedOpCodes.*;
  63 import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
  64 import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
  65 import sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType;
  66 import java.awt.BufferCapabilities.FlipContents;
  67 import java.awt.Dimension;
  68 import java.awt.Window;
  69 import java.awt.geom.AffineTransform;
  70 import sun.awt.SunToolkit;
  71 import sun.awt.image.SunVolatileImage;
  72 import sun.awt.windows.WWindowPeer;
  73 import sun.java2d.ScreenUpdateManager;
  74 import sun.java2d.StateTracker;
  75 import sun.java2d.SurfaceDataProxy;
  76 import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
  77 
  78 /**
  79  * This class describes a D3D "surface", that is, a region of pixels
  80  * managed via D3D.  An D3DSurfaceData can be tagged with one of three
  81  * different SurfaceType objects for the purpose of registering loops, etc.


 220                              int width, int height, Image image,
 221                              ColorModel cm, int numBackBuffers,
 222                              int swapEffect, VSyncType vSyncType,
 223                              int type)
 224     {
 225         super(getCustomSurfaceType(type), cm);
 226         this.graphicsDevice = gc.getD3DDevice();
 227         this.scaleX = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleX();
 228         this.scaleY = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleY();
 229         this.peer = peer;
 230         this.type = type;
 231 
 232         if (scaleX == 1 && scaleY == 1) {
 233             this.width = width;
 234             this.height = height;
 235         } else if (peer instanceof WWindowPeer) {
 236             Dimension scaledSize = ((WWindowPeer) peer).getScaledWindowSize();
 237             this.width = scaledSize.width;
 238             this.height = scaledSize.height;
 239         } else {
 240             this.width = Region.clipRound(width * scaleX);
 241             this.height = Region.clipRound(height * scaleY);
 242         }
 243 
 244         this.offscreenImage = image;
 245         this.backBuffersNum = numBackBuffers;
 246         this.swapEffect = swapEffect;
 247         this.syncType = vSyncType;
 248 
 249         initOps(graphicsDevice.getScreen(), this.width, this.height);
 250         if (type == WINDOW) {
 251             // we put the surface into the "lost"
 252             // state; it will be restored by the D3DScreenUpdateManager
 253             // prior to rendering to it for the first time. This is done
 254             // so that vram is not wasted for surfaces never rendered to
 255             setSurfaceLost(true);
 256         } else {
 257             initSurface();
 258         }
 259         setBlitProxyKey(gc.getProxyKey());
 260     }
 261 


 796             buf.putInt(y2);
 797             rq.flushNow();
 798         } finally {
 799             rq.unlock();
 800         }
 801     }
 802 
 803     /**
 804      * Returns destination Image associated with this SurfaceData.
 805      */
 806     public Object getDestination() {
 807         return offscreenImage;
 808     }
 809 
 810     public Rectangle getBounds() {
 811         if (type == FLIP_BACKBUFFER || type == WINDOW) {
 812             double scaleX = getDefaultScaleX();
 813             double scaleY = getDefaultScaleY();
 814             Rectangle r = peer.getBounds();
 815             r.x = r.y = 0;
 816             r.width = Region.clipRound(r.width * scaleX);
 817             r.height = Region.clipRound(r.height * scaleY);
 818             return r;
 819         } else {
 820             return new Rectangle(width, height);
 821         }
 822     }
 823 
 824     public Rectangle getNativeBounds() {
 825         D3DRenderQueue rq = D3DRenderQueue.getInstance();
 826         // need to lock to make sure nativeWidth and Height are consistent
 827         // since they are set from the render thread from the native
 828         // level
 829         rq.lock();
 830         try {
 831             // REMIND: use xyoffsets?
 832             return new Rectangle(nativeWidth, nativeHeight);
 833         } finally {
 834             rq.unlock();
 835         }
 836     }
 837 


< prev index next >