summaryrefslogtreecommitdiff
path: root/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
diff options
context:
space:
mode:
authorFrancis Kung <fkung@redhat.com>2006-11-21 21:21:36 +0000
committerFrancis Kung <fkung@redhat.com>2006-11-21 21:21:36 +0000
commit7186bace75ea84dda71f5d13e85dcc75aa5683cc (patch)
tree68bbeb9587a390293b04d3548886d7f7f9c591c9 /gnu/java/awt/peer/gtk/BufferedImageGraphics.java
parent488fa0077a655f3152140e74355b11b897352b1e (diff)
downloadclasspath-7186bace75ea84dda71f5d13e85dcc75aa5683cc.tar.gz
2006-11-21 Francis Kung <fkung@redhat.com>
* gnu/java/awt/peer/gtk/BufferedImageGraphics.java (draw): Include stroke width when calculating bounds. (updateBufferedImage): Round bounds more generously, handle negative height/width values, and clip more intelligently. * gnu/java/awt/peer/gtk/CairoGraphics2D.java (createPath): Add shortcut optimization for lines. (draw): Include stroke width when calculating bounds. (drawLine): Delegate to main draw() method. (drawRect): Likewise. (fillRect): Delegate to main fill() method. (findStrokedBounds): New method. (setCustomPaint): Round bounds more generously. * gnu/java/awt/peer/gtk/ComponentGraphics.java (drawLine): Removed. (drawRect): Removed. (fillRect): Removed.
Diffstat (limited to 'gnu/java/awt/peer/gtk/BufferedImageGraphics.java')
-rw-r--r--gnu/java/awt/peer/gtk/BufferedImageGraphics.java42
1 files changed, 31 insertions, 11 deletions
diff --git a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
index f83be870d..d58b6c258 100644
--- a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+++ b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
@@ -188,16 +188,32 @@ public class BufferedImageGraphics extends CairoGraphics2D
transform.transform(points, 0, points, 0, 2);
x = (int)points[0];
y = (int)points[1];
- width = (int)(points[2] - x);
- height = (int)(points[3] - y);
+ width = (int)Math.ceil(points[2] - points[0]);
+ height = (int)Math.ceil(points[3] - points[1]);
int[] pixels = surface.getPixels(imageWidth * imageHeight);
if( x > imageWidth || y > imageHeight )
return;
+
+ // Deal with negative width/height.
+ if (height < 0)
+ {
+ y += height;
+ height = -height;
+ }
+ if (width < 0)
+ {
+ x += width;
+ width = -width;
+ }
+
// Clip edges.
- if( x < 0 ){ width = width + x; x = 0; }
- if( y < 0 ){ height = height + y; y = 0; }
+ if( x < 0 )
+ x = 0;
+ if( y < 0 )
+ y = 0;
+
if( x + width > imageWidth )
width = imageWidth - x;
if( y + height > imageHeight )
@@ -247,15 +263,19 @@ public class BufferedImageGraphics extends CairoGraphics2D
*/
public void draw(Shape s)
{
+ // Find total bounds of shape
+ Rectangle r = findStrokedBounds(s);
+ if (shiftDrawCalls)
+ {
+ r.width++;
+ r.height++;
+ }
+
+ // Do the drawing
if (comp == null || comp instanceof AlphaComposite)
{
super.draw(s);
- Rectangle r = s.getBounds();
-
- if (shiftDrawCalls)
- updateBufferedImage(r.x, r.y, r.width+1, r.height+1);
- else
- updateBufferedImage(r.x, r.y, r.width, r.height);
+ updateBufferedImage(r.x, r.y, r.width, r.height);
}
else
{
@@ -266,7 +286,7 @@ public class BufferedImageGraphics extends CairoGraphics2D
g2d.setColor(this.getColor());
g2d.draw(s);
- drawComposite(s.getBounds2D(), null);
+ drawComposite(r.getBounds2D(), null);
}
}