762 lines · 29.0 KB · Java
RawDownload
class OGLSurfaceToSwBlit extends Blit {     private int typeval;     // REMIND: destination will actually be opaque/premultiplied...    OGLSurfaceToSwBlit(SurfaceType dstType, int typeval) {        super(OGLSurfaceData.OpenGLSurface,              CompositeType.SrcNoEa,              dstType);        this.typeval = typeval;    }     public void Blit(SurfaceData src, SurfaceData dst,                     Composite comp, Region clip,                     int sx, int sy, int dx, int dy,                     int w, int h)    {        OGLRenderQueue rq = OGLRenderQueue.getInstance();        rq.lock();        try {            // make sure the RenderQueue keeps a hard reference to the            // destination (sysmem) SurfaceData to prevent it from being            // disposed while the operation is processed on the QFT            rq.addReference(dst);             RenderBuffer buf = rq.getBuffer();            OGLContext.validateContext((OGLSurfaceData)src);             rq.ensureCapacityAndAlignment(48, 32);            buf.putInt(SURFACE_TO_SW_BLIT);            buf.putInt(sx).putInt(sy);            buf.putInt(dx).putInt(dy);            buf.putInt(w).putInt(h);            buf.putInt(typeval);            buf.putLong(src.getNativeOps());            buf.putLong(dst.getNativeOps());             // always flush immediately            rq.flushNow();        } finally {            rq.unlock();        }    }} class OGLSwToSurfaceBlit extends Blit {     private int typeval;     OGLSwToSurfaceBlit(SurfaceType srcType, int typeval) {        super(srcType,              CompositeType.AnyAlpha,              OGLSurfaceData.OpenGLSurface);        this.typeval = typeval;    }     public void Blit(SurfaceData src, SurfaceData dst,                     Composite comp, Region clip,                     int sx, int sy, int dx, int dy, int w, int h)    {        OGLBlitLoops.Blit(src, dst,                          comp, clip, null,                          AffineTransformOp.TYPE_NEAREST_NEIGHBOR,                          sx, sy, sx+w, sy+h,                          dx, dy, dx+w, dy+h,                          typeval, false);    }} class OGLSwToSurfaceScale extends ScaledBlit {     private int typeval;     OGLSwToSurfaceScale(SurfaceType srcType, int typeval) {        super(srcType,              CompositeType.AnyAlpha,              OGLSurfaceData.OpenGLSurface);        this.typeval = typeval;    }     public void Scale(SurfaceData src, SurfaceData dst,                      Composite comp, Region clip,                      int sx1, int sy1,                      int sx2, int sy2,                      double dx1, double dy1,                      double dx2, double dy2)    {        OGLBlitLoops.Blit(src, dst,                          comp, clip, null,                          AffineTransformOp.TYPE_NEAREST_NEIGHBOR,                          sx1, sy1, sx2, sy2,                          dx1, dy1, dx2, dy2,                          typeval, false);    }} class OGLSwToSurfaceTransform extends TransformBlit {     private int typeval;     OGLSwToSurfaceTransform(SurfaceType srcType, int typeval) {        super(srcType,              CompositeType.AnyAlpha,              OGLSurfaceData.OpenGLSurface);        this.typeval = typeval;    }     public void Transform(SurfaceData src, SurfaceData dst,                          Composite comp, Region clip,                          AffineTransform at, int hint,                          int sx, int sy, int dx, int dy, int w, int h)    {        OGLBlitLoops.Blit(src, dst,                          comp, clip, at, hint,                          sx, sy, sx+w, sy+h,                          dx, dy, dx+w, dy+h,                          typeval, false);    }} class OGLSwToTextureBlit extends Blit {     private int typeval;     OGLSwToTextureBlit(SurfaceType srcType, int typeval) {        super(srcType,              CompositeType.SrcNoEa,              OGLSurfaceData.OpenGLTexture);        this.typeval = typeval;    }     public void Blit(SurfaceData src, SurfaceData dst,                     Composite comp, Region clip,                     int sx, int sy, int dx, int dy, int w, int h)    {        OGLBlitLoops.Blit(src, dst,                          comp, clip, null,                          AffineTransformOp.TYPE_NEAREST_NEIGHBOR,                          sx, sy, sx+w, sy+h,                          dx, dy, dx+w, dy+h,                          typeval, true);    }} class OGLTextureToSurfaceBlit extends Blit {     OGLTextureToSurfaceBlit() {        super(OGLSurfaceData.OpenGLTexture,              CompositeType.AnyAlpha,              OGLSurfaceData.OpenGLSurface);    }     public void Blit(SurfaceData src, SurfaceData dst,                     Composite comp, Region clip,                     int sx, int sy, int dx, int dy, int w, int h)    {        OGLBlitLoops.IsoBlit(src, dst,                             null, null,                             comp, clip, null,                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,                             sx, sy, sx+w, sy+h,                             dx, dy, dx+w, dy+h,                             true);    }} class OGLTextureToSurfaceScale extends ScaledBlit {     OGLTextureToSurfaceScale() {        super(OGLSurfaceData.OpenGLTexture,              CompositeType.AnyAlpha,              OGLSurfaceData.OpenGLSurface);    }     public void Scale(SurfaceData src, SurfaceData dst,                      Composite comp, Region clip,                      int sx1, int sy1,                      int sx2, int sy2,                      double dx1, double dy1,                      double dx2, double dy2)    {        OGLBlitLoops.IsoBlit(src, dst,                             null, null,                             comp, clip, null,                             AffineTransformOp.TYPE_NEAREST_NEIGHBOR,                             sx1, sy1, sx2, sy2,                             dx1, dy1, dx2, dy2,                             true);    }} class OGLTextureToSurfaceTransform extends TransformBlit {     OGLTextureToSurfaceTransform() {        super(OGLSurfaceData.OpenGLTexture,              CompositeType.AnyAlpha,              OGLSurfaceData.OpenGLSurface);    }     public void Transform(SurfaceData src, SurfaceData dst,                          Composite comp, Region clip,                          AffineTransform at, int hint,                          int sx, int sy, int dx, int dy,                          int w, int h)    {        OGLBlitLoops.IsoBlit(src, dst,                             null, null,                             comp, clip, at, hint,                             sx, sy, sx+w, sy+h,                             dx, dy, dx+w, dy+h,                             true);    }} /** * This general Blit implemenation converts any source surface to an * intermediate IntArgbPre surface, and then uses the more specific * IntArgbPre->OpenGLSurface/Texture loop to get the intermediate * (premultiplied) surface down to OpenGL. */class OGLGeneralBlit extends Blit {     private Blit performop;    private WeakReference srcTmp;     OGLGeneralBlit(SurfaceType dstType,                   CompositeType compType,                   Blit performop)    {        super(SurfaceType.Any, compType, dstType);        this.performop = performop;    }     public synchronized void Blit(SurfaceData src, SurfaceData dst,                                  Composite comp, Region clip,                                  int sx, int sy, int dx, int dy,                                  int w, int h)    {        Blit convertsrc = Blit.getFromCache(src.getSurfaceType(),                                            CompositeType.SrcNoEa,                                            SurfaceType.IntArgbPre);         SurfaceData cachedSrc = null;        if (srcTmp != null) {            // use cached intermediate surface, if available            cachedSrc = (SurfaceData)srcTmp.get();        }         // convert source to IntArgbPre        src = convertFrom(convertsrc, src, sx, sy, w, h,                          cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);         // copy IntArgbPre intermediate surface to OpenGL surface        performop.Blit(src, dst, comp, clip,                       0, 0, dx, dy, w, h);         if (src != cachedSrc) {            // cache the intermediate surface            srcTmp = new WeakReference(src);        }    }}

Lines 501–762 of 762. Previous lines