changeset 33:8e66d9386273

Double-buffer applet frame drawing.
author Deepak Bhole <dbhole@redhat.com>
date Thu, 04 Nov 2010 16:44:27 -0700
parents 2405cef22921
children 9dd09feb371b
files ChangeLog NEWS plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
diffstat 3 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Nov 03 23:06:23 2010 +0000
+++ b/ChangeLog	Thu Nov 04 16:44:27 2010 -0700
@@ -1,3 +1,8 @@
+2010-11-04  Deepak Bhole <dbhole@redhat.com>
+
+	* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java (update):
+	Override method and implement double-buffering.
+
 2010-10-28  Andrew John Hughes  <ahughes@redhat.com>
 
 	* Makefile.am:
--- a/NEWS	Wed Nov 03 23:06:23 2010 +0000
+++ b/NEWS	Thu Nov 04 16:44:27 2010 -0700
@@ -12,3 +12,4 @@
 
 * Initial release of IcedTea-Web
 * PR542: Plugin fails with NPE on http://www.openprocessing.org/visuals/iframe.php?visualID=2615
+* Applets are now double-buffered to eliminate flicker in ones that do heavy drawing
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Wed Nov 03 23:06:23 2010 +0000
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java	Thu Nov 04 16:44:27 2010 -0700
@@ -359,6 +359,9 @@
 
      private static Long requestIdentityCounter = 0L;
      
+     private Image bufFrameImg;
+     private Graphics bufFrameImgGraphics;
+     
      /**
       * Null constructor to allow instantiation via newInstance()
       */
@@ -2163,4 +2166,26 @@
         }
     }
      }
+
+     /**
+      * {@inheritDoc}
+      *
+      * This method calls paint directly, rather than via super.update() since
+      * the parent class's update() just does a couple of checks (both of 
+      * which are accounted for) and then calls paint anyway.
+      */
+     public void update(Graphics g) {
+
+    	 // If the image or the graphics don't exist, create new ones
+    	 if (bufFrameImg == null || bufFrameImgGraphics == null) {
+    		 bufFrameImg = createImage(getWidth(), getHeight());
+    		 bufFrameImgGraphics = bufFrameImg.getGraphics ();
+    	 }
+
+    	 // Paint off-screen
+    	 paint(bufFrameImgGraphics);
+
+    	 // Draw the painted image
+    	 g.drawImage(bufFrameImg, 0, 0, this);
+     }
  }