src/java.desktop/unix/classes/sun/java2d/xr/XRPMBlitLoops.java

Print this page




 110                 new XrSwToPMTransformedBlit(SurfaceType.ByteIndexed, XRSurfaceData.IntArgbPreX11), };
 111         GraphicsPrimitiveMgr.register(primitives);
 112     }
 113 
 114     /**
 115      * Caches a SW surface using a temporary pixmap. The pixmap is held by a WeakReference,
 116      *  allowing it to shrink again after some time.
 117      */
 118     protected static XRSurfaceData cacheToTmpSurface(SurfaceData src, XRSurfaceData dst, int w, int h, int sx, int sy) {
 119         SunVolatileImage vImg;
 120         SurfaceType vImgSurfaceType;
 121 
 122         if (src.getTransparency() == Transparency.OPAQUE) {
 123             vImg = rgbTmpPM.get();
 124             vImgSurfaceType = SurfaceType.IntRgb;
 125         } else {
 126             vImg = argbTmpPM.get();
 127             vImgSurfaceType = SurfaceType.IntArgbPre;
 128         }
 129 
 130         if (vImg == null || vImg.getWidth() < w || vImg.getHeight() < h) {




 131             if (vImg != null) {
 132                 vImg.flush();
 133             }
 134             vImg = (SunVolatileImage) dst.getGraphicsConfig().createCompatibleVolatileImage(w, h, src.getTransparency());
 135             vImg.setAccelerationPriority(1.0f);
 136 
 137             if (src.getTransparency() == SurfaceData.OPAQUE) {
 138                 rgbTmpPM = new WeakReference<SunVolatileImage>(vImg);
 139             } else {
 140                 argbTmpPM = new WeakReference<SunVolatileImage>(vImg);
 141             }
 142         }
 143 
 144         Blit swToSurfaceBlit = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, vImgSurfaceType);





 145         XRSurfaceData vImgSurface = (XRSurfaceData) vImg.getDestSurface();
 146         swToSurfaceBlit.Blit(src, vImgSurface, AlphaComposite.Src, null,
 147                              sx, sy, 0, 0, w, h);
 148 
 149         return vImgSurface;
 150     }
 151 }
 152 
 153 class XRPMBlit extends Blit {
 154     public XRPMBlit(SurfaceType srcType, SurfaceType dstType) {
 155         super(srcType, CompositeType.AnyAlpha, dstType);
 156     }
 157 
 158     public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) {
 159         try {
 160             SunToolkit.awtLock();
 161 
 162             XRSurfaceData x11sdDst = (XRSurfaceData) dst;
 163             x11sdDst.validateAsDestination(null, clip);
 164             XRSurfaceData x11sdSrc = (XRSurfaceData) src;




 110                 new XrSwToPMTransformedBlit(SurfaceType.ByteIndexed, XRSurfaceData.IntArgbPreX11), };
 111         GraphicsPrimitiveMgr.register(primitives);
 112     }
 113 
 114     /**
 115      * Caches a SW surface using a temporary pixmap. The pixmap is held by a WeakReference,
 116      *  allowing it to shrink again after some time.
 117      */
 118     protected static XRSurfaceData cacheToTmpSurface(SurfaceData src, XRSurfaceData dst, int w, int h, int sx, int sy) {
 119         SunVolatileImage vImg;
 120         SurfaceType vImgSurfaceType;
 121 
 122         if (src.getTransparency() == Transparency.OPAQUE) {
 123             vImg = rgbTmpPM.get();
 124             vImgSurfaceType = SurfaceType.IntRgb;
 125         } else {
 126             vImg = argbTmpPM.get();
 127             vImgSurfaceType = SurfaceType.IntArgbPre;
 128         }
 129 
 130         if (vImg == null || vImg.getWidth() < w || vImg.getHeight() < h ||
 131             // Sometimes we get volatile image of wrong dest surface type, 
 132             // so recreating it
 133             !(vImg.getDestSurface() instanceof XRSurfaceData))
 134         {
 135             if (vImg != null) {
 136                 vImg.flush();
 137             }
 138             vImg = (SunVolatileImage) dst.getGraphicsConfig().createCompatibleVolatileImage(w, h, src.getTransparency());
 139             vImg.setAccelerationPriority(1.0f);
 140 
 141             if (src.getTransparency() == SurfaceData.OPAQUE) {
 142                 rgbTmpPM = new WeakReference<SunVolatileImage>(vImg);
 143             } else {
 144                 argbTmpPM = new WeakReference<SunVolatileImage>(vImg);
 145             }
 146         }
 147 
 148         Blit swToSurfaceBlit = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, vImgSurfaceType);
 149 
 150         if (!(vImg.getDestSurface() instanceof XRSurfaceData)) {
 151             throw new InvalidPipeException("wrong surface data type: " + vImg.getDestSurface());
 152         }
 153 
 154         XRSurfaceData vImgSurface = (XRSurfaceData) vImg.getDestSurface();
 155         swToSurfaceBlit.Blit(src, vImgSurface, AlphaComposite.Src, null,
 156                              sx, sy, 0, 0, w, h);
 157 
 158         return vImgSurface;
 159     }
 160 }
 161 
 162 class XRPMBlit extends Blit {
 163     public XRPMBlit(SurfaceType srcType, SurfaceType dstType) {
 164         super(srcType, CompositeType.AnyAlpha, dstType);
 165     }
 166 
 167     public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) {
 168         try {
 169             SunToolkit.awtLock();
 170 
 171             XRSurfaceData x11sdDst = (XRSurfaceData) dst;
 172             x11sdDst.validateAsDestination(null, clip);
 173             XRSurfaceData x11sdSrc = (XRSurfaceData) src;