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 -0000	1.4
+++ gnu/java/awt/peer/gtk/FreetypeGlyphVector.java	11 Jun 2006 03:03:04 -0000
@@ -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 -0000	1.9
+++ java/awt/font/TextLayout.java	11 Jun 2006 03:03:06 -0000
@@ -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 )

Reply via email to