gcc/libjava/gnu/gcj/xlib/natXImage.cc
Rolf W. Rasmussen 2622c79d2d Makefile.am: Added rules for libgcjx library.
* Makefile.am: Added rules for libgcjx library.
	* Makefile.in: Rebuilt.
	* configure.in: Added check for X.
	* configure: Rebuilt.
	* gnu/awt/LightweightRedirector.java: New file.
	* gnu/awt/j2d/AbstractGraphicsState.java: New file.
	* gnu/awt/j2d/DirectRasterGraphics.java: New file.
	* gnu/awt/j2d/Graphics2DImpl.java: New file.
	* gnu/awt/j2d/IntegerGraphicsState.java: New file.
	* gnu/awt/j2d/MappedRaster.java: New file.
	* gnu/awt/xlib/XCanvasPeer.java: New file.
	* gnu/awt/xlib/XEventLoop.java: New file.
	* gnu/awt/xlib/XEventQueue.java: New file.
	* gnu/awt/xlib/XFontMetrics.java: New file.
	* gnu/awt/xlib/XFramePeer.java: New file.
	* gnu/awt/xlib/XGraphics.java: New file.
	* gnu/awt/xlib/XGraphicsConfiguration.java: New file.
	* gnu/awt/xlib/XPanelPeer.java: New file.
	* gnu/awt/xlib/XToolkit.java: New file.
	* gnu/gcj/xlib/Clip.java: New file.
	* gnu/gcj/xlib/Colormap.java: New file.
	* gnu/gcj/xlib/Display.java: New file.
	* gnu/gcj/xlib/Drawable.java: New file.
	* gnu/gcj/xlib/Font.java: New file.
	* gnu/gcj/xlib/GC.java: New file.
	* gnu/gcj/xlib/Pixmap.java: New file.
	* gnu/gcj/xlib/Screen.java: New file.
	* gnu/gcj/xlib/Visual.java: New file.
	* gnu/gcj/xlib/WMSizeHints.java: New file.
	* gnu/gcj/xlib/Window.java: New file.
	* gnu/gcj/xlib/WindowAttributes.java: New file.
	* gnu/gcj/xlib/XAnyEvent.java: New file.
	* gnu/gcj/xlib/XButtonEvent.java: New file.
	* gnu/gcj/xlib/XColor.java: New file.
	* gnu/gcj/xlib/XConfigureEvent.java: New file.
	* gnu/gcj/xlib/XConnectException.java: New file.
	* gnu/gcj/xlib/XEvent.java: New file.
	* gnu/gcj/xlib/XException.java: New file.
	* gnu/gcj/xlib/XExposeEvent.java: New file.
	* gnu/gcj/xlib/XID.java: New file.
	* gnu/gcj/xlib/XImage.java: New file.
	* gnu/gcj/xlib/XUnmapEvent.java: New file.
	* gnu/gcj/xlib/natClip.cc: New file.
	* gnu/gcj/xlib/natColormap.cc: New file.
	* gnu/gcj/xlib/natDisplay.cc: New file.
	* gnu/gcj/xlib/natDrawable.cc: New file.
	* gnu/gcj/xlib/natFont.cc: New file.
	* gnu/gcj/xlib/natGC.cc: New file.
	* gnu/gcj/xlib/natPixmap.cc: New file.
	* gnu/gcj/xlib/natScreen.cc: New file.
	* gnu/gcj/xlib/natVisual.cc: New file.
	* gnu/gcj/xlib/natWMSizeHints.cc: New file.
	* gnu/gcj/xlib/natWindow.cc: New file.
	* gnu/gcj/xlib/natWindowAttributes.cc: New file.
	* gnu/gcj/xlib/natXAnyEvent.cc: New file.
	* gnu/gcj/xlib/natXButtonEvent.cc: New file.
	* gnu/gcj/xlib/natXColor.cc: New file.
	* gnu/gcj/xlib/natXConfigureEvent.cc: New file.
	* gnu/gcj/xlib/natXException.cc: New file.
	* gnu/gcj/xlib/natXExposeEvent.cc: New file.
	* gnu/gcj/xlib/natXImage.cc: New file.
	* gnu/gcj/xlib/natXUnmapEvent.cc: New file.
	* java/awt/EventDispatchThread.java: Start thead on creation.

From-SVN: r37005
2000-10-22 17:46:09 +00:00

221 lines
5.2 KiB
C++

