src/solaris/classes/sun/java2d/x11/X11SurfaceData.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 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 = (String) 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 = (String) 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 


 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 =
 268                     (String) java.security.AccessController.doPrivileged(
 269                         new sun.security.action.GetPropertyAction("sun.java2d.pmoffscreen"));
 270                 if (prop != null) {
 271                     // true iff prop==true, false otherwise
 272                     accelerationEnabled = Boolean.valueOf(prop);
 273                 } else {
 274                     boolean isDisplayLocal = false;
 275                     GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 276                     if (ge instanceof SunGraphicsEnvironment) {
 277                         isDisplayLocal = ((SunGraphicsEnvironment) ge).isDisplayLocal();
 278                      }
 279 
 280                     // EXA based drivers tend to place pixmaps in VRAM, slowing down readbacks.
 281                     // Don't use pixmaps if dga is available,
 282                     // or we are local and shared memory Pixmaps are not available.
 283                     accelerationEnabled =
 284                         !(isDgaAvailable() || (isDisplayLocal && !isShmPMAvailable()));
 285                 }
 286             }
 287         }
 288         return accelerationEnabled.booleanValue();


   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 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 


 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();