Re: Anyone pondering HotSpot+Classpath?

2006-11-13 Thread Sven de Marothy
Yup, I've been pondering that since they announced their plans.

I'd even suggested to Webmink that I'd like to see Hotspot released
early for that reason. I wouldn't take credit for the fact - but it
seems I got what I asked for. (In fact it seems it's playing out such
that I'm getting exactly what I asked for :)) 

Anyway, yes, I think we defininitely want to get CP working with HotSpot
as soon as possible. I also think that we should move to make our VM
interfaces compatible as soon as possible. That is, unless it turns out
that their VM interface is absolutely horrible. (Or we could chose to
support both)

/Sven




Re: Accessibility crash

2006-08-16 Thread Sven de Marothy
On Wed, 2006-08-16 at 13:49 +0200, Mario Torre wrote:
 Do we have known issues with classpath and accessibility on linux?

You're talking about Classpath + GTK with GTK's accessibility turned on,
right? IIRC, Robert Schuster had reported this before. 

Simple answer is that it's a threading issue. I don't know the cause,
but I think it's most likely that the crashes are due to trying to use
xlib from different threads at the same time, and that the hangs are 
deadlocks. (Although xlib can also sometimes hang instead of crash on
threading errors too.)

You didn't happen to see any Xlib: unexpected async reply messages
or similar? It's a popular message when your threading causes xlib
to crash.

/Sven




[cp-patches] FYI: java.util.Locale - fix broken serialization and equals()

2006-08-12 Thread Sven de Marothy
This is a major embarassment. 

2006-08-13  Sven de Marothy  [EMAIL PROTECTED]

* java/util/Locale.java
(hashcode): Is a serialized field, not transient.
(equals): Should NOT compare strings by reference.
(readObject/writeObject): Use the default methods and handle the hash
seperately.


Index: java/util/Locale.java
===
RCS file: /sources/classpath/classpath/java/util/Locale.java,v
retrieving revision 1.33
diff -U3 -r1.33 Locale.java
--- java/util/Locale.java	20 Apr 2006 09:29:27 -	1.33
+++ java/util/Locale.java	13 Aug 2006 00:17:42 -
@@ -192,7 +192,7 @@
*
* @serial should be -1 in serial streams
*/
-  private transient int hashcode;
+  private int hashcode;
 
   /**
* Array storing all available locales.
@@ -917,9 +917,9 @@
   return false;
 Locale l = (Locale) obj;
 
-return (language == l.language
- country == l.country
- variant == l.variant);
+return (language.equals( l.language )
+ country.equals( l.country )
+ variant.equals( l.variant ) );
   }
 
   /**
@@ -935,11 +935,11 @@
   private void writeObject(ObjectOutputStream s)
 throws IOException
   {
-s.writeObject(language);
-s.writeObject(country);
-s.writeObject(variant);
 // Hashcode field is always written as -1.
-s.writeInt(-1);
+int temp = hashcode;
+hashcode = -1;
+s.defaultWriteObject();
+hashcode = temp;
   }
 
   /**
@@ -953,9 +953,7 @@
   private void readObject(ObjectInputStream s)
 throws IOException, ClassNotFoundException
   {
-language = ((String) s.readObject()).intern();
-country = ((String) s.readObject()).intern();
-variant = ((String) s.readObject()).intern();
+s.defaultReadObject();
 // Recompute hashcode.
 hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
   }


[cp-patches] Re: FYI: java.util.Locale - fix broken serialization and equals()

2006-08-12 Thread Sven de Marothy
Now I get to share in the embarassment, I'd missed the strings are
supposed to be interned.

2006-08-13  Sven de Marothy  [EMAIL PROTECTED]

* java/util/Locale.java
(hashcodeCache): New field.
(hashCode): use the above field instead of the serialized one
(writeObject): Removed method.
(equals): Revert to previous method.

Index: java/util/Locale.java
===
RCS file: /sources/classpath/classpath/java/util/Locale.java,v
retrieving revision 1.34
diff -U3 -r1.34 Locale.java
--- java/util/Locale.java	13 Aug 2006 00:20:11 -	1.34
+++ java/util/Locale.java	13 Aug 2006 01:19:00 -
@@ -188,11 +188,17 @@
   private String variant;
 
   /**
-   * This is the cached hashcode. When writing to stream, we write -1.
+   * This is where the JDK caches its hashcode. This is is only here
+   * for serialization purposes. The actual cache is hashcodeCache
*
* @serial should be -1 in serial streams
*/
-  private int hashcode;
+  private int hashcode = -1;
+
+  /**
+   * This is the cached hashcode. 
+   */
+  private transient int hashcodeCache;
 
   /**
* Array storing all available locales.
@@ -324,7 +330,7 @@
 this.language = language;
 this.country = country;
 this.variant = variant;
-hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
+hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
   }
 
   /**
@@ -899,7 +905,7 @@
*/
   public int hashCode()
   {
-return hashcode;
+return hashcodeCache;
   }
 
   /**
@@ -917,29 +923,9 @@
   return false;
 Locale l = (Locale) obj;
 
-return (language.equals( l.language )
- country.equals( l.country )
- variant.equals( l.variant ) );
-  }
-
-  /**
-   * Write the locale to an object stream.
-   *
-   * @param s the stream to write to
-   * @throws IOException if the write fails
-   * @serialData The first three fields are Strings representing language,
-   * country, and variant. The fourth field is a placeholder for 
-   * the cached hashcode, but this is always written as -1, and 
-   * recomputed when reading it back.
-   */
-  private void writeObject(ObjectOutputStream s)
-throws IOException
-  {
-// Hashcode field is always written as -1.
-int temp = hashcode;
-hashcode = -1;
-s.defaultWriteObject();
-hashcode = temp;
+return (language == l.language 
+ country == l.country 
+ variant == l.variant);
   }
 
   /**
@@ -954,7 +940,9 @@
 throws IOException, ClassNotFoundException
   {
 s.defaultReadObject();
-// Recompute hashcode.
-hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
+language = language.intern();
+country = country.intern();
+variant = variant.intern();
+hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
   }
 } // class Locale


[commit-cp] classpath ChangeLog java/util/Locale.java

2006-08-12 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/13 01:24:14

Modified files:
.  : ChangeLog 
java/util  : Locale.java 

Log message:
2006-08-13  Sven de Marothy  [EMAIL PROTECTED]

* java/util/Locale.java
(hashcodeCache): New field.
(hashCode): use the above field instead of the serialized one
(writeObject): Removed method.
(readObject): Intern strings.
(equals): Revert to previous method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8376r2=1.8377
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Locale.java?cvsroot=classpathr1=1.34r2=1.35




[commit-cp] classpath ChangeLog java/util/Locale.java

2006-08-12 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/13 00:20:11

Modified files:
.  : ChangeLog 
java/util  : Locale.java 

Log message:
2006-08-13  Sven de Marothy  [EMAIL PROTECTED]

* java/util/Locale.java
(hashcode): Is a serialized field, not transient.
(equals): Should NOT compare strings by reference.
(readObject/writeObject): Use the default methods and handle 
the hash
seperately.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8371r2=1.8372
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Locale.java?cvsroot=classpathr1=1.33r2=1.34




[cp-patches] FYI: Minor JTree fix

2006-08-09 Thread Sven de Marothy
The default SelectionModel for JTree is DefaultTreeSelectionModel.

2006-08-09  Sven de Marothy  [EMAIL PROTECTED]

* javax/swing/JTree.java
(JTree): Default SelectionModel should be DefaultTreeSelectionModel.
(setSelectionModel): Null parameter should create an EmptySelectionM.


Index: javax/swing/JTree.java
===
RCS file: /sources/classpath/classpath/javax/swing/JTree.java,v
retrieving revision 1.71
diff -U3 -r1.71 JTree.java
--- javax/swing/JTree.java	1 Aug 2006 14:45:46 -	1.71
+++ javax/swing/JTree.java	9 Aug 2006 16:19:41 -
@@ -1509,8 +1509,7 @@
   public JTree(TreeModel model)
   {
 setRootVisible(true);
-setSelectionModel(new EmptySelectionModel());
-selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+setSelectionModel( new DefaultTreeSelectionModel() );
 
 // The root node appears expanded by default.
 nodeStates = new Hashtable();
@@ -2050,14 +2049,16 @@
 if (selectionModel == model)
   return;
 
+if( model == null )
+  model = EmptySelectionModel.sharedInstance();
+
 if (selectionModel != null)
   selectionModel.removeTreeSelectionListener(selectionRedirector);
 
 TreeSelectionModel oldValue = selectionModel;
 selectionModel = model;
 
-if (selectionModel != null)
-  selectionModel.addTreeSelectionListener(selectionRedirector);
+selectionModel.addTreeSelectionListener(selectionRedirector);
 
 firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, model);
 revalidate();


[cp-patches] FYI: Minor BufferedImage completion

2006-08-09 Thread Sven de Marothy
This doesn't make it alright. But it's a step.

2006-08-09  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/image/BufferedImage.java
(BufferedImage): Reimplement predefined-type constructor.
(observers/tileObservers): Field renamed to tileObservers.
(createDefaultIndexedColorModel): New method.


Index: java/awt/image/BufferedImage.java
===
RCS file: /sources/classpath/classpath/java/awt/image/BufferedImage.java,v
retrieving revision 1.17
diff -U3 -r1.17 BufferedImage.java
--- java/awt/image/BufferedImage.java	11 Jul 2006 09:24:41 -	1.17
+++ java/awt/image/BufferedImage.java	9 Aug 2006 18:17:18 -
@@ -79,27 +79,37 @@
   TYPE_BYTE_BINARY= 12,
   TYPE_BYTE_INDEXED   = 13;
   
-  static final int[] bits3 = { 8, 8, 8 };
-  static final int[] bits4 = { 8, 8, 8, 8 };
-  static final int[] bits1byte = { 8 };
-  static final int[] bits1ushort = { 16 };
-  
-  static final int[] masks_int = { 0x00ff,
-   0xff00,
-   0x00ff,
-   DataBuffer.TYPE_INT };
-  static final int[] masks_565 = { 0xf800,
-   0x07e0,
-   0x001f,
-   DataBuffer.TYPE_USHORT};
-  static final int[] masks_555 = { 0x7c00,
-   0x03e0,
-   0x001f,
-   DataBuffer.TYPE_USHORT};
-
-  Vector observers;
+  /**
+   * Vector of TileObservers (or null)
+   */
+  Vector tileObservers;
   
   /**
+   * The image's WritableRaster
+   */
+  WritableRaster raster;
+
+  /**
+   * The associated ColorModel
+   */
+  ColorModel colorModel;
+
+  /**
+   * The image's properties (or null)
+   */
+  Hashtable properties;
+
+  /**
+   * Whether alpha is premultiplied
+   */
+  boolean isPremultiplied;
+
+  /**
+   * The predefined type, if any.
+   */
+  int type;
+
+  /**
* Creates a new codeBufferedImage/code with the specified width, height
* and type.  Valid codetype/code values are:
* 
@@ -130,126 +140,148 @@
*/
   public BufferedImage(int w, int h, int type)
   {
+SampleModel sm = null;
 ColorModel cm = null;
-
-boolean alpha = false;
-boolean premultiplied = false;
-switch (type)
-  {
-  case TYPE_4BYTE_ABGR_PRE:
-  case TYPE_INT_ARGB_PRE:
-	premultiplied = true;
-	// fall through
-  case TYPE_INT_ARGB:
-  case TYPE_4BYTE_ABGR:
-	alpha = true;
-  }
-	
-ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
-switch (type)
+boolean premultiplied = (type == BufferedImage.TYPE_INT_ARGB_PRE || 
+			 type == BufferedImage.TYPE_4BYTE_ABGR_PRE);
+
+switch( type )
   {
-  case TYPE_INT_RGB:
-  case TYPE_INT_ARGB:
-  case TYPE_INT_ARGB_PRE:
-  case TYPE_USHORT_565_RGB:
-  case TYPE_USHORT_555_RGB:
-	int[] masks = null;
-	switch (type)
-	  {
-	  case TYPE_INT_RGB:
-	  case TYPE_INT_ARGB:
-	  case TYPE_INT_ARGB_PRE:
-	masks = masks_int;
-	break;
-	  case TYPE_USHORT_565_RGB:
-	masks = masks_565;
-	break;
-	  case TYPE_USHORT_555_RGB:
-	masks = masks_555;
-	break;
-	  }
-	
-	cm = new DirectColorModel(cs,
-  32, // 32 bits in an int
-  masks[0], // r
-  masks[1], // g
-  masks[2], // b
-  alpha ? 0xff00 : 0,
-  premultiplied,
-  masks[3] // data type
-  );
+  case BufferedImage.TYPE_INT_RGB:
+	sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, 
+	   width, height,
+	   new int[]{ 0x00FF, 
+			  0xFF00, 
+			  0x00FF } ) ;
+	cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff );
 	break;
 	
-  case TYPE_INT_BGR:
-	String msg =
-	  FIXME: Programmer is confused. Why (and how) does a  +
-	  TYPE_INT_BGR image use ComponentColorModel to store  +
-	  8-bit values? Is data type TYPE_INT or TYPE_BYTE. What  +
-	  is the difference between TYPE_INT_BGR and TYPE_3BYTE_BGR?;
-	throw new UnsupportedOperationException(msg);
-	
-  case TYPE_3BYTE_BGR:
-  case TYPE_4BYTE_ABGR:
-  case TYPE_4BYTE_ABGR_PRE:
-  case TYPE_BYTE_GRAY:
-  case TYPE_USHORT_GRAY:
-	int[] bits = null;
-	int dataType = DataBuffer.TYPE_BYTE;
-	switch (type) {
-	case TYPE_3BYTE_BGR:
-	  bits = bits3;
-	  break;
-	case TYPE_4BYTE_ABGR:
-	case TYPE_4BYTE_ABGR_PRE:
-	  bits = bits4;
-	  break;
-case TYPE_BYTE_GRAY:
-  bits = bits1byte;
-  cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
-  break;
-case TYPE_USHORT_GRAY:
-  bits = bits1ushort;
-  cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
-  dataType = DataBuffer.TYPE_USHORT;
-  break;
-	}
-	cm = new ComponentColorModel(cs, bits, alpha, premultiplied,
- alpha ?
- Transparency.TRANSLUCENT:
- Transparency.OPAQUE,
- dataType);
+  case BufferedImage.TYPE_3BYTE_BGR:
+	sm = new PixelInterleavedSampleModel( DataBuffer.TYPE_BYTE,
+	  width, height,
+	  3, width * 3, 
+	  new int[]{ 2, 1, 0 } );
+	cm

[cp-patches] Re: FYI: Minor BufferedImage completion (Part 2)

2006-08-09 Thread Sven de Marothy
Whoops! Last patch was a dud. Here's the fix (commited)

On Wed, 2006-08-09 at 20:20 +0200, Sven de Marothy wrote:
 This doesn't make it alright. But it's a step.
 
 2006-08-09  Sven de Marothy  [EMAIL PROTECTED]
 
   * java/awt/image/BufferedImage.java
   (BufferedImage): Reimplement predefined-type constructor.
   (observers/tileObservers): Field renamed to tileObservers.
   (createDefaultIndexedColorModel): New method.
 

Index: java/awt/image/BufferedImage.java
===
RCS file: /sources/classpath/classpath/java/awt/image/BufferedImage.java,v
retrieving revision 1.18
diff -U3 -r1.18 BufferedImage.java
--- java/awt/image/BufferedImage.java	9 Aug 2006 18:21:14 -	1.18
+++ java/awt/image/BufferedImage.java	9 Aug 2006 18:30:22 -
@@ -138,7 +138,7 @@
* @throws IllegalArgumentException if codetype/code is not one of the
* specified values.
*/
-  public BufferedImage(int w, int h, int type)
+  public BufferedImage(int width, int height, int type)
   {
 SampleModel sm = null;
 ColorModel cm = null;


[commit-cp] classpath ChangeLog javax/swing/JTree.java

2006-08-09 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/09 16:22:49

Modified files:
.  : ChangeLog 
javax/swing: JTree.java 

Log message:
2006-08-09  Sven de Marothy  [EMAIL PROTECTED]

* javax/swing/JTree.java
(JTree): Default SelectionModel should be 
DefaultTreeSelectionModel.
(setSelectionModel): Null parameter should create an 
EmptySelectionM.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8350r2=1.8351
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/swing/JTree.java?cvsroot=classpathr1=1.71r2=1.72




[commit-cp] classpath ChangeLog java/awt/image/BufferedImag...

2006-08-09 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/09 18:21:14

Modified files:
.  : ChangeLog 
java/awt/image : BufferedImage.java 

Log message:
2006-08-09  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/image/BufferedImage.java
(BufferedImage): Reimplement predefined-type constructor.
(observers/tileObservers): Field renamed to tileObservers.
(createDefaultIndexedColorModel): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8354r2=1.8355
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/image/BufferedImage.java?cvsroot=classpathr1=1.17r2=1.18




[commit-cp] classpath/java/awt/image BufferedImage.java

2006-08-09 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/09 18:31:14

Modified files:
java/awt/image : BufferedImage.java 

Log message:
2006-08-09  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/image/BufferedImage.java
(BufferedImage): Reimplement predefined-type constructor.
(observers/tileObservers): Field renamed to tileObservers.
(createDefaultIndexedColorModel): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/image/BufferedImage.java?cvsroot=classpathr1=1.18r2=1.19




[cp-patches] Re: RFC: Change GtkToolkit threading

2006-08-08 Thread Sven de Marothy
Commited this.

On Thu, 2006-08-03 at 08:35 +0200, Sven de Marothy wrote:
 This should fix PR #16203, and also make for a general improvement.
 
 In short: The main GTK loop is not started statically in GtkToolkit,
 but rather on creating the first window peer. (as it should be).
 
 In long:
 On destroying the last window peer, we call gtk to end the main
 loop and the thread exits. If a new window is opened, we create
 a new thread object and restart the main gtk loop.
 
 I also moved all the stuff related to this (except native methods) 
 out from GtkToolkit and into a new GtkMainThread class. This should
 help reduce the clutter in the already ugly GtkToolkit class.
 
 It seems to work just fine for me, but being a rather central thing
 I'd like some feedback and testing before committing it.
 (Obviously not intended for the 0.92 release)
 
 /Sven
 
 2006-08-03  Sven de Marothy  [EMAIL PROTECTED]
 
 * gnu/java/awt/peer/gtk/GtkMainThread.java
 New file.
 * gnu/java/awt/peer/gtk/GtkChoicePeer.java
 * gnu/java/awt/peer/gtk/GtkComponentPeer.java
 Replace occurances of GtkToolkit.mainThread to GtkMainThread.mainThread.
 * gnu/java/awt/peer/gtk/GtkToolkit.java
 Minor style fixes; removed unused fields, 
 set fields to private where possible.
 (createDialog, createFrame, createWindow, createEmbeddedWindow): 
 Call GtkMainThread.createWindow().
 * gnu/java/awt/peer/gtk/GtkWindowPeer.java
 (dispose): New method.
 * include/gnu_java_awt_peer_gtk_GtkToolkit.h
 * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
 (gtkQuit): New native method.





[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/GtkCh...

2006-08-08 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/08 22:23:36

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: GtkChoicePeer.java GtkComponentPeer.java 
   GtkToolkit.java GtkWindowPeer.java 
include: gnu_java_awt_peer_gtk_GtkToolkit.h 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GtkToolkit.c 
Added files:
gnu/java/awt/peer/gtk: GtkMainThread.java 

Log message:
2006-08-09  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkMainThread.java
New file.
* gnu/java/awt/peer/gtk/GtkChoicePeer.java
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
Replace GtkToolkit.mainThread with GtkMainThread.mainThread.
* gnu/java/awt/peer/gtk/GtkToolkit.java
Minor style fixes; removed unused fields, 
set fields to private where possible.
(createDialog, createFrame, createWindow, 
createEmbeddedWindow): 
Call GtkMainThread.createWindow().
* gnu/java/awt/peer/gtk/GtkWindowPeer.java
(dispose): New method.
* include/gnu_java_awt_peer_gtk_GtkToolkit.h
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
(gtkQuit): New native method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8346r2=1.8347
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java?cvsroot=classpathr1=1.27r2=1.28
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java?cvsroot=classpathr1=1.120r2=1.121
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java?cvsroot=classpathr1=1.92r2=1.93
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java?cvsroot=classpathr1=1.52r2=1.53
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkMainThread.java?cvsroot=classpathrev=1.15
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GtkToolkit.h?cvsroot=classpathr1=1.12r2=1.13
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c?cvsroot=classpathr1=1.28r2=1.29




[cp-patches] FYI: Fix font locking

2006-08-06 Thread Sven de Marothy
Here's a commited fix (for the release) for the problem with assert
failures/segfaults while drawing text.

This fix is kind of temporary since I'm doing a big overhaul of all
the font peer code.

2006-08-06  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(drawGlyphVector): Synchronize against font object when drawing.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
(nativeDrawGlyphVector): Use pango locking when drawing.
(install_font_peer): Use pango locking when creating the cairo face.


Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.35
diff -U3 -r1.35 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java	27 Jul 2006 20:59:42 -	1.35
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java	6 Aug 2006 20:58:04 -
@@ -1458,8 +1458,11 @@
 float[] positions = gv.getGlyphPositions (0, n, null);
 
 setFont (gv.getFont ());
-cairoDrawGlyphVector(nativePointer, (GdkFontPeer)getFont().getPeer(),
- x, y, n, codes, positions);
+	synchronized( this.font ) 
+	  { 
+	cairoDrawGlyphVector(nativePointer, (GdkFontPeer)getFont().getPeer(),
+ x, y, n, codes, positions);
+	  }
   }
 else
   {
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
===
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c,v
retrieving revision 1.13
diff -U3 -r1.13 gnu_java_awt_peer_gtk_CairoGraphics2D.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c	26 Jul 2006 22:12:21 -	1.13
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c	6 Aug 2006 20:58:04 -
@@ -315,7 +315,9 @@
   (*env)-ReleaseFloatArrayElements (env, java_positions, native_positions, 0);
   (*env)-ReleaseIntArrayElements (env, java_codes, native_codes, 0);
 
+  pango_fc_font_lock_face( (PangoFcFont *)pfont-font );
   cairo_show_glyphs (gr-cr, glyphs, n);
+  pango_fc_font_unlock_face( (PangoFcFont *)pfont-font );
 
   g_free(glyphs);
 }
@@ -761,18 +763,19 @@
 
   if (pfont-graphics_resource == NULL)
 {
-  face = pango_ft2_font_get_face (pfont-font);
+  face = pango_fc_font_lock_face( (PangoFcFont *)pfont-font );
   g_assert (face != NULL);
 
   ft = cairo_ft_font_face_create_for_ft_face (face, 0);
   g_assert (ft != NULL);
 
   cairo_set_font_face (cr, ft);
-  cairo_font_face_destroy (ft);
+  /*  cairo_font_face_destroy (ft);*/
   cairo_set_font_size (cr,
(pango_font_description_get_size (pfont-desc) /
 (double)PANGO_SCALE));
   ft = cairo_get_font_face (cr);
+  pango_fc_font_unlock_face( (PangoFcFont *)pfont-font );
   pfont-graphics_resource = ft;
 }
   else


[commit-cp] classpath gnu/java/awt/peer/gtk/CairoGraphics2D...

2006-08-06 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/06 21:00:54

Modified files:
gnu/java/awt/peer/gtk: CairoGraphics2D.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_CairoGraphics2D.c 

Log message:
2006-08-06  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(drawGlyphVector): Synchronize against font object when drawing.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
(nativeDrawGlyphVector): Use pango locking when drawing.
(install_font_peer): Use pango locking when creating the cairo 
face.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java?cvsroot=classpathr1=1.35r2=1.36
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c?cvsroot=classpathr1=1.13r2=1.14




[commit-cp] classpath ChangeLog

2006-08-06 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/06 21:23:06

Modified files:
.  : ChangeLog 

Log message:
2006-08-06  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(drawGlyphVector): Synchronize against font object when drawing.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c
(nativeDrawGlyphVector): Use pango locking when drawing.
(install_font_peer): Use pango locking when creating the cairo 
face.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8331r2=1.8332




Re: Torturing image ops and Swing

2006-08-04 Thread Sven de Marothy
On Fri, 2006-08-04 at 13:17 +0900, [EMAIL PROTECTED] wrote:
 Hi Sven,
 As you say, if we go after too many goals, we may end accomplishing none
 of them, or worse complete them half way and leave users scratching their
 heads as to what went wrong(this leaves a really bad impression). 

In general, definetly. 

 So it is better for us to say, It maybe slow, but at least it is working and 
 it is
 an equivalent to JDK 1.4(or 1.5). I think that after we achieve
 compatibility with ONE version of Java API, we can go after the
 optimizations. We can then say, We have a solid equivalent of JDK 1.4.
 This will be enough to gain many peoples attention.

I agree. Compatibility goes first. But. There are cases where speed and
furthering the implementation's compatibility aren't in conflict.
In some cases, (AWT imaging is a good example), we have (or have had) 
implementations of things which were more or less fundamentally wrong.
And where that fundamental problem had caused both issues with speed and
with compatibility. The API is such that it's often difficult to
do something fundamentally different from how Sun does it and still
be fully compatible. And often, these ways of doing things are slower,
too. (However, this isn't always the case)

 I think we should reach a consensus of SPEC compatibility vs RI
 compatibility, then we should write it down on the WIKI and stick to it
 until it is complete. That way we can all stay focused.

Actually, I'm a bit sceptical of having a policy on compatibility. I
think it might be spending time on a non-existant problem. 

Spec-vs-JDK compatibility sounds like a big issue, and does turn
up in cases now and then, but it's only is a big issue if you decide to
turn all those cases into a general problem. If you do, you start
looking for a big general solution and consensus on it. Which is hard to
get for any general idea that's big enough. 

However, in my experience, when you do run into these issues (and it's
actually fairly rare to do so), there usually is a quite broad consensus
on what the right thing to do is in that particular case. And that's of
course in rare event that someone actually consults the rest. 
In the vast majority of cases, the developer himself (who's presumably
more in-touch with the particulars of the method involved than anyone
else anyway) makes a judgement call. And unless it turns out this
actually causes a real-world problem, you never hear from it again.

I can't really imagine any consensus on the issue that wouldn't really
just boil down to Use common sense.. But if someone needs guidelines,
here are at least the points I tend to evaluate myself if I run into
something.

* Re-read the spec. Are you sure there's no possible way the spec could
be interpreted such that it supports this behaviour?
(Happens quite a lot. Remember, in general, Sun's API docs tend to be
written to fit their implementation and not vice-versa. )

* Does the actual behaviour accidentally seem to match the behaviour
you'd get with simpler/less code than what the docs say?
(Common, especially for Exceptions! A recent example I brought up is
BigDecimal.setScale. Which delegates to BigDecimal.divide, (in our impl)
and throws the exceptions that method throws. Which changed in 1.5,
although Sun forgot to change the javadocs for the former method.)

* Is this really a compatibility issue? Is it reasonable that any
sanely-coded program could depend on this certain behaviour?
(Most discrepancies would fall into this category)

* Do other TCK-approved (IBM, Apple) VMs do it this way?
(E.g. dependence on com.sun* classes.)

* Check Sun's bug page, has someone reported this or something
related which can provide additional insight into what the actual
intended behaviour is here?
(Remember, Sun has bugs, and people may create dependencies on them. 
If Sun acknowledges it's a bug, then it's not our problem.)

* Do other Sun versions do it this way?
(Sun has regressions, too.)

/Sven





Re: [cp-patches] RFC: Change GtkToolkit threading

2006-08-03 Thread Sven de Marothy
On Thu, 2006-08-03 at 13:10 -0400, Thomas Fitzsimmons wrote:

 the three exit conditions are:
 
  * There are no displayable AWT or Swing components.
  * There are no native events in the native event queue.
  * There are no AWT events in java EventQueues.
 
 The first two conditions are satisfied by quitting the GTK main thread (no 
 native events) when there are no windows left (no displayable AWT or Swing 
 components).  I'm wondering if we need a check for the third condition before 
 quitting the GTK main loop.

Right, 1) is what I just implemented. As for 2), calling gtk_main_quit()
doesn't quit immediately but rather Makes the innermost invocation of
the main loop return when it regains control. as the GTK docs say. 
So I'm 95% sure that's to be interpreted as the native queue being empty
at that point.

Condition 3) Is also fulfilled. The EventDispatchThread shuts itself
down as it should, and I'm certain we don't need to check with the GTK
thread. The way I read it, the first two points relate only to the main
GTK thread, and the third point only to the EventDispatchThread. 

