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 23 * questions. 24 */ 25 26 package sun.java2d; 27 28 import java.awt.Color; 29 import java.awt.Rectangle; 30 import java.awt.AlphaComposite; 31 import java.awt.GraphicsEnvironment; 32 33 import sun.awt.DisplayChangedListener; 34 import sun.java2d.StateTrackable.State; 35 import sun.java2d.loops.CompositeType; 36 import sun.java2d.loops.SurfaceType; 37 import sun.java2d.loops.Blit; 38 import sun.java2d.loops.BlitBg; 39 import sun.awt.image.SurfaceManager; 40 import sun.awt.image.SurfaceManager.FlushableCacheData; 41 42 import java.security.AccessController; 43 import sun.security.action.GetPropertyAction; 44 45 /** 46 * The proxy class encapsulates the logic for managing alternate 47 * SurfaceData representations of a primary SurfaceData. 48 * The main class will handle tracking the state changes of the 49 * primary SurfaceData and updating the associated SurfaceData 50 * proxy variants. 51 * <p> 52 * Subclasses have 2 main responsibilities: 53 * <ul> 54 * <li> Override the isSupportedOperation() method to determine if 55 * a given operation can be accelerated with a given source 56 * SurfaceData 57 * <li> Override the validateSurfaceData() method to create or update 58 * a given accelerated surface to hold the pixels for the indicated 59 * source SurfaceData 60 * </ul> 61 * If necessary, a subclass may also override the updateSurfaceData 62 * method to transfer the pixels to the accelerated surface. 63 * By default the parent class will transfer the pixels using a 64 * standard Blit operation between the two SurfaceData objects. 65 */ 66 public abstract class SurfaceDataProxy 67 implements DisplayChangedListener, SurfaceManager.FlushableCacheData 68 { 69 private static boolean cachingAllowed; 70 private static int defaultThreshold; 71 72 static { 73 cachingAllowed = true; 74 String manimg = (String)AccessController.doPrivileged( 75 new GetPropertyAction("sun.java2d.managedimages")); 76 if (manimg != null && manimg.equals("false")) { 77 cachingAllowed = false; 78 System.out.println("Disabling managed images"); 79 } 80 81 defaultThreshold = 1; 82 String num = (String)AccessController.doPrivileged( 83 new GetPropertyAction("sun.java2d.accthreshold")); 84 if (num != null) { 85 try { 86 int parsed = Integer.parseInt(num); 87 if (parsed >= 0) { 88 defaultThreshold = parsed; 89 System.out.println("New Default Acceleration Threshold: " + 90 defaultThreshold); 91 } 92 } catch (NumberFormatException e) { 93 System.err.println("Error setting new threshold:" + e); 94 } 95 } 96 } 97 98 public static boolean isCachingAllowed() { 99 return cachingAllowed; 100 } 101 102 /** | 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 23 * questions. 24 */ 25 26 package sun.java2d; 27 28 import java.awt.Color; 29 import java.awt.Rectangle; 30 import java.awt.AlphaComposite; 31 import java.awt.GraphicsEnvironment; 32 33 import sun.awt.DisplayChangedListener; 34 import sun.java2d.StateTrackable.State; 35 import sun.java2d.loops.CompositeType; 36 import sun.java2d.loops.SurfaceType; 37 import sun.java2d.loops.Blit; 38 import sun.java2d.loops.BlitBg; 39 import sun.awt.image.SurfaceManager; 40 41 import java.security.AccessController; 42 import sun.security.action.GetPropertyAction; 43 44 /** 45 * The proxy class encapsulates the logic for managing alternate 46 * SurfaceData representations of a primary SurfaceData. 47 * The main class will handle tracking the state changes of the 48 * primary SurfaceData and updating the associated SurfaceData 49 * proxy variants. 50 * <p> 51 * Subclasses have 2 main responsibilities: 52 * <ul> 53 * <li> Override the isSupportedOperation() method to determine if 54 * a given operation can be accelerated with a given source 55 * SurfaceData 56 * <li> Override the validateSurfaceData() method to create or update 57 * a given accelerated surface to hold the pixels for the indicated 58 * source SurfaceData 59 * </ul> 60 * If necessary, a subclass may also override the updateSurfaceData 61 * method to transfer the pixels to the accelerated surface. 62 * By default the parent class will transfer the pixels using a 63 * standard Blit operation between the two SurfaceData objects. 64 */ 65 public abstract class SurfaceDataProxy 66 implements DisplayChangedListener, SurfaceManager.FlushableCacheData 67 { 68 private static boolean cachingAllowed; 69 private static int defaultThreshold; 70 71 static { 72 cachingAllowed = true; 73 String manimg = AccessController.doPrivileged( 74 new GetPropertyAction("sun.java2d.managedimages")); 75 if (manimg != null && manimg.equals("false")) { 76 cachingAllowed = false; 77 System.out.println("Disabling managed images"); 78 } 79 80 defaultThreshold = 1; 81 String num = AccessController.doPrivileged( 82 new GetPropertyAction("sun.java2d.accthreshold")); 83 if (num != null) { 84 try { 85 int parsed = Integer.parseInt(num); 86 if (parsed >= 0) { 87 defaultThreshold = parsed; 88 System.out.println("New Default Acceleration Threshold: " + 89 defaultThreshold); 90 } 91 } catch (NumberFormatException e) { 92 System.err.println("Error setting new threshold:" + e); 93 } 94 } 95 } 96 97 public static boolean isCachingAllowed() { 98 return cachingAllowed; 99 } 100 101 /** |