From 8c8125ea529bfedac13ece8d1769d2097760052b Mon Sep 17 00:00:00 2001 From: sgilbertson Date: Mon, 25 Aug 2003 19:02:29 +0000 Subject: * Makefile.am: added gnu/awt/xlib/XOffScreenImage.java. * Makefile.in: re-generated. * gnu/awt/j2d/IntegerGraphicsState.java (ScreenCoupledImage): new interface. (drawImage): detect ScreenCoupledImage instances. * gnu/awt/xlib/XCanvasPeer.java (createImage) implemented. * gnu/awt/xlib/XEventLoop.java (createEvent): re-formatted, and rearranged to avoid null pointer. * gnu/awt/xlib/XGraphics.java (drawImage): added XOffScreenImage handling. * gnu/awt/xlib/XOffScreenImage.java: new file. * gnu/gcj/xlib/Drawable.java (getDepth): new native method. * gnu/gcj/xlib/GC.java (copyArea): new native method. * 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. * gnu/gcj/xlib/natDrawable.cc (getDepth): new method. * gnu/gcj/xlib/natGC.cc (copyArea): new method * java/awt/Component.java (createImage): changed to use peer method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70776 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/awt/j2d/IntegerGraphicsState.java | 133 +++++++++++++++----------- 1 file changed, 76 insertions(+), 57 deletions(-) (limited to 'libjava/gnu/awt/j2d/IntegerGraphicsState.java') diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState.java b/libjava/gnu/awt/j2d/IntegerGraphicsState.java index 3befcb41707..4eb4c6182b1 100644 --- a/libjava/gnu/awt/j2d/IntegerGraphicsState.java +++ b/libjava/gnu/awt/j2d/IntegerGraphicsState.java @@ -44,6 +44,19 @@ public class IntegerGraphicsState extends AbstractGraphicsState DirectRasterGraphics directGfx; Shape clip; + /** Interface for images which are coupled to a GraphicsConfiguration, + * as is typically the case for an off-screen buffer used in + * double-buffering. Any image which implements this interface is + * rendered directly by DirectRasterGraphics (i.e. by directGfx.drawImage) + */ + public interface ScreenCoupledImage + { + /** Get the GraphicsConfiguration to which this image is coupled + * @return the GraphicsConfiguration + */ + GraphicsConfiguration getGraphicsConfiguration (); + } + public IntegerGraphicsState(DirectRasterGraphics directGfx) { this.directGfx = directGfx; @@ -245,66 +258,72 @@ public class IntegerGraphicsState extends AbstractGraphicsState x += tx; y += ty; + if (image instanceof ScreenCoupledImage) + { + GraphicsConfiguration config + = ((ScreenCoupledImage)image).getGraphicsConfiguration (); + if (config == frontend.config) + return directGfx.drawImage (image, x, y, observer); + } if (image instanceof BufferedImage) + { + BufferedImage bImage = (BufferedImage) image; + // FIXME: eliminate? ScreenCoupledImage is probably more efficient + Object config = bImage.getProperty ("java.awt.GraphicsConfiguration"); + if (config == frontend.config) + return directGfx.drawImage (image, x, y, observer); + + int width = image.getWidth (null); + int height = image.getHeight (null); + + Rectangle bounds = new Rectangle (x, y, width, height); + + MappedRaster mr = directGfx.mapRaster (bounds); + + // manipulate raster here... + ColorModel colorModel = mr.getColorModel (); + WritableRaster raster = mr.getRaster (); + + int xEnd = x + width; + int yEnd = y + height; + + // FIXME: Use the following code only as a fallback. It's SLOW! + + Object rgbElem = null; + for (int yy=0; yy>> 24) & 0xff) + 1; - int sr = ((srgb >>> 16) & 0xff) + 1; - int sg = ((srgb >>> 8) & 0xff) + 1; - int sb = (srgb & 0xff) + 1; - - rgbElem = raster.getDataElements(xx+x, yy+y, rgbElem); - int drgb = colorModel.getRGB(rgbElem); - int dr = ((drgb >>> 16) & 0xff) + 1; - int dg = ((drgb >>> 8) & 0xff) + 1; - int db = (drgb & 0xff) + 1; - int da = 256 - sa; - - dr = ((sr*sa + dr*da) >>> 8) - 1; - dg = ((sg*sa + dg*da) >>> 8) - 1; - db = ((sb*sa + db*da) >>> 8) - 1; - - drgb = (dr<<16) | (dg<<8) | db; - - rgbElem = colorModel.getDataElements(drgb, rgbElem); - - raster.setDataElements(xx+x, yy+y, rgbElem); - } - } - directGfx.unmapRaster(mr); - return true; - + for (int xx=0; xx>> 24) & 0xff) + 1; + int sr = ((srgb >>> 16) & 0xff) + 1; + int sg = ((srgb >>> 8) & 0xff) + 1; + int sb = (srgb & 0xff) + 1; + + rgbElem = raster.getDataElements (xx+x, yy+y, rgbElem); + int drgb = colorModel.getRGB (rgbElem); + int dr = ((drgb >>> 16) & 0xff) + 1; + int dg = ((drgb >>> 8) & 0xff) + 1; + int db = (drgb & 0xff) + 1; + int da = 256 - sa; + + dr = ((sr*sa + dr*da) >>> 8) - 1; + dg = ((sg*sa + dg*da) >>> 8) - 1; + db = ((sb*sa + db*da) >>> 8) - 1; + + drgb = (dr<<16) | (dg<<8) | db; + + rgbElem = colorModel.getDataElements (drgb, rgbElem); + + raster.setDataElements (xx+x, yy+y, rgbElem); + } } - throw new UnsupportedOperationException("drawing image " + image + - "not implemented"); + directGfx.unmapRaster (mr); + return true; + + } + throw new UnsupportedOperationException ("drawing image " + image + + "not implemented"); } -- cgit v1.2.3