[icedtea-web] RFC: Patch to double-buffer applets
Dr Andrew John Hughes
ahughes at redhat.com
Tue Nov 2 16:04:25 PDT 2010
On 17:37 Tue 02 Nov , Deepak Bhole wrote:
> * 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
>
Looks good to me. Maybe the variable names could be shorter, while still
conveying the same meaning e.g. bufPanelImage.
> > 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);
> > + }
> > }
>
> 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);
> + }
> }
--
Andrew :)
Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)
Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8
More information about the distro-pkg-dev
mailing list