So basically when 1) and 2) are satisfied we can shut down the GTK
thread (since the peers are disposed of at that point, the EventQueue
can't call into them and cause new native events). There's no apparent 
reason why we'd need or want to shut them all down at the same time.

Once the GTK thread is shut down the EventQueue empties itself and then
shuts down. It seems to work just fine. I'm attaching a little testcase
that creates and destroys some windows and prints the number of active
threads. As expected we have two; the main GTK thread and the
EventDispatchThread.

Interestingly, the testcase shows that the 1.4 JDK revs up 6 (!)
threads by then. (But 'only' 4 on the 1.5 JDK). I dunno what it's
doing with all those extra threads. Running a botnet? :)

/Sven
import java.awt.*;

public class ThreadTest
{
  public static void main(String[] args)
  {
System.out.println(Thread initially active:+Thread.activeCount());
Frame f = new Frame();
f.setSize(100,100);
f.setVisible(true);
System.out.println(Active after opening window:+Thread.activeCount());
long t = System.currentTimeMillis();
System.out.println(Delaying 5s);
while( (System.currentTimeMillis() - t)  5000 )
  Thread.yield();
System.out.println(Active now:+Thread.activeCount());
System.out.println(Disposing peers.);
f.dispose();
f = null;
t = System.currentTimeMillis();
System.out.println(Active now::+Thread.activeCount());
System.out.println(Waiting 5 s);
while( (System.currentTimeMillis() - t)  5000 )
  Thread.yield();
f = new Frame();
f.setSize(100,100);
System.out.println(Recreating peers.);
f.setVisible(true);
System.out.println(# of active threads now:+Thread.activeCount());
System.out.println(End.);
  }
}


Re: Torturing image ops and Swing

2006-08-03 Thread Sven de Marothy
On Thu, 2006-08-03 at 15:59 +0200, [EMAIL PROTECTED]
wrote:
 Hello all,
 
 anyone interested in torturing our Swing, awt.image and javax.image operations
 a bit? Long text with a question buried at the end. Sorry, but I had  
 to get this
 off my soul; feeling much better already :-)

No problem :) Anyone's who's looked at our awt.image code is probably 
just as frustrated. :) The way I see it, this is the last major piece
of work that needs to be done for the whole Java2D bit. (or AWT as a
whole even) The rest is fairly easy stuff.

[Snip: How to run the program]

 4a. Loading typical digicam images with 4+ Mpixels is somewhat slower,  
 but still
 almost acceptable. jamvm needs about 5 seconds for a 3000x2000 JPEG for
 image loading, plus about 7 seconds for calculating the histogram  
 (when enabled).
 JDK 1.5 needs about 1.5 seconds for loading plus 0.3 secs for the  
 histogram.

The discrepancy is rather large, since the actual loading in
this case (using Toolkit.createImage) is done natively. I'm guessing
most of the overhead is coming from any and all java processing we do
afterwards.

 4b. Cacao calculates the histogram much faster (almost as fast as the  
 JDK), but
   unfortunately it leaks memory and crashes after loading a few  
 4+Mpixel images
   (with -Xmx300m and top reporting about 320M RSS actually used.)
 
   It seems that cacao 0.96 never garbage-collects image data?

Well, it should. But we should check up on that. See what Herr Thalinger
has to say.

 For the following, use smaller images (800x600 or so) to avoid frustration.
 
 5. Select Tools  Sharpen  Laplace 3x3. Simple convolution filter implemented
  with ConvolveOp and applied to a BufferedImage TYPE_INT_RGB.
 
 java.lang.ArrayIndexOutOfBoundsException: 3
 at java.awt.image.ColorModel.getComponentSize(ColorModel.java:200)
 at java.awt.image.ColorModel.coerceData(ColorModel.java:641)
 at java.awt.image.DirectColorModel.coerceData(DirectColorModel.java:405)
 at java.awt.image.BufferedImage.coerceData(BufferedImage.java:288)
 at java.awt.image.ConvolveOp.filter(ConvolveOp.java:126)

Looks like a regression. Overall we're making progress on awt.image
though, mainly thanks to Mr Gilbert, at the moment.

 This worked a week ago, but very slowly. Try the Tools  Edges  Mexican
 Hat 13x13 filter, if you don't believe me. The JDK seems to include some
 optimizations for such (separable?) kernels.

Yes, this is one of those things which is left to do with awt.image.
There's a lot of optimization that can and should be done.


 6. Select Tools  Negative Image. Obvious implementation based on
  LookupOp. Works. Performance is ok (1 sec for 800x600). The result is
  a BufferedImage.TYPE_INT_RGB.
 
  BUT repainting suddenly takes 3 seconds for each paintComponent,
  and the application is pretty much dead. For comparison, a repaint of the
  BufferedImage before the filtering took about 10 msec.

Right. BufferedImages created with Component.createImage(int, int) are
backed by a Cairo surface. Ones created directly by BufferedImage are
not. Again, this is one of these things that needs to be fixed,
basically so that all BufferedImages can have some native backing
buffer.)

  For 3000x2000 images, each repaint takes 40 seconds on my system.
  Any ideas about what I am doing wrong here are HIGHLY appreciated.

Nothing really, we're to blame here (Well, Cairo is a bit slow too. But
not _that_ slow.) Since we can only draw Cairo surfaces,
non-CairoSurface backed BufferedImages will draw much slower, as this
requires transferring (and possibly converting all) the pixels. 

  Load a new image. Repainting time is back to the millisecond range.

Right, it's a CairoSurface-backed buffer then too.

 
 7. Perhaps LookupOp and ConvolveOp are bad? Select Tools  Rotate
  image left (or right). Implemented 'by hand' via getRGB and setRGB.
  Much slower than LookupOp, about 4 seconds on my system at 800x600.

They can probably be faster, but I don't think they're the main problem
if the times you're measuring also include the repaint time.

  But again, repainting suddenly takes many seconds.

Same explanation as before.

  Edit  Load images via ImageIO.
 
  Loading a 800x600 JPEG takes about 200 msecs with Toolkit, and about
  7 seconds with Toolkit. Loading a 3000x2000 JPEG takes 200+ seconds.

Too slow.

  The imageio GIF reader is much faster (4 seconds at 3000x2000), but now
  the conversion to BufferedImage.TYPE_INT_RGB takes 90+ seconds...

Really? That sounds too fast, almost. How do you mean conversion?
Running it through a filter, or just drawing the image returned by
IIO onto the the aforementioned BufferedImagE?

  Images returned by the PNG reader render as transparent.
 
 9. Select Help  Commands...  A simple JTextArea in a JScrollPanel, but
  with about 700 lines of text. Try scrolling. Painfully slow. The 

Re: Torturing image ops and Swing

2006-08-03 Thread Sven de Marothy
On Thu, 2006-08-03 at 22:28 +0200, [EMAIL PROTECTED]
wrote:
 Hello Sven,
 
 thanks for your detailed answers to my questions!  New Niffler version  
 uploaded
 and available right now (niffler-exif.jar and niffler-src.zip).

Ok good. :)

 I added a special classpath workaround to Niffler that checks for  
 java.vendor
 and calls ImageUtils.getCairoBackedImage( bufferedImage) before rendering when
 GNU something is detected. This adds another image conversion (BufferedImage
 drawn into an Image created by Component.createImage()), but makes the editing
 operations useable with jamvm. Good.

Well, lemme just point out that Component.createImage() is basically the
same thing as calling GraphicsConfiguration.createCompatibleImage() for
the GraphicsConfiguration of that Component (Read: The
graphicsconfiguration of your screen). 

So as such, it's supposed to return a BufferedImage with a pixel format
best suited for fast drawing on your screen (using whatever color mode
you've got set). So this will always result in faster images, regardless
of Java impl.

 Yep. Please excuse my typo there; the 7 and 200+ seconds are for jamvm and
 classpath loading a 800x600 or 3000x2000 JPEG via the imageio JPEG plugin.
 You can try the 10+ MPixel images from the Brussels' mort subite for  
 yourself...

Yes, the existing ImageIO plugin for JPEG (Which is a generic wrapper
around gdk-pixbuf that someone coded) is totaly flawed. I haven't
actually looked at the code, but I think that however it's doing its job
it's doing it in a horribly bad way. The plan (or my plan at least) is
to just throw this out as soon as we get a real JPEG decoder.

  Really? That sounds too fast, almost. How do you mean conversion?
  Running it through a filter, or just drawing the image returned by
  IIO onto the the aforementioned BufferedImagE?
 
 You consider, 4+90 seconds too fast for 3000x2000?  Wait for next years'
 digicams and cellphone cams :-)

90 seconds is very slow. But that part wasn't so unexpected to me, it's
basically due to the inefficient awt.image impl we have. But 5 seconds
to decode such a large GIF is pretty dang good considering that it's
all done in Java. (I guess I'm particularily interested in this since
I wrote the GIF decoder).

[ JTextArea in a JScrollPanel with 700 lines .. ]

  I'll have to check this out. drawString is fairly slow nowadays.
  However, drawGlyphVector (and by extension TextLayout.draw) are quite
  snappy, comparable to the JDK in speed. We might need to tune
  Swing here.
 
 Should I submit another bug for this?  Once upon a time, this used to be
 PR24152...

Naw, I'll do it. I'll want to check up on where the problem is first. 
While drawString() is slow, I doubt a that bit it's slow enough to
render the thing unusable. It's probably something else.
(Basically we're talking about rendering a large string in 4 ms or .4
ms, but since I assume you're not showing all 700 at once, I doubt
that's it.)

 I guess we need some technique to include performance-related tests in
 Mauve for regular regression testing. Unfortunately, I don't know how to
 do this, because both raw system speed and user picky-ness seem to
 differ greatly between different systems...

I'd much rather not. Tests in general and benchmarks in particular often
make people lose focus. IMHO, people will tend to fix the test but
sometimes cause a worse regression in something not as well tested.

With a fixed set of benchmarks people will invariably end up sacrificing
speed of non-benchmarked things to improve the benchmark scores. Either
that, or there's a large risk they'll start microoptimizing and trying
to improve things that are already more than adequately fast while
ignoring bigger problems elsewhere. 
Premature optimization is the root of all evil. 

So my opinion is that we should do benchmarking, but the way we 
tend to do it now; sporadically and thoroughly by the people 
hacking on the code and know it well, and know what to look 
for and what to check for. 

Writing a benchmark is trivial. Writing a benchmark that actually
measures something meaningful is not.

In short: Superficial automated benchmarks will only result in
superficial automated optimizations. 

To give a practical example, there about a half dozen optimizations
I know about which could improve the drawing performance of
CairoGraphics2D for shapes. (not images) I posted the results earlier,
which were that they're entirely insignificant because Cairo is so very
slow. And in that case, it's not worth complicating the code at this
stage for what amounts to almost nothing relatively speaking.

Plus some speed losses are simply necessary. You can't expect to improve
performance consistently in code as immature as most of our Java2D code.
There are some fundamental design issues that need to be fixed first.

/Sven




[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Compo...

2006-08-03 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/03 08:08:14

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: ComponentGraphics.java 
   GtkComponentPeer.java 
include: gnu_java_awt_peer_gtk_ComponentGraphics.h 
java/awt   : Component.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_ComponentGraphics.c 

Log message:
2006-08-03  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/ComponentGraphics.java
(grab, nativeGrab): New methods.
* include/gnu_java_awt_peer_gtk_ComponentGraphics.h
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
(nativeGrab): New method.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(print): Implement.
* java/awt/Component.java
(printAll): Should call peer print method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8305r2=1.8306
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/ComponentGraphics.java?cvsroot=classpathr1=1.19r2=1.20
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java?cvsroot=classpathr1=1.119r2=1.120
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_ComponentGraphics.h?cvsroot=classpathr1=1.8r2=1.9
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Component.java?cvsroot=classpathr1=1.141r2=1.142
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c?cvsroot=classpathr1=1.17r2=1.18




Re: Xara backend over cairo?

2006-08-02 Thread Sven de Marothy
On Sat, 2006-07-29 at 21:08 +0530, प्रवीण् ए (Praveen A) wrote:
 The benchmark shows good perfomance than Cairo.
 http://www.xaraxtreme.org/about/performance.html

Well, to the defense of Cairo, they've not done any serious work on
improving performance yet, I think. That's scheduled for the upcoming
releases. However I must admit that from the benchmarks I've done 
personally (some of which I posted here), I am a bit disappointed
with its performance so far. (However, performance isn't the reason
why we're using it)

 But I don't know whether we can also use it for class path (though it
 is basically a vector rendering engine). 

If someone's willing to do the work, it can certainly be used to some
extent. AFAIK, their engine isn't quite a drop-in replacement though.

It'd be interesting to see it benchmarked against some other libraries
like Sun's Java2D, and AGG (http://www.antigrain.com/), though.

/Sven




[commit-cp] classpath ChangeLog java/awt/font/FontRenderCon...

2006-08-02 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/02 17:29:07

Modified files:
.  : ChangeLog 
java/awt/font  : FontRenderContext.java 
java/awt/geom  : AffineTransform.java 

Log message:
2006-08-02  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/geom/AffineTransform.java
(hashCode): Tweak impl. 
* java/awt/font/FontRenderContext.java
(hashCode): Implement. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8295r2=1.8296
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/FontRenderContext.java?cvsroot=classpathr1=1.4r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/geom/AffineTransform.java?cvsroot=classpathr1=1.10r2=1.11




[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/GtkCh...

2006-08-02 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/08/03 04:31:03

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: GtkChoicePeer.java 
java/awt   : Choice.java 

Log message:
2006-08-02  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GtkChoicePeer.java
(remove): Force event on removing item 0 when it's selected.
(handleEvent): Always call Choice.selected().
* java/awt/Choice.java:
(remove): Simplify and correct.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8304r2=1.8305
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java?cvsroot=classpathr1=1.26r2=1.27
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Choice.java?cvsroot=classpathr1=1.29r2=1.30




AWT peer event handling (Important)

2006-07-30 Thread Sven de Marothy
Hi all,
Our Choice impl was pretty screwed-up; The index of the selected item
was not getting updated (unless you had an ItemListener attached).
That's pretty terrible. And looking at the history of the thing,
it's pretty clear there's a lot of confusion about how this stuff is
supposed to work. 

So I took it upon myself to do a proper investigation
and get this stuff sorted out once and for all. (Note that while I
belive the following to be true for most peer properties, painting
is not one of them.)

First off, some observations: 
1) When a property of a Component changes, the corresponding setProperty
method of the Component object IS called. E.g. selecting Choice item
WILL result in a call to Choice.select(index) method.
(Test: Overload the setProperty method)

2) The above call is done from the event dispatch thread.
(Test: Print Toolkit.getSystemEventQueue().isDispatchThread() )

3) The call is from the peer handleEvent and NOT from the peer
dispatchEventImpl. The latter must also always call
super.dispatchEventImpl for the former to be called.
(Test: Construct your own event and send it to EventQueue.postEvent(ie)
fake events are passed on to listeners but do not change the state of
the Component or its peer.)
An example of where this is wrong is the current version of Checkbox.

4) The Component-subclass's processEvent/processXXXEvent methods are
only called if the class has listeners (this much we seem to do right)
(Test: Overload processEvent)

5) The initial setting-up of the native state (on creating the peer)
does not trigger any events. (Test: Add a listener). (the obvious
paint events, etc are exceptions of course)

So, how this works is that the peer keeps track of the native state,
and what happens is:

Case 1: The user clicks on something, changing the native state. A
callback to the peer occurs, and if the state has changed, the peer
updates its state and posts an event. This event is then executed
by the event dispatch thread, calling the peer handleEvent() method. 
The peer handleEvent method checks if it's an event specific
to its peer type (or delegates it to super.handleEvent), and then, if
the owner's state needs updating, it calls its setProperty() method. 

Case 2: The program calls Component.setProperty(). If the property
isn't changed, do nothing. Otherwise, set the property and call the peer
setProperty() method. This triggers a callback and posts an event, but
in this case the peer handleEvent() method does NOT call the owner's
setProperty() method a second time since the owner's state does not need
updating.

Case 3: Somebody sticks in a bogus event in the event queue. The peer
handleEvent() method does not call its owner's setProperty() method
because its state does not need updating.

So our behaviour here goes from broken, to almost-right to completely
wrong (although a bit functional). But we need to strive to do this
stuff the Right way. All this behaviour is testable, and by testable
I mean you can write a program that relys on it. Which means that this
is a compatibility problem.

/Sven




[commit-cp] classpath ChangeLog java/awt/Choice.java

2006-07-30 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/30 08:52:23

Modified files:
.  : ChangeLog 
java/awt   : Choice.java 

Log message:
2006-07-30  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/Choice:
Reformat, fix copyright year.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8269r2=1.8270
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Choice.java?cvsroot=classpathr1=1.26r2=1.27




