Commit 44bffd9f by Andreas Tobler Committed by Andreas Tobler

configure.ac: Introduce AC_C_BIGENDIAN_CROSS for WORDS_BIGENDIAN.

2004-09-22  Andreas Tobler  <a.tobler@schweiz.ch>

	* configure.ac: Introduce AC_C_BIGENDIAN_CROSS for WORDS_BIGENDIAN.
	* configure: Regenerate.
	* include/config.h.in: Likewise.
	* jni/gtk-peer/gtkpeer.h (SWAPU32): Introduce macro to swap pixels.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c: Moved SWAPU32
	macro to gtkpeer.h.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
	(Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePixels): Convert
	pixels from  0xBBGGRRAA to 0xAARRGGBB only on Little Endian
	architectures.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c (area_updated):
	Likewise.

From-SVN: r87889
parent 08fb229e
2004-09-22 Andreas Tobler <a.tobler@schweiz.ch>
* configure.ac: Introduce AC_C_BIGENDIAN_CROSS for WORDS_BIGENDIAN.
* configure: Regenerate.
* include/config.h.in: Likewise.
* jni/gtk-peer/gtkpeer.h (SWAPU32): Introduce macro to swap pixels.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c: Moved SWAPU32
macro to gtkpeer.h.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c
(Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePixels): Convert
pixels from 0xBBGGRRAA to 0xAARRGGBB only on Little Endian
architectures.
* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c (area_updated):
Likewise.
2004-09-22 Tom Tromey <tromey@redhat.com> 2004-09-22 Tom Tromey <tromey@redhat.com>
PR libgcj/14446: PR libgcj/14446:
......
...@@ -1124,6 +1124,8 @@ CPPFLAGS=$GCJ_SAVE_CPPFLAGS ...@@ -1124,6 +1124,8 @@ CPPFLAGS=$GCJ_SAVE_CPPFLAGS
AC_COMPILE_CHECK_SIZEOF(void *) AC_COMPILE_CHECK_SIZEOF(void *)
AC_C_BIGENDIAN_CROSS
ZLIBS= ZLIBS=
SYS_ZLIBS= SYS_ZLIBS=
ZINCS= ZINCS=
......
/* include/config.h.in. Generated from configure.ac by autoheader. */ /* include/config.h.in. Generated from configure.ac by autoheader. */
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#undef BYTEORDER
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems. systems. This function is required for `alloca.c' support on those systems.
*/ */
...@@ -351,6 +354,10 @@ ...@@ -351,6 +354,10 @@
/* Define to 1 if you have the file `AC_File'. */ /* Define to 1 if you have the file `AC_File'. */
#undef HAVE__PROC_SELF_EXE #undef HAVE__PROC_SELF_EXE
/* Define if the host machine stores words of multi-word integers in
big-endian order. */
#undef HOST_WORDS_BIG_ENDIAN
/* Define as const if the declaration of iconv() needs const. */ /* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST #undef ICONV_CONST
...@@ -441,6 +448,9 @@ ...@@ -441,6 +448,9 @@
/* Version number of package */ /* Version number of package */
#undef VERSION #undef VERSION
/* whether byteorder is bigendian */
#undef WORDS_BIGENDIAN
/* Define to 1 if the X Window System is missing or not being used. */ /* Define to 1 if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING #undef X_DISPLAY_MISSING
......
/* gnu_java_awt_peer_gtk_GdkGraphics2d.c /* gnu_java_awt_peer_gtk_GdkGraphics2d.c
Copyright (C) 2003 Free Software Foundation, Inc. Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -748,7 +748,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix ...@@ -748,7 +748,7 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix
gint bits_per_sample = 8; gint bits_per_sample = 8;
gboolean has_alpha = TRUE; gboolean has_alpha = TRUE;
gint total_channels = 4; gint total_channels = 4;
jint i, px; jint i;
gdk_threads_enter(); gdk_threads_enter();
if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return NULL; } if (peer_is_disposed(env, obj)) { gdk_threads_leave(); return NULL; }
...@@ -777,23 +777,13 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix ...@@ -777,23 +777,13 @@ JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics2D_getImagePix
native_pixels= gdk_pixbuf_get_pixels (buf); native_pixels= gdk_pixbuf_get_pixels (buf);
#ifndef WORDS_BIGENDIAN
/* NOTE: The pixels we got in the pixbuf are stored /* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */
in reversed order. i.e 0xBBGGRRAA.
We need to convert them to 0xAARRGGBB. */
for (i=0; i<width * height; i++) for (i=0; i<width * height; i++)
{ {
native_pixels[i] = SWAPU32 ((unsigned)native_pixels[i]);
/* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */
px = native_pixels[i];
px = ((px >> 24) & 0xff) | ((px << 8) & 0xffffff00);
px = ((px >> 8) & 0x00ff00ff) | ((px << 8) & 0xff00ff00);
px = ((px >> 16) & 0x0000ffff) | ((px << 16) & 0xffff0000);
native_pixels[i] = px;
} }
#endif
java_pixels = (*env) -> NewIntArray (env, width * height); java_pixels = (*env) -> NewIntArray (env, width * height);
......
...@@ -99,7 +99,7 @@ area_updated (GdkPixbufLoader *loader, ...@@ -99,7 +99,7 @@ area_updated (GdkPixbufLoader *loader,
JNIEnv *env; JNIEnv *env;
union env_union e; union env_union e;
jint stride_bytes, stride_pixels, n_channels, n_pixels; jint stride_bytes, stride_pixels, n_channels, n_pixels;
int i, px; int i;
jintArray jpixels; jintArray jpixels;
jint *java_pixels; jint *java_pixels;
guchar *gdk_pixels; guchar *gdk_pixels;
...@@ -129,21 +129,13 @@ area_updated (GdkPixbufLoader *loader, ...@@ -129,21 +129,13 @@ area_updated (GdkPixbufLoader *loader,
gdk_pixels + (y * stride_bytes), gdk_pixels + (y * stride_bytes),
(height * stride_bytes)); (height * stride_bytes));
#ifndef WORDS_BIGENDIAN
/* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */
for (i = 0; i < n_pixels; ++i) for (i = 0; i < n_pixels; ++i)
{ {
px = java_pixels[i]; java_pixels[i] = SWAPU32 ((unsigned)java_pixels[i]);
/* move alpha around (GdkPixbufLoader results are AGBR not GBRA, in
the lsb sense) */
/* px = ((px >> 24) & 0xff) | ((px << 8) & 0xffffff00); */
/* it appears to require a full byte swap, now, not just a shift to
the A channel. why did this change? don't know. */
px = ((px >> 8) & 0x00ff00ff) | ((px << 8) & 0xff00ff00);
px = ((px >> 16) & 0x0000ffff) | ((px << 16) & 0xffff0000);
java_pixels[i] = px;
} }
#endif
g_object_unref (pixbuf); g_object_unref (pixbuf);
......
/* gtkimagepainter.c /* gtkimagepainter.c
Copyright (C) 1999 Free Software Foundation, Inc. Copyright (C) 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -40,8 +40,6 @@ exception statement from your version. */ ...@@ -40,8 +40,6 @@ exception statement from your version. */
#include <libart_lgpl/art_misc.h> #include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_rgb_affine.h> #include <libart_lgpl/art_rgb_affine.h>
#define SWAPU32(w) \
(((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels
(JNIEnv *env, jobject obj __attribute__((unused)), jobject gc_obj, (JNIEnv *env, jobject obj __attribute__((unused)), jobject gc_obj,
......
/* gtkpeer.h -- Some global variables and #defines /* gtkpeer.h -- Some global variables and #defines
Copyright (C) 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -107,6 +107,9 @@ extern struct state_table *native_pixbufdecoder_state_table; ...@@ -107,6 +107,9 @@ extern struct state_table *native_pixbufdecoder_state_table;
#endif /* JVM_SUN */ #endif /* JVM_SUN */
#define SWAPU32(w) \
(((w) << 24) | (((w) & 0xff00) << 8) | (((w) >> 8) & 0xff00) | ((w) >> 24))
struct graphics struct graphics
{ {
GdkDrawable *drawable; GdkDrawable *drawable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment