harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r566093 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main/java: common/org/apache/harmony/awt/gl/render/JavaBlitter.java unix/org/apache/harmony/awt/gl/linux/XBlitter.java unix/org/apache/harmony/awt/gl/linux/XSurface.java
Date Wed, 15 Aug 2007 10:26:15 GMT
Author: apetrenko
Date: Wed Aug 15 03:26:14 2007
New Revision: 566093

URL: http://svn.apache.org/viewvc?view=rev&rev=566093
Log:
Patch for HARMONY-4617 "[classlib][awt] NPE while drawing Images with rotation"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java?view=diff&rev=566093&r1=566092&r2=566093
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/JavaBlitter.java
Wed Aug 15 03:26:14 2007
@@ -357,7 +357,7 @@
         Rectangle dstBlitBounds = new Rectangle(dstX, dstY, srcR.getWidth(), srcR.getHeight());
 
         Rectangle transSrcBounds = getBounds2D(at, srcBounds).getBounds();
-        Rectangle transDstBlitBounds = getBounds2D(at, dstBlitBounds).getBounds();
+        Rectangle transDstBlitBounds = new Rectangle(0, 0, dstR.getWidth(), dstR.getHeight());
 
         int translateX = transDstBlitBounds.x - transSrcBounds.x;
         int translateY = transDstBlitBounds.y - transSrcBounds.y;
@@ -474,7 +474,7 @@
 
     }
 
-    private Rectangle2D getBounds2D(AffineTransform at, Rectangle r) {
+    public static Rectangle2D getBounds2D(AffineTransform at, Rectangle r) {
         int x = r.x;
         int y = r.y;
         int width = r.width;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java?view=diff&rev=566093&r1=566092&r2=566093
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
Wed Aug 15 03:26:14 2007
@@ -31,6 +31,7 @@
 
 import org.apache.harmony.awt.gl.*;
 import org.apache.harmony.awt.gl.render.Blitter;
+import org.apache.harmony.awt.gl.render.JavaBlitter;
 import org.apache.harmony.awt.gl.render.NativeImageBlitter;
 import org.apache.harmony.awt.nativebridge.linux.X11;
 import org.apache.harmony.awt.nativebridge.linux.X11Defs;
@@ -169,76 +170,49 @@
             default:
                 XSurface xDstSurf = (XSurface) dstSurf;
 
-                BufferedImage compIm;
-                int w = srcSurf.getWidth();
-                int h = srcSurf.getHeight();
-
-                if (!(srcSurf instanceof ImageSurface)) {
-                    compIm = xDstSurf.g2d.xConfig.createCompatibleImage(w, h);
-
-                    NativeImageBlitter.getInstance().blit(
-                            srcX, srcY, srcSurf,
-                            srcX, srcY,
-                            AwtImageBackdoorAccessor.getInstance().getImageSurface(compIm),
-                            w, h,
-                            AlphaComposite.Src, null, null
-                    );
-                } else {
-                    ColorModel cm = srcSurf.getColorModel();
-                    compIm = new BufferedImage(
-                            cm,
-                            srcSurf.getRaster(),
-                            cm.isAlphaPremultiplied(),
-                            null
-                    );
-                }
-
-                WritableRaster compRaster = compIm.getRaster();
-
                 AffineTransform at = (AffineTransform) sysxform.clone();
 
-                AffineTransformOp atop =
-                        new AffineTransformOp(at, xDstSurf.g2d.getRenderingHints());
-
-                Rectangle r = atop.getBounds2D(compRaster).getBounds();
-                int tWidth = r.width;
-                int tHeight = r.height;
+                Rectangle transDstBounds = JavaBlitter.getBounds2D(at, new Rectangle(dstX,
dstY, width, height)).getBounds();
+                int tWidth = transDstBounds.width;
+                int tHeight = transDstBounds.height;
+                dstX = transDstBounds.x;
+                dstY = transDstBounds.y;
+
+                ColorModel cm = srcSurf.getColorModel();
+                WritableRaster compRaster = srcSurf.getRaster();
+                BufferedImage compIm = new BufferedImage(
+                        cm,
+                        compRaster,
+                        cm.isAlphaPremultiplied(),
+                        null
+                );
 
-                BufferedImage transformed;
-                if (compIm.getColorModel().getTransparency() == Transparency.OPAQUE) {
-                    transformed = xDstSurf.g2d.xConfig.createCompatibleImage(tWidth, tHeight);
-                } else {
-                    ColorModel cm = compIm.getColorModel();
-                    transformed =
-                            new BufferedImage(
-                                    cm,
-                                    compIm.getRaster().createCompatibleWritableRaster(
-                                            tWidth,
-                                            tHeight
-                                    ),
-                                    cm.isAlphaPremultiplied(),
-                                    null
-                            );
-                }
+                BufferedImage transformed = new BufferedImage(tWidth, tHeight, BufferedImage.TYPE_INT_ARGB);
 
-                atop.filter(compIm, transformed);
+                Surface transfSurf = Surface.getImageSurface(transformed);
+                JavaBlitter.getInstance().blit(srcX, srcY, Surface.getImageSurface(compIm),

+                        0, 0, transfSurf, width, height, at, AlphaComposite.Src, null, null);
 
                 if (dstX < 0){
                     tWidth += dstX;
+                    srcX = -dstX;
                     dstX = 0;
                 }
 
                 if (dstY < 0){
                     tHeight += dstY;
+                    srcY = -dstY;
                     dstY = 0;
                 }
 
+                if(tWidth <= 0 || tHeight <= 0 || srcX >= tWidth || srcY >= tHeight)
return;
                 blit(
-                        0, 0, AwtImageBackdoorAccessor.getInstance().getImageSurface(transformed),
+                        srcX, srcY, transfSurf,
                         dstX, dstY, dstSurf,
                         tWidth, tHeight,
                         comp, bgcolor, clip
                 );
+
         }
     }
 
