< prev index next >

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

Print this page
rev 48927 : Xrender: make aa tile mask handling a responsibility of the backend implementation
rev 48928 : Xrender: Introduction of the deferred backend, allows for accumulated AA mask upload.
rev 48930 : Xrender: Perform Ximg allocation for tile upload only for non-deferred mode


  24  */
  25 
  26 package sun.java2d.xr;
  27 
  28 import java.awt.geom.*;
  29 import java.util.*;
  30 
  31 import sun.font.*;
  32 import sun.java2d.pipe.*;
  33 
  34 import static sun.java2d.xr.XRUtils.XDoubleToFixed;
  35 
  36 /**
  37  * Native implementation of XRBackend.
  38  * Almost direct 1:1 binding to libX11.
  39  *
  40  * @author Clemens Eisserer
  41  */
  42 
  43 public class XRBackendNative implements XRBackend {






  44 
  45     static {
  46         initIDs();
  47     }
  48 
  49     private static long FMTPTR_A8;
  50     private static long FMTPTR_ARGB32;
  51     private static long MASK_XIMG;
















  52 
  53     private static native void initIDs();
  54 


  55     public native long createGC(int drawable);
  56 
  57     public native void freeGC(long gc);
  58 
  59     public native int createPixmap(int drawable, int depth,
  60                                    int width, int height);
  61 
  62     private native int createPictureNative(int drawable, long formatID);
  63 
  64     public native void freePicture(int picture);
  65 
  66     public native void freePixmap(int pixmap);
  67 
  68     public native void setGCExposures(long gc, boolean exposure);
  69 
  70     public native void setGCForeground(long gc, int pixel);
  71 
  72     public native void setPictureRepeat(int picture, int repeat);
  73 
  74     public native void copyArea(int src, int dst, long gc,


 256                                    int[] eltArray, int[] glyphIDs, int eltCnt,
 257                                    int glyphCnt);
 258 
 259     public int XRenderCreateGlyphSet(int formatID) {
 260         return XRenderCreateGlyphSetNative(getFormatPtr(formatID));
 261     }
 262 
 263     private static native int XRenderCreateGlyphSetNative(long format);
 264 
 265     public void XRenderCompositeText(byte op, int src, int dst,
 266                                      int maskFormatID,
 267                                      int sx, int sy, int dx, int dy,
 268                                      int glyphset, GrowableEltArray elts) {
 269 
 270         GrowableIntArray glyphs = elts.getGlyphs();
 271         XRenderCompositeTextNative(op, src, dst, sx, sy, 0, elts.getArray(),
 272                                    glyphs.getArray(), elts.getSize(),
 273                                    glyphs.getSize());
 274     }
 275 











 276     public void putMaskImage(int drawable, long gc, byte[] imageData,
 277                              int sx, int sy, int dx, int dy,
 278                              int width, int height, int maskOff,
 279                              int maskScan, float ea) {
 280         putMaskNative(drawable, gc, imageData, sx, sy, dx, dy,
 281                       width, height, maskOff, maskScan, ea, MASK_XIMG);
 282     }
 283 
 284     private static native void putMaskNative(int drawable, long gc,
 285                                              byte[] imageData,
 286                                              int sx, int sy, int dx, int dy,
 287                                              int width, int height,
 288                                              int maskOff, int maskScan,
 289                                              float ea, long xImg);
 290 
 291     public void padBlit(byte op, int srcPict, int maskPict, int dstPict,
 292                         AffineTransform maskTrx, int maskWidth, int maskHeight,
 293                         int lastMaskWidth, int lastMaskHeight,
 294                         int sx, int sy, int dx, int dy, int w, int h) {
 295 
 296         padBlitNative(op, srcPict, maskPict, dstPict,
 297                       XDoubleToFixed(maskTrx.getScaleX()),
 298                       XDoubleToFixed(maskTrx.getShearX()),
 299                       XDoubleToFixed(maskTrx.getTranslateX()),
 300                       XDoubleToFixed(maskTrx.getShearY()),
 301                       XDoubleToFixed(maskTrx.getScaleY()),


  24  */
  25 
  26 package sun.java2d.xr;
  27 
  28 import java.awt.geom.*;
  29 import java.util.*;
  30 
  31 import sun.font.*;
  32 import sun.java2d.pipe.*;
  33 
  34 import static sun.java2d.xr.XRUtils.XDoubleToFixed;
  35 
  36 /**
  37  * Native implementation of XRBackend.
  38  * Almost direct 1:1 binding to libX11.
  39  *
  40  * @author Clemens Eisserer
  41  */
  42 
  43 public class XRBackendNative implements XRBackend {
  44     private static long FMTPTR_A8;
  45     private static long FMTPTR_ARGB32;
  46     private static long ximgPtr;
  47     
  48     private static final int AA_MASK_WIDTH = 128;
  49     private static final int AA_MASK_HEIGHT = 64;
  50     
  51     static {
  52         initIDs();
  53     } 
  54 
  55     int maskPicture;
  56     int maskPixmap;
  57     long maskGC;
  58     
  59     public XRBackendNative() {
  60 
  61     }
  62     
  63     public void initResources(int parentXID) {
  64         ximgPtr = initDefaultAAXImg(AA_MASK_WIDTH, AA_MASK_HEIGHT);
  65         if(ximgPtr == 0) {
  66             throw new OutOfMemoryError("failed to allocate ximg");
  67         }
  68         
  69         maskPixmap = createPixmap(parentXID, 8, AA_MASK_WIDTH, AA_MASK_HEIGHT);
  70         maskPicture = createPicture(maskPixmap, XRUtils.PictStandardA8);
  71         maskGC = createGC(maskPixmap);
  72         setGCExposures(maskGC, false);
  73     }
  74     
  75     private static native void initIDs();
  76     
  77     private static native long initDefaultAAXImg(int maxAATileWidth, int maxAATileHeight);
  78 
  79     public native long createGC(int drawable);
  80 
  81     public native void freeGC(long gc);
  82 
  83     public native int createPixmap(int drawable, int depth,
  84                                    int width, int height);
  85 
  86     private native int createPictureNative(int drawable, long formatID);
  87 
  88     public native void freePicture(int picture);
  89 
  90     public native void freePixmap(int pixmap);
  91 
  92     public native void setGCExposures(long gc, boolean exposure);
  93 
  94     public native void setGCForeground(long gc, int pixel);
  95 
  96     public native void setPictureRepeat(int picture, int repeat);
  97 
  98     public native void copyArea(int src, int dst, long gc,


 280                                    int[] eltArray, int[] glyphIDs, int eltCnt,
 281                                    int glyphCnt);
 282 
 283     public int XRenderCreateGlyphSet(int formatID) {
 284         return XRenderCreateGlyphSetNative(getFormatPtr(formatID));
 285     }
 286 
 287     private static native int XRenderCreateGlyphSetNative(long format);
 288 
 289     public void XRenderCompositeText(byte op, int src, int dst,
 290                                      int maskFormatID,
 291                                      int sx, int sy, int dx, int dy,
 292                                      int glyphset, GrowableEltArray elts) {
 293 
 294         GrowableIntArray glyphs = elts.getGlyphs();
 295         XRenderCompositeTextNative(op, src, dst, sx, sy, 0, elts.getArray(),
 296                                    glyphs.getArray(), elts.getSize(),
 297                                    glyphs.getSize());
 298     }
 299     
 300     public void maskedComposite(byte op, int src, int eaMask, int dst, 
 301             int srcX, int srcY, int dstX, int dstY, int width, 
 302             int height, int maskScan, int maskOff, byte[] mask, float ea) {
 303         if(mask == null) {
 304               renderComposite(op, src, eaMask, dst, srcX, srcY, 0, 0, dstX, dstY, width, height);
 305         } else {
 306             putMaskImage(maskPixmap, maskGC, mask, 0, 0, 0, 0, width, height, maskOff, maskScan, ea);
 307             renderComposite(op, src, maskPicture, dst, srcX, srcY, 0, 0, dstX, dstY, width, height);
 308         }
 309     }
 310 
 311     public void putMaskImage(int drawable, long gc, byte[] imageData,
 312                              int sx, int sy, int dx, int dy,
 313                              int width, int height, int maskOff,
 314                              int maskScan, float ea) {
 315         putMaskNative(drawable, gc, imageData, sx, sy, dx, dy,
 316                       width, height, maskOff, maskScan, ea, ximgPtr);
 317     }
 318 
 319     private static native void putMaskNative(int drawable, long gc,
 320                                              byte[] imageData,
 321                                              int sx, int sy, int dx, int dy,
 322                                              int width, int height,
 323                                              int maskOff, int maskScan,
 324                                              float ea, long xImg);
 325 
 326     public void padBlit(byte op, int srcPict, int maskPict, int dstPict,
 327                         AffineTransform maskTrx, int maskWidth, int maskHeight,
 328                         int lastMaskWidth, int lastMaskHeight,
 329                         int sx, int sy, int dx, int dy, int w, int h) {
 330 
 331         padBlitNative(op, srcPict, maskPict, dstPict,
 332                       XDoubleToFixed(maskTrx.getScaleX()),
 333                       XDoubleToFixed(maskTrx.getShearX()),
 334                       XDoubleToFixed(maskTrx.getTranslateX()),
 335                       XDoubleToFixed(maskTrx.getShearY()),
 336                       XDoubleToFixed(maskTrx.getScaleY()),
< prev index next >