aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java
diff options
context:
space:
mode:
authorThomas Fitzsimmons <fitzsim@redhat.com>2005-05-06 23:06:18 +0000
committerThomas Fitzsimmons <fitzsim@gcc.gnu.org>2005-05-06 23:06:18 +0000
commit2ed0018eb41c5b8fe2b39415facab3c1f7114b95 (patch)
tree81ea3a47bbb3d6ce4bcf710fb8c56e517fc413aa /libjava/gnu/java
parent91a01f21abfe192fd660da55be548f52008e3f51 (diff)
downloadgcc-2ed0018eb41c5b8fe2b39415facab3c1f7114b95.zip
gcc-2ed0018eb41c5b8fe2b39415facab3c1f7114b95.tar.gz
gcc-2ed0018eb41c5b8fe2b39415facab3c1f7114b95.tar.bz2
Makefile.am (gtk_awt_peer_sources): Add GtkVolatileImage.java.
2005-05-06 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (gtk_awt_peer_sources): Add GtkVolatileImage.java. * Makefile.in: Regenerate. * gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java (createCompatibleVolatileImage(int,int)): Implement. (createCompatibleVolatileImage(int,int,ImageCapabilities)): Likewise. * gnu/java/awt/peer/gtk/GtkComponentPeer.java (backBuffer, caps): New fields. (createVolatileImage): Implement. (createBuffers): Likewise. (getBackBuffer): Likewise. (flip): Likewise. (destroyBuffers): Likewise. * gnu/java/awt/peer/gtk/GtkVolatileImage.java: New file. * java/awt/Canvas.java (CanvasBltBufferStrategy): New class. (CanvasFlipBufferStrategy): Likewise. (createBufferStrategy(int)): New method. (createBufferStrategy(int,BufferCapabilities)): Likewise. * java/awt/Component.java (BltBufferStrategy): Implement and document class. (FlipBufferStrategy): Likewise. * java/awt/Window.java (WindowBltBufferStrategy): New class. (WindowFlipBufferStrategy): Likewise. (createBufferStrategy(int)): New method. (createBufferStrategy(int,BufferCapabilities)): Likewise. (getBufferStrategy): Likewise. * java/awt/BufferCapabilities.java (BufferCapabilities): Rename front to frontCaps and back to backCaps. From-SVN: r99336
Diffstat (limited to 'libjava/gnu/java')
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java4
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java54
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkVolatileImage.java114
3 files changed, 159 insertions, 13 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java b/libjava/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
index c485db2..94e1b0f 100644
--- a/libjava/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
+++ b/libjava/gnu/java/awt/peer/gtk/GdkGraphicsConfiguration.java
@@ -86,14 +86,14 @@ public class GdkGraphicsConfiguration
public VolatileImage createCompatibleVolatileImage(int w, int h)
{
- throw new java.lang.UnsupportedOperationException ();
+ return new GtkVolatileImage(w, h);
}
public VolatileImage createCompatibleVolatileImage(int w, int h,
ImageCapabilities caps)
throws java.awt.AWTException
{
- throw new java.lang.UnsupportedOperationException ();
+ return new GtkVolatileImage(w, h, caps);
}
public ColorModel getColorModel()
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index 2625f56..e3e7afb 100644
--- a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.AWTEvent;
+import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Color;
import java.awt.Component;
@@ -71,6 +72,9 @@ import java.awt.peer.ComponentPeer;
public class GtkComponentPeer extends GtkGenericPeer
implements ComponentPeer
{
+ VolatileImage backBuffer;
+ BufferCapabilities caps;
+
Component awtComponent;
Insets insets;
@@ -596,35 +600,63 @@ public class GtkComponentPeer extends GtkGenericPeer
}
- public VolatileImage createVolatileImage (int width, int height)
- {
- return null;
- }
-
public boolean handlesWheelScrolling ()
{
return false;
}
- public void createBuffers (int x, BufferCapabilities capabilities)
- throws java.awt.AWTException
+ // Convenience method to create a new volatile image on the screen
+ // on which this component is displayed.
+ public VolatileImage createVolatileImage (int width, int height)
+ {
+ return new GtkVolatileImage (width, height);
+ }
+ // Creates buffers used in a buffering strategy.
+ public void createBuffers (int numBuffers, BufferCapabilities caps)
+ throws AWTException
{
-
+ // numBuffers == 2 implies double-buffering, meaning one back
+ // buffer and one front buffer.
+ if (numBuffers == 2)
+ backBuffer = new GtkVolatileImage(awtComponent.getWidth(),
+ awtComponent.getHeight(),
+ caps.getBackBufferCapabilities());
+ else
+ throw new AWTException("GtkComponentPeer.createBuffers:"
+ + " multi-buffering not supported");
+ this.caps = caps;
}
+ // Return the back buffer.
public Image getBackBuffer ()
{
- return null;
+ return backBuffer;
}
+ // FIXME: flip should be implemented as a fast native operation
public void flip (BufferCapabilities.FlipContents contents)
{
-
+ getGraphics().drawImage(backBuffer,
+ awtComponent.getWidth(),
+ awtComponent.getHeight(),
+ null);
+
+ // create new back buffer and clear it to the background color.
+ if (contents == BufferCapabilities.FlipContents.BACKGROUND)
+ {
+ backBuffer = createVolatileImage(awtComponent.getWidth(),
+ awtComponent.getHeight());
+ backBuffer.getGraphics().clearRect(0, 0,
+ awtComponent.getWidth(),
+ awtComponent.getHeight());
+ }
+ // FIXME: support BufferCapabilities.FlipContents.PRIOR
}
+ // Release the resources allocated to back buffers.
public void destroyBuffers ()
{
-
+ backBuffer.flush();
}
}
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkVolatileImage.java b/libjava/gnu/java/awt/peer/gtk/GtkVolatileImage.java
new file mode 100644
index 0000000..3ac3b31
--- /dev/null
+++ b/libjava/gnu/java/awt/peer/gtk/GtkVolatileImage.java
@@ -0,0 +1,114 @@
+/* GtkVolatileImage.java -- a hardware-accelerated image buffer
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.java.awt.peer.gtk;
+
+import java.awt.ImageCapabilities;
+import java.awt.image.VolatileImage;
+
+public class GtkVolatileImage extends VolatileImage
+{
+ private int width;
+ private int height;
+ private ImageCapabilities caps;
+
+ public GtkVolatileImage(int width, int height)
+ {
+ this(width, height, null);
+ }
+
+ public GtkVolatileImage(int width, int height, ImageCapabilities caps)
+ {
+ this.width = width;
+ this.height = height;
+ this.caps = caps;
+ }
+
+ // FIXME: should return a buffered image snapshot of the accelerated
+ // visual
+ public BufferedImage getSnapshot()
+ {
+ return null;
+ }
+
+ public int getWidth()
+ {
+ return width;
+ }
+
+ public int getHeight()
+ {
+ return height;
+ }
+
+ // FIXME: should return a graphics wrapper around this image's
+ // visual
+ public Graphics2D createGraphics()
+ {
+ return null;
+ }
+
+ public int validate(GraphicsConfiguration gc)
+ {
+ return VolatileImage.IMAGE_OK;
+ }
+
+ public boolean contentsLost()
+ {
+ return false;
+ }
+
+ public ImageCapabilities getCapabilities()
+ {
+ return caps;
+ }
+
+ public synchronized Object getProperty (String name, ImageObserver observer)
+ {
+ return null;
+ }
+
+ public synchronized int getWidth (ImageObserver observer)
+ {
+ return width;
+ }
+
+ public synchronized int getHeight (ImageObserver observer)
+ {
+ return height;
+ }
+}