Awt implementation in libgcj?

Rolf W. Rasmussen rolfwr@ii.uib.no
Tue Dec 14 03:45:00 GMT 1999


On Mon, Dec 13, 1999 at 06:52:44PM -0800, Anthony Green wrote:
>[...] 
> This looks really cool. I tried building it with a recent gcj/libgcj.
> There are some issues in your code, and some in libgcj...
>> In PackedColorModel.java...
>> public PackedColorModel(ColorSpace cspace, int pixelBits,
> 			 int[] colorMaskArray, int alphaMask,
> 			 boolean isAlphaPremultiplied,
> 			 int transparency,
> 			 int transferType) {
>> 	super(pixelBits, initMasks(colorMaskArray, alphaMask), cspace,
> 	 (alphaMask != 0), isAlphaPremultiplied, transparency,
> 	 transferType);
>>> The call to initMasks is really a reference to `this', which can't
> appear before the call to the super constructor. Older versions of
> gcj didn't catch this - but current ones do (as does SUn's javac).

Silly mistake. The patch below fixes this. 
 
> natWindow.cc includes two files that we don't currently install:
> config.h and jvm.h. They don't appear to be required by natWindow.cc
> (at least, with a recent libgcj), so you should probably remove them.

They are not required. I really don't remember why I put them in
there.
> The linker is complaining that _Jv_Throw doesn't exist. I tried this
> on a platform that uses sjlj exceptions. cni.h says:
>> #ifdef SJLJ_EXCEPTIONS
> #define _Jv_Throw _Jv_Sjlj_Throw
> #endif
>> SJLJ_EXCEPTIONS is defined in config.h, which we don't install or
> include in this file. What should we do about this - Tom? Andrew?

I was using an old version of libgcj where I didn't encounter this
problem. Am I using JvThrow(..) in an unusual manner, or is this a general
problem with new versions of libgcj?
diff -ur jcnix-19991211/java/awt/image/PackedColorModel.java jcnix-19991214/java/awt/image/PackedColorModel.java
--- jcnix-19991211/java/awt/image/PackedColorModel.java	Wed Oct 13 14:17:55 1999
+++ jcnix-19991214/java/awt/image/PackedColorModel.java	Tue Dec 14 12:29:18 1999
@@ -18,9 +18,10 @@
 			 int transparency,
 			 int transferType) {
 	
-	super(pixelBits, initMasks(colorMaskArray, alphaMask), cspace,
-	 (alphaMask != 0), isAlphaPremultiplied, transparency,
+	super(pixelBits, calcBitsPerComponent(colorMaskArray, alphaMask),
+	 cspace, (alphaMask != 0), isAlphaPremultiplied, transparency,
 	 transferType);
+	initMasks(colorMaskArray, alphaMask);
 	if ((pixelBits<1) || (pixelBits>32)) {
 	 throw new IllegalArgumentException("pixels per bits must be " +
 					 "in the range [1, 32]");
@@ -28,13 +29,31 @@
 }
 
 
+ private static int[] calcBitsPerComponent(int[] colorMaskArray,
+					 int alphaMask) {
+	int numComponents = colorMaskArray.length;
+	if (alphaMask != 0) numComponents++;
+
+	int[] bitsPerComponent = new int[numComponents];
+
+	BitMaskExtent extent = new BitMaskExtent();
+	for (int b=0; b<colorMaskArray.length; b++) {
+	 extent.setMask(colorMaskArray[b]);
+	 bitsPerComponent[b] = extent.bitWidth;
+	}
+	if (alphaMask != 0) {
+	 extent.setMask(alphaMask);
+	 bitsPerComponent[numComponents-1] = extent.bitWidth;
+	}
+	return bitsPerComponent;
+ }
+
 /** Initializes the masks.
 	
 	@return an array containing the number of bits per color
 	component. */
 
- private int[] initMasks(int[] colorMaskArray, int alphaMask) {
-
+ private void initMasks(int[] colorMaskArray, int alphaMask) {
 	int numComponents = colorMaskArray.length;
 	if (alphaMask == 0) {
 	 masks = colorMaskArray;
@@ -46,7 +65,6 @@
 	 masks[numComponents++] = alphaMask;
 	}
 	
-	int[] bitsPerComponent = new int[numComponents];
 	shifts = new int[numComponents];
 	
 	/* This code is similar to the code in
@@ -56,11 +74,8 @@
 	BitMaskExtent extent = new BitMaskExtent();
 	for (int b=0; b<numComponents; b++) {
 	 extent.setMask(colorMaskArray[b]);
-	 bitsPerComponent[b] = extent.bitWidth;
 	 shifts[b] = extent.leastSignificantBit;
 	}
-
-	return bitsPerComponent;
 }
 
 public PackedColorModel(ColorSpace cspace, int pixelBits,
diff -ur jcnix-19991211/no/rwr/x/natWindow.cc jcnix-19991214/no/rwr/x/natWindow.cc
--- jcnix-19991211/no/rwr/x/natWindow.cc	Sun Sep 19 23:06:35 1999
+++ jcnix-19991214/no/rwr/x/natWindow.cc	Tue Dec 14 12:12:25 1999
@@ -1,11 +1,9 @@
 
 #include <vector>
-#include <config.h>
 
 #include <X11/Xlib.h>
 
 #include <cni.h>
-#include <jvm.h>
 #include "java/awt/Rectangle.h"
 #include "no/rwr/x/Display.h"
 #include "no/rwr/x/Window.h"
-- 
Rolf W. Rasmussen
 Smith's Law: "Any sufficiently optimistic statement is
 indistinguishable from sarcasm." -- Eric Smith


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /