summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-19 14:55:08 -0400
committerSilenio Quarti <Silenio_Quarti@ca.ibm.com>2011-10-19 14:55:08 -0400
commitf2afadf3ecbde81e97161d4a80435b171827f960 (patch)
tree72bbe5342b1c6edf644fd1a95b092ed109e39bcb
parent56e38c6de2a27e129a62fd8d7ab5278ff81de9e1 (diff)
downloadeclipse.platform.swt-f2afadf3ecbde81e97161d4a80435b171827f960.tar.gz
eclipse.platform.swt-f2afadf3ecbde81e97161d4a80435b171827f960.tar.xz
eclipse.platform.swt-f2afadf3ecbde81e97161d4a80435b171827f960.zip
make BIG_ENDIAN a constant
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java31
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java7
3 files changed, 14 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 159dd7742f..377ace524a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -23,7 +23,7 @@ public class OS extends C {
}
/** OS Constants */
- public static final boolean IsAIX, IsSunOS, IsLinux, IsHPUX;
+ public static final boolean IsAIX, IsSunOS, IsLinux, IsHPUX, BIG_ENDIAN;
static {
/* Initialize the OS flags and locale constants */
@@ -35,6 +35,13 @@ public class OS extends C {
if (osName.equals ("SunOS")) isSunOS = true;
if (osName.equals ("HP-UX")) isHPUX = true;
IsAIX = isAIX; IsSunOS = isSunOS; IsLinux = isLinux; IsHPUX = isHPUX;
+
+ byte[] buffer = new byte[4];
+ int /*long*/ ptr = OS.malloc(4);
+ OS.memmove(ptr, new int[]{1}, 4);
+ OS.memmove(buffer, ptr, 1);
+ OS.free(ptr);
+ BIG_ENDIAN = buffer[0] == 0;
}
/** Constants */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index a69927c02d..e01fe2d71d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -602,13 +602,8 @@ void createFromPixbuf(int type, int /*long*/ pixbuf) {
surface = Cairo.cairo_image_surface_create_for_data(surfaceData, format, width, height, cairoStride);
if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
byte[] line = new byte[stride];
- int /*long*/ ptr = OS.malloc(4);
- OS.memmove(ptr, new int[]{1}, 4);
- OS.memmove(line, ptr, 1);
- OS.free(ptr);
- boolean bigendian = line[0] == 0;
int oa = 0, or = 0, og = 0, ob = 0;
- if (bigendian) {
+ if (OS.BIG_ENDIAN) {
oa = 0; or = 1; og = 2; ob = 3;
} else {
oa = 3; or = 2; og = 1; ob = 0;
@@ -719,13 +714,8 @@ void createSurface() {
int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
byte[] line = new byte[stride];
- int /*long*/ ptr = OS.malloc(4);
- OS.memmove(ptr, new int[]{1}, 4);
- OS.memmove(line, ptr, 1);
- OS.free(ptr);
int oa, or, og, ob;
- boolean bigendian = line[0] == 0;
- if (bigendian) {
+ if (OS.BIG_ENDIAN) {
oa = 0; or = 1; og = 2; ob = 3;
} else {
oa = 3; or = 2; og = 1; ob = 0;
@@ -940,13 +930,8 @@ public ImageData getImageData() {
int height = this.height;
int stride = Cairo.cairo_format_stride_for_width(Cairo.CAIRO_FORMAT_ARGB32, width);
byte[] srcData = new byte[stride * height];
- int /*long*/ ptr = OS.malloc(4);
- OS.memmove(ptr, new int[]{1}, 4);
- OS.memmove(srcData, ptr, 1);
- OS.free(ptr);
int oa, or, og, ob;
- boolean bigendian = srcData[0] == 0;
- if (bigendian) {
+ if (OS.BIG_ENDIAN) {
oa = 0; or = 1; og = 2; ob = 3;
} else {
oa = 3; or = 2; og = 1; ob = 0;
@@ -1139,15 +1124,9 @@ void init(ImageData image) {
if (surfaceData == 0) SWT.error(SWT.ERROR_NO_HANDLES);
surface = Cairo.cairo_image_surface_create_for_data(surfaceData, Cairo.CAIRO_FORMAT_ARGB32, width, height, stride);
if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- byte[] buffer = new byte[4];
- int /*long*/ ptr = OS.malloc(4);
- OS.memmove(ptr, new int[]{1}, 4);
- OS.memmove(buffer, ptr, 1);
- OS.free(ptr);
- boolean bigendian = buffer[0] == 0;
int oa = 0, or = 0, og = 0, ob = 0;
int redMask, greenMask, blueMask, destDepth = 32, destOrder;
- if (bigendian) {
+ if (OS.BIG_ENDIAN) {
oa = 0; or = 1; og = 2; ob = 3;
redMask = 0xFF00;
greenMask = 0xFF0000;
@@ -1160,7 +1139,7 @@ void init(ImageData image) {
blueMask = 0xFF;
destOrder = ImageData.LSB_FIRST;
}
- buffer = image.data;
+ byte[] buffer = image.data;
if (!palette.isDirect || image.depth != destDepth || stride != image.bytesPerLine || palette.redMask != redMask || palette.greenMask != greenMask || palette.blueMask != blueMask) {
buffer = new byte[stride * height];
if (palette.isDirect) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
index 7890307512..1702cfc4c8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
@@ -35,13 +35,8 @@ public static int /*long*/ createPixbuf(Image image) {
int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
byte[] line = new byte[stride];
- int /*long*/ ptr = OS.malloc(4);
- OS.memmove(ptr, new int[]{1}, 4);
- OS.memmove(line, ptr, 1);
- OS.free(ptr);
int oa, or, og, ob;
- boolean bigendian = line[0] == 0;
- if (bigendian) {
+ if (OS.BIG_ENDIAN) {
oa = 0; or = 1; og = 2; ob = 3;
} else {
oa = 3; or = 2; og = 1; ob = 0;