changeset 4984:877523a1e150

Add -Dsun.perflog.fx.firstpaintexit and move properties to PrismSettings Reviewed by: Richard B
author snorthov
date Thu, 05 Sep 2013 15:44:58 -0400
parents eac39a252c9a
children dc0086b1cad0
files modules/graphics/src/main/java/com/sun/javafx/tk/quantum/PerformanceTrackerHelper.java modules/graphics/src/main/java/com/sun/prism/impl/PrismSettings.java modules/graphics/src/main/java/javafx/scene/Scene.java
diffstat 3 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/PerformanceTrackerHelper.java	Thu Sep 05 16:08:17 2013 +0200
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/PerformanceTrackerHelper.java	Thu Sep 05 15:44:58 2013 -0400
@@ -26,6 +26,8 @@
 package com.sun.javafx.tk.quantum;
 
 import com.sun.javafx.tk.Toolkit;
+import com.sun.prism.impl.PrismSettings;
+
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.security.AccessController;
@@ -52,12 +54,11 @@
                     @Override
                     public PerformanceTrackerHelper run() {
                         try {
-                            if (System.getProperty("sun.perflog") != null) {
+                            if (PrismSettings.perfLog) {
                                 final PerformanceTrackerHelper trackerImpl =
                                         new PerformanceTrackerDefaultImpl();
 
-                                if (System.getProperty(
-                                        "sun.perflog.fx.exitflush") != null) {
+                                if (PrismSettings.perfLogExitFlush) {
                                     Runtime.getRuntime().addShutdownHook(
                                             new Thread() {
 
--- a/modules/graphics/src/main/java/com/sun/prism/impl/PrismSettings.java	Thu Sep 05 16:08:17 2013 +0200
+++ b/modules/graphics/src/main/java/com/sun/prism/impl/PrismSettings.java	Thu Sep 05 15:44:58 2013 -0400
@@ -83,6 +83,10 @@
     public static final boolean disableEffects;
     public static final int glyphCacheWidth;
     public static final int glyphCacheHeight;
+    public static final boolean perfLog;
+    public static final boolean perfLogExitFlush;
+    public static final boolean perfLogFirstPaintFlush;
+    public static final boolean perfLogFirstPaintExit;
 
     private PrismSettings() {
     }
@@ -333,6 +337,16 @@
                 "Try -Dprism.glyphCacheWidth=<number>");
         glyphCacheHeight = getInt(systemProperties, "prism.glyphCacheHeight", 1024,
                 "Try -Dprism.glyphCacheHeight=<number>");
+
+        /*
+         * Performance Logger flags
+         * Enable the performance logger, print on exit, print on first paint etc.
+         */
+        perfLog = getBoolean(systemProperties, "sun.perflog", false, true);
+        perfLogExitFlush = getBoolean(systemProperties, "sun.perflog.fx.exitflush", false, true);
+        perfLogFirstPaintFlush = getBoolean(systemProperties, "sun.perflog.fx.firstpaintflush", false, true);
+        perfLogFirstPaintExit = getBoolean(systemProperties, "sun.perflog.fx.firstpaintexit", false, true);
+
     }
 
     private static int parseInt(String s, int dflt, int trueDflt,
@@ -398,6 +412,15 @@
         final String strval = properties.getProperty(key);
         return (strval != null) ? Boolean.parseBoolean(strval) : dflt;
     }
+    
+    private static boolean getBoolean(Properties properties,
+                                      String key,
+                                      boolean dflt,
+                                      boolean dfltIfDefined) {
+        final String strval = properties.getProperty(key);
+        if (strval != null && strval.length() == 0) return dfltIfDefined;
+        return (strval != null) ? Boolean.parseBoolean(strval) : dflt;
+    }
 
     private static int getInt(Properties properties,
                               String key,
--- a/modules/graphics/src/main/java/javafx/scene/Scene.java	Thu Sep 05 16:08:17 2013 +0200
+++ b/modules/graphics/src/main/java/javafx/scene/Scene.java	Thu Sep 05 15:44:58 2013 -0400
@@ -138,6 +138,7 @@
 import com.sun.javafx.tk.TKStage;
 import com.sun.javafx.tk.Toolkit;
 import com.sun.javafx.scene.LayoutFlags;
+import com.sun.prism.impl.PrismSettings;
 
 import sun.util.logging.PlatformLogger;
 import sun.util.logging.PlatformLogger.Level;
@@ -2337,14 +2338,12 @@
             if (firstPulse) {
                 if (PerformanceTracker.isLoggingEnabled()) {
                     PerformanceTracker.logEvent("Scene - first repaint - layout complete");
-                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                        @Override public Object run() {
-                            if (System.getProperty("sun.perflog.fx.firstpaintflush") != null) {
-                                PerformanceTracker.outputLog();
-                            }
-                            return null;
-                        }
-                    });
+                    if (PrismSettings.perfLogFirstPaintFlush) {
+                        PerformanceTracker.outputLog();
+                    }
+                    if (PrismSettings.perfLogFirstPaintExit) {
+                        System.exit(0);
+                    }
                 }
                 firstPulse = false;
             }