Revision: 4960
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4960&view=rev
Author:   bphinz
Date:     2012-08-26 18:20:15 +0000 (Sun, 26 Aug 2012)
Log Message:
-----------
Significantly improve performance by eliminating the intermediary 
MemoryImageSource and instead directly modifying the pixels in the 
BufferedImage.  Supposedly, doing this causes the BufferedImage to become 
unmanaged.  At one time, unmanaged images weren't hardware-accelerated on some 
platforms, but that doesn't seem to be the case with Java 1.5 and later.

Modified Paths:
--------------
    trunk/java/com/tigervnc/vncviewer/BIPixelBuffer.java

Modified: trunk/java/com/tigervnc/vncviewer/BIPixelBuffer.java
===================================================================
--- trunk/java/com/tigervnc/vncviewer/BIPixelBuffer.java        2012-08-26 
18:06:52 UTC (rev 4959)
+++ trunk/java/com/tigervnc/vncviewer/BIPixelBuffer.java        2012-08-26 
18:20:15 UTC (rev 4960)
@@ -1,4 +1,5 @@
 /* Copyright (C) 2012 Brian P. Hinz
+ * Copyright (C) 2012 D. R. Commander.  All Rights Reserved.
  * 
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,14 +34,10 @@
 
   public void setPF(PixelFormat pf) {
     super.setPF(pf);
-    if (source != null)
-      source.newPixels(data, cm, 0, width_);
   }
 
   public void updateColourMap() {
     cm = new IndexColorModel(8, nColours, reds, greens, blues);
-    if (source != null)
-      source.newPixels(data, cm, 0, width_);
   }
   
   // resize() resizes the image, preserving the image data where possible.
@@ -56,12 +53,11 @@
     image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
     image.setAccelerationPriority(1);
     image.createGraphics();
-    data = new int[width() * height()];
-    source = new MemoryImageSource(w, h, cm, data, 0, w);
-    source.setAnimated(true);
-    source.setFullBufferUpdates(false);
-    source.newPixels(data, cm, 0, width_);
-    sourceImage = tk.createImage(source);
+    WritableRaster wr = image.getRaster();
+    SinglePixelPackedSampleModel sm =
+      (SinglePixelPackedSampleModel)image.getSampleModel();
+    DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
+    data = db.getData();
   }
 
   public void fillRect(int x, int y, int w, int h, int pix) {
@@ -98,12 +94,6 @@
     } else {
       for (int j = 0; j < h; j++)
         System.arraycopy(pix, (w*j), data, width_ * (y + j) + x, w);
-      source.newPixels(x, y, w, h, true);
-      Graphics2D graphics = (Graphics2D)image.getGraphics();
-      graphics.setClip(x, y, w, h);
-      graphics.drawImage(sourceImage, 0, 0, null);
-      graphics.setClip(0, 0, width(), height());
-      graphics.dispose();
     }
   }
 
@@ -136,9 +126,6 @@
   }
 
   BufferedImage image;
-  MemoryImageSource source;
-  int[] data;
-  Image sourceImage;
   Rectangle clip;
 
   static LogWriter vlog = new LogWriter("BIPixelBuffer");

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Tigervnc-commits mailing list
Tigervnc-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to