Skip to content

Commit

Permalink
Use GDI Java2D blitting by default on Windows (because it's faster)
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.code.sf.net/p/turbovnc/code/trunk@2957 799e4f7b-5fd2-41f6-823c-2ecc41bc7f0b
  • Loading branch information
dcommander committed Feb 6, 2015
1 parent b79846b commit bab84cd
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
12 changes: 12 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ property to "true".)
The "turbovnc.forcealpha" Java system property can be used to override the
defualt behavior described above.
-------------------------------------------------------------------------------
[13]
Normally, Java2D uses Direct3D by default for blitting (image drawing) on
Windows platforms, but GDI blitting is almost always faster (sometimes much
faster.) Thus, the Java TurboVNC Viewer now attempts to disable Direct3D
blitting on Windows unless it is specifically requested (which can be
accomplished by setting the "sun.java2d.d3d" system property to "true".)
Because Direct3D blitting can't be disabled programmatically under Java 1.6 and
earlier, the vncviewer-java.bat script and the Windows start menu shortcut now
pass -Dsun.java2d.d3d=false to java to ensure that Direct3D blitting is
always disabled when the Java TurboVNC Viewer is run as a standalone
application.
-------------------------------------------------------------------------------


===============================================================================
Expand Down
23 changes: 20 additions & 3 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta name="language" content="en">
<meta name="date" content="2015-02-05T20:59:23">
<meta name="date" content="2015-02-06T00:40:56">
<meta name="generator" content="deplate.rb 0.8.5">
<title>User&rsquo;s Guide for TurboVNC 2.0</title>
<link rel="start" href="index.html" title="Frontpage">
Expand Down Expand Up @@ -1549,7 +1549,24 @@ <h3 id="hd007006002">Accelerating X11 Blitting</h3>



<h3 id="hd007006003">Using the Server VM</h3>
<h3 id="hd007006003">Accelerating Windows Blitting</h3>

<p>The default in Java2D on Windows platforms is to use Direct3D for
blitting, but in the case of TurboVNC, using GDI blitting is almost
always much faster. If you are using Java 1.7 or later, or if you are
running the Java TurboVNC Viewer using the
<code>vncviewer-java.bat</code> script or launching it using the Windows
Start Menu shortcut, then Direct3D blitting will be disabled by default,
and no further action is necessary. Otherwise, you should consider
setting the <code>sun.java2d.d3d</code> system property to
<code>false</code> (for instance, by passing
<code>-Dsun.java2d.d3d=false</code> as an argument to
<code>java</code>.) You can use the ImageDrawTest benchmark (see above)
to verify whether Direct3D blitting is enabled or disabled.</p>



<h3 id="hd007006004">Using the Server VM</h3>

<p>Passing an argument of <code>-server</code> to <code>java</code> when
launching the Java TurboVNC Viewer is recommended. This enables the
Expand All @@ -1563,7 +1580,7 @@ <h3 id="hd007006003">Using the Server VM</h3>



<h3 id="hd007006004">Java Web Start</h3>
<h3 id="hd007006005">Java Web Start</h3>

<p>Java Web Start can be used to deploy the Java TurboVNC Viewer and the
associated libjpeg-turbo JNI libraries from a web server. Deploying the
Expand Down
14 changes: 14 additions & 0 deletions doc/performance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,20 @@ However, on newer systems with fast memory access (particularly systems with a
large L2 or L3 cache), this overhead should have a negligible impact on overall
performance.

*** Accelerating Windows Blitting
#OPT: noList! plain!

The default in Java2D on Windows platforms is to use Direct3D for blitting,
but in the case of TurboVNC, using GDI blitting is almost always much faster.
If you are using Java 1.7 or later, or if you are running the Java TurboVNC
Viewer using the ''vncviewer-java.bat'' script or launching it using the
Windows Start Menu shortcut, then Direct3D blitting will be disabled by
default, and no further action is necessary. Otherwise, you should consider
setting the ''sun.java2d.d3d'' system property to ''false'' (for instance, by
passing ''-Dsun.java2d.d3d=false'' as an argument to ''java''.) You can use
the ImageDrawTest benchmark (see above) to verify whether Direct3D blitting is
enabled or disabled.

*** Using the Server VM
#OPT: noList! plain!

Expand Down
6 changes: 4 additions & 2 deletions java/com/turbovnc/vncviewer/ImageDrawTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ public ImageDrawTest(int width, int height, int colors) {
panel.display();
}

static {
VncViewer.setBlitterDefaults();
}

public static void main(String[] arg) {
int colors = -1, width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT;

VncViewer.setBlitterDefaults();

for (int i = 0; i < arg.length; i++) {
if (arg[i].toLowerCase().startsWith("-c") && i < arg.length - 1) {
int temp = -1;
Expand Down
18 changes: 16 additions & 2 deletions java/com/turbovnc/vncviewer/VncViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,22 @@ public static void setBlitterDefaults() {
defForceAlpha = true;

forceAlpha = getBooleanProperty("turbovnc.forcealpha", defForceAlpha);

// Disable Direct3D Java2D blitting unless the user specifically requests
// it (by setting the sun.java2d.d3d property to true.) GDI Java2D
// blitting is almost always faster than D3D, but D3D is normally the
// default. Note that this doesn't work with Java 1.6 and earlier, for
// unknown reasons. Apparently it reads the Java2D system properties
// before our code can influence them.
if (os.startsWith("windows")) {
String prop = System.getProperty("sun.java2d.d3d");
if (prop == null || prop.length() < 1 || !Boolean.parseBoolean(prop))
System.setProperty("sun.java2d.d3d", "false");
}
}

static {
setBlitterDefaults();
}

public static void main(String[] argv) {
Expand Down Expand Up @@ -281,7 +297,6 @@ public VncViewer(String[] argv) {
UserPreferences.load("global");

setVersion();
setBlitterDefaults();

// Override defaults with command-line options
for (int i = 0; i < argv.length; i++) {
Expand Down Expand Up @@ -429,7 +444,6 @@ public VncViewer() {
applet = true;
UserPreferences.load("global");
setVersion();
setBlitterDefaults();
setGlobalOptions();
}

Expand Down
2 changes: 1 addition & 1 deletion win/vncviewer-java/vncviewer-java.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ if "%JAVA_HOME%"=="" (
set JAVA=%JAVA:"=%

:start
"%JAVA%" -server -Djava.library.path=java -jar java\VncViewer.jar -reqarch @REQARCH@ %*
"%JAVA%" -server -Dsun.java2d.d3d=false -Djava.library.path=java -jar java\VncViewer.jar -reqarch @REQARCH@ %*
2 changes: 1 addition & 1 deletion win/vncviewer-java/vncviewer-javaw.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ if "%JAVA_HOME%"=="" (
set JAVAW=%JAVAW:"=%

:start
start /b "" "%JAVAW%" -server -Djava.library.path=java -jar java\VncViewer.jar -reqarch @REQARCH@ %*
start /b "" "%JAVAW%" -server -Dsun.java2d.d3d=false -Djava.library.path=java -jar java\VncViewer.jar -reqarch @REQARCH@ %*

0 comments on commit bab84cd

Please sign in to comment.