/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <gcj/cni.h>
#include <gnu/gcj/RawData.h>
#include <java/lang/OutOfMemoryError.h>
#include <gnu/gcj/xlib/Display.h>
#include <gnu/gcj/xlib/Screen.h>
#include <gnu/gcj/xlib/Visual.h>
#include <gnu/gcj/xlib/XImage.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
void gnu::gcj::xlib::XImage::init(Visual* visual, jint depth,
jint format, jint xoffset,
jint width, jint height,
jint bitmapPad, jint bytesPerLine,
jint bitsPerPixel)
{
::Display* dpy = (::Display*) visual->display->display;
::Visual* vis = (::Visual*) visual->getVisualStructure();
char* data = 0; // no preallocated data
::XImage* ximage = XCreateImage(dpy, vis, depth, format, xoffset,
data,
width, height,
bitmapPad,
bytesPerLine
);
if (ximage == 0)
{
jstring errorMessage = JvNewStringLatin1("XCreateImage failed");
JvThrow(new java::lang::OutOfMemoryError(errorMessage));
}
bool reinitialize = false;
if ((bitsPerPixel != 0) && (ximage->bits_per_pixel != bitsPerPixel))
{
ximage->bits_per_pixel = bitsPerPixel;
reinitialize = true;
}
// FIXME: make autoconf test?
jshort endianTestShort[] = { 1 };
jbyte* endianTestByte = reinterpret_cast<jbyte*>(endianTestShort);
jint byteOrder;
if (endianTestByte[0] == 1)
{
// little endian machine
byteOrder = LEAST_SIGNIFICANT_B_FIRST_ORDER;
}
else
{
// big endian machine
byteOrder = MOST_SIGNIFICANT_B_FIRST_ORDER;
}
/* NB: This doesn't consider those weird machines out there with
middle-endian byte order. */
if (byteOrder != ximage->byte_order)
{
ximage->byte_order = byteOrder;
reinitialize = true;
}
if (reinitialize)
XInitImage(ximage);
structure = reinterpret_cast<gnu::gcj::RawData*>(ximage);
// Notice that no image data has been allocated at this point
}
void gnu::gcj::xlib::XImage::init(Visual* visual,
jint width,
jint height)
{
int depth = visual->getDepth();
int format = ZPixmap; // Chunky, not planar.
int offset = 0;
int bitmapPad = 32; // FIXME, don't hardcode this
int bytesPerLine = 0; // Let the server figure it out
init(visual, depth, format, offset, width, height, bitmapPad,
bytesPerLine, 0);
}
void gnu::gcj::xlib::XImage::internalSetData(jbyteArray data, jint offset)
{
::XImage* ximage = (::XImage*) structure;
ximage->data = reinterpret_cast<char*>(elements(data)+offset);
}
void gnu::gcj::xlib::XImage::internalSetData(jshortArray data, jint offset)
{
::XImage* ximage = (::XImage*) structure;
ximage->data = reinterpret_cast<char*>(elements(data)+offset);
}
void gnu::gcj::xlib::XImage::internalSetData(jintArray data, jint offset)
{
::XImage* ximage = (::XImage*) structure;
ximage->data = reinterpret_cast<char*>(elements(data)+offset);
}
void gnu::gcj::xlib::XImage::finalize()
{
::XImage* ximage = (::XImage*) structure;
if (ownsData)
delete ximage->data;
ximage->data = 0; // Never allow XLib to free the data allocation.
dataRef = 0;
XDestroyImage(ximage);
}
jint gnu::gcj::xlib::XImage::getWidth()
{
::XImage* ximage = (::XImage*) structure;
return ximage->width;
}
jint gnu::gcj::xlib::XImage::getHeight()
{
::XImage* ximage = (::XImage*) structure;
return ximage->height;
}
jint gnu::gcj::xlib::XImage::getDepth()
{
::XImage* ximage = (::XImage*) structure;
return ximage->depth;
}
jint gnu::gcj::xlib::XImage::getFormat()
{
::XImage* ximage = (::XImage*) structure;
return ximage->format;
}
jint gnu::gcj::xlib::XImage::getXOffset()
{
::XImage* ximage = (::XImage*) structure;
return ximage->xoffset;
}
jint gnu::gcj::xlib::XImage::getImageByteOrder()
{
::XImage* ximage = (::XImage*) structure;
return ximage->byte_order;
}
jint gnu::gcj::xlib::XImage::getBitmapBitOrder()
{
::XImage* ximage = (::XImage*) structure;
return ximage->bitmap_bit_order;
}
jint gnu::gcj::xlib::XImage::getBitmapUnit()
{
::XImage* ximage = (::XImage*) structure;
return ximage->bitmap_unit;
}
jint gnu::gcj::xlib::XImage::getBitmapPad()
{
::XImage* ximage = (::XImage*) structure;
return ximage->bitmap_pad;
}
jint gnu::gcj::xlib::XImage::getBytesPerLine()
{
::XImage* ximage = (::XImage*) structure;
return ximage->bytes_per_line;
}
jint gnu::gcj::xlib::XImage::getBitsPerPixel()
{
::XImage* ximage = (::XImage*) structure;
return ximage->bits_per_pixel;
}
// True/Direct Color specific:
jint gnu::gcj::xlib::XImage::getRedMask()
{
::XImage* ximage = (::XImage*) structure;
return ximage->red_mask;
}
jint gnu::gcj::xlib::XImage::getGreenMask()
{
::XImage* ximage = (::XImage*) structure;
return ximage->green_mask;
}
jint gnu::gcj::xlib::XImage::getBlueMask()
{
::XImage* ximage = (::XImage*) structure;
return ximage->blue_mask;
}
void gnu::gcj::xlib::XImage::setPixel(jint x, jint y, jint pixel)
{
::XImage* ximage = (::XImage*) structure;
XPutPixel(ximage, x, y, pixel);
}