< prev index next >

src/java.desktop/unix/classes/sun/java2d/x11/X11SurfaceData.java

Print this page




  55 import sun.java2d.SurfaceData;
  56 import sun.java2d.SurfaceDataProxy;
  57 import sun.java2d.loops.SurfaceType;
  58 import sun.java2d.loops.CompositeType;
  59 import sun.java2d.loops.RenderLoops;
  60 import sun.java2d.loops.GraphicsPrimitive;
  61 import sun.java2d.loops.XORComposite;
  62 import sun.java2d.loops.Blit;
  63 import sun.java2d.pipe.ValidatePipe;
  64 import sun.java2d.pipe.PixelToShapeConverter;
  65 import sun.java2d.pipe.TextPipe;
  66 import sun.java2d.pipe.Region;
  67 
  68 public abstract class X11SurfaceData extends XSurfaceData {
  69     X11ComponentPeer peer;
  70     X11GraphicsConfig graphicsConfig;
  71     private RenderLoops solidloops;
  72 
  73     protected int depth;
  74 
  75     private static native void initIDs(Class<?> xorComp, boolean tryDGA);
  76     protected native void initSurface(int depth, int width, int height,
  77                                       long drawable);
  78 
  79     public static final String
  80         DESC_INT_BGR_X11        = "Integer BGR Pixmap";
  81     public static final String
  82         DESC_INT_RGB_X11        = "Integer RGB Pixmap";
  83 
  84     public static final String
  85         DESC_4BYTE_ABGR_PRE_X11 = "4 byte ABGR Pixmap with pre-multplied alpha";
  86     public static final String
  87         DESC_INT_ARGB_PRE_X11   = "Integer ARGB Pixmap with pre-multiplied " +
  88                                   "alpha";
  89 
  90     public static final String
  91         DESC_BYTE_IND_OPQ_X11   = "Byte Indexed Opaque Pixmap";
  92 
  93     public static final String
  94         DESC_INT_BGR_X11_BM     = "Integer BGR Pixmap with 1-bit transp";
  95     public static final String


 196     public static final SurfaceType ByteGrayX11_BM =
 197         SurfaceType.Custom.deriveSubType(DESC_BYTE_GRAY_X11_BM);
 198     public static final SurfaceType Index8GrayX11_BM =
 199         SurfaceType.Custom.deriveSubType(DESC_INDEX8_GRAY_X11_BM);
 200 
 201 
 202     private static Boolean accelerationEnabled = null;
 203 
 204     public Raster getRaster(int x, int y, int w, int h) {
 205         throw new InternalError("not implemented yet");
 206     }
 207 
 208     protected X11Renderer x11pipe;
 209     protected PixelToShapeConverter x11txpipe;
 210     protected static TextPipe x11textpipe;
 211     protected static boolean dgaAvailable;
 212 
 213     static {
 214        if (!isX11SurfaceDataInitialized() &&
 215            !GraphicsEnvironment.isHeadless()) {
 216             // If a screen magnifier is present, don't attempt to use DGA
 217             String magPresent = java.security.AccessController.doPrivileged
 218                 (new sun.security.action.GetPropertyAction("javax.accessibility.screen_magnifier_present"));
 219             boolean tryDGA = magPresent == null || !"true".equals(magPresent);
 220 
 221             initIDs(XORComposite.class, tryDGA);
 222 
 223             String xtextpipe = java.security.AccessController.doPrivileged
 224                 (new sun.security.action.GetPropertyAction("sun.java2d.xtextpipe"));
 225             if (xtextpipe == null || "true".startsWith(xtextpipe)) {
 226                 if ("true".equals(xtextpipe)) {
 227                     // Only verbose if they use the full string "true"
 228                     System.out.println("using X11 text renderer");
 229                 }
 230                 x11textpipe = new X11TextRenderer();
 231                 if (GraphicsPrimitive.tracingEnabled()) {
 232                     x11textpipe = ((X11TextRenderer) x11textpipe).traceWrap();
 233                 }
 234             } else {
 235                 if ("false".equals(xtextpipe)) {
 236                     // Only verbose if they use the full string "false"
 237                     System.out.println("using DGA text renderer");
 238                 }
 239                 x11textpipe = solidTextRenderer;
 240             }
 241 
 242             dgaAvailable = isDgaAvailable();
 243 
 244             if (isAccelerationEnabled()) {
 245                 X11PMBlitLoops.register();
 246                 X11PMBlitBgLoops.register();
 247             }
 248        }
 249     }
 250 
 251     /**
 252      * Returns true if we can use DGA on any of the screens
 253      */
 254     public static native boolean isDgaAvailable();
 255 
 256     /**
 257      * Returns true if shared memory pixmaps are available
 258      */
 259     private static native boolean isShmPMAvailable();
 260 
 261     public static boolean isAccelerationEnabled() {
 262         if (accelerationEnabled == null) {
 263 
 264             if (GraphicsEnvironment.isHeadless()) {
 265                 accelerationEnabled = Boolean.FALSE;
 266             } else {
 267                 String prop = java.security.AccessController.doPrivileged(
 268                         new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
 269                 if (prop != null) {
 270                     // true iff prop==true, false otherwise
 271                     accelerationEnabled = Boolean.valueOf(prop);
 272                 } else {
 273                     boolean isDisplayLocal = false;
 274                     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 275                     if (ge instanceof SunGraphicsEnvironment) {
 276                         isDisplayLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
 277                      }
 278 
 279                     // EXA based drivers tend to place pixmaps in VRAM, slowing down readbacks.
 280                     // Don't use pixmaps if dga is available,
 281                     // or we are local and shared memory Pixmaps are not available.
 282                     accelerationEnabled =
 283                         !(isDgaAvailable() || (isDisplayLocal && !isShmPMAvailable()));
 284                 }
 285             }
 286         }
 287         return accelerationEnabled.booleanValue();
 288     }
 289 
 290     @Override
 291     public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
 292         return X11SurfaceDataProxy.createProxy(srcData, graphicsConfig);
 293     }
 294 
 295     public void validatePipe(SunGraphics2D sg2d) {
 296         if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
 297             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
 298             (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
 299              sg2d.compositeState == SunGraphics2D.COMP_XOR))
 300         {
 301             if (x11txpipe == null) {
 302                 /*
 303                  * Note: this is thread-safe since x11txpipe is the




  55 import sun.java2d.SurfaceData;
  56 import sun.java2d.SurfaceDataProxy;
  57 import sun.java2d.loops.SurfaceType;
  58 import sun.java2d.loops.CompositeType;
  59 import sun.java2d.loops.RenderLoops;
  60 import sun.java2d.loops.GraphicsPrimitive;
  61 import sun.java2d.loops.XORComposite;
  62 import sun.java2d.loops.Blit;
  63 import sun.java2d.pipe.ValidatePipe;
  64 import sun.java2d.pipe.PixelToShapeConverter;
  65 import sun.java2d.pipe.TextPipe;
  66 import sun.java2d.pipe.Region;
  67 
  68 public abstract class X11SurfaceData extends XSurfaceData {
  69     X11ComponentPeer peer;
  70     X11GraphicsConfig graphicsConfig;
  71     private RenderLoops solidloops;
  72 
  73     protected int depth;
  74 
  75     private static native void initIDs(Class<?> xorComp);
  76     protected native void initSurface(int depth, int width, int height,
  77                                       long drawable);
  78 
  79     public static final String
  80         DESC_INT_BGR_X11        = "Integer BGR Pixmap";
  81     public static final String
  82         DESC_INT_RGB_X11        = "Integer RGB Pixmap";
  83 
  84     public static final String
  85         DESC_4BYTE_ABGR_PRE_X11 = "4 byte ABGR Pixmap with pre-multplied alpha";
  86     public static final String
  87         DESC_INT_ARGB_PRE_X11   = "Integer ARGB Pixmap with pre-multiplied " +
  88                                   "alpha";
  89 
  90     public static final String
  91         DESC_BYTE_IND_OPQ_X11   = "Byte Indexed Opaque Pixmap";
  92 
  93     public static final String
  94         DESC_INT_BGR_X11_BM     = "Integer BGR Pixmap with 1-bit transp";
  95     public static final String


 196     public static final SurfaceType ByteGrayX11_BM =
 197         SurfaceType.Custom.deriveSubType(DESC_BYTE_GRAY_X11_BM);
 198     public static final SurfaceType Index8GrayX11_BM =
 199         SurfaceType.Custom.deriveSubType(DESC_INDEX8_GRAY_X11_BM);
 200 
 201 
 202     private static Boolean accelerationEnabled = null;
 203 
 204     public Raster getRaster(int x, int y, int w, int h) {
 205         throw new InternalError("not implemented yet");
 206     }
 207 
 208     protected X11Renderer x11pipe;
 209     protected PixelToShapeConverter x11txpipe;
 210     protected static TextPipe x11textpipe;
 211     protected static boolean dgaAvailable;
 212 
 213     static {
 214        if (!isX11SurfaceDataInitialized() &&
 215            !GraphicsEnvironment.isHeadless()) {




 216 
 217             initIDs(XORComposite.class);
 218 
 219             String xtextpipe = java.security.AccessController.doPrivileged
 220                 (new sun.security.action.GetPropertyAction("sun.java2d.xtextpipe"));
 221             if (xtextpipe == null || "true".startsWith(xtextpipe)) {
 222                 if ("true".equals(xtextpipe)) {
 223                     // Only verbose if they use the full string "true"
 224                     System.out.println("using X11 text renderer");
 225                 }
 226                 x11textpipe = new X11TextRenderer();
 227                 if (GraphicsPrimitive.tracingEnabled()) {
 228                     x11textpipe = ((X11TextRenderer) x11textpipe).traceWrap();
 229                 }
 230             } else {
 231                 if ("false".equals(xtextpipe)) {
 232                     // Only verbose if they use the full string "false"
 233                     System.out.println("using DGA text renderer");
 234                 }
 235                 x11textpipe = solidTextRenderer;
 236             }
 237 


 238             if (isAccelerationEnabled()) {
 239                 X11PMBlitLoops.register();
 240                 X11PMBlitBgLoops.register();
 241             }
 242        }
 243     }
 244 
 245     /**





 246      * Returns true if shared memory pixmaps are available
 247      */
 248     private static native boolean isShmPMAvailable();
 249 
 250     public static boolean isAccelerationEnabled() {
 251         if (accelerationEnabled == null) {
 252 
 253             if (GraphicsEnvironment.isHeadless()) {
 254                 accelerationEnabled = Boolean.FALSE;
 255             } else {
 256                 String prop = java.security.AccessController.doPrivileged(
 257                         new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
 258                 if (prop != null) {
 259                     // true iff prop==true, false otherwise
 260                     accelerationEnabled = Boolean.valueOf(prop);
 261                 } else {
 262                     boolean isDisplayLocal = false;
 263                     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 264                     if (ge instanceof SunGraphicsEnvironment) {
 265                         isDisplayLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
 266                      }
 267 
 268                     // EXA based drivers tend to place pixmaps in VRAM, slowing down readbacks.
 269                     // Don't use pixmaps if we are local and shared memory Pixmaps
 270                     // are not available.
 271                     accelerationEnabled = !(isDisplayLocal && !isShmPMAvailable());

 272                 }
 273             }
 274         }
 275         return accelerationEnabled.booleanValue();
 276     }
 277 
 278     @Override
 279     public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
 280         return X11SurfaceDataProxy.createProxy(srcData, graphicsConfig);
 281     }
 282 
 283     public void validatePipe(SunGraphics2D sg2d) {
 284         if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
 285             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
 286             (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
 287              sg2d.compositeState == SunGraphics2D.COMP_XOR))
 288         {
 289             if (x11txpipe == null) {
 290                 /*
 291                  * Note: this is thread-safe since x11txpipe is the


< prev index next >