summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Kung <fkung@redhat.com>2006-11-24 16:33:26 +0000
committerFrancis Kung <fkung@redhat.com>2006-11-24 16:33:26 +0000
commit5a348add86cf8b31de3944d9053d9c870947c5d9 (patch)
treecc8a0498fd41dc262f645d03d33628d555b8a288
parent112026671d7b59a4e09851c323bd3a9ae68f8b9a (diff)
downloadclasspath-5a348add86cf8b31de3944d9053d9c870947c5d9.tar.gz
2006-11-24 Francis Kung <fkung@redhat.com>
* gnu/java/awt/peer/gtk/BufferedImageGraphics.java (constructor): Check sample model when setting fastCM flag. (updateBufferedImage): Check scanline and sample model offsets before copying data directly into the image data buffer.
-rw-r--r--ChangeLog7
-rw-r--r--gnu/java/awt/peer/gtk/BufferedImageGraphics.java51
2 files changed, 47 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 43bb5eb95..c9fd6b9e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-11-24 Francis Kung <fkung@redhat.com>
+ * gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+ (constructor): Check sample model when setting fastCM flag.
+ (updateBufferedImage): Check scanline and sample model offsets before
+ copying data directly into the image data buffer.
+
+2006-11-24 Francis Kung <fkung@redhat.com>
+
* gnu/java/awt/java2d/QuadSegment.java
(offsetSubdivided): Handle special straight-line cases.
diff --git a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
index b89febd74..7de9c057e 100644
--- a/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
+++ b/gnu/java/awt/peer/gtk/BufferedImageGraphics.java
@@ -58,6 +58,7 @@ import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
+import java.awt.image.SinglePixelPackedSampleModel;
import java.util.WeakHashMap;
/**
@@ -110,7 +111,9 @@ public class BufferedImageGraphics extends CairoGraphics2D
imageHeight = bi.getHeight();
locked = false;
- if(bi.getColorModel().equals(CairoSurface.cairoCM_opaque))
+ if (!(image.getSampleModel() instanceof SinglePixelPackedSampleModel))
+ hasFastCM = false;
+ else if(bi.getColorModel().equals(CairoSurface.cairoCM_opaque))
{
hasFastCM = true;
hasAlpha = false;
@@ -219,18 +222,44 @@ public class BufferedImageGraphics extends CairoGraphics2D
if( y + height > imageHeight )
height = imageHeight - y;
- // The setRGB method assumes (or should assume) that pixels are NOT
- // alpha-premultiplied, but Cairo stores data with premultiplication
- // (thus the pixels returned in getPixels are premultiplied).
- // This is ignored for consistency, however, since in
- // CairoGrahpics2D.drawImage we also use non-premultiplied data
if(!hasFastCM)
- image.setRGB(x, y, width, height, pixels,
- x + y * imageWidth, imageWidth);
+ {
+ image.setRGB(x, y, width, height, pixels,
+ x + y * imageWidth, imageWidth);
+ // The setRGB method assumes (or should assume) that pixels are NOT
+ // alpha-premultiplied, but Cairo stores data with premultiplication
+ // (thus the pixels returned in getPixels are premultiplied).
+ // This is ignored for consistency, however, since in
+ // CairoGrahpics2D.drawImage we also use non-premultiplied data
+
+ }
else
- System.arraycopy(pixels, y * imageWidth,
- ((DataBufferInt)image.getRaster().getDataBuffer()).
- getData(), y * imageWidth, height * imageWidth);
+ {
+ int[] db = ((DataBufferInt)image.getRaster().getDataBuffer()).
+ getData();
+
+ // This should not fail, as we check the image sample model when we
+ // set the hasFastCM flag
+ SinglePixelPackedSampleModel sm = (SinglePixelPackedSampleModel)image.getSampleModel() ;
+
+ int minX = image.getRaster().getSampleModelTranslateX();
+ int minY = image.getRaster().getSampleModelTranslateY();
+
+ if (sm.getScanlineStride() == imageWidth && minX == 0)
+ {
+ System.arraycopy(pixels, y * imageWidth,
+ db, y * imageWidth - minY,
+ height * imageWidth);
+ }
+ else
+ {
+ int scanline = sm.getScanlineStride();
+ for (int i = y; i < height; i++)
+ System.arraycopy(pixels, i * imageWidth + x, db,
+ (i - minY) * scanline + x - minX, width);
+
+ }
+ }
}
/**