[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/GtkCh...

2006-07-30 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/30 09:01:33

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: GtkChoicePeer.java 
include: gnu_java_awt_peer_gtk_GtkChoicePeer.h 
java/awt   : Choice.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GtkChoicePeer.c 

Log message:
2006-07-30  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/Choice.java:
(accessibleAction): Call select() directly.
(add, insert, remove): Reimplement.
(dispatchEventImpl): Always call super.
(processItemEvent): Does not set the index.
* include/gnu_java_awt_peer_gtk_GtkChoicePeer.h
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
(append): removed.
(nativeAdd): Name changed to add.
(selection_changed_cb): Simplify callback.
* gnu/java/awt/peer/gtk/GtkChoicePeer.java
(selected): New field.
(add): Replaced with native impl.
(handleEvent): New method.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8270r2=1.8271
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkChoicePeer.java?cvsroot=classpathr1=1.25r2=1.26
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GtkChoicePeer.h?cvsroot=classpathr1=1.9r2=1.10
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Choice.java?cvsroot=classpathr1=1.27r2=1.28
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c?cvsroot=classpathr1=1.21r2=1.22




[cp-patches] Re: BigDecimal mauve regressions (FYI: patch)

2006-07-29 Thread Sven de Marothy
On Sat, 2006-07-29 at 16:54 +0200, Mark Wielaard wrote:

 Did you also happen to look at the DiagBigDecimal test? It passed with
 0.91, but current CVS (with or without you patch) gives the following
 failures:
..[snip list of 22 failures]..

Yes. I didn't investigate those further because the 1.5 JRE fails
the same set of tests (+4 more). The 1.4 JRE fails only 3 of them.

So these tests need a bit of looking into, but I'm pretty sure
that like the construct() failure, it's due to the change in toString()
behaviour, and not any real bugs.

/Sven




Re: BigDecimal mauve regressions (FYI: patch)

2006-07-29 Thread Sven de Marothy
On Sat, 2006-07-29 at 16:54 +0200, Mark Wielaard wrote:

 Did you also happen to look at the DiagBigDecimal test? It passed with
 0.91, but current CVS (with or without you patch) gives the following
 failures:
..[snip list of 22 failures]..

Yes. I didn't investigate those further because the 1.5 JRE fails
the same set of tests (+4 more). The 1.4 JRE fails only 3 of them.

So these tests need a bit of looking into, but I'm pretty sure
that like the construct() failure, it's due to the change in toString()
behaviour, and not any real bugs.

/Sven




[cp-patches] BigDecimal mauve regressions (FYI: patch)

2006-07-28 Thread Sven de Marothy
I commited this:

2006-07-27  Sven de Marothy  

* java/math/BigDecimal.java
Adjust copyright date.
(divide(BigDecimal): Implement.
(precision): Reimplement.
(numDigitsInBigInteger, numDigitsInLong): Removed.
(toString): Get exponent from string length, 
fix negative values with exponential form.
(toEngineeringString): Same as for toString. 
(setScale): Throw ArithmeticException if scale  0.

This fixes all the BigDecimal regressions, with
the exception of one in BigDecimal.construct,
which isn't a regression, just that the string
representation returned from toString() changed
in this case from 1000 to 1E+3, which is also
what the 1.5 JRE returns (but not 1.4). Either
value is still allowed by the spec, so it's more
a case of a too rigid test.

We need a lot more tests for this, in particular for
the new 1.5 methods.

The setScale() regression may not be one, as the 1.5 JRE no longer
throws ArithmeticException with a negative scale here, despite
the 1.5 docs still saying that it does. (1.4 and earlier do
throw the exception). I'm thinking this is a Sun regression in
1.5. But if it's still around in 1.6. we should probably change.

/Sven

Index: java/math/BigDecimal.java
===
RCS file: /sources/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.23
diff -U3 -r1.23 BigDecimal.java
--- java/math/BigDecimal.java	7 Jun 2006 19:01:07 -	1.23
+++ java/math/BigDecimal.java	28 Jul 2006 08:28:35 -
@@ -1,5 +1,5 @@
 /* java.math.BigDecimal -- Arbitrary precision decimals.
-   Copyright (C) 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -266,8 +266,10 @@
 long mantissa = bits  mantMask;
 long exponent = (bits  mantissaBits)  expMask;
 boolean denormal = exponent == 0;
+
 // Correct the exponent for the bias.
 exponent -= denormal ? 1022 : 1023;
+
 // Now correct the exponent to account for the bits to the right
 // of the decimal.
 exponent -= mantissaBits;
@@ -748,6 +750,19 @@
   }
   
   /**
+   * Performs division, if the resulting quotient requires rounding
+   * (has a nonterminating decimal expansion), 
+   * an ArithmeticException is thrown. 
+   * #see divide(BigDecimal, int, int)
+   * @since 1.5
+   */
+  public BigDecimal divide(BigDecimal divisor)
+throws ArithmeticException, IllegalArgumentException 
+  {
+return divide(divisor, scale, ROUND_UNNECESSARY);
+  }
+
+  /**
* Returns a BigDecimal whose value is the remainder in the quotient
* this / val.  This is obtained by 
* subtract(divideToIntegralValue(val).multiply(val)).  
@@ -760,7 +775,7 @@
   {
 return subtract(divideToIntegralValue(val).multiply(val));
   }
-  
+
   /**
* Returns a BigDecimal array, the first element of which is the integer part
* of this / val, and the second element of which is the remainder of 
@@ -994,84 +1009,13 @@
   {
 if (precision == 0)
   {
-if (intVal.compareTo(BigInteger.TEN.pow(18)) == 1)
-  precision = numDigitsInBigInteger(intVal);
-else
-  precision = numDigitsInLong(intVal.longValue());
-  }
+	String s = intVal.toString();
+	precision = s.length() - (( s.charAt(0) == '-' ) ? 1 : 0);
+  }
 return precision;
   }
   
   /**
-   * This method is used to determine the precision of BigIntegers with 19 or
-   * more digits.
-   * @param b the BigInteger
-   * @return the number of digits in codeb/code
-   */
-  int numDigitsInBigInteger(BigInteger b)
-  {
-int i = 19;
-BigInteger comp = BigInteger.TEN.pow(i);
-while (b.compareTo(comp) = 0)  
-  comp = BigInteger.TEN.pow(++i);
-  
-return i;
-  }
-
-  /**
-   * This method determines the number of digits in the long value l. 
-   * @param l1 the long value
-   * @return the number of digits in l
-   */
-  private static int numDigitsInLong(long l1)
-  {
-long l = l1 = 0 ? l1 : -l1; 
-// We divide up the range in a binary fashion, this first if
-// takes care of numbers with 1 to 9 digits.
-if (l  10L)
-{
-  // This if is for numbers with 1 to 5 digits.
-  if (l  10L)
-{
-  if (l  100L)
-return (l  10L) ? 1 : 2;
-  if (l  1L)
-return (l  1000L) ? 3 : 4;
-  return 5;
-}
-  // Here we handle numbers with 6 to 9 digits.
-  if (l  1000L)
-return (l  100L) ? 6 : 7;
-  return (l  1L) ? 8 : 9;
-}
-// If we are at this point that means we didn't enter the loop for
-// numbers with 1 to 9 digits, so our number has 10 to 19 digits. 
-// This first if handles numbers with 10 to 14 digits.
-if (l  100L)
-  {
-// This handles numbers with 10 to 12 digits.
-if (l  1L)
-  {
-if (l

BigDecimal mauve regressions (FYI: patch)

2006-07-28 Thread Sven de Marothy
I commited this:

2006-07-27  Sven de Marothy  

* java/math/BigDecimal.java
Adjust copyright date.
(divide(BigDecimal): Implement.
(precision): Reimplement.
(numDigitsInBigInteger, numDigitsInLong): Removed.
(toString): Get exponent from string length, 
fix negative values with exponential form.
(toEngineeringString): Same as for toString. 
(setScale): Throw ArithmeticException if scale  0.

This fixes all the BigDecimal regressions, with
the exception of one in BigDecimal.construct,
which isn't a regression, just that the string
representation returned from toString() changed
in this case from 1000 to 1E+3, which is also
what the 1.5 JRE returns (but not 1.4). Either
value is still allowed by the spec, so it's more
a case of a too rigid test.

We need a lot more tests for this, in particular for
the new 1.5 methods.

The setScale() regression may not be one, as the 1.5 JRE no longer
throws ArithmeticException with a negative scale here, despite
the 1.5 docs still saying that it does. (1.4 and earlier do
throw the exception). I'm thinking this is a Sun regression in
1.5. But if it's still around in 1.6. we should probably change.

/Sven

Index: java/math/BigDecimal.java
===
RCS file: /sources/classpath/classpath/java/math/BigDecimal.java,v
retrieving revision 1.23
diff -U3 -r1.23 BigDecimal.java
--- java/math/BigDecimal.java	7 Jun 2006 19:01:07 -	1.23
+++ java/math/BigDecimal.java	28 Jul 2006 08:28:35 -
@@ -1,5 +1,5 @@
 /* java.math.BigDecimal -- Arbitrary precision decimals.
-   Copyright (C) 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -266,8 +266,10 @@
 long mantissa = bits  mantMask;
 long exponent = (bits  mantissaBits)  expMask;
 boolean denormal = exponent == 0;
+
 // Correct the exponent for the bias.
 exponent -= denormal ? 1022 : 1023;
+
 // Now correct the exponent to account for the bits to the right
 // of the decimal.
 exponent -= mantissaBits;
@@ -748,6 +750,19 @@
   }
   
   /**
+   * Performs division, if the resulting quotient requires rounding
+   * (has a nonterminating decimal expansion), 
+   * an ArithmeticException is thrown. 
+   * #see divide(BigDecimal, int, int)
+   * @since 1.5
+   */
+  public BigDecimal divide(BigDecimal divisor)
+throws ArithmeticException, IllegalArgumentException 
+  {
+return divide(divisor, scale, ROUND_UNNECESSARY);
+  }
+
+  /**
* Returns a BigDecimal whose value is the remainder in the quotient
* this / val.  This is obtained by 
* subtract(divideToIntegralValue(val).multiply(val)).  
@@ -760,7 +775,7 @@
   {
 return subtract(divideToIntegralValue(val).multiply(val));
   }
-  
+
   /**
* Returns a BigDecimal array, the first element of which is the integer part
* of this / val, and the second element of which is the remainder of 
@@ -994,84 +1009,13 @@
   {
 if (precision == 0)
   {
-if (intVal.compareTo(BigInteger.TEN.pow(18)) == 1)
-  precision = numDigitsInBigInteger(intVal);
-else
-  precision = numDigitsInLong(intVal.longValue());
-  }
+	String s = intVal.toString();
+	precision = s.length() - (( s.charAt(0) == '-' ) ? 1 : 0);
+  }
 return precision;
   }
   
   /**
-   * This method is used to determine the precision of BigIntegers with 19 or
-   * more digits.
-   * @param b the BigInteger
-   * @return the number of digits in codeb/code
-   */
-  int numDigitsInBigInteger(BigInteger b)
-  {
-int i = 19;
-BigInteger comp = BigInteger.TEN.pow(i);
-while (b.compareTo(comp) = 0)  
-  comp = BigInteger.TEN.pow(++i);
-  
-return i;
-  }
-
-  /**
-   * This method determines the number of digits in the long value l. 
-   * @param l1 the long value
-   * @return the number of digits in l
-   */
-  private static int numDigitsInLong(long l1)
-  {
-long l = l1 = 0 ? l1 : -l1; 
-// We divide up the range in a binary fashion, this first if
-// takes care of numbers with 1 to 9 digits.
-if (l  10L)
-{
-  // This if is for numbers with 1 to 5 digits.
-  if (l  10L)
-{
-  if (l  100L)
-return (l  10L) ? 1 : 2;
-  if (l  1L)
-return (l  1000L) ? 3 : 4;
-  return 5;
-}
-  // Here we handle numbers with 6 to 9 digits.
-  if (l  1000L)
-return (l  100L) ? 6 : 7;
-  return (l  1L) ? 8 : 9;
-}
-// If we are at this point that means we didn't enter the loop for
-// numbers with 1 to 9 digits, so our number has 10 to 19 digits. 
-// This first if handles numbers with 10 to 14 digits.
-if (l  100L)
-  {
-// This handles numbers with 10 to 12 digits.
-if (l  1L)
-  {
-if (l

RE: Testing JDK bugs?

2006-07-28 Thread Sven de Marothy
On Fri, 2006-07-28 at 09:56 +0200, Jeroen Frijters wrote:

 Even if something is Obviously Wrong, it may not be a good idea to fix
 it because it would be a breaking change. For example:
 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6227069
 

Obvious? Anyway, IMHO fixing something in a compatibility-breaking
way simply isn't a fix at all. It's the opposite. 

However, this goes in the opposite direction as well. And that's when
you really need to make a judgement call. I just did so in the
BigDecimal patch I just commited (which is why I was rude enough to
cross-post it to the main list).

Which is that setScale(scale, rounding) should throw an
ArithmeticException if scale  0. The spec says so, and the JRE
does so prior to v1.5. In 1.5 it does not (with no change to the doc).

So without thinking too hard I figured it was a 1.5 regression and 
put the exception back in (fixing a mauve regression on our part).
After all, this could break compatibility, in theory.

Although now I'm not quite so sure, because the probable cause
of this is that the divide(BigDecimal, scale, rounding) method
which we (and Sun, presumably) implement this on, shows the same
behaviour, only the docs have changed. 

/Sven




[commit-cp] classpath ChangeLog java/math/BigDecimal.java

2006-07-28 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/28 08:37:28

Modified files:
.  : ChangeLog 
java/math  : BigDecimal.java 

Log message:
2006-07-27  Sven de Marothy  [EMAIL PROTECTED]

* java/math/BigDecimal.java
Adjust copyright date.
(divide(BigDecimal): Implement.
(precision): Reimplement.
(numDigitsInBigInteger, numDigitsInLong): Removed.
(toString): Get exponent from string length, 
fix negative values with exponential form.
(toEngineeringString): Same as for toString.
(setScale): Throw ArithmeticException if scale  0.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8251r2=1.8252
http://cvs.savannah.gnu.org/viewcvs/classpath/java/math/BigDecimal.java?cvsroot=classpathr1=1.23r2=1.24




Java2D vs. Cairo stroking shootout

2006-07-27 Thread Sven de Marothy
Hi, 
with all the talk of AWT performance and some talk about caching
stroking, I did some benchmarking. (Attached)

Basically, we suck :) All tests run on FC5 on an x86.
Java 1.5.0: 0.47 seconds
Java 1.4.2: 0.40 seconds (consistently faster!)

JamVM/Classpath/Cairo 1.0.4: 7.9 seconds (ugh)

Now, having implemented all the speedup ideas I have for this,
(caching of path objects), the speedup was negligible[1].

The reason is simple, measuring the time spent in cairo_stroke() only,
(benchmark not included, this was hacked into the C code of our
 CairoGraphics2D), we find that way over 95%, of the time here is spent
in cairo_stroke(). And since cairo_fill() doesn't work significantly
faster, my conclusion is that there's no workaround for a slow Cairo and
there's no point in us trying to speed this up much more at the moment.

Some results:
Drawing to a Cairo surface (instead of an xlib one) was 
somewhat faster, around 5.8 seconds. Still very slow.

Cairo 1.2 seemed a tad faster for cairo surface, about 5.7 s,
for xlib surfaces there was no significant difference.

[1] The things I tried were: 
* Caching PathIterator objects in the Shape (the benchmark uses
GeneralPath, which does not cache its PIs in the current
version). 
* Caching the cairo_path_t:s of various object, avoiding iterating over
the path and calling into cairo every time.
* Stroking the path ourselves with BasicStroke and and using
cairo_fill() instead. 
* Caching the above.

Again, none of this yields any significant speedups.

So basically, let's go bug the Cairo guys. :)
Supposedly they're going to work on making stuff faster now, so
it'll be interesting to revisit these results later.

/Sven

import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.geom.GeneralPath;
import java.util.Random;

public class StrokeBench extends Frame
{
  private static final int NPATHS = 500;
  private static final int MAXSEGMENTS = 30;
  private static final long SEED = 1294;
  private static final int WINSIZE = 500;

  private static final int NITERATIONS = 10;

  private GeneralPath[] paths;
  private long totalTime;
  private double iterations;
  private Random r;

  private StrokeBench()
  {
super(Stroke benchmark);
r = new Random(SEED);
generatePaths();
// Random ID # to confirm we've used the same numbers.
System.out.println(ID: +r.nextInt()); 
setSize(WINSIZE, WINSIZE);
totalTime = 0;
setVisible(true);
  }

  private void generatePaths()
  {
paths = new GeneralPath[ NPATHS ];
for(int i = 0; i  NPATHS; i++ )
  {
	paths[i] = new GeneralPath();
	int nSegs = r.nextInt(MAXSEGMENTS);
	paths[i].moveTo((float)(r.nextFloat() * WINSIZE),
			(float)(r.nextFloat() * WINSIZE));
	for(int j = 0; j  nSegs; j++ )
	  addRandomSegment( paths[i] );
	if( r.nextBoolean() ) 
	  paths[i].closePath();
  }
  }

  private void addRandomSegment( GeneralPath path )
  {
int type = r.nextInt(3);

switch(type)
  {
  case 0:
	path.lineTo((float)(r.nextFloat() * WINSIZE),
		(float)(r.nextFloat() * WINSIZE));
	break;
  case 1:
	path.quadTo((float)(r.nextFloat() * WINSIZE),
		(float)(r.nextFloat() * WINSIZE),
		(float)(r.nextFloat() * WINSIZE),
		(float)(r.nextFloat() * WINSIZE));
	break;
  case 2:
	path.curveTo((float)(r.nextFloat() * WINSIZE),
		 (float)(r.nextFloat() * WINSIZE),
		 (float)(r.nextFloat() * WINSIZE),
		 (float)(r.nextFloat() * WINSIZE),
		 (float)(r.nextFloat() * WINSIZE),
		 (float)(r.nextFloat() * WINSIZE));
	break;
  }
  }

  public void paint(Graphics gr)
  {
Graphics2D g = (Graphics2D)gr;
g.setColor(Color.white);
g.fillRect(0, 0, WINSIZE, WINSIZE);
g.setColor(Color.black);
long start = System.currentTimeMillis(); 
for( int i = 0; i  NPATHS; i++ )
  g.draw( paths[ i ] );
long time = System.currentTimeMillis() - start;
totalTime += time;
iterations += 1.0;
System.out.println(Time: +time+ ms\tTotal time: 
		   +totalTime+ ms\t Average: +
		   (((double)totalTime)/(1000*iterations))+ s);
if( iterations  NITERATIONS )
  System.exit(0);
repaint(); // Keep triggering repaints, quite nasty :)
  }

  public static void main(String[] args) 
  {
new StrokeBench();
  }
}


Re: OpenTasks?

2006-07-27 Thread Sven de Marothy
On Thu, 2006-07-27 at 16:01 +0530, Hari Shreedharan wrote:
 hi,
 
 I had mailed couple of weeks back on opentasks pending on GNU
 Classpath.Kindly tell me what are all the open tasks except for Swing,
 especially if any in networking and RMI.
 

Right here is one:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27383

We need an implementation of what Sun names rmiURLContextFactory,
which I belive (this isn't quite my area) is an InitialContextFactory
for RMI. The JDK includes such a provider, we don't. So we need one.

(For an example of such a provider, only for HTTP instead of RMI, you
can see, for example:)
http://docs.jboss.org/jbossas/javadoc/4.0.2/org/jboss/naming/HttpNamingContextFactory.java.html

/Sven






[cp-patches] FYI: Fix nanotime

2006-07-26 Thread Sven de Marothy
Fixes nanotime and also implements currentTimeMillis on top of it 
instead of vice-versa. The ref impl therefore now returns with
microsecond precision.

2006-07-26  Sven de Marothy  [EMAIL PROTECTED]

* include/java_lang_VMSystem.h
* vm/reference/java/lang/VMSystem.java
* native/jni/java-lang/java_lang_VMSystem.c
(nanoTime, currentTimeMillis): Switch the former to native code and
the latter to java.


Index: include/java_lang_VMSystem.h
===
RCS file: /sources/classpath/classpath/include/java_lang_VMSystem.h,v
retrieving revision 1.8
diff -U3 -r1.8 java_lang_VMSystem.h
--- include/java_lang_VMSystem.h	3 May 2006 20:22:55 -	1.8
+++ include/java_lang_VMSystem.h	26 Jul 2006 19:36:33 -
@@ -15,7 +15,7 @@
 JNIEXPORT void JNICALL Java_java_lang_VMSystem_setIn (JNIEnv *env, jclass, jobject);
 JNIEXPORT void JNICALL Java_java_lang_VMSystem_setOut (JNIEnv *env, jclass, jobject);
 JNIEXPORT void JNICALL Java_java_lang_VMSystem_setErr (JNIEnv *env, jclass, jobject);
-JNIEXPORT jlong JNICALL Java_java_lang_VMSystem_currentTimeMillis (JNIEnv *env, jclass);
+JNIEXPORT jlong JNICALL Java_java_lang_VMSystem_nanoTime (JNIEnv *env, jclass);
 JNIEXPORT jobject JNICALL Java_java_lang_VMSystem_environ (JNIEnv *env, jclass);
 JNIEXPORT jstring JNICALL Java_java_lang_VMSystem_getenv (JNIEnv *env, jclass, jstring);
 
Index: native/jni/java-lang/java_lang_VMSystem.c
===
RCS file: /sources/classpath/classpath/native/jni/java-lang/java_lang_VMSystem.c,v
retrieving revision 1.14
diff -U3 -r1.14 java_lang_VMSystem.c
--- native/jni/java-lang/java_lang_VMSystem.c	22 Apr 2006 21:52:18 -	1.14
+++ native/jni/java-lang/java_lang_VMSystem.c	26 Jul 2006 19:36:34 -
@@ -113,11 +113,11 @@
 
 /*
  * Class: java_lang_VMSystem
- * Method:currentTimeMillis
+ * Method:nanoTime
  * Signature: ()J
  */
 JNIEXPORT jlong JNICALL
-Java_java_lang_VMSystem_currentTimeMillis
+Java_java_lang_VMSystem_nanoTime
   (JNIEnv * env __attribute__ ((__unused__)),
jclass thisClass __attribute__ ((__unused__)))
 {
@@ -129,8 +129,9 @@
 (*env)-FatalError (env, gettimeofday call failed.);
 
   result = (jlong) tp.tv_sec;
-  result *= 1000;
-  result += (tp.tv_usec / 1000);
+  result *= (jlong)100L;
+  result += (jlong)tp.tv_usec;
+  result *= (jlong)1000;
 
   return result;
 }
Index: vm/reference/java/lang/VMSystem.java
===
RCS file: /sources/classpath/classpath/vm/reference/java/lang/VMSystem.java,v
retrieving revision 1.16
diff -U3 -r1.16 VMSystem.java
--- vm/reference/java/lang/VMSystem.java	22 Apr 2006 21:52:18 -	1.16
+++ vm/reference/java/lang/VMSystem.java	26 Jul 2006 19:36:35 -
@@ -135,7 +135,10 @@
* @return the current time
* @see java.util.Date
*/
-   public static native long currentTimeMillis();
+   public static long currentTimeMillis()
+   {
+ return nanoTime() / 100L;
+   }
 
   /**
* p
@@ -162,10 +165,7 @@
* @return the time of a system timer in nanoseconds.
* @since 1.5 
*/
-   public static long nanoTime()
-   {
- return currentTimeMillis() * 1000;
-   }
+  public static native long nanoTime();
 
   /**
* Returns a list of 'name=value' pairs representing the current environment


[cp-patches] FYI: GeneralPath doc fix.

2006-07-26 Thread Sven de Marothy
2006-07-26  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/geom/GeneralPath.java: Fix severe typo.


Index: java/awt/geom/GeneralPath.java
===
RCS file: /sources/classpath/classpath/java/awt/geom/GeneralPath.java,v
retrieving revision 1.16
diff -U3 -r1.16 GeneralPath.java
--- java/awt/geom/GeneralPath.java	15 Jun 2006 18:18:51 -	1.16
+++ java/awt/geom/GeneralPath.java	26 Jul 2006 20:27:59 -
@@ -65,8 +65,8 @@
  * #x2019;up#x2019;
  * direction, one in the #x2019;down#x2019; direction) Point bB/b in 
  * the image is inside (one intersection #x2019;down#x2019;)
- * Point bC/b in the image is outside (two intersections 
- * #x2019;down#x2019;)
+ * Point bC/b in the image is inside (two intersections in the 
+ * #x2019;down#x2019; direction)
  *
  * @see Line2D
  * @see CubicCurve2D


[commit-cp] classpath ChangeLog java/awt/geom/GeneralPath.java

2006-07-26 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/26 20:32:06

Modified files:
.  : ChangeLog 
java/awt/geom  : GeneralPath.java 

Log message:
2006-07-26  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/geom/GeneralPath.java: Fix severe typo.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8239r2=1.8240
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/geom/GeneralPath.java?cvsroot=classpathr1=1.16r2=1.17




[cp-patches] FYI: Minor Font, GtkVolatileImage stuff

2006-07-25 Thread Sven de Marothy
Just some random minor fixes from my tree.

2006-07-25  Sven de Marothy  [EMAIL PROTECTED]

* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
(init): Default to the actual depth in the worst case.

* java/awt/Font.java
(createFont(int, File)): New method.


Index: java/awt/Font.java
===
RCS file: /sources/classpath/classpath/java/awt/Font.java,v
retrieving revision 1.36
diff -U3 -r1.36 Font.java
--- java/awt/Font.java	16 Jun 2006 16:10:22 -	1.36
+++ java/awt/Font.java	25 Jul 2006 17:51:21 -
@@ -48,6 +48,8 @@
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.awt.peer.FontPeer;
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
@@ -583,6 +585,34 @@
   }
 
   /**
+   * Creates a new font from a File object.
+   *
+   * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int)
+   *
+   * @param fontFormat - Integer code indicating the format the font data is
+   * in.Currently this can only be [EMAIL PROTECTED] #TRUETYPE_FONT}.
+   * @param file - a [EMAIL PROTECTED] File} from which font data will be read.
+   *
+   * @return A new [EMAIL PROTECTED] Font} of the format indicated.
+   *
+   * @throws IllegalArgumentException if codefontType/code is not
+   * recognized.
+   * @throws NullPointerException if codefile/code is codenull/code.
+   * @throws FontFormatException if data in the file is invalid or cannot be read..
+   * @throws SecurityException if the caller has no read permission for the file.
+   * @throws IOException if the file cannot be read
+   *
+   * @since 1.5
+   */
+  public static Font createFont (int fontFormat, File file)
+throws FontFormatException, IOException
+  {
+if( file == null )
+  throw new NullPointerException(Null file argument);
+return tk().createFont(fontFormat, new FileInputStream( file ));
+  }
+
+  /**
* Maps characters to glyphs in a one-to-one relationship, returning a new
* [EMAIL PROTECTED] GlyphVector} with a mapped glyph for each input character. This
* sort of mapping is often sufficient for some scripts such as Roman, but
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
===
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c,v
retrieving revision 1.5
diff -U3 -r1.5 gnu_java_awt_peer_gtk_GtkVolatileImage.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c	10 Jun 2006 14:16:09 -	1.5
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c	25 Jul 2006 17:51:23 -
@@ -73,7 +73,8 @@
   pixmap = gdk_pixmap_new( widget-window, width, height, -1 );
 }
   else
-pixmap = gdk_pixmap_new( NULL, width, height, 16 );
+pixmap = gdk_pixmap_new( NULL, width, height, 
+			 gdk_rgb_get_visual()-depth );
 
   gdk_threads_leave();
 


[commit-cp] classpath ChangeLog java/awt/Font.java native/j...

2006-07-25 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/25 17:58:53

Modified files:
.  : ChangeLog 
java/awt   : Font.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GtkVolatileImage.c 

Log message:
2006-07-25  Sven de Marothy  [EMAIL PROTECTED]

* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c
(init): Default to the actual depth in the worst case.

* java/awt/Font.java
(createFont(int, File)): New method.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8208r2=1.8209
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Font.java?cvsroot=classpathr1=1.36r2=1.37
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkVolatileImage.c?cvsroot=classpathr1=1.5r2=1.6




Re: VM interface changes for splash-screen support

2006-07-24 Thread Sven de Marothy
Hey all (again).

Disregard this. I've made a lot of changes and I'll post an improved
version shortly (with working code).

/Sven

On Sun, 2006-07-23 at 19:23 +0200, Sven de Marothy wrote:
 Hey all,
 So it seems AWT in 1.6 will include support for splash-screens.
 This will require a little (optional) VM support, so here's a proposal
 and some prototype code for this I'd like feedback on.
 
 This is done by either:
 1) Giving the VM a command line option and filename (JPEG/GIF/PNG is
 supported)
 2) Including such an image in a JAR and using an option in the manifest.
 (In the case of both, the former has precedence.)
 
 The idea is that the splashscreen should be loaded and shown as quickly
 as possible. Once the first AWT window is opened by the app, the
 splashscreen is closed. But once user code is running the program can
 update the splashscreen prior to that, using a new SplashScreen class.
 
 * For VM implementors:
 Ok, so I've got a proposal for how to do this. For the VM part, 
 see splashscreen.h. There are two native functions to call:
  int cp_awt_splashscreen_load_file( char *filename );
  int cp_awt_splashscreen_load_data( char *url, char *imagedata );
 
 Corresponding to loading from the command line and from a jar,
 respectively. These methods should load the file, create a frameless
 window, display it, and return as fast as they can, using the
 native toolkit instead of java.
 
 Strictly speaking we only need one function, but since the 
 command-line option takes precedence we can use that to show
 the splash earlier. On failure, the VM can display a message
 or silently ignore it. 
 
 * For peer implementors:
 A new ClasspathToolkit method:
 public abstract SplashWindow getSplashWindow();
 
 The public SplashScreen class is implemented on top
 of our SplashWindow class. This is more or less an ordinary
 Window. But more on this later, first the native side of things:
 
 The native methods above set a global variable (cp_splashscreen) which
 is a struct splashscreenhandle
 {
   void *nativeWindowHandle;
   void *nativeImageHandle;
 }
 If set (the variable is null if no splashscreen is available
 or if loading failed), the structure should be populated with
 platform-specific values for the window handle and image data.
 On X/GTK/Qt, this should be understood to mean XIDs for the
 window and a pixmap, respectively. NOT a toolkit-specific
 structure (See below). On Windows (athough we don't have peers 
 for that yet) it'd be a HWND and HBITMAP, and so on.
 
 The reason why we want to use X structures here is this:
 We cannot know from the start which set of peers the user
 is using, and therefore we don't know which peers will want
 to create the SplashWindow instance. 
 
 The idea here is that the native splashscreen code should be compiled 
 to use the default toolkit (or none). If the user has chosen a
 different toolkit at runtime, the thing should still work.
 
 Q and A..
 
 Q: What does the peer need to do, then? 
 A: Implement getSplashWindow. What this should do, is retrive
 the cp_splashscreen structure and use the X handles to wrap it 
 in the native toolit (e.g. gdk_window_foreign_new on GTK). This 
 object should then be wrapped with a WindowPeer from which a
 SplashWindow implementation can be created. (This is a lot less
 code than it sounds like)
 
 Q: What does the VM need to do, then?
 A: Nothing. But if it wants splashscreens it should. Call
 cp_awt_splashscreen_load_file or cp_awt_splashscreen_load_data,
 and do so as soon as it can (after parsing the command line and reading
 the jar manifest, respectively).
 
 Q: Native toolkit?! But what about JNode/IKVM/Other pure-java peers?
 A: In those cases the VM is already loaded, or will need to be. In which
 case displaying a splash-screen during VM loading is rather pointless.
 However, a pure-java implementation which the VM can show at some point
 of its choice is simple to do, and should be done.
 
 /Sven




VM interface changes for splash-screen support

2006-07-23 Thread Sven de Marothy
Hey all,
So it seems AWT in 1.6 will include support for splash-screens.
This will require a little (optional) VM support, so here's a proposal
and some prototype code for this I'd like feedback on.

This is done by either:
1) Giving the VM a command line option and filename (JPEG/GIF/PNG is
supported)
2) Including such an image in a JAR and using an option in the manifest.
(In the case of both, the former has precedence.)

The idea is that the splashscreen should be loaded and shown as quickly
as possible. Once the first AWT window is opened by the app, the
splashscreen is closed. But once user code is running the program can
update the splashscreen prior to that, using a new SplashScreen class.

* For VM implementors:
Ok, so I've got a proposal for how to do this. For the VM part, 
see splashscreen.h. There are two native functions to call:
 int cp_awt_splashscreen_load_file( char *filename );
 int cp_awt_splashscreen_load_data( char *url, char *imagedata );

Corresponding to loading from the command line and from a jar,
respectively. These methods should load the file, create a frameless
window, display it, and return as fast as they can, using the
native toolkit instead of java.

Strictly speaking we only need one function, but since the 
command-line option takes precedence we can use that to show
the splash earlier. On failure, the VM can display a message
or silently ignore it. 

* For peer implementors:
A new ClasspathToolkit method:
public abstract SplashWindow getSplashWindow();

The public SplashScreen class is implemented on top
of our SplashWindow class. This is more or less an ordinary
Window. But more on this later, first the native side of things:

The native methods above set a global variable (cp_splashscreen) which
is a struct splashscreenhandle
{
  void *nativeWindowHandle;
  void *nativeImageHandle;
}
If set (the variable is null if no splashscreen is available
or if loading failed), the structure should be populated with
platform-specific values for the window handle and image data.
On X/GTK/Qt, this should be understood to mean XIDs for the
window and a pixmap, respectively. NOT a toolkit-specific
structure (See below). On Windows (athough we don't have peers 
for that yet) it'd be a HWND and HBITMAP, and so on.

The reason why we want to use X structures here is this:
We cannot know from the start which set of peers the user
is using, and therefore we don't know which peers will want
to create the SplashWindow instance. 

The idea here is that the native splashscreen code should be compiled 
to use the default toolkit (or none). If the user has chosen a
different toolkit at runtime, the thing should still work.

Q and A..

Q: What does the peer need to do, then? 
A: Implement getSplashWindow. What this should do, is retrive
the cp_splashscreen structure and use the X handles to wrap it 
in the native toolit (e.g. gdk_window_foreign_new on GTK). This 
object should then be wrapped with a WindowPeer from which a
SplashWindow implementation can be created. (This is a lot less
code than it sounds like)

Q: What does the VM need to do, then?
A: Nothing. But if it wants splashscreens it should. Call
cp_awt_splashscreen_load_file or cp_awt_splashscreen_load_data,
and do so as soon as it can (after parsing the command line and reading
the jar manifest, respectively).

Q: Native toolkit?! But what about JNode/IKVM/Other pure-java peers?
A: In those cases the VM is already loaded, or will need to be. In which
case displaying a splash-screen during VM loading is rather pointless.
However, a pure-java implementation which the VM can show at some point
of its choice is simple to do, and should be done.

/Sven

/ PROTOTYPE CODE ***/

/* SplashScreen.java -- 
   Copyright (C) 2006 Free Software Foundation

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the 

Re: [cp-patches] RFC: java.awt.color.ICC_Profile missing constants added

2006-07-20 Thread Sven de Marothy
On Wed, 2006-07-19 at 19:38 +0200, Carsten Neumann wrote:
   Hi,
 
 this adds the missing fields pointed out by JAPI (classpath vs. jdk-1.5).
 
 Please comment/commit.
 

Yeah, please don't. :) These new fields are for ICC v4.0.0 profiles,
which our CMS doesn't support yet, so adding them wouldn't actually
update the class to 1.5. However, (somewhat coincidentally) I just got
started working on the ICC v4 support. So it'll be fixed soon enough.

/Sven




Re: [cp-patches] FYI: Inet6Address updated to 1.5

2006-07-19 Thread Sven de Marothy
On Tue, 2006-07-18 at 09:53 -0600, Tom Tromey wrote:
  Sven == Sven de Marothy [EMAIL PROTECTED] writes:
 
 Sven + * @status Updated to 1.5. Serialization compatibility is tested.
 
 According to JAPI it looks as though we're still missing a couple
 methods: getScopeId and getScopedInterface.

Ah right. :) I'd implemented this and accidentally deleted it and had to
do it all again. I must've forgotten them the second time around. 

No problem, it's a trivial fix.

/Sven




Re: [cp-patches] FYI: Inet6Address updated to 1.5 (patch)

2006-07-19 Thread Sven de Marothy
Here are the two remaining methods.

2006-07-19  Sven de Marothy  [EMAIL PROTECTED]

* java/net/Inet6Address.java:
(getScopedId, getScopedInterface): New methods.

On Wed, 2006-07-19 at 15:40 +0200, Sven de Marothy wrote:
 On Tue, 2006-07-18 at 09:53 -0600, Tom Tromey wrote:
   Sven == Sven de Marothy [EMAIL PROTECTED] writes:
  
  Sven + * @status Updated to 1.5. Serialization compatibility is tested.
  
  According to JAPI it looks as though we're still missing a couple
  methods: getScopeId and getScopedInterface.
 
 Ah right. :) I'd implemented this and accidentally deleted it and had to
 do it all again. I must've forgotten them the second time around. 
 
 No problem, it's a trivial fix.
 
 /Sven
 
 
-- 
Sven de Marothy [EMAIL PROTECTED]
Index: java/net/Inet6Address.java
===
RCS file: /sources/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.12
diff -U3 -r1.12 Inet6Address.java
--- java/net/Inet6Address.java	18 Jul 2006 02:58:14 -	1.12
+++ java/net/Inet6Address.java	19 Jul 2006 16:19:44 -
@@ -242,6 +242,7 @@
* Creates a scoped Inet6Address where the scope has an integer id.
*
* @throws UnkownHostException if the address is an invalid number of bytes.
+   * @since 1.5
*/  
   public static Inet6Address getByAddress(String host, byte[] addr, 
 	  int scopeId)
@@ -261,6 +262,7 @@
* NetworkInterface.
*
* @throws UnkownHostException if the address is an invalid number of bytes.
+   * @since 1.5
*/  
   public static Inet6Address getByAddress(String host, byte[] addr, 
 	  NetworkInterface nif)
@@ -276,6 +278,36 @@
   }
 
   /**
+   * Returns the codeNetworkInterface/code of the address scope
+   * if it is a scoped address and the scope is given in the form of a
+   * NetworkInterface. 
+   * (I.e. the address was created using  the 
+   * getByAddress(String, byte[], NetworkInterface) method)
+   * Otherwise this method returns codenull/code.
+   * @since 1.5
+   */
+  public NetworkInterface getScopedInterface()
+  {
+return nif;
+  }
+
+  /**
+   * Returns the scope ID of the address scope if it is a scoped adress using
+   * an integer to identify the scope.
+   *
+   * Otherwise this method returns 0.
+   * @since 1.5
+   */
+  public int getScopeId()
+  {
+// check scope_id_set because some JDK-serialized objects seem to have
+// scope_id set to a nonzero value even when scope_id_set == false
+if( scope_id_set )
+  return scope_id; 
+return 0;
+  }
+
+  /**
* Returns the IP address string in textual presentation
*/
   public String getHostAddress()


[commit-cp] classpath ChangeLog java/net/Inet6Address.java

2006-07-19 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/19 16:21:20

Modified files:
.  : ChangeLog 
java/net   : Inet6Address.java 

Log message:
2006-07-19  Sven de Marothy  [EMAIL PROTECTED]

* java/net/Inet6Address.java:
(getScopedId, getScopedInterface): New methods.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8164r2=1.8165
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet6Address.java?cvsroot=classpathr1=1.12r2=1.13




[commit-cp] classpath/gnu/javax/imageio/png

2006-07-19 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/19 16:48:23

New directory:
gnu/javax/imageio/png

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/?cvsroot=classpath




[commit-cp] classpath ChangeLog gnu/javax/imageio/png/PNGCh...

2006-07-19 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/19 16:49:18

Modified files:
.  : ChangeLog 
Added files:
gnu/javax/imageio/png: PNGChunk.java PNGData.java 
   PNGDecoder.java PNGEncoder.java 
   PNGException.java PNGFile.java 
   PNGFilter.java PNGGamma.java 
   PNGHeader.java PNGICCProfile.java 
   PNGPalette.java PNGPhys.java PNGTime.java 

Log message:
2006-07-19  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/imageio/png/PNGChunk.java,
* gnu/javax/imageio/png/PNGData.java,
* gnu/javax/imageio/png/PNGDecoder.java,
* gnu/javax/imageio/png/PNGEncoder.java,
* gnu/javax/imageio/png/PNGException.java,
* gnu/javax/imageio/png/PNGFile.java,
* gnu/javax/imageio/png/PNGFilter.java,
* gnu/javax/imageio/png/PNGGamma.java,
* gnu/javax/imageio/png/PNGHeader.java,
* gnu/javax/imageio/png/PNGICCProfile.java,
* gnu/javax/imageio/png/PNGPalette.java,
* gnu/javax/imageio/png/PNGPhys.java,
* gnu/javax/imageio/png/PNGTime.java:
New files.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8165r2=1.8166
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGChunk.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGData.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGDecoder.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGEncoder.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGException.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGFile.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGFilter.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGGamma.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGHeader.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGICCProfile.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGPalette.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGPhys.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/png/PNGTime.java?cvsroot=classpathrev=1.1




Re: Hello:Interested in classpath

2006-07-18 Thread Sven de Marothy
On Tue, 2006-07-18 at 15:24 +0100, Robert Lougher wrote:
 Hi David,
 
 Let me know if you any questions regarding the packaging of JamVM.
 I'll be pleased to help as this is something that's needed doing for a
 while...
 

Could you put more of those styrofoam peanuts in the box?

M... peanuts...

/Sven





Re: [cp-patches] FYI: Using the custom DTD for the Swing HTML parser.

2006-07-17 Thread Sven de Marothy
This patch breaks the build. For me, at least. I tried from a fresh tree
and that didn't work. It did compile minus this patch.

/Sven

On Sun, 2006-07-16 at 16:54 +0200, Audrius Meskauskas wrote:
 Fixing the 28392, I have concluded that HTMLEditorKit is getting more 
 and more unnecessarily complicated functionality, and that the 
 suggestions of Roman and others (discussed in Brussels) to have the 
 custom DTD model for our Swing are probably correct. This patch 
 introduces the HTML_401Swing.java which is derived from HTML_401F.java 
 and allows us to define additional rules exclusively for the parser of 
 the HTMLDocument. It will not affect any applications that use the 
 parser directly, creating the instance of the ParserDelegator.
 
 The custom DTD model generates the implied P tags for the top level 
 document body text that is not in a paragraph. It also generates P tags 
 for the top level tags like I, B, U, A, FONT and so on, because, if not 
 wrapped into paragraph at the top body level, they cause the same 
 problems. The tags are not generated when they are not necessary and are 
 closed where they end is supposed from the context. The DTD model can be 
 extended to work about more our HTML rendering problems.
 
 The implied paragraph handling in HTMLDocument is no longer needed as is 
 removed.
 
 2006-07-16  Audrius Meskauskas  [EMAIL PROTECTED]
 
   PR 28392
 * examples/gnu/classpath/examples/swing/HtmlDemo.java:
 Removed heading p tag from the parsing example.
 * gnu/javax/swing/text/html/parser/HTML_401F.java:
 (createHtmlContentModel): Explained.
 (defineElements): Call getBodyElements to get the body
 elements. (getBodyElements): New method. (model):
 Made protected from private.
 * gnu/javax/swing/text/html/parser/htmlValidator.java
 (openTag): Mind that current content model may be null.
 (tagIsValidForContext): If the tag is PCDATA, and it is not
 valid for context, but the paragraph (P) is valid for context,
 suggest to insert the P tag here.
 * javax/swing/text/html/HTMLDocument.java (HTMLReader.addContent,
 HTMLReader.blockOpen, HTMLReader.blockClose): Do not handle
 implied P tags here.
 * javax/swing/text/html/HTMLEditorKit.java (getParser):
 Get the custom parser, using  DTD.
 * javax/swing/text/html/parser/ParserDelegator.java:
 Removed the obsolete note that HTMLEditorKit does not exist.
 * gnu/javax/swing/text/html/parser/GnuParserDelegator.java,
 gnu/javax/swing/text/html/parser/HTML_401Swing.java: New files.
-- 
Sven de Marothy [EMAIL PROTECTED]




Re: [cp-patches] FYI: Using the custom DTD for the Swing HTML parser.

2006-07-17 Thread Sven de Marothy
Oh I forgot, this is with the options I usually use:
--with-jikes --disable-plugin 

/Sven

On Mon, 2006-07-17 at 12:59 +0200, Sven de Marothy wrote:
 This patch breaks the build. For me, at least. I tried from a fresh tree
 and that didn't work. It did compile minus this patch.
 
 /Sven





[cp-patches] FYI: Inet6Address updated to 1.5

2006-07-17 Thread Sven de Marothy

2006-07-18  Sven de Marothy  [EMAIL PROTECTED]

* java/net/Inet6Address.java:
Add 1.5 serialized fields.
(getByAddress): New methods.
(readObject, writeObject): New methods. 
(equals): Reimplement.


Index: java/net/Inet6Address.java
===
RCS file: /sources/classpath/classpath/java/net/Inet6Address.java,v
retrieving revision 1.11
diff -U3 -r1.11 Inet6Address.java
--- java/net/Inet6Address.java	2 Jul 2005 20:32:39 -	1.11
+++ java/net/Inet6Address.java	18 Jul 2006 02:55:16 -
@@ -39,13 +39,16 @@
 package java.net;
 
 import java.util.Arrays;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
 
 /*
  * Written using on-line Java Platform 1.4 API Specification and
  * RFC 1884 (http://www.ietf.org/rfc/rfc1884.txt)
  * 
  * @author Michael Koch
- * @status Believed complete and correct.
+ * @status Updated to 1.5. Serialization compatibility is tested.
  */
 public final class Inet6Address extends InetAddress
 {
@@ -57,6 +60,39 @@
   byte[] ipaddress;
 
   /**
+   * The scope ID, if any. 
+   * @since 1.5
+   * @serial 
+   */
+  private int scope_id;
+
+  /**
+   * The scope ID, if any. 
+   * @since 1.5
+   * @serial 
+   */
+  private boolean scope_id_set;
+
+  /**
+   * Whether ifname is set or not.
+   * @since 1.5
+   * @serial 
+   */
+  private boolean scope_ifname_set;
+
+  /**
+   * Name of the network interface, used only by the serialization methods
+   * @since 1.5
+   * @serial 
+   */
+  private String ifname;
+
+  /**
+   * Scope network interface, or codenull/code.
+   */
+  private transient NetworkInterface nif; 
+
+  /**
* Create an Inet6Address object
*
* @param addr The IP address
@@ -67,6 +103,10 @@
 super(addr, host);
 // Super constructor clones the addr.  Get a reference to the clone.
 this.ipaddress = this.addr;
+ifname = null;
+scope_ifname_set = scope_id_set = false;
+scope_id = 0;
+nif = null;
   }
 
   /**
@@ -199,6 +239,43 @@
   }
 
   /**
+   * Creates a scoped Inet6Address where the scope has an integer id.
+   *
+   * @throws UnkownHostException if the address is an invalid number of bytes.
+   */  
+  public static Inet6Address getByAddress(String host, byte[] addr, 
+	  int scopeId)
+throws UnknownHostException
+  {
+if( addr.length != 16 )
+  throw new UnknownHostException(Illegal address length:  + addr.length
+ +  bytes.);
+Inet6Address ip = new Inet6Address( addr, host );
+ip.scope_id = scopeId;
+ip.scope_id_set = true;
+return ip;
+  }
+
+  /**
+   * Creates a scoped Inet6Address where the scope is a given
+   * NetworkInterface.
+   *
+   * @throws UnkownHostException if the address is an invalid number of bytes.
+   */  
+  public static Inet6Address getByAddress(String host, byte[] addr, 
+	  NetworkInterface nif)
+throws UnknownHostException
+  {
+if( addr.length != 16 )
+  throw new UnknownHostException(Illegal address length:  + addr.length
+ +  bytes.);
+Inet6Address ip = new Inet6Address( addr, host );
+ip.nif = nif;
+
+return ip;
+  }
+
+  /**
* Returns the IP address string in textual presentation
*/
   public String getHostAddress()
@@ -214,12 +291,17 @@
 
 	sbuf.append(Integer.toHexString(x));
   }
+if( nif != null )
+  sbuf.append( % + nif.getName() );
+else if( scope_id_set )
+  sbuf.append( % + scope_id );
 
 return sbuf.toString();
   }
 
   /**
* Returns a hashcode for this IP address
+   * (The hashcode is independent of scope)
*/
   public int hashCode()
   {
@@ -234,10 +316,23 @@
 if (! (obj instanceof Inet6Address))
   return false;
 
-// this.ipaddress is never set in this class except to
-// the value of the super class' addr.  The super classes
-// equals(Object) will do the compare.
-return super.equals(obj);
+Inet6Address ip = (Inet6Address)obj;
+if (ipaddress.length != ip.ipaddress.length)
+  return false;
+
+for (int i = 0; i  ip.ipaddress.length; i++)
+  if (ipaddress[i] != ip.ipaddress[i])
+	return false;
+
+if( ip.nif != null  nif != null )
+  return nif.equals( ip.nif );
+if( ip.nif != nif )
+  return false;
+if( ip.scope_id_set != scope_id_set )
+  return false;
+if( scope_id_set )
+  return (scope_id == ip.scope_id);
+return true;
   }
 
   /**
@@ -258,4 +353,38 @@
 
 return true;
   }
+
+  /**
+   * Required for 1.5-compatible serialization.
+   * @since 1.5
+   */
+  private void readObject(ObjectInputStream s)
+throws IOException, ClassNotFoundException
+  {  
+s.defaultReadObject();
+try
+  {
+	if( scope_ifname_set )
+	  nif = NetworkInterface.getByName( ifname );
+  }
+catch( SocketException se )
+  {
+	// FIXME: Ignore this? or throw an IOException?
+  }
+  }
+
+  /**
+   * Required for 1.5-compatible

[commit-cp] classpath ChangeLog java/net/Inet6Address.java

2006-07-17 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/18 02:58:14

Modified files:
.  : ChangeLog 
java/net   : Inet6Address.java 

Log message:
2006-07-18  Sven de Marothy  [EMAIL PROTECTED]

* java/net/Inet6Address.java:
Add 1.5 serialized fields.
(getByAddress): New methods.
(readObject, writeObject): New methods. 
(equals): Reimplement.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8149r2=1.8150
http://cvs.savannah.gnu.org/viewcvs/classpath/java/net/Inet6Address.java?cvsroot=classpathr1=1.11r2=1.12




[commit-cp] classpath/javax/rmi/ssl

2006-07-16 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/16 08:07:14

New directory:
javax/rmi/ssl

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/rmi/ssl/?cvsroot=classpath




Re: [cp-patches] FYI: Some AWT 1.5 stuff

2006-07-15 Thread Sven de Marothy
Whoops, forgot to attach the new files. Here they are.

On Sat, 2006-07-15 at 09:56 +0200, Sven de Marothy wrote:
 This implements some of the new 1.5 stuff for AWT.
 - changes to Image (accelerationPriority)
 - always-on-top Window (and GTK peer support)
 - MouseInfo and PointerInfo classes and the necessary
 peers and Toolkit changes.
 - GTK implementation of MouseInfoPeer.
 
 (Note that the getMouseInfoPeer method is not abstract
 in Toolkit and is allowed to throw UnsupportedOpException,
 so I made that the default. Toolkit implementations should
 obviously overload this if possible. That means you, Roman ;))
 
 /Sven
 
 2006-07-15  Sven de Marothy  [EMAIL PROTECTED]
 
   * gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java,
   * java/awt/MouseInfo.java,
   * java/awt/PointerInfo.java,
   * java/awt/peer/MouseInfoPeer.java:
   New files.
 
   * java/awt/Image.java
   (accelerationPriority): New field.
   (setAccelerationPriority, getAccelerationPriority): New methods..
 
   * include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,
   * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c,
   * gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java:
   (getMouseCoordinates): New method.
 
   * gnu/java/awt/peer/gtk/GtkFramePeer.java
   (updateAlwaysOnTop): Remove stub overload.
 
   * gnu/java/awt/ClasspathToolkit.java,
   * gnu/java/awt/peer/gtk/GtkToolkit.java,
   * include/gnu_java_awt_peer_gtk_GtkToolkit.h,
   * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c:
   (getMouseInfoPeer): New method.
   (getMouseNumberOfButtons): New method.
   
   * gnu/java/awt/peer/gtk/GtkWindowPeer.java
   * include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
   * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
   (gtkWindowSetAlwaysOnTop): New method.
   (updateAlwaysOnTop): Implement.
 
   * java/awt/Toolkit.java,
   (getMouseInfoPeer): New method.
 
   * java/awt/Window.java
   (alwaysOnTop): New field.
   (isAlwaysOnTop, setAlwaysOnTop): New methods.
 
   * java/awt/peer/WindowPeer.java: Doc fix.
 
 
-- 
Sven de Marothy [EMAIL PROTECTED]
/* GtkToolkit.java -- Implements an AWT Toolkit using GTK for peers
   Copyright (C) 2006
   Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package gnu.java.awt.peer.gtk;

import java.awt.Point;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.awt.peer.MouseInfoPeer;

/**
 * The MouseInfoPeer is so small, I'm including it here.
 */
public class GtkMouseInfoPeer implements MouseInfoPeer
{
  private static GdkGraphicsEnvironment gde = new GdkGraphicsEnvironment();
  
  public int fillPointWithCoords(Point p)
  {
int[] coords = gde.getMouseCoordinates();
  p.x = coords[1]; 
  p.y = coords[2];
  return coords[0];
  }
  
  public boolean isWindowUnderMouse(Window w)
  {
int[] coords = gde.getMouseCoordinates();
GraphicsDevice[] gds = gde.getScreenDevices();

// Check if the screen  of the Window and the cursor match
if( gds[ coords[0] ] != w.getGraphicsConfiguration().getDevice() )
  return false;

// Return the bounds-check.
Point p = w.getLocationOnScreen();
return (coords[1] = p.x  coords[1]  p.x + w.getWidth() 
	coords[2] = p.y

Re: [cp-patches] [RFA] JVMTI (ATTN:contains offer for free beer)

2006-07-15 Thread Sven de Marothy
On Sat, 2006-07-15 at 10:26 -0700, Keith Seitz wrote:
 With no further comments, I have committed this patch.
 
 Thank you for taking a look at it, Tom!
 
 Keith

Yay! Great job Keith!

First VM to implement JVMTI now gets a beer from me!

/Sven




[commit-cp] classpath ChangeLog java/util/UUID.java

2006-07-15 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/16 04:23:37

Modified files:
.  : ChangeLog 
Added files:
java/util  : UUID.java 

Log message:
2006-07-16  Sven de Marothy  [EMAIL PROTECTED]

* java/util/UUID.java: New file.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8125r2=1.8126
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/UUID.java?cvsroot=classpathrev=1.1




[cp-patches] FYI: Databuffer fixlet

2006-07-14 Thread Sven de Marothy
2006-07-14  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/image/DataBuffer.java
(DataBuffer): Call constructors in the correct order,


Index: java/awt/image/DataBuffer.java
===
RCS file: /sources/classpath/classpath/java/awt/image/DataBuffer.java,v
retrieving revision 1.6
diff -U3 -r1.6 DataBuffer.java
--- java/awt/image/DataBuffer.java	2 Jul 2005 20:32:30 -	1.6
+++ java/awt/image/DataBuffer.java	14 Jul 2006 22:40:23 -
@@ -114,8 +114,7 @@
*/
   protected DataBuffer(int dataType, int size)
   {
-this.dataType = dataType;
-this.size = size;
+this(dataType, size, 1);
   }
 
   /**
@@ -132,9 +131,7 @@
* @param numBanks the number of data banks.
*/
   protected DataBuffer(int dataType, int size, int numBanks) {
-this(dataType, size);
-banks = numBanks;
-offsets = new int[numBanks];
+this(dataType, size, numBanks, 0);
   }
 
   /**
@@ -153,11 +150,14 @@
* @param offset the offset to the first element for all banks.
*/
   protected DataBuffer(int dataType, int size, int numBanks, int offset) {
-this(dataType, size, numBanks);
-
-java.util.Arrays.fill(offsets, offset);  
-
+banks = numBanks;
+this.dataType = dataType;
+this.size = size;
 this.offset = offset;
+
+offsets = new int[ numBanks ];
+for(int i = 0; i  numBanks; i++ )
+  offsets[i] = offset;
   }
 
   /**
@@ -179,10 +179,11 @@
* codenumBanks != offsets.length/code.
*/
   protected DataBuffer(int dataType, int size, int numBanks, int[] offsets) {
-this(dataType, size);
 if (numBanks != offsets.length) 
   throw new ArrayIndexOutOfBoundsException();
-
+
+this.dataType = dataType;
+this.size = size;
 banks = numBanks;
 this.offsets = offsets;
 


[cp-patches] RFC: Some JFileChooser fixes

2006-07-14 Thread Sven de Marothy
This fixes some bugs:
-Default mode is FILES_ONLY.
-FILES_ONLY mode doesn't mean show only files it means allow only
files to be selected. 
-Hitting enter or return doesn't cancel renaming of files.
-File-name textbox is not set to directory names when in FILES_ONLY,
(but you can still traverse them, requiring a new field for the selected
directory)

And completes BasicDirectoryModel, which I think is all right now.

Some remaining bugs:
- Changing to list view and back screws things up (the table header is
still there, for instance)
- Scrolling size is wrong.
- Sometimes you can select empty entries.

Let me know if there are any regressions.

/Sven

2006-07-14  Sven de Marothy  [EMAIL PROTECTED]

* javax/swing/JFileChooser.java
Change default selection mode to FILES_ONLY.
* javax/swing/plaf/basic/BasicDirectoryModel.java
Document, fix selection mode filtering.
(renameFile): Implement
* javax/swing/plaf/basic/BasicFileChooserUI.java
(selectedDir): New field to handle selected directories,
disallow selecting of directories in FILES_ONLY mode.
* javax/swing/plaf/metal/MetalFileChooserUI.java:
(EditingActionListener.actionPerformed):
Stop editing on all actions (e.g. return-key press)


Index: javax/swing/JFileChooser.java
===
RCS file: /sources/classpath/classpath/javax/swing/JFileChooser.java,v
retrieving revision 1.34
diff -U3 -r1.34 JFileChooser.java
--- javax/swing/JFileChooser.java	12 Jul 2006 21:22:22 -	1.34
+++ javax/swing/JFileChooser.java	14 Jul 2006 23:35:37 -
@@ -353,7 +353,7 @@
* The file selection mode.
* @see #setFileSelectionMode(int) 
*/
-  private int fileSelectionMode = FILES_AND_DIRECTORIES;
+  private int fileSelectionMode = FILES_ONLY;
 
   /** 
* The file view.
Index: javax/swing/plaf/basic/BasicDirectoryModel.java
===
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicDirectoryModel.java,v
retrieving revision 1.3
diff -U3 -r1.3 BasicDirectoryModel.java
--- javax/swing/plaf/basic/BasicDirectoryModel.java	1 Jun 2006 05:17:02 -	1.3
+++ javax/swing/plaf/basic/BasicDirectoryModel.java	14 Jul 2006 23:35:37 -
@@ -1,5 +1,5 @@
 /* BasicDirectoryModel.java --
-   Copyright (C) 2005  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -51,24 +51,29 @@
 
 
 /**
- * DOCUMENT ME!
+ * Implements an AbstractListModel for directories where the source
+ * of the files is a JFileChooser object. 
+ *
+ * This class is used for sorting and ordering the file list in
+ * a JFileChooser LF object.
  */
 public class BasicDirectoryModel extends AbstractListModel
   implements PropertyChangeListener
 {
-  /** DOCUMENT ME! */
+  /** The list of files itself */
   private Vector contents;
 
-  /** DOCUMENT ME! */
+  /** The number of directories in the list */
   private int directories;
 
-  /** DOCUMENT ME! */
+  /** The listing mode of the associated JFileChooser,
+  either FILES_ONLY, DIRECTORIES_ONLY or FILES_AND_DIRECTORIES */
   private int listingMode;
 
-  /** DOCUMENT ME! */
+  /** The JFileCooser associated with this model */
   private JFileChooser filechooser;
 
-  /** DOCUMENT ME! */
+  /** A Comparator class/object for sorting the file list. */
   private Comparator comparator = new Comparator()
 {
   public int compare(Object o1, Object o2)
@@ -91,14 +96,15 @@
 filechooser.addPropertyChangeListener(this);
 listingMode = filechooser.getFileSelectionMode();
 contents = new Vector();
+validateFileCache();
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns whether a given (File) object is included in the list.
*
-   * @param o DOCUMENT ME!
+   * @param o - The file object to test.
*
-   * @return DOCUMENT ME!
+   * @return codetrue/code if the list contains the given object.
*/
   public boolean contains(Object o)
   {
@@ -106,7 +112,7 @@
   }
 
   /**
-   * DOCUMENT ME!
+   * Fires a content change event. 
*/
   public void fireContentsChanged()
   {
@@ -114,9 +120,10 @@
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns a Vector of (java.io.File) objects containing
+   * the directories in this list.
*
-   * @return DOCUMENT ME!
+   * @return a Vector
*/
   public Vector getDirectories()
   {
@@ -127,26 +134,24 @@
   }
 
   /**
-   * DOCUMENT ME!
+   * Returns the (java.io.File) object at 
+   * an index in the list.
*
-   * @param index DOCUMENT ME!
-   *
-   * @return DOCUMENT ME!
+   * @param index The list index
+   * @return a File object
*/
   public Object getElementAt(int index)
   {
 if (index  getSize() - 1)
   return null;
-if (listingMode == JFileChooser.FILES_ONLY)
-  return contents.get(directories + index);
-else
-  return contents.elementAt(index);
+return

Re: Hello:Interested in classpath

2006-07-14 Thread Sven de Marothy
On Fri, 2006-07-14 at 22:06 +0900, [EMAIL PROTECTED] wrote:
 Hi Audrius,
 Ok! I am trying the CVS version, and it looks like some attributes for the
 html tags are not working yet. But it is still cool to be able to see it
 in action ;)  Is there a good starting point I can work from?
 David Fu.

Hi David, This is great. There's all the work you could possibly want in
the HTML department :) Where to start depends entirely on your own
preferences, like what you're interested in, what you're familiar with
and what your personal style of hacking is. 

You could start with some small unimplemented thing and fix that, or you
could grab a bug (there are lots to choose from in the text/HTML
department) and try to fix it. Or you could just take an arbitrary class
and just test it, debug it and complete it. (The swing.text and
swing.text.HTML stuff is still pretty immature code, so chances are
you'll find something to improve on in most classes.)

But to give a more concrete example, I implemented MinimalHTMLWriter a
while back, and tested it against the JDK, where it seems to work pretty
much as it's supposed to. It doesn't work right on Classpath though,
because of bugs in the AbstractWriter super-class. So you could fix
that class up, make sure it's all working the way it's supposed to be.

This shouldn't be so bad since you can use the MinimalHTMLWriter to
test it and be pretty sure that part works. (I can send you a demo
if you want)

/Sven






[commit-cp] classpath ChangeLog java/awt/font/TextLayout.ja...

2006-07-14 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/14 23:35:16

Modified files:
.  : ChangeLog 
java/awt/font  : TextLayout.java TextMeasurer.java 

Log message:
2006-07-14  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/font/TextLayout.java:
(hitTestChar): Stub method.
* java/awt/font/TextMeasurer.java:
(getLayout): Throw exception on invalid argument.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8111r2=1.8112
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/TextLayout.java?cvsroot=classpathr1=1.13r2=1.14
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/TextMeasurer.java?cvsroot=classpathr1=1.5r2=1.6




Re: [cp-patches] RFC: java.lang.StrictMath#cbrt implemented

2006-07-13 Thread Sven de Marothy
On Thu, 2006-07-13 at 19:46 +0200, Carsten Neumann wrote:
   Hi,
 
 the attached patch implements java.lang.StrictMath#cbrt, but I'm
 actually quite ashamed to post it: I'm not very knowledgeable about
 floating point arithmetic, so I just followed the implementation in
 fdlibm (www.netlib.org/fdlibm). Unfortunately this library does some
 weird manipulations of the bits of a double, which I simply mimicked in
 java.

That's probably okay though. Actually it's probably a lot better coding
practice to do it in Java than in C since Java at least has a strictly
defined idea of what a double is.

(A bigger problem with some VMs (*cough* GCJ) is that the internal
representation of a double isn't right. E.g. the might use the
processors extended 80-bit doubles *cough* instead of IEEE 64-bit ones)

One question though.. would it make sense to use longs instead of
int[2] for the 'word' stuff? You could use the Double.doubleFromRawLong
method to convert back to double then.

/Sven




[cp-patches] FYI: GIFImageReader cleaning

2006-07-13 Thread Sven de Marothy
2006-07-12  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/imageio/gif/GIFImageReader.java
(read): Remove old debugging trace.


Index: gnu/javax/imageio/gif/GIFImageReader.java
===
RCS file: /sources/classpath/classpath/gnu/javax/imageio/gif/GIFImageReader.java,v
retrieving revision 1.1
diff -U3 -r1.1 GIFImageReader.java
--- gnu/javax/imageio/gif/GIFImageReader.java	26 Jun 2006 16:06:30 -	1.1
+++ gnu/javax/imageio/gif/GIFImageReader.java	13 Jul 2006 21:41:11 -
@@ -231,9 +231,6 @@
 	  new int[] {0xFF});
 	break;
   }
-byte[] bits = f.getRawImage();
-for(int i = 0; i  5; i++)
-  System.out.println(Bits +i+:+bits[i]);
 DataBuffer db = new DataBufferByte(f.getRawImage(), width * height, 0);
 WritableRaster raster = Raster.createWritableRaster(sm, db, null);
 


[commit-cp] classpath ChangeLog gnu/javax/imageio/gif/GIFIm...

2006-07-13 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/13 21:49:22

Modified files:
.  : ChangeLog 
gnu/javax/imageio/gif: GIFImageReader.java 

Log message:
2006-07-13  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/imageio/gif/GIFImageReader.java
(read): Remove old debugging trace.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8092r2=1.8093
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/gif/GIFImageReader.java?cvsroot=classpathr1=1.1r2=1.2




Re: [cp-patches] RFA: java2d ellipse optimization

2006-07-12 Thread Sven de Marothy
On Wed, 2006-07-12 at 14:34 -0400, Francis Kung wrote:
 Hi,
 
 Attached is a patch to optimize ellipse drawing in java2d.  I'm seeing a
 ~25% speed boost from it on both draw and fill.
 
 Also, ignore my earlier patch re alpha composite; I realised that it
 doesn't work with gradients/textures, and am working on a better patch.
 
 Francis

Looks fine to me!

/Sven




[commit-cp] classpath ChangeLog javax/swing/JFileChooser.java

2006-07-12 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/12 21:22:22

Modified files:
.  : ChangeLog 
javax/swing: JFileChooser.java 

Log message:
2006-07-12  Sven de Marothy  [EMAIL PROTECTED]

* javax/swing/JFileChooser.java:
(createDialog): Close operation should cause a cancel.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8082r2=1.8083
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/swing/JFileChooser.java?cvsroot=classpathr1=1.33r2=1.34




[cp-patches] Re: FYI: AU reader fixlet

2006-07-11 Thread Sven de Marothy
On Tue, 2006-07-11 at 19:47 +0200, Sven de Marothy wrote:
 Whoops, forgot I'd renamed the extension from .au to .as for debugging
 purposes. (So I could test it against the JDK without conflicting with
 its existing AU Reader) This changes it back.

(as being a mild curse in Swedish, meaning carcass) 

/Sven




[commit-cp] classpath/gnu/javax/sound/sampled/AU

2006-07-11 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/11 17:24:37

New directory:
gnu/javax/sound/sampled/AU

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/sound/sampled/AU/?cvsroot=classpath




[commit-cp] classpath ChangeLog resource/META-INF/services/...

2006-07-11 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/11 17:25:37

Modified files:
.  : ChangeLog 
resource/META-INF/services: 
javax.sound.sampled.spi.AudioFileReader 
Added files:
gnu/javax/sound/sampled/AU: AUReader.java 

Log message:
2006-07-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/sound/sampled/AU/AUReader.java:
New file.
* 
resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader: 
Added new provider.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8070r2=1.8071
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/sound/sampled/AU/AUReader.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/resource/META-INF/services/javax.sound.sampled.spi.AudioFileReader?cvsroot=classpathr1=1.1r2=1.2




[commit-cp] classpath ChangeLog gnu/javax/sound/sampled/AU/...

2006-07-11 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/07/11 17:47:39

Modified files:
.  : ChangeLog 
gnu/javax/sound/sampled/AU: AUReader.java 

Log message:
2006-07-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/sound/sampled/AU/AUReader.java:
Correct file extension from .as to .au.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.8071r2=1.8072
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/sound/sampled/AU/AUReader.java?cvsroot=classpathr1=1.1r2=1.2




Re: Random list of AWT TODOs

2006-07-06 Thread Sven de Marothy
On Thu, 2006-07-06 at 15:24 +0200, Juerg Lehni wrote:

 Will it be possible to decide which one to use both at compile time  
 and runtime? I mean, will it be possible to compile Classpath to only  
 compile and use the Headless Toolkit, for environments where GTK is  
 not supported well (e.g. OS X without X11)?

That's the idea, yes. Switching toolkits is pretty easy.

 Of corse, if more than one Toolkit is available, the normal  
 java.awt.headless switch should be used to activate Headless mode.

Right.

 Another question: Will the GTK backend continue to depend on X11 as  
 well? I tried to compile the current version of AWT with the OS X /  
 Quartz implementations of GTK and Cairo, and realized there are quite  
 a few dependencies on X11 stuff in the AWT sources. 

That's an interesting question, actually. I don't really know. Obviously
we should try to avoid X-specific dependencies wherever possible.

 But then there was gnu_java_awt_peer_gtk_ComponentGraphics.c, in  
 which the fix will not be that easy:
[..]
 The code then has various dependencies on X11 that will not run in  
 such a Quartz environment. I'm not into GTK on Windows, but I doubt  
 it will work there either.

Hmm.. the thing here is that the code gets the X pixmap associated with
the component, and uses the X-surface-drawing backend of Cairo to draw
to that. I'm not 100% sure of how to adress this, but you/we will
probably need a replacement for that. Most likely using the Quartz/Win32
backends for that. (Although I don't know how you create one of those
for a GTK component under Windows/OS X, but it should be possible
somehow.) On the plus side, it's relatively little code since most of
the work is done by the abstract CairoGraphics class.

Another, related, issue is VolatileImage, which maps to an X pixmap,
and also uses ComponentGraphics (being an X surface). That'll need
to map to some other native structure (on which Cairo can draw).

So, obviously and unfortunately, it's not just a matter of replacing a
few X class with GTK equivalents. But on the other hand, I think that's
the most of it, and luckily it's fairly straightforward to do your own 
implementation extending CairoGraphics for the various backends.

(The rest of you can thank me here for doing that big refactoring
separating the Cairo code from the GTK code from the X code ;))

/Sven




Re: Random list of AWT TODOs

2006-07-01 Thread Sven de Marothy
On Sat, 2006-07-01 at 10:53 +0100, Andrew John Hughes wrote:

 Wasn't there talk a while back about having an ImageMagick ImageIO
 plugin?  I don't know what happened to it, but this would handle a lot
 of these obscure formats.

Yup. Still, pure-java plugins are still desirable though, I'm not really
sure the need for an ImageMagick plugin is as great now that most of the
usual suspects (GIF/PNG/JPEG) are coming along in pure java.

 Is there also no way that Gtk+ or Qt image support could be leveraged
 for our purposes?

Yes, we currently do use this, there's a IIO plugin based on Gdk-pixbuf
(which sucks, however.. something's wrong with it.) and both the 
Toolkits use the native libraries for createImage().

However, neither lib is really that great; Qt supports PNG/JPEG/GIF and
Gdk has additional support for pcx, ras, ico, wmf and xpm/xbm.* None of
which is really a hard format to support. (Actually I might have a PCX
decoder lying around somewhere that I wrote 10 years ago (when that was
still a popular format))

/Sven




Random list of AWT TODOs

2006-06-30 Thread Sven de Marothy
Hello all.
I thought I'd just post my laundry-list of TODOs here, in case someone
else wanted to jump in and help out.

awt.font
* Arabic shaping.
Arabic text is currently written in correct order (right-to-left) but
the characters need joining. This job is to be done by
FreetypeGlyphvector. For details on the algorithm, see Chapter 8.2 of
the Unicode standard. 
(http://www.unicode.org/versions/Unicode4.0.0/ch08.pdf)
This isn't that hard to do, but certain character pairs will end up
represented as one glyph. The glyphvector impl needs some small
modifications to handle this. (TextLayout *should* be able to handle
this already, however this is not well tested).

* Devanagari  friends.
Similarily, the south-Asian scripts require some more work to be done in
order to convert to glyphs. This is detailed in chapter 9 of the
standard. (http://www.unicode.org/versions/Unicode4.0.0/ch09.pdf)
It's a bit more work than the Arabic case, but mostly it'd be helpful if
someone who knows the language did this.

* Finish TextLayout - not too much work left here, but you can see the
methods in the JAPI scores. More testing and bug-hunting is of course
welcome too.

awt.image
* Make CairoSurface extend Raster and implement some interface for
BufferedImage to get Cairo implementations of Raster.

So that creating an ARGB BufferedImage will create a surface Cairo can
draw directly and also draw to. Other BufferedImage types can keep a
copy of themselves as this kind of raster and copy that data back to the
original raster when the user does a BufferedImage.getData().
BufferedImageGraphics can then be dropped. 

* The awt.image code needs to be checked and tested closely. There's a
lot of bugs in there and some stuff which is plain wrong. (E.g. calls to
ColorSpace methods with bad parameters).

ImageIO
* Still needs a lot of work. But getting awt.image working is probably a
prerequisite for this. A GIF plugin is now available, and a PNG one for
writing and reading is nearing completion. JPEG is still missing.

We can never have enough plugins! If anyone wants there's all kinds of
obscure formats left to support. TIFF, PICT, Targa, ICO, CUR, Sunraster,
XBM, XPM, PCX, Amiga IFF. Whatever you feel like (some of these are
really simple). 

If you're a newbie and can't be bothered to learn the whole IIO
framework just to contribute a simple plugin, if you want, you can
always just contribute something along the lines of:
  static BufferedImage loadImage( InputStream in )
and someone more experienced around here can wrap that with the
necessary plugin code.

Headless

We need a headless toolkit which getDefaultToolkit() can return. 
(which can do the job of throwing the HeadlessExceptions, not as now in
the AWT code). At least right now I've got plans for a Cairo
+Freetype-based one, which'll allow us to reuse existing code. 
This will require:

* The actual toolkit, which should be fairly simple to implement.
(Most peers throw HeadlessException, except lightweight peers like
Canvas and Panel which get dummy implementations. createImage() returns
a BufferedImage or uses ImageIO, and so on.

* A Freetype-based Font peer. (Not too much work) This can pretty much
be used as-is with the existing GlyphVector implementation and by
extension all text rendering. (This peer can then be reused by the GTK
peers for Font.createFont).

* A few modifications to the build to accomodate all that. 

awt.print

* Page margins are off.

* Gradients are written as Level-3 PostScript, which isn't really useful
for most people in the real-world who don't have level-3 printers. (I
was hoping CUPS RIP-filter would take care of it, but it doesn't seem so
on my machine/printer at least)

* Some stuff remains to be implemented, e.g. compositing (which is
indeed a long-standing problem with anyone trying to generate sane
PostScript)

So, anyone want to help out, let us know!

/Sven




[commit-cp] classpath ChangeLog gnu/java/awt/ClasspathToolk...

2006-06-30 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/30 18:20:06

Modified files:
.  : ChangeLog 
gnu/java/awt   : ClasspathToolkit.java 
gnu/java/awt/peer/gtk: GtkToolkit.java 
gnu/java/awt/peer/qt: QtToolkit.java 
gnu/java/awt/peer/x: XToolkit.java 
Removed files:
gnu/java/awt/peer: ClasspathTextLayoutPeer.java 
gnu/java/awt/peer/gtk: GdkTextLayout.java 

Log message:
2006-06-30  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/ClasspathToolkit.java,
* gnu/java/awt/peer/x/XToolkit.java,
* gnu/java/awt/peer/qt/QtToolkit.java,
* gnu/java/awt/peer/gtk/GtkToolkit.java,
Remove ClasspathTextLayoutPeer.
* gnu/java/awt/peer/gtk/GdkTextLayout.java,
* gnu/java/awt/peer/ClasspathTextLayoutPeer,
Files removed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7978r2=1.7979
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/ClasspathToolkit.java?cvsroot=classpathr1=1.19r2=1.20
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/ClasspathTextLayoutPeer.java?cvsroot=classpathr1=1.3r2=0
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java?cvsroot=classpathr1=1.88r2=1.89
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GdkTextLayout.java?cvsroot=classpathr1=1.10r2=0
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/qt/QtToolkit.java?cvsroot=classpathr1=1.7r2=1.8
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/x/XToolkit.java?cvsroot=classpathr1=1.1r2=1.2




[commit-cp] classpath ChangeLog

2006-06-27 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/27 16:12:23

Modified files:
.  : ChangeLog 

Log message:
2006-06-26  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/imageio/gif/GIFFile.java
* gnu/javax/imageio/gif/GIFImageReader.java
* gnu/javax/imageio/gif/GIFImageSpi.java
* gnu/javax/imageio/gif/GIFStream.java
New files.
* javax/imageio/spi/IIORegistry.java: Load new GIF decoder 
plugin.
(forgot changelog entry yesterday)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7950r2=1.7951




[cp-patches] FYI: ImageIO GIF decoder plugin

2006-06-26 Thread Sven de Marothy
2006-06-26  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/imageio/gif/GIFFile.java
* gnu/javax/imageio/gif/GIFImageReader.java
* gnu/javax/imageio/gif/GIFImageSpi.java
* gnu/javax/imageio/gif/GIFStream.java
New files.
* javax/imageio/spi/IIORegistry.java: Load new GIF decoder plugin.


Index: javax/imageio/spi/IIORegistry.java
===
RCS file: /sources/classpath/classpath/javax/imageio/spi/IIORegistry.java,v
retrieving revision 1.8
diff -U3 -r1.8 IIORegistry.java
--- javax/imageio/spi/IIORegistry.java	2 Sep 2005 09:15:22 -	1.8
+++ javax/imageio/spi/IIORegistry.java	26 Jun 2006 15:53:49 -
@@ -45,6 +45,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import gnu.javax.imageio.gif.GIFImageReaderSpi;
 
 public final class IIORegistry extends ServiceRegistry
 {
@@ -81,7 +82,7 @@
 super(defaultCategories.iterator());
 
 // XXX: Register built-in Spis here.
-
+registerServiceProvider(new GIFImageReaderSpi()); // Register GIF decoder
 Toolkit toolkit = Toolkit.getDefaultToolkit();
 if (toolkit instanceof ClasspathToolkit)
   ((ClasspathToolkit)toolkit).registerImageIOSpis(this);
/* GIFFile.java -- GIF decoder
   Copyright (C) 2006  Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package gnu.javax.imageio.gif;

import java.io.IOException;
import java.io.InputStream;
import java.util.Vector;

/**
 * GIFFile - reads a GIF file.
 * 
 * This class only does the bare minimum work, and returns the data in raw
 * formats (described below). The class is J2ME compatible, and hopefully
 * we can keep it that way without any significant overhead.
 *
 * @author Sven de Marothy. 
 */
public class GIFFile 
{
  // NETSCAPE2.0 - identifier
  private final static byte[] nsBlock = new byte[]
  {0x4e, 0x45, 0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2e, 0x30 };

  /**
   * Block identifiers
   */
  private final static int EXTENSION = 0x21;
  private final static int LOCAL = 0x2C;
  private final static int TERMINATOR = 0x3B;

  /**
   * Extension block types
   */
  private final static int EXTENSION_COMMENT = 254;
  private final static int EXTENSION_GCONTROL = 249; 
  private final static int EXTENSION_APPLICATION = 255;

  /**
   * Undraw commands for animation.
   */
  private final static int UNDRAW_OVERWRITE = 1;
  private final static int UNDRAW_RESTORE_BACKGROUND = 2;
  private final static int UNDRAW_RESTORE_PREVIOUS = 3; 

  /**
   * Image position and dimensions (images may be partial)
   */
  private int x, y, width, height;

  /**
   * Global dimensions
   */
  private int globalWidth, globalHeight;

  /**
   * Background color index.
   */
  private byte bgIndex;

  /**
   * Number of colors
   */
  private int nColors;

  /**
   * Global palette, if any
   */
  private byte[] globalPalette;

  /**
   * Any
   */
  private boolean hasGlobalColorMap;

  /**
   * Local palette, if any (used if available)
   */
  private byte[] localPalette;

  /**
   * Interlaced GIF or not?
   */
  private boolean interlaced;

  /**
   * Has transparency?
   */
  private boolean hasTransparency;
  
  /**
   * Undraw mode (animations)
   */
  private int undraw;

  /**
   * Transparent index;
   */
  private int transparentIndex

[commit-cp] classpath/gnu/javax/imageio/gif

2006-06-26 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/26 16:05:09

New directory:
gnu/javax/imageio/gif

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/gif/?cvsroot=classpath




[commit-cp] classpath javax/imageio/spiIIORegistry.java gnu...

2006-06-26 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/26 16:06:30

Modified files:
javax/imageio/spi: IIORegistry.java 
Added files:
gnu/javax/imageio/gif: GIFFile.java GIFImageReader.java 
   GIFImageReaderSpi.java GIFStream.java 

Log message:
2006-06-26  Sven de Marothy  [EMAIL PROTECTED]

* gnu/javax/imageio/gif/GIFFile.java
* gnu/javax/imageio/gif/GIFImageReader.java
* gnu/javax/imageio/gif/GIFImageSpi.java
* gnu/javax/imageio/gif/GIFStream.java
New files.
* javax/imageio/spi/IIORegistry.java: Load new GIF decoder 
plugin.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/javax/imageio/spi/IIORegistry.java?cvsroot=classpathr1=1.8r2=1.9
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/gif/GIFFile.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/gif/GIFImageReader.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java?cvsroot=classpathrev=1.1
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/javax/imageio/gif/GIFStream.java?cvsroot=classpathrev=1.1




Re: Java2d Benchmarking results

2006-06-21 Thread Sven de Marothy
On Tue, 2006-06-20 at 16:40 -0400, Francis Kung wrote:
 Hi,
 
 I've run the java2d benchmarker in a few configurations, with the
 results as follows.  Natively compiling the code doesn't yield much of
 an improvement over jamVM.  Some interesting results.

Did you take into account the fact that Sun's impl defaults to
antialiasing turned off (on Linux) wheras Classpath defaults to having
antialiasing on? I imagine that can have an effect, too.

/Sven




[cp-patches] FYI: More font stuff

2006-06-17 Thread Sven de Marothy
2006-06-18  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(FreetypeGlyphVector, clone): Implement cloning.
(getGlyphLogicalBounds): Bounds should be offset to the glyph 
position.
* java/awt/font/TextMeasurer.java: Implement.
* java/awt/font/LineBreakMeasurer.java: 
Reimplement to use TextMeasurer.
* java/awt/font/TextLayout.java
New constructors.
(getBlackboxBounds, getLogicalHighlightShape): Reimplement.
(getText, getFont): New private static methods.
(setCharIndices): New method.
* java/text/AttributedString.java
(AttributedString): Fix constructor to stop at end point.

Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: 
/sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.6
diff -U3 -r1.6 FreetypeGlyphVector.java
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  11 Jun 2006 08:29:57 
-  1.6
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  18 Jun 2006 00:47:35 
-
@@ -137,6 +137,35 @@
   }
 
   /**
+   * Cloning constructor
+   */  
+  private FreetypeGlyphVector( FreetypeGlyphVector gv )
+  {
+font = gv.font;
+peer = gv.peer;
+frc = gv.frc;
+s = gv.s;
+nGlyphs = gv.nGlyphs;
+logicalBounds = gv.logicalBounds.getBounds2D();
+
+if( gv.metricsCache != null )
+  {
+   metricsCache = new GlyphMetrics[ nGlyphs ];
+   System.arraycopy(gv.metricsCache, 0, metricsCache, 0, nGlyphs);
+  }
+
+glyphCodes = new int[ nGlyphs ];
+glyphPositions = new float[ nGlyphs ];
+glyphTransforms = new AffineTransform[ nGlyphs ];
+for(int i = 0; i  nGlyphs; i++ )
+  {
+   glyphTransforms[ i ] = new AffineTransform( gv.glyphTransforms[ i ] );
+   glyphCodes[i] = gv.glyphCodes[ i ];
+   glyphPositions[i] = gv.glyphPositions[ i ];
+  }
+  }
+
+  /**
* Create the array of glyph codes.
*/
   private void getGlyphs()
@@ -172,6 +201,12 @@
 
   private native GeneralPath getGlyphOutlineNative(int glyphIndex);
 
+
+  public Object clone()
+  {
+return new FreetypeGlyphVector( this );
+  }
+
   /**
* Duh, compares two instances.
*/
@@ -260,8 +295,11 @@
 if( gm == null )
   return null; 
 Rectangle2D r = gm.getBounds2D();
-return new Rectangle2D.Double( r.getX() - gm.getLSB(), r.getY(),
-  gm.getAdvanceX(), r.getHeight() );
+Point2D p = getGlyphPosition( glyphIndex );
+return new Rectangle2D.Double( p.getX() + r.getX() - gm.getLSB(), 
+  p.getY() + r.getY(),
+  gm.getAdvanceX(), 
+  r.getHeight() );
   }
 
   /*
@@ -385,8 +423,6 @@
 for( int i = 1; i  nGlyphs; i++ )
   {
Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
-   Point2D p = getGlyphPosition( i );
-   r2.setRect( p.getX(), p.getY(), r2.getWidth(), r2.getHeight() );
rect = rect.createUnion( r2 );
   }
 
Index: java/awt/font/LineBreakMeasurer.java
===
RCS file: /sources/classpath/classpath/java/awt/font/LineBreakMeasurer.java,v
retrieving revision 1.4
diff -U3 -r1.4 LineBreakMeasurer.java
--- java/awt/font/LineBreakMeasurer.java13 Jun 2006 00:14:27 -  
1.4
+++ java/awt/font/LineBreakMeasurer.java18 Jun 2006 00:47:36 -
@@ -41,57 +41,41 @@
 import java.text.AttributedCharacterIterator;
 import java.text.AttributedString;
 import java.text.BreakIterator;
-import java.awt.font.TextLayout;
-import java.awt.font.FontRenderContext;
 import java.awt.Shape;
 
 public final class LineBreakMeasurer
 {
   private AttributedCharacterIterator text;
   private int position;
-  private FontRenderContext frc;
-  private TextLayout totalLayout;
+  private TextMeasurer tm; 
   private int numChars;
 
   public LineBreakMeasurer(AttributedCharacterIterator text, 
   BreakIterator breakIter, FontRenderContext frc)
   {
-this.text = text;
-this.frc = frc;
-position = 0;
-totalLayout = new TextLayout(text, frc);
-numChars = totalLayout.getCharacterCount();
+this( text, frc );
   }
 
   public LineBreakMeasurer(AttributedCharacterIterator text, 
   FontRenderContext frc)
   {
 this.text = text;
-this.frc = frc;
 position = 0;
-totalLayout = new TextLayout(text, frc);
-numChars = totalLayout.getCharacterCount();
+numChars = text.getEndIndex();
+tm = new TextMeasurer( text, frc );
   }
 
   public void deleteChar(AttributedCharacterIterator newParagraph, 
 int deletePos)
   {
-totalLayout = new TextLayout(newParagraph, frc);
-if( deletePos  0 || deletePos  totalLayout.getCharacterCount

[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Freet...

2006-06-17 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/18 00:54:47

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: FreetypeGlyphVector.java 
java/awt/font  : LineBreakMeasurer.java TextLayout.java 
 TextMeasurer.java 
java/text  : AttributedString.java 

Log message:
2006-06-18  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(FreetypeGlyphVector, clone): Implement cloning.
(getGlyphLogicalBounds): Bounds should be offset to the glyph 
position.
* java/awt/font/TextMeasurer.java: Implement.
* java/awt/font/LineBreakMeasurer.java: 
Reimplement to use TextMeasurer.
* java/awt/font/TextLayout.java
New constructors.
(getBlackboxBounds, getLogicalHighlightShape): Reimplement.
(getText, getFont): New private static methods.
(setCharIndices): New method.
* java/text/AttributedString.java
(AttributedString): Fix constructor to stop at end point.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7861r2=1.7862
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java?cvsroot=classpathr1=1.6r2=1.7
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/LineBreakMeasurer.java?cvsroot=classpathr1=1.4r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/TextLayout.java?cvsroot=classpathr1=1.12r2=1.13
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/TextMeasurer.java?cvsroot=classpathr1=1.3r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/java/text/AttributedString.java?cvsroot=classpathr1=1.15r2=1.16

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7861
retrieving revision 1.7862
diff -u -b -r1.7861 -r1.7862
--- ChangeLog   17 Jun 2006 23:58:41 -  1.7861
+++ ChangeLog   18 Jun 2006 00:54:46 -  1.7862
@@ -1,4 +1,20 @@
-2006-0-12  Mario torre  neugens at limasoftware.net
+2006-06-18  Sven de Marothy  [EMAIL PROTECTED]
+
+   * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+   (FreetypeGlyphVector, clone): Implement cloning.
+   (getGlyphLogicalBounds): Bounds should be offset to the glyph position.
+   * java/awt/font/TextMeasurer.java: Implement.
+   * java/awt/font/LineBreakMeasurer.java: 
+   Reimplement to use TextMeasurer.
+   * java/awt/font/TextLayout.java
+   New constructors.
+   (getBlackboxBounds, getLogicalHighlightShape): Reimplement.
+   (getText, getFont): New private static methods.
+   (setCharIndices): New method.
+   * java/text/AttributedString.java
+   (AttributedString): Fix constructor to stop at end point.
+   
+2006-06-12  Mario torre  neugens at limasoftware.net
 
* gnu/java/util/prefs/GConfBasedPreferences.java: new class.
* gnu/java/util/prefs/GConfBasedFactory.java: new class.

Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: 
/sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  11 Jun 2006 08:29:57 
-  1.6
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  18 Jun 2006 00:54:47 
-  1.7
@@ -137,6 +137,35 @@
   }
 
   /**
+   * Cloning constructor
+   */  
+  private FreetypeGlyphVector( FreetypeGlyphVector gv )
+  {
+font = gv.font;
+peer = gv.peer;
+frc = gv.frc;
+s = gv.s;
+nGlyphs = gv.nGlyphs;
+logicalBounds = gv.logicalBounds.getBounds2D();
+
+if( gv.metricsCache != null )
+  {
+   metricsCache = new GlyphMetrics[ nGlyphs ];
+   System.arraycopy(gv.metricsCache, 0, metricsCache, 0, nGlyphs);
+  }
+
+glyphCodes = new int[ nGlyphs ];
+glyphPositions = new float[ nGlyphs ];
+glyphTransforms = new AffineTransform[ nGlyphs ];
+for(int i = 0; i  nGlyphs; i++ )
+  {
+   glyphTransforms[ i ] = new AffineTransform( gv.glyphTransforms[ i ] );
+   glyphCodes[i] = gv.glyphCodes[ i ];
+   glyphPositions[i] = gv.glyphPositions[ i ];
+  }
+  }
+
+  /**
* Create the array of glyph codes.
*/
   private void getGlyphs()
@@ -172,6 +201,12 @@
 
   private native GeneralPath getGlyphOutlineNative(int glyphIndex);
 
+
+  public Object clone()
+  {
+return new FreetypeGlyphVector( this );
+  }
+
   /**
* Duh, compares two instances.
*/
@@ -260,8 +295,11 @@
 if( gm == null )
   return null; 
 Rectangle2D r = gm.getBounds2D();
-return new

[commit-cp] classpath ChangeLog java/awt/GridBagLayout.java...

2006-06-17 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/18 02:22:17

Modified files:
.  : ChangeLog 
java/awt   : GridBagLayout.java 
java/awt/font  : TextMeasurer.java 

Log message:
2006-06-18  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/GridBagLayout.java (AdjustForGravity): Implement.
* java/awt/font/TextMeasurer.java: Fix copyright date, 
remove commented-out code.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7862r2=1.7863
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/GridBagLayout.java?cvsroot=classpathr1=1.28r2=1.29
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/TextMeasurer.java?cvsroot=classpathr1=1.4r2=1.5

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7862
retrieving revision 1.7863
diff -u -b -r1.7862 -r1.7863
--- ChangeLog   18 Jun 2006 00:54:46 -  1.7862
+++ ChangeLog   18 Jun 2006 02:22:16 -  1.7863
@@ -1,5 +1,11 @@
 2006-06-18  Sven de Marothy  [EMAIL PROTECTED]
 
+   * java/awt/GridBagLayout.java (AdjustForGravity): Implement.
+   * java/awt/font/TextMeasurer.java: Fix copyright date, 
+   remove commented-out code.
+
+2006-06-18  Sven de Marothy  [EMAIL PROTECTED]
+
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(FreetypeGlyphVector, clone): Implement cloning.
(getGlyphLogicalBounds): Bounds should be offset to the glyph position.

Index: java/awt/GridBagLayout.java
===
RCS file: /sources/classpath/classpath/java/awt/GridBagLayout.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- java/awt/GridBagLayout.java 22 Mar 2006 19:15:24 -  1.28
+++ java/awt/GridBagLayout.java 18 Jun 2006 02:22:17 -  1.29
@@ -324,11 +324,17 @@
 /**
  * Obsolete.
  */
-protected void AdjustForGravity (GridBagConstraints gbc, Rectangle rect)
-  throws NotImplementedException
+  protected void AdjustForGravity (GridBagConstraints constraints, 
+  Rectangle rect)
 {
-  // FIXME
-  throw new Error (Not implemented);
+Insets insets = constraints.insets;
+if (insets != null)
+  {
+   rect.x += insets.left;
+   rect.y += insets.top;
+   rect.width -= insets.left + insets.right;
+   rect.height -= insets.top + insets.bottom;
+  }
 }
 
 /**
@@ -353,10 +359,9 @@
   // layoutInfo.  So we wait until after this for loop to set
   // layoutInfo.
   Component lastComp = null;
-  int cellx = 0;
-  int celly = 0;
-  int cellw = 0;
-  int cellh = 0;
+
+  Rectangle cell = new Rectangle();
+
   for (int i = 0; i  components.length; i++)
   {
 Component component = components[i];
@@ -370,29 +375,23 @@
 
 if (lastComp != null
  constraints.gridheight == GridBagConstraints.REMAINDER)
-  celly += cellh;
+  cell.y += cell.height;
 else
-  celly = sumIntArray(info.rowHeights, constraints.gridy);
+  cell.y = sumIntArray(info.rowHeights, constraints.gridy);
 
 if (lastComp != null
  constraints.gridwidth == GridBagConstraints.REMAINDER)
-  cellx += cellw;
+  cell.x += cell.width;
 else
-  cellx = sumIntArray(info.colWidths, constraints.gridx);
+  cell.x = sumIntArray(info.colWidths, constraints.gridx);
 
-cellw = sumIntArray(info.colWidths, constraints.gridx
-+ constraints.gridwidth) - cellx;
-cellh = sumIntArray(info.rowHeights, constraints.gridy
- + constraints.gridheight) - celly;
+cell.width = sumIntArray(info.colWidths, constraints.gridx
++ constraints.gridwidth) - cell.x;
+cell.height = sumIntArray(info.rowHeights, constraints.gridy
+ + constraints.gridheight) - 
cell.y;
 
-Insets insets = constraints.insets;
-if (insets != null)
-  {
-cellx += insets.left;
-celly += insets.top;
-cellw -= insets.left + insets.right;
-cellh -= insets.top + insets.bottom;
-  }
+// Adjust for insets.
+   AdjustForGravity( constraints, cell );
 
 // Note: Documentation says that padding is added on both sides, but
 // visual inspection shows that the Sun implementation only adds it
@@ -403,14 +402,14 @@
 switch (constraints.fill)
   {
   case GridBagConstraints.HORIZONTAL:
-dim.width = cellw

[commit-cp] classpath ChangeLog java/awt/event/KeyEvent.jav...

2006-06-17 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/18 03:45:29

Modified files:
.  : ChangeLog 
java/awt/event : KeyEvent.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_GtkWindowPeer.c 

Log message:
2006-06-18  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/event/KeyEvent.java:
(VK_WINDOWS, VK_CONTEXT_MENU, VK_BEGIN): Add new keysym fields.
*  natve/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c:
Implement WINDOWS, ALT_GR and CONTEXT_MENU keysyms.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7864r2=1.7865
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/event/KeyEvent.java?cvsroot=classpathr1=1.14r2=1.15
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c?cvsroot=classpathr1=1.66r2=1.67

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7864
retrieving revision 1.7865
diff -u -b -r1.7864 -r1.7865
--- ChangeLog   18 Jun 2006 02:43:55 -  1.7864
+++ ChangeLog   18 Jun 2006 03:45:27 -  1.7865
@@ -1,3 +1,10 @@
+2006-06-18  Sven de Marothy  [EMAIL PROTECTED]
+
+   * java/awt/event/KeyEvent.java:
+   (VK_WINDOWS, VK_CONTEXT_MENU, VK_BEGIN): Add new keysym fields.
+   *  natve/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c:
+   Implement WINDOWS, ALT_GR and CONTEXT_MENU keysyms.
+
 2006-06-18  Raif S. Naffah  [EMAIL PROTECTED]
 
* gnu/java/security/util/Prime2.java: Removed.

Index: java/awt/event/KeyEvent.java
===
RCS file: /sources/classpath/classpath/java/awt/event/KeyEvent.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- java/awt/event/KeyEvent.java12 Sep 2005 03:46:42 -  1.14
+++ java/awt/event/KeyEvent.java18 Jun 2006 03:45:28 -  1.15
@@ -993,6 +993,27 @@
   public static final int VK_ALT_GRAPH = 65406;
 
   /**
+   * The 'begin' key VK_BEGIN
+   *
+   * @since 1.5
+   */
+  public static final int VK_BEGIN = 65368;
+
+  /**
+   * The context-menu key VK_CONTEXT_MENU
+   *
+   * @since 1.5
+   */
+  public static final int VK_CONTEXT_MENU = 525;
+
+  /**
+   * The 'Windows' key VK_WINDOWS
+   *
+   * @since 1.5
+   */
+  public static final int VK_WINDOWS = 524;
+
+  /**
* The virtual key VK_UNDEFINED. This is used for key typed events, which
* do not have a virtual key.
*/

Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
===
RCS file: 
/sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c   8 Apr 2006 
22:58:56 -   1.66
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c   18 Jun 2006 
03:45:28 -  1.67
@@ -246,6 +246,10 @@
 #define VK_COMPOSE 65312
 #define VK_ALT_GRAPH 65406
 #define VK_UNDEFINED 0
+#define VK_BEGIN 65368
+#define VK_CONTEXT_MENU 525
+#define VK_WINDOWS 524
+
 
 #define AWT_KEY_CHAR_UNDEFINED 0
 
@@ -721,14 +725,28 @@
   return VK_CUT;
   return VK_COPY;
   return VK_PASTE;
+  */
+case GDK_Undo:
   return VK_UNDO;
+case GDK_Redo:
   return VK_AGAIN;
+  /*
   return VK_FIND;
   return VK_PROPS;
   return VK_STOP;
   return VK_COMPOSE;
+  */
+case GDK_ISO_Level3_Shift:
   return VK_ALT_GRAPH;
+  /*
+   case VK_BEGIN:
   */
+case GDK_Menu:
+  return VK_CONTEXT_MENU;
+case GDK_Super_L:
+case GDK_Super_R:
+  return VK_WINDOWS;
+
 default:
   return VK_UNDEFINED;
 }
@@ -2115,14 +2133,27 @@
 case VK_CUT:
 case VK_COPY:
 case VK_PASTE:
+  */
 case VK_UNDO:
+  return GDK_Undo;
 case VK_AGAIN:
+  return GDK_Redo;
+  /*
 case VK_FIND:
 case VK_PROPS:
 case VK_STOP:
 case VK_COMPOSE:
+  */
 case VK_ALT_GRAPH:
+  return GDK_ISO_Level3_Shift;
+  /*
+   case VK_BEGIN:
   */
+case VK_CONTEXT_MENU:
+  return GDK_Menu;
+case VK_WINDOWS:
+  return GDK_Super_R;
+
 default:
   return GDK_VoidSymbol;
 }




Re: [cp-patches] FYI: CairoGraphics2D speedup

2006-06-14 Thread Sven de Marothy
On Wed, 14 Jun 2006, Mark Wielaard wrote:

 Nice, but unfortunately that doesn't work for ComponentGraphics which
 manipulate the X state. In that case we need locking before drawing. We
 used to get that for free since ComponentGraphics overrides draw(Shape)
 and fill(Shape). So we need to override these three new public methods
 so we do correct locking again.

Correct.
 
 Unfortunately I am unable to say how much speed loss this gives because
 without this patch the benchmark program kept crashing on me. With this
 it runs reliable though.

Zero speed loss compared to before. You're not doing any less work.
 
 We might want to think a bit more about how we do this locking since the
 current way means we do three separate JNI calls and a little extra
 bookkeeping in ComponentGraphics to account for the gdk lock not being
 reentrant. It is probably much more efficient if we had some
 needs_drawing_lock flag inside CairoGraphics itself that subclasses
 could set if needed.

Absolutely not. Never. No way. I refactored the drawing classes precisely
to get away from bullshit like this. CairoGraphics draws to a generic 
Cairo context. Most Cairo context do not require any kind of locking. 
That's the whole idea of why things are done the way they are. 

Trust me, the existing code is a lot more thought through than your idea.
What you're proposing here is going to first introduce a gdk dependency in 
CairoGraphics, which I do not want at all. 

Second, it will slow down all the other drawing contexts by performing an 
unncessary check for whether to do locking.

Third, you're not going to gain much speed regardless, because the 
overhead of making two extra JNI calls is negligable compared to the time 
required to release and get the locks, and in comparison to the fact that 
all those drawing operations have to go through Xlib (and possible 
client-server communication), which is why they need locks to begin with.

This short-sighted thinking is what made the Graphics2D code such a mess
in the first place. It's cleaned up now, and let's not go back there.

-Sven



Re: [cp-patches] RFA: CairoGraphics2D.java fixlet

2006-06-14 Thread Sven de Marothy
On Wed, 14 Jun 2006, David Gilbert wrote:

 I'm requesting approval for this patch, just in case I'm missing something
 important.
 
 As I understand the getPathIterator(AffineTransform) method defined in the
 Shape interface, if you want the path returned without transformation, you can
 pass in null for the AffineTransform.  So it is wasteful to create a new
 identity transform as we seem to be doing here.
 

Seems sane to me.

-Sven



Re: First FMJ release

2006-06-14 Thread Sven de Marothy
On Wed, 14 Jun 2006, Ken Larson wrote:

 As you may know, FMJ (open source implementation of JMF) aims, as one of its
 goals, to be compatible with and support the classpath project.
 
 That said, I'm pleased to announce the first release of FMJ,

Cool! Maybe we should have a link to this, either on our page or on the 
ClasspathX page?

/Sven



[cp-patches] FYI: CairoSurface fix

2006-06-13 Thread Sven de Marothy
Whoops! Two wrongs make a right, CairoSurface was allocating 4x too much
memory due to an inconsistent row stride parameter.

2006-06-13  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoSurface.java
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
(create): Use stride in ints.


Index: gnu/java/awt/peer/gtk/CairoSurface.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoSurface.java,v
retrieving revision 1.9
diff -U3 -r1.9 CairoSurface.java
--- gnu/java/awt/peer/gtk/CairoSurface.java	12 Jun 2006 10:32:44 -	1.9
+++ gnu/java/awt/peer/gtk/CairoSurface.java	13 Jun 2006 15:56:39 -
@@ -88,7 +88,7 @@
   /**
* Allocates and clears the buffer and creates the cairo surface.
* @param width, height - the image size
-   * @param stride - the buffer row stride.
+   * @param stride - the buffer row stride. (in ints)
*/
   private native void create(int width, int height, int stride);
 
@@ -146,7 +146,7 @@
* The format will be ARGB32 with premultiplied alpha and native bit 
* and word ordering.
*/
-  CairoSurface(int width, int height)
+  public CairoSurface(int width, int height)
   {
 super(DataBuffer.TYPE_INT, width * height);
 
@@ -156,7 +156,7 @@
 this.width = width;
 this.height = height;
 
-create(width, height, width * 4);
+create(width, height, width);
 
 if(surfacePointer == 0 || bufferPointer == 0)
   throw new Error(Could not allocate bitmap.);
@@ -176,7 +176,7 @@
 width = image.width;
 height = image.height;
 
-create(width, height, width * 4);
+create(width, height, width);
 
 if(surfacePointer == 0 || bufferPointer == 0)
   throw new Error(Could not allocate bitmap.);
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
===
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c,v
retrieving revision 1.19
diff -U3 -r1.19 gnu_java_awt_peer_gtk_CairoSurface.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c	12 Jun 2006 10:32:44 -	1.19
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c	13 Jun 2006 15:56:40 -
@@ -64,7 +64,7 @@
   setNativeObject(env, obj, data, BUFFER);
 
   surface = cairo_image_surface_create_for_data
-(data, CAIRO_FORMAT_ARGB32, width, height, stride);
+(data, CAIRO_FORMAT_ARGB32, width, height, stride * 4);
 
   setNativeObject(env, obj, surface, SURFACE);
 }


[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Cairo...

2006-06-13 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/13 15:59:36

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: CairoSurface.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_CairoSurface.c 

Log message:
2006-06-13  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoSurface.java
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
(create): Use stride in ints.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7798r2=1.7799
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/CairoSurface.java?cvsroot=classpathr1=1.9r2=1.10
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c?cvsroot=classpathr1=1.19r2=1.20

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7798
retrieving revision 1.7799
diff -u -b -r1.7798 -r1.7799
--- ChangeLog   13 Jun 2006 15:17:07 -  1.7798
+++ ChangeLog   13 Jun 2006 15:59:35 -  1.7799
@@ -1,3 +1,9 @@
+2006-06-13  Sven de Marothy  [EMAIL PROTECTED]
+
+   * gnu/java/awt/peer/gtk/CairoSurface.java
+   * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
+   (create): Use stride in ints.
+
 2006-06-13  Keith Seitz  [EMAIL PROTECTED]
 
From Kyle Galloway  [EMAIL PROTECTED]:

Index: gnu/java/awt/peer/gtk/CairoSurface.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoSurface.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gnu/java/awt/peer/gtk/CairoSurface.java 12 Jun 2006 10:32:44 -  
1.9
+++ gnu/java/awt/peer/gtk/CairoSurface.java 13 Jun 2006 15:59:36 -  
1.10
@@ -88,7 +88,7 @@
   /**
* Allocates and clears the buffer and creates the cairo surface.
* @param width, height - the image size
-   * @param stride - the buffer row stride.
+   * @param stride - the buffer row stride. (in ints)
*/
   private native void create(int width, int height, int stride);
 
@@ -146,7 +146,7 @@
* The format will be ARGB32 with premultiplied alpha and native bit 
* and word ordering.
*/
-  CairoSurface(int width, int height)
+  public CairoSurface(int width, int height)
   {
 super(DataBuffer.TYPE_INT, width * height);
 
@@ -156,7 +156,7 @@
 this.width = width;
 this.height = height;
 
-create(width, height, width * 4);
+create(width, height, width);
 
 if(surfacePointer == 0 || bufferPointer == 0)
   throw new Error(Could not allocate bitmap.);
@@ -176,7 +176,7 @@
 width = image.width;
 height = image.height;
 
-create(width, height, width * 4);
+create(width, height, width);
 
 if(surfacePointer == 0 || bufferPointer == 0)
   throw new Error(Could not allocate bitmap.);

Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c
===
RCS file: 
/sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c12 Jun 2006 
10:32:44 -  1.19
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoSurface.c13 Jun 2006 
15:59:36 -  1.20
@@ -64,7 +64,7 @@
   setNativeObject(env, obj, data, BUFFER);
 
   surface = cairo_image_surface_create_for_data
-(data, CAIRO_FORMAT_ARGB32, width, height, stride);
+(data, CAIRO_FORMAT_ARGB32, width, height, stride * 4);
 
   setNativeObject(env, obj, surface, SURFACE);
 }




[cp-patches] FYI: Implement lineBreakMeasurer

2006-06-12 Thread Sven de Marothy
Here's LineBreakMeasurer. The rest of you can't quite use it yet because
the CVS TextLayout isn't up to snuff. So you'll just have to take my
word for it. :) 

2006-06-12  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/font/LineBreakMeasurer.java): Implement.


Index: java/awt/font/LineBreakMeasurer.java
===
RCS file: /sources/classpath/classpath/java/awt/font/LineBreakMeasurer.java,v
retrieving revision 1.3
diff -U3 -r1.3 LineBreakMeasurer.java
--- java/awt/font/LineBreakMeasurer.java	22 Mar 2006 19:15:24 -	1.3
+++ java/awt/font/LineBreakMeasurer.java	13 Jun 2006 00:12:13 -
@@ -1,5 +1,5 @@
 /* LineBreakMeasurer.java
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,84 +38,161 @@
 
 package java.awt.font;
 
-import gnu.classpath.NotImplementedException;
-
 import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
 import java.text.BreakIterator;
+import java.awt.font.TextLayout;
+import java.awt.font.FontRenderContext;
+import java.awt.Shape;
 
 public final class LineBreakMeasurer
 {
-  private AttributedCharacterIterator ci;
+  private AttributedCharacterIterator text;
+  private int position;
   private FontRenderContext frc;
-  private BreakIterator bi;
+  private TextLayout totalLayout;
+  private int numChars;
 
-  /**
-   * Constructs a codeLineBreakMeasurer/code object.
-   */
-  public LineBreakMeasurer (AttributedCharacterIterator text,
-FontRenderContext frc)
+  public LineBreakMeasurer(AttributedCharacterIterator text, 
+			   BreakIterator breakIter, FontRenderContext frc)
   {
-this (text, null, frc);
+this.text = text;
+this.frc = frc;
+position = 0;
+totalLayout = new TextLayout(text, frc);
+numChars = totalLayout.getCharacterCount();
   }
 
-  /**
-   * Constructs a codeLineBreakMeasurer/code object.
-   */
-  public LineBreakMeasurer (AttributedCharacterIterator text,
-BreakIterator breakIter, FontRenderContext frc) 
+  public LineBreakMeasurer(AttributedCharacterIterator text, 
+			   FontRenderContext frc)
   {
-this.ci = text;
-this.bi = breakIter;
+this.text = text;
 this.frc = frc;
+position = 0;
+totalLayout = new TextLayout(text, frc);
+numChars = totalLayout.getCharacterCount();
   }
 
-  public void deleteChar (AttributedCharacterIterator newParagraph,
-  int deletePos)
-throws NotImplementedException
+  public void deleteChar(AttributedCharacterIterator newParagraph, 
+			 int deletePos)
   {
-throw new Error (not implemented);
+totalLayout = new TextLayout(newParagraph, frc);
+if( deletePos  0 || deletePos  totalLayout.getCharacterCount() )
+  throw new NullPointerException(Invalid deletePos:+deletePos);
+numChars = totalLayout.getCharacterCount();
+text = newParagraph;
+position = 0;
   }
 
-  public int getPosition ()
+  public void insertChar(AttributedCharacterIterator newParagraph, 
+			 int insertPos)
   {
-return ci.getIndex ();
+totalLayout = new TextLayout(newParagraph, frc);
+if( insertPos  0 || insertPos  totalLayout.getCharacterCount() )
+  throw new NullPointerException(Invalid insertPos:+insertPos);
+numChars = totalLayout.getCharacterCount();
+text = newParagraph;
+position = 0;
   }
 
-  public void insertChar (AttributedCharacterIterator newParagraph,
-  int insertPos)
-throws NotImplementedException
+  public TextLayout nextLayout(float wrappingWidth)
   {
-throw new Error (not implemented);
+return nextLayout( wrappingWidth, numChars, false );
   }
 
-  public TextLayout nextLayout (float wrappingWidth)
-throws NotImplementedException
+  public TextLayout nextLayout(float wrappingWidth, int offsetLimit, 
+			   boolean requireNextWord)
   {
-throw new Error (not implemented);
+int next = nextOffset( wrappingWidth, offsetLimit, requireNextWord );
+AttributedCharacterIterator aci = (new AttributedString( text, 
+			 position, next )
+   ).getIterator();
+position = next;
+return new TextLayout( aci, frc );
   }
 
-  public TextLayout nextLayout (float wrappingWidth, int offsetLimit,
-boolean requireNextWord)
-throws NotImplementedException
+  public int nextOffset(float wrappingWidth)
   {
-throw new Error (not implemented);
+return nextOffset( wrappingWidth, numChars, false );
   }
 
-  public int nextOffset (float wrappingWidth)
-throws NotImplementedException
+  public int nextOffset(float wrappingWidth, int offsetLimit, 
+			boolean requireNextWord)
   {
-throw new Error (not implemented);
+Shape s = totalLayout.getBlackBoxBounds( position, offsetLimit );
+double remainingLength = s.getBounds2D().getWidth();
+
+int

[commit-cp] classpath ChangeLog java/awt/font/LineBreakMeas...

2006-06-12 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/13 00:14:27

Modified files:
.  : ChangeLog 
java/awt/font  : LineBreakMeasurer.java 

Log message:
2006-06-12  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/font/LineBreakMeasurer.java): Implement.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7791r2=1.7792
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/LineBreakMeasurer.java?cvsroot=classpathr1=1.3r2=1.4

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7791
retrieving revision 1.7792
diff -u -b -r1.7791 -r1.7792
--- ChangeLog   12 Jun 2006 21:29:38 -  1.7791
+++ ChangeLog   13 Jun 2006 00:14:26 -  1.7792
@@ -1,3 +1,7 @@
+2006-06-12  Sven de Marothy  [EMAIL PROTECTED]
+
+   * java/awt/font/LineBreakMeasurer.java): Implement.
+
 2006-06-12  Keith Seitz  [EMAIL PROTECTED]
 
From Kyle Galloway  [EMAIL PROTECTED]:

Index: java/awt/font/LineBreakMeasurer.java
===
RCS file: /sources/classpath/classpath/java/awt/font/LineBreakMeasurer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- java/awt/font/LineBreakMeasurer.java22 Mar 2006 19:15:24 -  
1.3
+++ java/awt/font/LineBreakMeasurer.java13 Jun 2006 00:14:27 -  
1.4
@@ -1,5 +1,5 @@
 /* LineBreakMeasurer.java
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2006 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -38,84 +38,161 @@
 
 package java.awt.font;
 
-import gnu.classpath.NotImplementedException;
-
 import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
 import java.text.BreakIterator;
+import java.awt.font.TextLayout;
+import java.awt.font.FontRenderContext;
+import java.awt.Shape;
 
 public final class LineBreakMeasurer
 {
-  private AttributedCharacterIterator ci;
+  private AttributedCharacterIterator text;
+  private int position;
   private FontRenderContext frc;
-  private BreakIterator bi;
+  private TextLayout totalLayout;
+  private int numChars;
 
-  /**
-   * Constructs a codeLineBreakMeasurer/code object.
-   */
-  public LineBreakMeasurer (AttributedCharacterIterator text,
-FontRenderContext frc)
+  public LineBreakMeasurer(AttributedCharacterIterator text, 
+  BreakIterator breakIter, FontRenderContext frc)
   {
-this (text, null, frc);
+this.text = text;
+this.frc = frc;
+position = 0;
+totalLayout = new TextLayout(text, frc);
+numChars = totalLayout.getCharacterCount();
   }
 
-  /**
-   * Constructs a codeLineBreakMeasurer/code object.
-   */
-  public LineBreakMeasurer (AttributedCharacterIterator text,
-BreakIterator breakIter, FontRenderContext frc) 
+  public LineBreakMeasurer(AttributedCharacterIterator text, 
+  FontRenderContext frc)
   {
-this.ci = text;
-this.bi = breakIter;
+this.text = text;
 this.frc = frc;
+position = 0;
+totalLayout = new TextLayout(text, frc);
+numChars = totalLayout.getCharacterCount();
   }
 
-  public void deleteChar (AttributedCharacterIterator newParagraph,
+  public void deleteChar(AttributedCharacterIterator newParagraph, 
   int deletePos)
-throws NotImplementedException
   {
-throw new Error (not implemented);
+totalLayout = new TextLayout(newParagraph, frc);
+if( deletePos  0 || deletePos  totalLayout.getCharacterCount() )
+  throw new NullPointerException(Invalid deletePos:+deletePos);
+numChars = totalLayout.getCharacterCount();
+text = newParagraph;
+position = 0;
   }
 
-  public int getPosition ()
+  public void insertChar(AttributedCharacterIterator newParagraph, 
+int insertPos)
   {
-return ci.getIndex ();
+totalLayout = new TextLayout(newParagraph, frc);
+if( insertPos  0 || insertPos  totalLayout.getCharacterCount() )
+  throw new NullPointerException(Invalid insertPos:+insertPos);
+numChars = totalLayout.getCharacterCount();
+text = newParagraph;
+position = 0;
   }
 
-  public void insertChar (AttributedCharacterIterator newParagraph,
-  int insertPos)
-throws NotImplementedException
+  public TextLayout nextLayout(float wrappingWidth)
   {
-throw new Error (not implemented);
+return nextLayout( wrappingWidth, numChars, false );
   }
 
-  public TextLayout nextLayout (float wrappingWidth)
-throws NotImplementedException
+  public TextLayout nextLayout(float wrappingWidth, int offsetLimit, 
+  boolean requireNextWord)
   {
-throw new

[cp-patches] FYI: Faster drawString.

2006-06-11 Thread Sven de Marothy
All in all, this makes drawString() about 3 times as fast.

2006-06-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(setupGlyphMetrics): New method. Add glyphmetrics caching.
(getOutline): Operate on the shape directly.
* gnu/java/awt/peer/gtk/GdkFontPeer.java
(getGlyphMetrics,putGlyphMetrics): Add GlyphMetrics caching.
* include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
(getGlyph renamed getGlyphs)
* java/awt/geom/AffineTransform.java
(getTranslateInstance): Set fields directly.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
(getGlyphs): Get all glyph codes at once.


Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.5
diff -U3 -r1.5 FreetypeGlyphVector.java
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	11 Jun 2006 03:09:03 -	1.5
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	11 Jun 2006 08:23:21 -
@@ -84,11 +84,7 @@
*/
   private AffineTransform[] glyphTransforms;
 
-  /**
-   * Keep track of which glyphs are whitespace, since we don't have
-   * reporting from the peers yet. TextLayout needs this for justification.
-   */
-  private boolean[] whiteSpace;
+  private GlyphMetrics[] metricsCache;
 
   /**
* Create a glyphvector from a given (Freetype) font and a String.
@@ -147,21 +143,25 @@
   {
 nGlyphs = s.codePointCount( 0, s.length() );
 glyphCodes = new int[ nGlyphs ];
+int[] codePoints = new int[ nGlyphs ];
 int stringIndex = 0;
+
 for(int i = 0; i  nGlyphs; i++)
   {
-	glyphCodes[i] = getGlyph( s.codePointAt(stringIndex) );
+	codePoints[i] = s.codePointAt( stringIndex );
 	// UTF32 surrogate handling
-	if( s.codePointAt( stringIndex ) != (int)s.charAt( stringIndex ) )
+	if( codePoints[i] != (int)s.charAt( stringIndex ) )
 	  stringIndex ++;
 	stringIndex ++;
   }
+
+   glyphCodes = getGlyphs( codePoints );
   }
 
   /**
* Returns the glyph code within the font for a given character
*/
-  public native int getGlyph(int codepoint);
+  public native int[] getGlyphs(int[] codepoints);
 
   /**
* Returns the kerning of a glyph pair
@@ -209,14 +209,12 @@
 logicalBounds = null; // invalidate caches.
 glyphPositions = null;
 
-whiteSpace = new boolean[ nGlyphs ]; 
 glyphTransforms = new AffineTransform[ nGlyphs ]; 
 double x = 0;
+
 for(int i = 0; i  nGlyphs; i++)
   {
-	whiteSpace[i] = Character.isWhitespace( glyphCodes[ i ] );
 	GlyphMetrics gm = getGlyphMetrics( i );
-	Rectangle2D r = gm.getBounds2D();
 	glyphTransforms[ i ] = AffineTransform.getTranslateInstance(x, 0);
 	x += gm.getAdvanceX();
 	if( i  0 )
@@ -266,22 +264,48 @@
    gm.getAdvanceX(), r.getHeight() );
   }
 
+  /*
+   * FIXME: Not all glyph types are supported.
+   * (The JDK doesn't really seem to do so either)
+   */
+  public void setupGlyphMetrics()
+  {
+metricsCache = new GlyphMetrics[ nGlyphs ];
+
+for(int i = 0; i  nGlyphs; i++)
+  {
+	GlyphMetrics gm = (GlyphMetrics)
+	  peer.getGlyphMetrics( glyphCodes[ i ] );
+	if( gm == null )
+	  {
+	double[] val = getMetricsNative( glyphCodes[ i ] );
+	if( val == null )
+	  gm = null;
+	else
+	  {
+		gm = new GlyphMetrics( true, 
+   (float)val[1], 
+   (float)val[2], 
+   new Rectangle2D.Double
+   ( val[3], val[4], 
+	 val[5], val[6] ),
+   GlyphMetrics.STANDARD );
+		peer.putGlyphMetrics( glyphCodes[ i ], gm );
+	  }
+	  }
+	metricsCache[ i ] = gm;
+  }
+  }
+
   /**
* Returns the metrics of a single glyph.
-   * FIXME: Not all glyph types are supported.
*/
   public GlyphMetrics getGlyphMetrics(int glyphIndex)
   {
-double[] val = getMetricsNative( glyphCodes[ glyphIndex ] );
-if( val == null )
-  return null;
-byte type = whiteSpace[ glyphIndex ] ? 
-  GlyphMetrics.WHITESPACE : GlyphMetrics.STANDARD;
-
-return new GlyphMetrics( true, (float)val[1], (float)val[2], 
-			 new Rectangle2D.Double( val[3], val[4], 
-		 val[5], val[6] ),
-			 type );
+if( metricsCache == null )
+  setupGlyphMetrics();
+
+return metricsCache[ glyphIndex ];
   }
 
   /**
@@ -406,7 +430,9 @@
   public Shape getOutline(float x, float y)
   {
 AffineTransform tx = AffineTransform.getTranslateInstance( x, y );
-return tx.createTransformedShape( getOutline() );
+GeneralPath gp = (GeneralPath)getOutline();
+gp.transform( tx );
+return gp;
   }
 
   /**
Index: gnu/java/awt/peer/gtk/GdkFontPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java,v
retrieving revision 1.17
diff -U3 -r1.17 GdkFontPeer.java
--- gnu/java/awt/peer

[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Freet...

2006-06-11 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/11 08:29:57

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: FreetypeGlyphVector.java GdkFontPeer.java 
include: gnu_java_awt_peer_gtk_FreetypeGlyphVector.h 
java/awt/geom  : AffineTransform.java 
native/jni/gtk-peer: gnu_java_awt_peer_gtk_FreetypeGlyphVector.c 

Log message:
2006-06-11  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(setupGlyphMetrics): New method. Add glyphmetrics caching.
(getOutline): Operate on the shape directly.
* gnu/java/awt/peer/gtk/GdkFontPeer.java
(getGlyphMetrics,putGlyphMetrics): Add GlyphMetrics caching.
* include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
(getGlyph renamed getGlyphs)
* java/awt/geom/AffineTransform.java
(getTranslateInstance): Set fields directly.
* 
native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
(getGlyphs): Get all glyph codes at once.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7766r2=1.7767
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java?cvsroot=classpathr1=1.5r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java?cvsroot=classpathr1=1.17r2=1.18
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h?cvsroot=classpathr1=1.1r2=1.2
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/geom/AffineTransform.java?cvsroot=classpathr1=1.9r2=1.10
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c?cvsroot=classpathr1=1.2r2=1.3

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7766
retrieving revision 1.7767
diff -u -b -r1.7766 -r1.7767
--- ChangeLog   11 Jun 2006 07:20:41 -  1.7766
+++ ChangeLog   11 Jun 2006 08:29:56 -  1.7767
@@ -1,3 +1,17 @@
+2006-06-11  Sven de Marothy  [EMAIL PROTECTED]
+
+   * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+   (setupGlyphMetrics): New method. Add glyphmetrics caching.
+   (getOutline): Operate on the shape directly.
+   * gnu/java/awt/peer/gtk/GdkFontPeer.java
+   (getGlyphMetrics,putGlyphMetrics): Add GlyphMetrics caching.
+   * include/gnu_java_awt_peer_gtk_FreetypeGlyphVector.h
+   (getGlyph renamed getGlyphs)
+   * java/awt/geom/AffineTransform.java
+   (getTranslateInstance): Set fields directly.
+   * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
+   (getGlyphs): Get all glyph codes at once.
+   
 2006-06-11  Raif S. Naffah  [EMAIL PROTECTED]
 
PR Classpath/27853

Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: 
/sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  11 Jun 2006 03:09:03 
-  1.5
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  11 Jun 2006 08:29:57 
-  1.6
@@ -84,11 +84,7 @@
*/
   private AffineTransform[] glyphTransforms;
 
-  /**
-   * Keep track of which glyphs are whitespace, since we don't have
-   * reporting from the peers yet. TextLayout needs this for justification.
-   */
-  private boolean[] whiteSpace;
+  private GlyphMetrics[] metricsCache;
 
   /**
* Create a glyphvector from a given (Freetype) font and a String.
@@ -147,21 +143,25 @@
   {
 nGlyphs = s.codePointCount( 0, s.length() );
 glyphCodes = new int[ nGlyphs ];
+int[] codePoints = new int[ nGlyphs ];
 int stringIndex = 0;
+
 for(int i = 0; i  nGlyphs; i++)
   {
-   glyphCodes[i] = getGlyph( s.codePointAt(stringIndex) );
+   codePoints[i] = s.codePointAt( stringIndex );
// UTF32 surrogate handling
-   if( s.codePointAt( stringIndex ) != (int)s.charAt( stringIndex ) )
+   if( codePoints[i] != (int)s.charAt( stringIndex ) )
  stringIndex ++;
stringIndex ++;
   }
+
+   glyphCodes = getGlyphs( codePoints );
   }
 
   /**
* Returns the glyph code within the font for a given character
*/
-  public native int getGlyph(int codepoint);
+  public native int[] getGlyphs(int[] codepoints);
 
   /**
* Returns the kerning of a glyph pair
@@ -209,14 +209,12 @@
 logicalBounds = null; // invalidate caches.
 glyphPositions = null;
 
-whiteSpace = new boolean[ nGlyphs ]; 
 glyphTransforms = new AffineTransform[ nGlyphs ]; 
 double x = 0

Re: [cp-patches] FYI: VolatileImage backbuffer for Swing

2006-06-10 Thread Sven de Marothy
On Sat, 2006-06-10 at 10:11 +0200, Roman Kennke wrote:
 Hi again,
 
 Am Samstag, den 10.06.2006, 10:02 +0200 schrieb Roman Kennke:
  This enables the use of VolatileImages as backbuffer for Swing. This
  effectively solves the performance problems brought by the Java2D
  rewrite.
 
 Well, actually this seemed to be wishful thinking. Comparison in the
 FillRect demo shows that painting is comparable for the 'standard'
 benchmark, and even slower on VolatileImage with both checkboxes checked
 (on my machine ~1000ms for VI vs ~500ms for BI). I guess we need to fix
 the VolatileImage impl.

Forget about the fillRect demo. It's a terrible benchmark. The values it
gives do not actually provide any meaningful measure of drawing speed.

/Sven




[cp-patches] Re: RFC: deadlock with Componet/CairoGraphics.drawImage()

2006-06-10 Thread Sven de Marothy
On Sat, 2006-06-10 at 23:17 +0200, Mark Wielaard wrote:
 Hi,
 
 I was seeing deadlocks in some cases with ComponentGraphics.drawImage().
 ComponentGraphics takes the gdk lock and then calls super.drawImage().
 But in some cases when the image isn't a BufferedImage CairoGraphics
 would recurse into drawImage() again. And since the gdk lock isn't
 reentrant that would cause a deadlock. There was a second problem if the
 image was the error image, in that case it wouldn't have a ImageProducer
 and later on in CairoGraphics.drawImage() an Exception would be thrown.
 In that case the gdk lock would never be released. To prevent against
 such situations this patch also moves all operations that have to
 operate with the gdk lock held into a try-finally block to make sure the
 lock is always released.

Looks OK. But on a seperate but related note, could we move that error
image stuff to a seperate dummy class instead though? 

/Sven




[cp-patches] FYI: TextLayout fixlet and some GlyphVector caches.

2006-06-10 Thread Sven de Marothy
2006-06-11  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/font/TextLayout.java
(getLogicalHighlightShape): Add check.
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(getLogicalBounds, getGlyphPositions): Cache bounds, positions.


Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.4
diff -U3 -r1.4 FreetypeGlyphVector.java
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	9 Jun 2006 20:23:55 -	1.4
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	11 Jun 2006 03:03:04 -
@@ -56,6 +56,9 @@
   private Font font;
   private GdkFontPeer peer; // ATTN: Accessed from native code.
 
+  private Rectangle2D logicalBounds;
+
+  private float[] glyphPositions;
   /**
* The string represented by this GlyphVector.
*/
@@ -203,6 +206,9 @@
*/
   public void performDefaultLayout()
   {
+logicalBounds = null; // invalidate caches.
+glyphPositions = null;
+
 whiteSpace = new boolean[ nGlyphs ]; 
 glyphTransforms = new AffineTransform[ nGlyphs ]; 
 double x = 0;
@@ -303,6 +309,9 @@
   public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, 
    float[] positionReturn)
   {
+if( glyphPositions != null )
+  return glyphPositions;
+
 float[] rval;
 
 if( positionReturn == null )
@@ -317,6 +326,7 @@
 	rval[i * 2 + 1] = (float)p.getY();
   }
 
+glyphPositions = rval;
 return rval;
   }
 
@@ -344,6 +354,8 @@
   {
 if( nGlyphs == 0 )
   return new Rectangle2D.Double(0, 0, 0, 0);
+if( logicalBounds != null )
+  return logicalBounds;
 
 Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 );
 for( int i = 1; i  nGlyphs; i++ )
@@ -354,6 +366,7 @@
 	rect = rect.createUnion( r2 );
   }
 
+logicalBounds = rect;
 return rect;
   }
 
@@ -413,6 +426,8 @@
 // FIXME: Scaling, etc.?
 glyphTransforms[ glyphIndex ].setToTranslation( newPos.getX(), 
 		newPos.getY() );
+logicalBounds = null;
+glyphPositions = null;
   }
 
   /**
@@ -421,5 +436,7 @@
   public void setGlyphTransform(int glyphIndex, AffineTransform newTX)
   {
 glyphTransforms[ glyphIndex ].setTransform( newTX );
+logicalBounds = null;
+glyphPositions = null;
   }
 }
Index: java/awt/font/TextLayout.java
===
RCS file: /sources/classpath/classpath/java/awt/font/TextLayout.java,v
retrieving revision 1.9
diff -U3 -r1.9 TextLayout.java
--- java/awt/font/TextLayout.java	9 Jun 2006 20:48:02 -	1.9
+++ java/awt/font/TextLayout.java	11 Jun 2006 03:03:06 -
@@ -391,11 +391,12 @@
 double advance = 0;
 
 // go to first run
-while( runIndices[i + 1][1]  firstEndpoint ) 
-  {
-	advance += runs[i].getLogicalBounds().getWidth();
-	i++;
-  }
+if( i  0 )
+  while( runIndices[i + 1][1]  firstEndpoint ) 
+	{
+	  advance += runs[i].getLogicalBounds().getWidth();
+	  i++;
+	}
 
 int j = 0; // index into the run.
 if( runIndices[i][1] - runIndices[i][0]  1 )


[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/Freet...

2006-06-10 Thread Sven de Marothy
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Sven de Marothy smarothy  06/06/11 03:09:03

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: FreetypeGlyphVector.java 
java/awt/font  : TextLayout.java 

Log message:
2006-06-11  Sven de Marothy  [EMAIL PROTECTED]

* java/awt/font/TextLayout.java
(getLogicalHighlightShape): Add check.
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
(getLogicalBounds, getGlyphPositions): Cache bounds, positions.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.7764r2=1.7765
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java?cvsroot=classpathr1=1.4r2=1.5
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/font/TextLayout.java?cvsroot=classpathr1=1.9r2=1.10

Patches:
Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7764
retrieving revision 1.7765
diff -u -b -r1.7764 -r1.7765
--- ChangeLog   11 Jun 2006 00:05:10 -  1.7764
+++ ChangeLog   11 Jun 2006 03:09:02 -  1.7765
@@ -1,3 +1,10 @@
+2006-06-11  Sven de Marothy  [EMAIL PROTECTED]
+
+   * java/awt/font/TextLayout.java
+   (getLogicalHighlightShape): Add check.
+   * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+   (getLogicalBounds, getGlyphPositions): Cache bounds, positions.
+
 2006-06-11  Raif S. Naffah  [EMAIL PROTECTED]
 
* gnu/javax/security/auth/login/ConfigFileParser.java 
(validateClassName):

Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: 
/sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  9 Jun 2006 20:23:55 
-   1.4
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java  11 Jun 2006 03:09:03 
-  1.5
@@ -56,6 +56,9 @@
   private Font font;
   private GdkFontPeer peer; // ATTN: Accessed from native code.
 
+  private Rectangle2D logicalBounds;
+
+  private float[] glyphPositions;
   /**
* The string represented by this GlyphVector.
*/
@@ -203,6 +206,9 @@
*/
   public void performDefaultLayout()
   {
+logicalBounds = null; // invalidate caches.
+glyphPositions = null;
+
 whiteSpace = new boolean[ nGlyphs ]; 
 glyphTransforms = new AffineTransform[ nGlyphs ]; 
 double x = 0;
@@ -303,6 +309,9 @@
   public float[] getGlyphPositions(int beginGlyphIndex, int numEntries, 
   float[] positionReturn)
   {
+if( glyphPositions != null )
+  return glyphPositions;
+
 float[] rval;
 
 if( positionReturn == null )
@@ -317,6 +326,7 @@
rval[i * 2 + 1] = (float)p.getY();
   }
 
+glyphPositions = rval;
 return rval;
   }
 
@@ -344,6 +354,8 @@
   {
 if( nGlyphs == 0 )
   return new Rectangle2D.Double(0, 0, 0, 0);
+if( logicalBounds != null )
+  return logicalBounds;
 
 Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 );
 for( int i = 1; i  nGlyphs; i++ )
@@ -354,6 +366,7 @@
rect = rect.createUnion( r2 );
   }
 
+logicalBounds = rect;
 return rect;
   }
 
@@ -413,6 +426,8 @@
 // FIXME: Scaling, etc.?
 glyphTransforms[ glyphIndex ].setToTranslation( newPos.getX(), 
newPos.getY() );
+logicalBounds = null;
+glyphPositions = null;
   }
 
   /**
@@ -421,5 +436,7 @@
   public void setGlyphTransform(int glyphIndex, AffineTransform newTX)
   {
 glyphTransforms[ glyphIndex ].setTransform( newTX );
+logicalBounds = null;
+glyphPositions = null;
   }
 }

Index: java/awt/font/TextLayout.java
===
RCS file: /sources/classpath/classpath/java/awt/font/TextLayout.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- java/awt/font/TextLayout.java   9 Jun 2006 20:48:02 -   1.9
+++ java/awt/font/TextLayout.java   11 Jun 2006 03:09:03 -  1.10
@@ -391,6 +391,7 @@
 double advance = 0;
 
 // go to first run
+if( i  0 )
 while( runIndices[i + 1][1]  firstEndpoint ) 
   {
advance += runs[i].getLogicalBounds().getWidth();




[cp-patches] FYI: TextLayout patch Bidi fix

2006-06-09 Thread Sven de Marothy
Hey all, this is my initial implementation of TextLayout, deprecating
the whole old TextLayoutPeer stuff.

Work's still needed (no hit testing yet), but it's mostly there.
/Sven

2006-06-08  Sven de Marothy  [EMAIL PROTECTED]

* java/text/Bidi.java: Treat WS as neutral for rules N1  N2.
* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
New constructor for bidirectionality.
(getGlyphMetrics): Return whitespace glyphs.
(getLogicalBounds): Offset rectangles to correct positions.
* gnu/java/awt/peer/gtk/GdkFontPeer.java
(getBaselineFor): Default to ROMAN_BASELINE.
(GdkFontLineMetrics): Guess some values for underline and 
strikethrough.
(layoutGlyphVector): Use bidirectionality.
* java/awt/font/TextLayout.java: Implement, mostly.


Index: ChangeLog
===
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7743
diff -U3 -r1.7743 ChangeLog
--- ChangeLog	9 Jun 2006 17:02:31 -	1.7743
+++ ChangeLog	9 Jun 2006 20:20:03 -
@@ -1,3 +1,17 @@
+2006-06-08  Sven de Marothy  [EMAIL PROTECTED]
+
+	* java/text/Bidi.java: Treat WS as neutral for rules N1  N2.
+	* gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
+	New constructor for bidirectionality.
+	(getGlyphMetrics): Return whitespace glyphs.
+	(getLogicalBounds): Offset rectangles to correct positions.
+	* gnu/java/awt/peer/gtk/GdkFontPeer.java
+	(getBaselineFor): Default to ROMAN_BASELINE.
+	(GdkFontLineMetrics): Guess some values for underline and 
+	strikethrough.
+	(layoutGlyphVector): Use bidirectionality.
+	* java/awt/font/TextLayout.java: Implement, mostly.
+	
 2006-06-09  Anthony Green  [EMAIL PROTECTED]
 
 	PR classpath/27888:
Index: gnu/java/awt/peer/gtk/FreetypeGlyphVector.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/FreetypeGlyphVector.java,v
retrieving revision 1.3
diff -U3 -r1.3 FreetypeGlyphVector.java
--- gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	7 Jun 2006 23:48:05 -	1.3
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	9 Jun 2006 20:20:08 -
@@ -82,10 +82,25 @@
   private AffineTransform[] glyphTransforms;
 
   /**
+   * Keep track of which glyphs are whitespace, since we don't have
+   * reporting from the peers yet. TextLayout needs this for justification.
+   */
+  private boolean[] whiteSpace;
+
+  /**
* Create a glyphvector from a given (Freetype) font and a String.
*/
   public FreetypeGlyphVector(Font f, String s, FontRenderContext frc)
   {
+this(f, s, frc, Font.LAYOUT_LEFT_TO_RIGHT);
+  }
+
+  /**
+   * Create a glyphvector from a given (Freetype) font and a String.
+   */
+  public FreetypeGlyphVector(Font f, String s, FontRenderContext frc,
+			 int flags)
+  {
 this.s = s;
 this.font = f;
 this.frc = frc;
@@ -94,6 +109,14 @@
 peer = (GdkFontPeer)font.getPeer();
 
 getGlyphs();
+if( flags == Font.LAYOUT_RIGHT_TO_LEFT )
+  {
+	// reverse the glyph ordering.
+	int[] temp = new int[ nGlyphs ];
+	for(int i = 0; i  nGlyphs; i++)
+	  temp[ i ] = glyphCodes[ nGlyphs - i - 1];
+	glyphCodes = temp;
+  }
 performDefaultLayout();
   }
 
@@ -180,10 +203,12 @@
*/
   public void performDefaultLayout()
   {
+whiteSpace = new boolean[ nGlyphs ]; 
 glyphTransforms = new AffineTransform[ nGlyphs ]; 
 double x = 0;
 for(int i = 0; i  nGlyphs; i++)
   {
+	whiteSpace[i] = Character.isWhitespace( glyphCodes[ i ] );
 	GlyphMetrics gm = getGlyphMetrics( i );
 	Rectangle2D r = gm.getBounds2D();
 	glyphTransforms[ i ] = AffineTransform.getTranslateInstance(x, 0);
@@ -237,17 +262,20 @@
 
   /**
* Returns the metrics of a single glyph.
+   * FIXME: Not all glyph types are supported.
*/
   public GlyphMetrics getGlyphMetrics(int glyphIndex)
   {
 double[] val = getMetricsNative( glyphCodes[ glyphIndex ] );
 if( val == null )
   return null;
+byte type = whiteSpace[ glyphIndex ] ? 
+  GlyphMetrics.WHITESPACE : GlyphMetrics.STANDARD;
 
 return new GlyphMetrics( true, (float)val[1], (float)val[2], 
 			 new Rectangle2D.Double( val[3], val[4], 
 		 val[5], val[6] ),
-			 GlyphMetrics.STANDARD );
+			 type );
   }
 
   /**
@@ -319,7 +347,12 @@
 
 Rectangle2D rect = (Rectangle2D)getGlyphLogicalBounds( 0 );
 for( int i = 1; i  nGlyphs; i++ )
-  rect = rect.createUnion( (Rectangle2D)getGlyphLogicalBounds( i ) );
+  {
+	Rectangle2D r2 = (Rectangle2D)getGlyphLogicalBounds( i );
+	Point2D p = getGlyphPosition( i );
+	r2.setRect( p.getX(), p.getY(), r2.getWidth(), r2.getHeight() );
+	rect = rect.createUnion( r2 );
+  }
 
 return rect;
   }
Index: gnu/java/awt/peer/gtk/GdkFontPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GdkFontPeer.java,v
retrieving revision 1.15

[cp-patches] FYI: CairoGraphics2D.drawString implemented on TextLayout

2006-06-09 Thread Sven de Marothy
2006-06-08  Sven de Marothy  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/CairoGraphics2D.java
(drawString): Use TextLayout instead of GlyphVector.


Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.16
diff -U3 -r1.16 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java	9 Jun 2006 16:04:20 -	1.16
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java	9 Jun 2006 20:36:47 -
@@ -63,6 +63,7 @@
 import java.awt.Toolkit;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
+import java.awt.font.TextLayout;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Arc2D;
 import java.awt.geom.Area;
@@ -1271,8 +1272,8 @@
   {
 if (str == null || str.length() == 0)
   return;
-
-drawGlyphVector(getFont().createGlyphVector(null, str), x, y);
+(new TextLayout( str, getFont(), getFontRenderContext() )).
+  draw(this, x, y);
   }
 
   public void drawString(String str, int x, int y)


[cp-patches] FYI: Fix locking in componentgraphics.

2006-06-09 Thread Sven de Marothy
2006-06-09  Sven de Marothy  [EMAIL PROTECTED]

* native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
(Java_gnu_java_awt_peer_gtk_ComponentGraphics_disposeSurface):
Use GTK locks while disposing (Xlib) surface.


Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c
===
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c,v
retrieving revision 1.14
diff -U3 -r1.14 gnu_java_awt_peer_gtk_ComponentGraphics.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c	7 Jun 2006 09:40:54 -	1.14
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c	9 Jun 2006 22:03:53 -
@@ -186,7 +186,11 @@
 
   surface = cairo_get_target (gr-cr);
   if (surface != NULL)
-cairo_surface_destroy (surface);
+{
+  gdk_threads_enter();
+  cairo_surface_destroy (surface);
+  gdk_threads_leave();
+}
 }
 
 JNIEXPORT jlong JNICALL 


  1   2   3   4   >