jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java
changeset 1739 ed98610896e7
parent 2 90ce3da70b43
child 2758 d2fbe9b5857a
equal deleted inserted replaced
1738:64832045cb32 1739:ed98610896e7
    48 import sun.awt.X11GraphicsConfig;
    48 import sun.awt.X11GraphicsConfig;
    49 import sun.awt.image.PixelConverter;
    49 import sun.awt.image.PixelConverter;
    50 import sun.font.X11TextRenderer;
    50 import sun.font.X11TextRenderer;
    51 import sun.java2d.InvalidPipeException;
    51 import sun.java2d.InvalidPipeException;
    52 import sun.java2d.SunGraphics2D;
    52 import sun.java2d.SunGraphics2D;
       
    53 import sun.java2d.SunGraphicsEnvironment;
    53 import sun.java2d.SurfaceData;
    54 import sun.java2d.SurfaceData;
    54 import sun.java2d.SurfaceDataProxy;
    55 import sun.java2d.SurfaceDataProxy;
    55 import sun.java2d.loops.SurfaceType;
    56 import sun.java2d.loops.SurfaceType;
    56 import sun.java2d.loops.CompositeType;
    57 import sun.java2d.loops.CompositeType;
    57 import sun.java2d.loops.RenderLoops;
    58 import sun.java2d.loops.RenderLoops;
   238     /**
   239     /**
   239      * Returns true if we can use DGA on any of the screens
   240      * Returns true if we can use DGA on any of the screens
   240      */
   241      */
   241     public static native boolean isDgaAvailable();
   242     public static native boolean isDgaAvailable();
   242 
   243 
       
   244     /**
       
   245      * Returns true if shared memory pixmaps are available
       
   246      */
       
   247     private static native boolean isShmPMAvailable();
       
   248 
   243     public static boolean isAccelerationEnabled() {
   249     public static boolean isAccelerationEnabled() {
   244         if (accelerationEnabled == null) {
   250         if (accelerationEnabled == null) {
   245 
   251 
   246             if (GraphicsEnvironment.isHeadless()) {
   252             if (GraphicsEnvironment.isHeadless()) {
   247                 accelerationEnabled = Boolean.FALSE;
   253                 accelerationEnabled = Boolean.FALSE;
   251                         new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
   257                         new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
   252                 if (prop != null) {
   258                 if (prop != null) {
   253                     // true iff prop==true, false otherwise
   259                     // true iff prop==true, false otherwise
   254                     accelerationEnabled = Boolean.valueOf(prop);
   260                     accelerationEnabled = Boolean.valueOf(prop);
   255                 } else {
   261                 } else {
   256                     // use pixmaps if there is no dga, no matter local or remote
   262                     boolean isDisplayLocal = false;
   257                     accelerationEnabled = Boolean.valueOf(!isDgaAvailable());
   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 dga is available,
       
   270                     // or we are local and shared memory Pixmaps are not available.
       
   271                     accelerationEnabled =
       
   272                         !(isDgaAvailable() || (isDisplayLocal && !isShmPMAvailable()));
   258                 }
   273                 }
   259             }
   274             }
   260         }
   275         }
   261         return accelerationEnabled.booleanValue();
   276         return accelerationEnabled.booleanValue();
   262     }
   277     }