FileDocCategorySizeDatePackage
NativeImageBlitter.javaAPI DocAndroid 1.5 API9555Wed May 06 22:41:54 BST 2009org.apache.harmony.awt.gl.render

NativeImageBlitter

public class NativeImageBlitter extends Object implements Blitter
This kind of blitters is intended for drawing one image on the buffered or volatile image. For the moment we can blit natively Buffered Images which have sRGB, Linear_RGB, Linear_Gray Color Space and type different from BufferedImage.TYPE_CUSTOM, Volatile Images and Images which received using Toolkit and Component classes.

Fields Summary
static final NativeImageBlitter
inst
Constructors Summary
Methods Summary
public voidblit(int srcX, int srcY, org.apache.harmony.awt.gl.Surface srcSurf, int dstX, int dstY, org.apache.harmony.awt.gl.Surface dstSurf, int width, int height, java.awt.geom.AffineTransform sysxform, java.awt.geom.AffineTransform xform, java.awt.Composite comp, java.awt.Color bgcolor, org.apache.harmony.awt.gl.MultiRectArea clip)


        if(!srcSurf.isNativeDrawable()){
            JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
                    sysxform, xform, comp, bgcolor, clip);
        }else{
            if(xform == null){
                blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
                        sysxform, comp, bgcolor, clip);
            }else{
                double scaleX = xform.getScaleX();
                double scaleY = xform.getScaleY();
                double scaledX = dstX / scaleX;
                double scaledY = dstY / scaleY;
                AffineTransform at = new AffineTransform();
                at.setToTranslation(scaledX, scaledY);
                xform.concatenate(at);
                sysxform.concatenate(xform);
                blit(srcX, srcY, srcSurf, 0, 0, dstSurf, width, height,
                        sysxform, comp, bgcolor, clip);
            }
        }
    
public voidblit(int srcX, int srcY, org.apache.harmony.awt.gl.Surface srcSurf, int dstX, int dstY, org.apache.harmony.awt.gl.Surface dstSurf, int width, int height, java.awt.geom.AffineTransform sysxform, java.awt.Composite comp, java.awt.Color bgcolor, org.apache.harmony.awt.gl.MultiRectArea clip)


        if(!srcSurf.isNativeDrawable()){
            JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
                    sysxform, comp, bgcolor, clip);
        }else{
            int type = sysxform.getType();
            switch(type){
                case AffineTransform.TYPE_TRANSLATION:
                    dstX += sysxform.getTranslateX();
                    dstY += sysxform.getTranslateY();
                case AffineTransform.TYPE_IDENTITY:
                    blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf,
                            width, height, comp, bgcolor, clip);
                    break;
                default:
                    // TODO Need to realize Affine Transformation
                    if(srcSurf instanceof ImageSurface){
                        JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, 
                                dstSurf, width, height,
                                sysxform, comp, bgcolor, clip);
                    }else{
                        int w = srcSurf.getWidth();
                        int h = srcSurf.getHeight();
                        BufferedImage tmp = new BufferedImage(w, h, 
                                BufferedImage.TYPE_INT_RGB);
                        Surface tmpSurf = Surface.getImageSurface(tmp);
                        blit(0, 0, srcSurf, 0, 0, tmpSurf,
                                w, h, AlphaComposite.SrcOver, null, null);
                        JavaBlitter.inst.blit(srcX, srcY, tmpSurf, dstX, dstY, 
                                dstSurf, width, height,
                                sysxform, comp, bgcolor, clip);
                    }
            }
        }
    
