This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: xlib double-buffering support


The attached patch implements everything you need for double buffered
graphics using xlib peers.  I have also attached a test program.  The basic
idea is to have a special Image subclass specific to off-screen rendering,
which allows you to create a Graphics to draw on it, but which does not
allow you to obtain its raster.  These characteristics are consistent with
what the 1.4 JRE does.

The patch doesn't modify anything associated with the creation of in-memory
images from bitmap sources.  For that you'd use the
XGraphicsConfiguration.createImage functions, which I've left as-is.

I looked at the gtk peers, which implement GtkComponentPeer.createImage and
are therefore almost compatible with this patch.  I think all the gtk peers
need is for GtkOffScreenImage to implement the
IntegerGraphicsState.ScreenCoupledImage interface.  I haven't tried that,
though, because I'm pretty focused on xlib peers.  Someone doing gtk stuff
should probably try it.

All of the changes are contained in the xlib peer code except:

1. gnu.awt.j2d.IntegerGraphicsState - to recognize special off-screen images
and use the peer code (DirectRasterGraphics.drawImage) to display them.  I
included an interface which allows this recognition, and provides access to
the GraphicsConfiguration associated with the image.  Some existing code
uses a BufferedImage property for this purpose, but:
 a) it's not very efficient, and
 b) it requires a complicated BufferedImage subclass, when an Image subclass
should be adequate

2. java.awt.Component - to use ComponentPeer.createImage instead of
GraphicsConfiguration.createImage.  I think
GraphicsConfiguration.createImage is really intended for creating images
which use existing raster data (as from an image file), whereas
ComponentPeer.createImage has no obvious purpose other than to create an
off-screen image buffer.

The patch includes one new file: gnu/awt/xlib/XOffScreenImage.java.  The
rest of the changes are to pre-existing files.

Index: libjava/ChangeLog
from  Scott Gilbertson  <scottg@mantatest.com>

    * libjava/Makefile.am: added gnu/awt/xlib/XOffScreenImage.java.
    * libjava/Makefile.in: re-generated.
    * libjava/gnu/awt/j2d/IntegerGraphicsState.java
    (ScreenCoupledImage): new interface.
    (drawImage): detect ScreenCoupledImage instances.
    * libjava/gnu/awt/xlib/XCanvasPeer.java (createImage) implemented.
    * libjava/gnu/awt/xlib/XEventLoop.java
    (createEvent): re-formatted, and rearranged to avoid null pointer.
    * libjava/gnu/awt/xlib/XGraphics.java
    (drawImage): added XOffScreenImage handling.
    * libjava/gnu/awt/xlib/XOffScreenImage.java: new file.
    * libjava/gnu/gcj/xlib/Drawable.java (getDepth): new native method.
    * libjava/gnu/gcj/xlib/GC.java (copyArea): new native method.
    * libjava/gnu/gcj/xlib/XAnyEvent.java
    (TYPE_KEY_PRESS): new constant.
    (TYPE_KEY_RELEASE): new constant.
    (TYPE_MOTION_NOTIFY): new constant.
    (TYPE_ENTER_NOTIFY): new constant.
    (TYPE_LEAVE_NOTIFY): new constant.
    (TYPE_FOCUS_IN): new constant.
    (TYPE_FOCUS_OUT): new constant.
    (TYPE_KEYMAP_NOTIFY): new constant.
    (TYPE_GRAPHICS_EXPOSE): new constant.
    (TYPE_NO_EXPOSE): new constant.
    (TYPE_VISIBILITY_NOTIFY): new constant.
    (TYPE_CREATE_NOTIFY): new constant.
    (TYPE_DESTROY_NOTIFY): new constant.
    (TYPE_MAP_REQUEST): new constant.
    (TYPE_CONFIGURE_REQUEST): new constant.
    (TYPE_GRAVITY_NOTIFY): new constant.
    (TYPE_RESIZE_REQUEST): new constant.
    (TYPE_CIRCULATE_NOTIFY): new constant.
    (TYPE_CIRCULATE_REQUEST): new constant.
    (TYPE_PROPERTY_NOTIFY): new constant.
    (TYPE_SELECTION_CLEAR): new constant.
    (TYPE_SELECTION_REQUEST): new constant.
    (TYPE_SELECTION_NOTIFY): new constant.
    (TYPE_COLORMAP_NOTIFY): new constant.
    (TYPE_MAPPING_NOTIFY): new constant.
    * libjava/gnu/gcj/xlib/natDrawable.cc (getDepth): new method.
    * libjava/gnu/gcj/xlib/natGC.cc (copyArea): new method
    * libjava/java/awt/Component.java (createImage): changed to use peer met
hod.

Attachment: DoubleBuffer.java
Description: Binary data

Attachment: 20030619_doubleBuffer.patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]