@@ -248,6 +222,7 @@
             int width, int height,
             Composite comp, Color bgcolor, MultiRectArea clip
     ) {
+
         if (clip == null) {
             clip = new MultiRectArea(new Rectangle(dstX, dstY, width, height));
         } else {
@@ -384,8 +359,10 @@
             MultiRectArea clip
     ) {
         XSurface xDstSurf = ((XSurface) dstSurf);
+
         boolean srcNoAlpha =
                 srcSurf.getColorModel().getTransparency() == Transparency.OPAQUE;
+
         if (comp instanceof AlphaComposite) {
             AlphaComposite acomp = (AlphaComposite) comp;
             if (
@@ -400,28 +377,27 @@
             }
         }
 
-        AffineTransform t = xDstSurf.g2d.getTransform();
-        int tx = (int) t.getTranslateX();
-        int ty = (int) t.getTranslateY();
-
-        if (xDstSurf.needServerData) {
-            xDstSurf.setRoi(new Rectangle2D.Float(dstX - tx, dstY - ty, width, height));
-        }
-
-        clip.translate(-tx, -ty);
-
+        Rectangle2D roi = new Rectangle2D.Float(dstX, dstY, width, height); 
+        xDstSurf.setRoi(roi);
         NativeImageBlitter.getInstance().blit(
                 srcX, srcY, srcSurf,
-                dstX - tx, dstY - ty, xDstSurf.getImageSurface(),
+                0, 0, xDstSurf.getImageSurface(),
                 width, height,
-                comp, bgcolor, clip
+                comp, bgcolor, null
         );
 
-        clip.translate(tx, ty);
+        if (xDstSurf.needServerData) {
+            xDstSurf.putImage(clip,
+                    (int) (roi.getX()),
+                    (int) (roi.getY()),
+                    (int) roi.getWidth(), 
+                    (int) roi.getHeight()
+            );
+
+        } else {
+            xDstSurf.putImage(clip, dstX, dstY, width, height);
+        }
 
-        // Get translated clip
-        makeClip(dstX, dstY, width, height, clip);
-        xDstSurf.putImage(clip);
         xDstSurf.needServerData = true;
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java?view=diff&rev=566093&r1=566092&r2=566093
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java
Wed Aug 15 03:26:14 2007
@@ -100,8 +100,8 @@
                     g2d.drawable,
                     pixmap,
                     g2d.imageGC,
-                    (int) (g2d.getTransform().getTranslateX() + roi.getX()),
-                    (int) (g2d.getTransform().getTranslateY() + roi.getY()),
+                    (int) roi.getX(),
+                    (int) roi.getY(),
                     (int) roi.getWidth(), (int) roi.getHeight(),
                     0, 0
             );
@@ -155,11 +155,9 @@
                     (int) roi.getWidth(), (int) roi.getHeight(),
                     ~(0L), // All bits set to 1, should be same as XAllPlanes() result
                     X11Defs.ZPixmap,
-                    xImage,
-                    (int) (roi.getX()),
-                    (int) (roi.getY())
+                    xImage, 0, 0
             );
-
+            x11.XFreePixmap(g2d.display, pixmap);
             lastSnapshot = XVolatileImage.biFromXImage(xImage, g2d.xConfig);
 
             // Cleanup
@@ -167,16 +165,15 @@
         } else {
             lastSnapshot = g2d.xConfig.createCompatibleImage(width, height);
         }
+
         return lastSnapshot.getRaster();
     }
 
-    void putImage(MultiRectArea clip) {
+    void putImage(MultiRectArea clip, int x, int y, int width, int height) {
         putImage(
                 clip,
                 lastSnapshot.getRaster(),
-                (int) g2d.getTransform().getTranslateX(),
-                (int) g2d.getTransform().getTranslateY(),
-                width, height
+                x, y, width, height 
         );
     }
 



Mime
View raw message