public voidblit(int srcX, int srcY, org.apache.harmony.awt.gl.Surface srcSurf, int dstX, int dstY, org.apache.harmony.awt.gl.Surface dstSurf, int width, int height, java.awt.Composite comp, java.awt.Color bgcolor, org.apache.harmony.awt.gl.MultiRectArea clip)


        if(!srcSurf.isNativeDrawable()){
            JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
                    comp, bgcolor, clip);
        }else{
            long dstSurfStruct = dstSurf.getSurfaceDataPtr();
            Object dstData = dstSurf.getData();
            int clipRects[];
            if(clip != null){
                clipRects = clip.rect;
            }else{
                clipRects = new int[]{5, 0, 0, dstSurf.getWidth(),
                        dstSurf.getHeight()};
            }

            if(!(srcSurf instanceof ImageSurface)){
                srcSurf = srcSurf.getImageSurface();
                if(bgcolor != null){
                    bgcolor = null;
                }
            }

            long srcSurfStruct = srcSurf.getSurfaceDataPtr();
            Object srcData = srcSurf.getData();
            if(comp instanceof AlphaComposite){
                AlphaComposite ac = (AlphaComposite) comp;
                int compType = ac.getRule();
                float alpha = ac.getAlpha();
                if(bgcolor != null){
                    bltBG(srcX, srcY, srcSurfStruct, srcData,
                            dstX, dstY, dstSurfStruct, dstData,
                            width, height, bgcolor.getRGB(),
                            compType, alpha, clipRects, srcSurf.invalidated());
                    dstSurf.invalidate();
                    srcSurf.validate();
                }else{
                    blt(srcX, srcY, srcSurfStruct, srcData,
                            dstX, dstY, dstSurfStruct, dstData,
                            width, height, compType, alpha,
                            clipRects, srcSurf.invalidated());
                    dstSurf.invalidate();
                    srcSurf.validate();
                }
            }else if(comp instanceof XORComposite){
                XORComposite xcomp = (XORComposite) comp;
                xor(srcX, srcY, srcSurfStruct, srcData,
                        dstX, dstY, dstSurfStruct, dstData,
                        width, height, xcomp.getXORColor().getRGB(),
                        clipRects, srcSurf.invalidated());
                dstSurf.invalidate();
                srcSurf.validate();
            }else{
                if(srcSurf instanceof ImageSurface){
                    JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, 
                            dstSurf, width, height,
                            comp, bgcolor, clip);
                }else{
                    int w = srcSurf.getWidth();
                    int h = srcSurf.getHeight();
                    BufferedImage tmp = new BufferedImage(w, h, 
                            BufferedImage.TYPE_INT_RGB);
                    Surface tmpSurf = Surface.getImageSurface(tmp);
                    long tmpSurfStruct = tmpSurf.getSurfaceDataPtr();
                    Object tmpData = tmpSurf.getData();
                    int tmpClip[] = new int[]{5, 0, 0, srcSurf.getWidth(),
                            srcSurf.getHeight()};
                    
                    blt(0, 0, srcSurfStruct, srcData, 0, 0,
                            tmpSurfStruct, tmpData, w, h, 
                            AlphaComposite.SRC_OVER,
                            1.0f, tmpClip, srcSurf.invalidated());
                    srcSurf.validate();
                    JavaBlitter.inst.blit(srcX, srcY, tmpSurf, dstX, dstY, 
                            dstSurf, width, height,
                            comp, bgcolor, clip);
                }
            }
        }

    
private native voidblt(int srcX, int srcY, long srsSurfDataPtr, java.lang.Object srcData, int dstX, int dstY, long dstSurfDataPtr, java.lang.Object dstData, int width, int height, int compType, float alpha, int[] clip, boolean invalidated)

private native voidbltBG(int srcX, int srcY, long srsSurfDataPtr, java.lang.Object srcData, int dstX, int dstY, long dstSurfDataPtr, java.lang.Object dstData, int width, int height, int bgcolor, int compType, float alpha, int[] clip, boolean invalidated)

public static org.apache.harmony.awt.gl.render.NativeImageBlittergetInstance()


       
        return inst;
    
private native voidxor(int srcX, int srcY, long srsSurfDataPtr, java.lang.Object srcData, int dstX, int dstY, long dstSurfDataPtr, java.lang.Object dstData, int width, int height, int xorcolor, int[] clip, boolean invalidated)