[icedtea-web] RFC: Patch to double-buffer applets
Deepak Bhole
dbhole at redhat.com
Tue Nov 2 14:37:57 PDT 2010
* Deepak Bhole <dbhole at redhat.com> [2010-11-02 17:31]:
> Hi,
>
> IcedTea plugin currently does not double-buffer the applet panel. As a
> result, some applets may flicker depending on the machine.
>
> Attached patch buffers the frame offscreen and then draws it, thereby
> addressing the issue.
>
> ChangeLog:
> 2010-11-02 Deepak Bhole <dbhole at redhat.com>
>
> * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java (update):
> Override method and implement double-buffering.
>
> Cheers,
> Deepak
Doh! There shouldn't be a println in there. New patch attached. I also
fixed the variable names for the image and its graphics.
Cheers,
Deepak
> diff -r 6c2527d42900 ChangeLog
> --- a/ChangeLog Mon Nov 01 11:44:15 2010 -0400
> +++ b/ChangeLog Tue Nov 02 17:29:03 2010 -0700
> @@ -1,3 +1,8 @@
> +2010-11-02 Deepak Bhole <dbhole at redhat.com>
> +
> + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java (update):
> + Override method and implement double-buffering.
> +
> 2010-11-01 Omair Majid <omajid at redhat.com>
>
> * Makefile.am (clean-IcedTeaPlugin): Only delete launcher directory if it
> diff -r 6c2527d42900 NEWS
> --- a/NEWS Mon Nov 01 11:44:15 2010 -0400
> +++ b/NEWS Tue Nov 02 17:29:03 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
> diff -r 6c2527d42900 plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
> --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Mon Nov 01 11:44:15 2010 -0400
> +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Tue Nov 02 17:29:03 2010 -0700
> @@ -359,6 +366,9 @@
>
> private static Long requestIdentityCounter = 0L;
>
> + private Image bufferedPanelImage;
> + private Graphics bufferedImageGraphics;
> +
> /**
> * Null constructor to allow instantiation via newInstance()
> */
> @@ -2163,4 +2178,24 @@
> }
> }
> }
> +
> + /**
> + * {@inheritDoc}
> + */
> + public void update(Graphics g) {
> +
> + System.err.println("Buffering and drawing");
> +
> + // If the image or the graphics don't exist, create new ones
> + if (bufferedPanelImage == null || bufferedImageGraphics == null) {
> + bufferedPanelImage = createImage(getWidth(), getHeight());
> + bufferedImageGraphics = bufferedPanelImage.getGraphics ();
> + }
> +
> + // Paint off-screen
> + paint(bufferedImageGraphics);
> +
> + // Draw the painted image
> + g.drawImage(bufferedPanelImage, 0, 0, this);
> + }
> }
-------------- next part --------------
diff -r 6c2527d42900 ChangeLog
--- a/ChangeLog Mon Nov 01 11:44:15 2010 -0400
+++ b/ChangeLog Tue Nov 02 17:37:09 2010 -0700
@@ -1,3 +1,8 @@
+2010-11-02 Deepak Bhole <dbhole at redhat.com>
+
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java (update):
+ Override method and implement double-buffering.
+
2010-11-01 Omair Majid <omajid at redhat.com>
* Makefile.am (clean-IcedTeaPlugin): Only delete launcher directory if it
diff -r 6c2527d42900 NEWS
--- a/NEWS Mon Nov 01 11:44:15 2010 -0400
+++ b/NEWS Tue Nov 02 17:37:09 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
diff -r 6c2527d42900 plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Mon Nov 01 11:44:15 2010 -0400
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Tue Nov 02 17:37:09 2010 -0700
@@ -359,6 +366,9 @@
private static Long requestIdentityCounter = 0L;
+ private Image bufferedFrameImage;
+ private Graphics bufferedFrameImageGraphics;
+
/**
* Null constructor to allow instantiation via newInstance()
*/
@@ -2163,4 +2178,22 @@
}
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(Graphics g) {
+
+ // If the image or the graphics don't exist, create new ones
+ if (bufferedFrameImage == null || bufferedFrameImageGraphics == null) {
+ bufferedFrameImage = createImage(getWidth(), getHeight());
+ bufferedFrameImageGraphics = bufferedFrameImage.getGraphics ();
+ }
+
+ // Paint off-screen
+ paint(bufferedFrameImageGraphics);
+
+ // Draw the painted image
+ g.drawImage(bufferedFrameImage, 0, 0, this);
+ }
}
More information about the distro-pkg-dev
mailing list