623 lines · 22.1 KB · Java
RawDownload
        }         gbo.setPrimitives(convertsrc, convertdst, performop, convertres);    }     protected void setupGeneralUnaryOp(GeneralUnaryOp guo) {        int primID = guo.getPrimTypeID();        String methodSignature = guo.getSignature();        CompositeType comptype = guo.getCompositeType();        SurfaceType dsttype = guo.getDestType();         Blit convertdst = createConverter(dsttype, SurfaceType.IntArgb);        GraphicsPrimitive performop = getGeneralOp(primID, comptype);        Blit convertres = createConverter(SurfaceType.IntArgb, dsttype);        if (convertdst == null || performop == null || convertres == null) {            throw new InternalError("Cannot construct binary op for "+                                    comptype+" "+dsttype);        }         guo.setPrimitives(convertdst, performop, convertres);    }     protected static Blit createConverter(SurfaceType srctype,                                          SurfaceType dsttype)    {        if (srctype.equals(dsttype)) {            return null;        }        Blit cv = Blit.getFromCache(srctype, CompositeType.SrcNoEa, dsttype);        if (cv == null) {            throw new InternalError("Cannot construct converter for "+                                    srctype+"=>"+dsttype);        }        return cv;    }     protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,                                             int srcX, int srcY, int w, int h,                                             SurfaceData dstData)    {        return convertFrom(ob, srcData,                           srcX, srcY, w, h, dstData,                           BufferedImage.TYPE_INT_ARGB);    }     protected static SurfaceData convertFrom(Blit ob, SurfaceData srcData,                                             int srcX, int srcY, int w, int h,                                             SurfaceData dstData, int type)    {        if (dstData != null) {            Rectangle r = dstData.getBounds();            if (w > r.width || h > r.height) {                dstData = null;            }        }        if (dstData == null) {            BufferedImage dstBI = new BufferedImage(w, h, type);            dstData = BufImgSurfaceData.createData(dstBI);        }        ob.Blit(srcData, dstData, AlphaComposite.Src, null,                srcX, srcY, 0, 0, w, h);        return dstData;    }     protected static void convertTo(Blit ob,                                    SurfaceData srcImg, SurfaceData dstImg,                                    Region clip,                                    int dstX, int dstY, int w, int h)    {        if (ob != null) {            ob.Blit(srcImg, dstImg, AlphaComposite.Src, clip,                    0, 0, dstX, dstY, w, h);        }    }     protected static GraphicsPrimitive getGeneralOp(int primID,                                                    CompositeType comptype)    {        return GraphicsPrimitiveMgr.locatePrim(primID,                                               SurfaceType.IntArgb,                                               comptype,                                               SurfaceType.IntArgb);    }     public static String simplename(Field[] fields, Object o) {        for (int i = 0; i < fields.length; i++) {            Field f = fields[i];            try {                if (o == f.get(null)) {                    return f.getName();                }            } catch (Exception e) {            }        }        return "\""+o.toString()+"\"";    }     public static String simplename(SurfaceType st) {        return simplename(SurfaceType.class.getDeclaredFields(), st);    }     public static String simplename(CompositeType ct) {        return simplename(CompositeType.class.getDeclaredFields(), ct);    }     private String cachedname;     public String toString() {        if (cachedname == null) {            String sig = methodSignature;            int index = sig.indexOf('(');            if (index >= 0) {                sig = sig.substring(0, index);            }            cachedname = (getClass().getName()+"::"+                          sig+"("+                          simplename(sourceType)+", "+                          simplename(compositeType)+", "+                          simplename(destType)+")");        }        return cachedname;    }}

Lines 501–623 of 623. Previous lines