harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r589194 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main: java/common/org/apache/harmony/awt/gl/ java/common/org/apache/harmony/awt/gl/image/ java/common/org/apache/harmony/awt/gl/render/ java/windows/org/apache/harmony/awt/gl/win...
Date Sat, 27 Oct 2007 19:34:31 GMT
Author: apetrenko
Date: Sat Oct 27 12:34:30 2007
New Revision: 589194

URL: http://svn.apache.org/viewvc?rev=589194&view=rev
Log:
Patch for HARMONY-5026 "[classlib][awt] Performance improvement for Big 
Image drawing"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/ImageSurface.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/Surface.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinVolatileImage.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.h
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_GDIBlitter.h
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JPEGDecoder.h
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JpegDecoder.c

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/ImageSurface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/ImageSurface.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/ImageSurface.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/ImageSurface.java Sat Oct 27 12:34:30 2007
@@ -22,12 +22,14 @@
  */
 package org.apache.harmony.awt.gl;
 
+import java.awt.Rectangle;
 import java.awt.color.ColorSpace;
 import java.awt.image.BandedSampleModel;
 import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
 import java.awt.image.ComponentColorModel;
 import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
 import java.awt.image.DirectColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.image.MultiPixelPackedSampleModel;
@@ -59,6 +61,8 @@
     
     private long cachedDataPtr;       // Pointer for cached Image Data
     private boolean alphaPre;         // Cached Image Data alpha premultiplied 
+    
+    AwtImageBackdoorAccessor ba = AwtImageBackdoorAccessor.getInstance();
 
     public ImageSurface(ColorModel cm, WritableRaster raster){
         this(cm, raster, Surface.getType(cm, raster));
@@ -73,12 +77,14 @@
         this.raster = raster;
         surfaceType = type;
 
-        data = AwtImageBackdoorAccessor.getInstance().
-        getData(raster.getDataBuffer());
+        DataBuffer db = raster.getDataBuffer();
+        data = ba.getData(db);
+        ba.addDataBufferListener(db, this);
         ColorSpace cs = cm.getColorSpace();
         transparency = cm.getTransparency();
         width = raster.getWidth();
         height = raster.getHeight();
+        addDirtyRegion(new Rectangle(0, 0, width, height));
 
         // For the moment we can build natively only images which have 
         // sRGB, Linear_RGB, Linear_Gray Color Space and type different
@@ -97,6 +103,7 @@
         if(type == BufferedImage.TYPE_CUSTOM){
             nativeDrawable = false;
         }
+        
     }
 
     @Override
@@ -219,6 +226,7 @@
 
     @Override
     public synchronized void dispose() {
+        ba.removeDataBufferListener(raster.getDataBuffer());
         if(surfaceDataPtr != 0L){
             dispose(surfaceDataPtr);
             surfaceDataPtr = 0L;
@@ -256,7 +264,9 @@
      */
     public void setRaster(WritableRaster r) {
         raster = r;
-        data = AwtImageBackdoorAccessor.getInstance().getData(r.getDataBuffer());
+        DataBuffer db = r.getDataBuffer();
+        data = ba.getData(db);
+        ba.addDataBufferListener(db, this);
         if (surfaceDataPtr != 0) {
             setImageSize(surfaceDataPtr, r.getWidth(), r.getHeight());
         }
@@ -313,11 +323,12 @@
             AwtImageBackdoorAccessor ba = AwtImageBackdoorAccessor.getInstance();
             ba.validate(raster.getDataBuffer());
         }
+        releaseDurtyRegions();
         
     }
     
     @Override
     public boolean invalidated(){
-        return needToRefresh;
+        return needToRefresh | dataTaken;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/Surface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/Surface.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/Surface.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/Surface.java Sat Oct 27 12:34:30 2007
@@ -23,6 +23,7 @@
 package org.apache.harmony.awt.gl;
 
 import java.awt.Image;
+import java.awt.Rectangle;
 import java.awt.Transparency;
 import java.awt.color.ColorSpace;
 import java.awt.image.BufferedImage;
@@ -90,6 +91,8 @@
     protected int transparency = OPAQUE;
     protected int width;
     protected int height;
+    
+    protected MultiRectArea dirtyRegions;
 
     /**
      * This list contains caches with the data of this surface that are valid at the moment.
@@ -171,6 +174,28 @@
     public void validate(){}
     
     public void invalidate(){}
+    
+    public void addDirtyRegion(Rectangle r){
+        if (dirtyRegions == null) {
+            dirtyRegions = new MultiRectArea(r);
+        } else {
+            Rectangle rects[] = dirtyRegions.getRectangles();
+            if (rects.length == 1){
+                if (rects[0].contains(r)) return;
+            }
+            dirtyRegions.add(r);
+        }
+        invalidate();
+    }
+    
+    public void releaseDurtyRegions(){
+        dirtyRegions = null;
+    }
+    
+    public int[] getDirtyRegions(){
+        if(dirtyRegions != null) return dirtyRegions.rect;
+        else return null;
+    }
 
     /**
      * Computation type of BufferedImage or Surface

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java Sat Oct 27 12:34:30 2007
@@ -54,8 +54,10 @@
     static final int IMPOSSIBLE_VALUE = 0x0FFFFFFF;
 
     // I/O buffer
-    private static final int BUFFER_SIZE = 1024;
-    private byte buffer[] = new byte[BUFFER_SIZE];
+    private static final int MIN_BUFFER_SIZE = 1024;
+    private static final int MAX_BUFFER_SIZE = 2097152;
+    private int buffer_size;
+    private byte buffer[];
 
     GifDataStream gifDataStream = new GifDataStream();
     GifGraphicBlock currBlock;
@@ -79,6 +81,19 @@
 
     public GifDecoder(DecodingImageSource src, InputStream is) {
         super(src, is);
+        try {
+            int available_bytes = is.available();
+            if (available_bytes < MIN_BUFFER_SIZE) {
+                buffer_size = MIN_BUFFER_SIZE;
+            } else if (available_bytes > MAX_BUFFER_SIZE) {
+                buffer_size = MAX_BUFFER_SIZE;
+            } else {
+                buffer_size = available_bytes;
+            }
+        } catch (IOException e) {
+            buffer_size = MIN_BUFFER_SIZE;
+        }
+        buffer = new byte[buffer_size];
     }
 
     private static native int[] toRGB(byte imageData[], byte colormap[], int transparentColor);
@@ -168,7 +183,7 @@
 
             // Read from the input stream
             for (;;) {
-                needBytes = BUFFER_SIZE - bytesInBuffer;
+                needBytes = buffer_size - bytesInBuffer;
                 offset = bytesInBuffer;
 
                 bytesRead = inputStream.read(buffer, offset, needBytes);

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java Sat Oct 27 12:34:30 2007
@@ -48,8 +48,10 @@
             hintflagsProgressive;
 
     // Buffer for the stream
-    private static final int BUFFER_SIZE = 1024;
-    private byte buffer[] = new byte[BUFFER_SIZE];
+    private static final int MIN_BUFFER_SIZE = 1024;
+    private static final int MAX_BUFFER_SIZE = 2097152;
+    private int buffer_size;
+    private byte buffer[];
 
     // 3 possible color models only
     private static ColorModel cmRGB;
@@ -96,6 +98,19 @@
 
     public JpegDecoder(DecodingImageSource src, InputStream is) {
         super(src, is);
+        try {
+            int available_bytes = is.available();
+            if (available_bytes < MIN_BUFFER_SIZE) {
+                buffer_size = MIN_BUFFER_SIZE;
+            } else if (available_bytes > MAX_BUFFER_SIZE) {
+                buffer_size = MAX_BUFFER_SIZE;
+            } else {
+                buffer_size = available_bytes;
+            }
+        } catch (IOException e) {
+            buffer_size = MIN_BUFFER_SIZE;
+        }
+        buffer = new byte[buffer_size];
     }
 
     /*
@@ -125,7 +140,7 @@
             int intOut[] = null;
             // Read from the input stream
             for (;;) {
-                needBytes = BUFFER_SIZE - bytesInBuffer;
+                needBytes = buffer_size - bytesInBuffer;
                 offset = bytesInBuffer;
 
                 bytesRead = inputStream.read(buffer, offset, needBytes);

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java Sat Oct 27 12:34:30 2007
@@ -26,6 +26,7 @@
 
 import java.awt.Graphics;
 import java.awt.Image;
+import java.awt.Rectangle;
 import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
 import java.awt.image.ComponentColorModel;
@@ -68,7 +69,6 @@
     private boolean producing;
     private boolean done;
     private ImageSurface imageSurf;
-    Object surfData;
     AwtImageBackdoorAccessor ba = AwtImageBackdoorAccessor.getInstance();
 
 
@@ -134,6 +134,7 @@
         synchronized (this) {
             imageState = 0;
             image = null;
+            imageSurf = null;
             cm = null;
             raster = null;
             hints = 0;
@@ -184,13 +185,16 @@
             forceToIntARGB();
         }
 
+        DataBuffer db = raster.getDataBuffer();
+        Object surfData = ba.getData(db);
+
         synchronized(surfData){
             if(cm == model && model.getTransferType() == DataBuffer.TYPE_INT &&
                     raster.getNumDataElements() == 1){
 
                 int data[] = (int[])surfData;
                 int scanline = raster.getWidth();
-                DataBufferInt dbi = (DataBufferInt) raster.getDataBuffer();
+                DataBufferInt dbi = (DataBufferInt) db;
                 int rof = dbi.getOffset() + y * scanline + x;
                 for(int lineOff = off, line = y; line < y + h;
                     line++, lineOff += scansize, rof += scanline){
@@ -202,7 +206,7 @@
                 int buff[] = new int[w];
                 int data[] = (int[])surfData;
                 int scanline = raster.getWidth();
-                DataBufferInt dbi = (DataBufferInt) raster.getDataBuffer();
+                DataBufferInt dbi = (DataBufferInt) db;
                 int rof = dbi.getOffset() + y * scanline + x;
                 for (int sy = y, sOff = off; sy < y + h; sy++, sOff += scansize,
                     rof += scanline) {
@@ -223,9 +227,10 @@
                 }
             }
         }
-
+        
+        ba.releaseData(db);
         if (imageSurf != null) {
-            imageSurf.invalidate();
+            imageSurf.addDirtyRegion(new Rectangle(x, y, w, h));
         }
 
         imageUpdate(ImageObserver.SOMEBITS);
@@ -251,6 +256,9 @@
             forceToIntARGB();
         }
 
+        DataBuffer db = raster.getDataBuffer();
+        Object surfData = ba.getData(db);
+
         synchronized(surfData){
             if(isIntRGB){
                 int buff[] = new int[w];
@@ -259,7 +267,7 @@
                 icm.getRGBs(colorMap);
                 int data[] = (int[])surfData;
                 int scanline = raster.getWidth();
-                DataBufferInt dbi = (DataBufferInt) raster.getDataBuffer();
+                DataBufferInt dbi = (DataBufferInt) db;
                 int rof = dbi.getOffset() + y * scanline + x;
                 if(model instanceof IndexColorModel){
 
@@ -285,7 +293,7 @@
 
                 byte data[] = (byte[])surfData;
                 int scanline = raster.getWidth();
-                DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
+                DataBufferByte dbb = (DataBufferByte) db;
                 int rof = dbb.getOffset() + y * scanline + x;
                 for(int lineOff = off, line = y; line < y + h;
                     line++, lineOff += scansize, rof += scanline){
@@ -310,8 +318,9 @@
             }
         }
 
+        ba.releaseData(db);
         if (imageSurf != null) {
-            imageSurf.invalidate();
+            imageSurf.addDirtyRegion(new Rectangle(x, y, w, h));
         }
 
         imageUpdate(ImageObserver.SOMEBITS);
@@ -475,7 +484,6 @@
             raster = cm.createCompatibleWritableRaster(width, height);
             isIntRGB = true;
         }
-        surfData = ba.getData(raster.getDataBuffer());
     }
 
     private void imageUpdate(int state){
@@ -548,7 +556,6 @@
             }
             cm = rgbCM;
             raster = destRaster;
-            surfData = ba.getData(raster.getDataBuffer());
             isIntRGB = true;
         }
     }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java Sat Oct 27 12:34:30 2007
@@ -57,8 +57,10 @@
     // Each pixel is an R,G,B triple, followed by an alpha sample.
     private static final int PNG_COLOR_TYPE_RGBA = 6;
 
-    private static final int INPUT_BUFFER_SIZE = 4096;
-    private byte buffer[] = new byte[INPUT_BUFFER_SIZE];
+    private static final int MIN_BUFFER_SIZE = 4096;
+    private static final int MAX_BUFFER_SIZE = 2097152;
+    private int buffer_size;
+    private byte buffer[];
 
     // Buffers for decoded image data
     byte byteOut[];
@@ -86,6 +88,19 @@
 
     public PngDecoder(DecodingImageSource src, InputStream is) {
         super(src, is);
+        try {
+            int available_bytes = is.available();
+            if (available_bytes < MIN_BUFFER_SIZE) {
+                buffer_size = MIN_BUFFER_SIZE;
+            } else if (available_bytes > MAX_BUFFER_SIZE) {
+                buffer_size = MAX_BUFFER_SIZE;
+            } else {
+                buffer_size = available_bytes;
+            }
+        } catch (IOException e) {
+            buffer_size = MIN_BUFFER_SIZE;
+        }
+        buffer = new byte[buffer_size];
     }
 
     @Override
@@ -95,7 +110,7 @@
             int needBytes, offset, bytesInBuffer = 0;
             // Read from the input stream
             for (;;) {
-                needBytes = INPUT_BUFFER_SIZE - bytesInBuffer;
+                needBytes = buffer_size - bytesInBuffer;
                 offset = bytesInBuffer;
 
                 bytesRead = inputStream.read(buffer, offset, needBytes);

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/render/NativeImageBlitter.java Sat Oct 27 12:34:30 2007
@@ -25,6 +25,7 @@
 import java.awt.AlphaComposite;
 import java.awt.Color;
 import java.awt.Composite;
+import java.awt.Rectangle;
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 
@@ -151,15 +152,13 @@
                             dstX, dstY, dstSurfStruct, dstData,
                             width, height, bgcolor.getRGB(),
                             compType, alpha, clipRects, srcSurf.invalidated());
-                    dstSurf.invalidate();
-                    srcSurf.validate();
+                    dstSurf.addDirtyRegion(new Rectangle(dstX, dstY, width, height));
                 }else{
                     blt(srcX, srcY, srcSurfStruct, srcData,
                             dstX, dstY, dstSurfStruct, dstData,
                             width, height, compType, alpha,
                             clipRects, srcSurf.invalidated());
-                    dstSurf.invalidate();
-                    srcSurf.validate();
+                    dstSurf.addDirtyRegion(new Rectangle(dstX, dstY, width, height));
                 }
             }else if(comp instanceof XORComposite){
                 XORComposite xcomp = (XORComposite) comp;
@@ -167,8 +166,7 @@
                         dstX, dstY, dstSurfStruct, dstData,
                         width, height, xcomp.getXORColor().getRGB(),
                         clipRects, srcSurf.invalidated());
-                dstSurf.invalidate();
-                srcSurf.validate();
+                dstSurf.addDirtyRegion(new Rectangle(dstX, dstY, width, height));
             }else{
                 if(srcSurf instanceof ImageSurface){
                     JavaBlitter.inst.blit(srcX, srcY, srcSurf, dstX, dstY, 
@@ -189,7 +187,6 @@
                             tmpSurfStruct, tmpData, w, h, 
                             AlphaComposite.SRC_OVER,
                             1.0f, tmpClip, srcSurf.invalidated());
-                    srcSurf.validate();
                     JavaBlitter.inst.blit(srcX, srcY, tmpSurf, dstX, dstY, 
                             dstSurf, width, height,
                             comp, bgcolor, clip);

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDIBlitter.java Sat Oct 27 12:34:30 2007
@@ -102,19 +102,24 @@
                 float alpha = ac.getAlpha();
                 if(srcSurf instanceof ImageSurface){
                     Object data = srcSurf.getData();
+
+                    int dirtyRegions[] = ((ImageSurface) srcSurf).getDirtyRegions();
+                    int regCount = 0;
+                    if(dirtyRegions != null) regCount = dirtyRegions[0] - 1;
+                    
                     synchronized(data){
                         if(bgcolor == null || srcSurf.getTransparency() == Transparency.OPAQUE){
                             bltImage(srcX, srcY, srcSurfStruct, srcSurf.getData(),
                                     dstX, dstY, dstSurfStruct,
                                     width, height, compType, alpha,
                                     matrix, clipRects, numVertex, 
-                                    srcSurf.invalidated());
+                                    srcSurf.invalidated(), dirtyRegions, regCount);
                         }else{
                             bltBGImage(srcX, srcY, srcSurfStruct, srcSurf.getData(),
                                     dstX, dstY, dstSurfStruct,
                                     width, height, bgcolor.getRGB(),
                                     compType, alpha, matrix, clipRects, 
-                                    numVertex, srcSurf.invalidated());
+                                    numVertex, srcSurf.invalidated(), dirtyRegions, regCount);
                         }
                     }
                     srcSurf.validate();
@@ -128,11 +133,17 @@
                 XORComposite xcomp = (XORComposite) comp;
                 if(srcSurf instanceof ImageSurface){
                     Object data = srcSurf.getData();
+
+                    int dirtyRegions[] = ((ImageSurface) srcSurf).getDirtyRegions();
+                    int regCount = 0;
+                    if(dirtyRegions != null) regCount = dirtyRegions[0] - 1;
+
                     synchronized(data){
                         xorImage(srcX, srcY, srcSurfStruct, data,
                                 dstX, dstY, dstSurfStruct,
                                 width, height, xcomp.getXORColor().getRGB(),
-                                matrix, clipRects, numVertex, srcSurf.invalidated());
+                                matrix, clipRects, numVertex, 
+                                srcSurf.invalidated(), dirtyRegions, regCount);
                     }
                     srcSurf.validate();
                 }else{
@@ -175,13 +186,13 @@
             Object srcData, int dstX, int dstY, long dstSurfDataPtr,
             int width, int height, int bgcolor,
             int compType, float alpha, double matrix[],
-            int clip[], int numVertex, boolean invalidated);
+            int clip[], int numVertex, boolean invalidated, int[] dirtyRegions, int regCount);
 
     private native void bltImage(int srcX, int srcY, long srsSurfDataPtr,
             Object srcData, int dstX, int dstY, long dstSurfDataPtr,
             int width, int height, int compType,
             float alpha, double matrix[],
-            int clip[], int numVertex, boolean invalidated);
+            int clip[], int numVertex, boolean invalidated, int[] dirtyRegions, int regCount);
 
     private native void bltBitmap(int srcX, int srcY, long srsSurfDataPtr,
             int dstX, int dstY, long dstSurfDataPtr,
@@ -192,7 +203,7 @@
     private native void xorImage(int srcX, int srcY, long srsSurfDataPtr,
             Object srcData, int dstX, int dstY, long dstSurfDataPtr,
             int width, int height, int xorcolor, double matrix[],
-            int clip[], int numVertex, boolean invalidated);
+            int clip[], int numVertex, boolean invalidated, int[] dirtyRegions, int regCount);
 
     private native void xorBitmap(int srcX, int srcY, long srsSurfDataPtr,
             int dstX, int dstY, long dstSurfDataPtr,

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinVolatileImage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinVolatileImage.java?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinVolatileImage.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinVolatileImage.java Sat Oct 27 12:34:30 2007
@@ -156,6 +156,7 @@
             WinGDIPGraphics2D.disposeGraphicsInfo(gi);
             gi = 0;
         }
+        if (surface != null) surface.dispose();
         super.flush();
     }
     

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp Sat Oct 27 12:34:30 2007
@@ -68,11 +68,11 @@
 }
 
 inline void updateCache
-(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, bool alphaPre){
+(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, bool alphaPre, int x, int y, int width, int height){
 
-    unsigned int srcstride, dststride, offset;
-    unsigned int h = srcSurf->height;
-    unsigned int w = srcSurf->width;
+    int src_stride, dst_stride, src_offset, dst_offset;
+    int h = height;
+    int w = width;
 
     void *bmpDataPtr = srcSurf->bmpData;
     void *srcDataPtr = env->GetPrimitiveArrayCritical((jarray)srcData, 0);
@@ -81,22 +81,18 @@
 
         case INT_RGB:
             {
-                unsigned int *src, *s, *dst, *d;
+                unsigned int *src, *dst;
 
-                srcstride = srcSurf->scanline_stride;
-                dststride = w;
+                src_stride = srcSurf->scanline_stride;
+                dst_stride = srcSurf->width;
 
-                offset = w - 1;
-                src = (unsigned int *)srcDataPtr + offset;
-                dst = (unsigned int *)bmpDataPtr + offset;
+                src_offset = y * src_stride + x;
+                dst_offset = y * dst_stride + x;
+                src = (unsigned int *)srcDataPtr + src_offset;
+                dst = (unsigned int *)bmpDataPtr + dst_offset;
 
-                for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
-                    s = src;
-                    d = dst;
-
-                    for(int x = w; x > 0 ; x--){
-                        *d-- = 0xff000000 | *s--;
-                    }
+                for(int _y = 0; _y < h; _y++, src += src_stride, dst += dst_stride){
+                    memcpy(dst, src, w * sizeof(int));
                 }
             }
             break;
@@ -105,19 +101,20 @@
             {
                 unsigned char *src, *s, *dst, *d, sa;
 
-                offset = (w << 2) - 1;
-                src = (unsigned char *)srcDataPtr + offset;
-                dst = (unsigned char *)bmpDataPtr + offset;
+                src_stride = srcSurf->scanline_stride_byte;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride_byte;
-                dststride = w << 2;
+                src_offset = y * src_stride + ((x + w) << 2) - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
                 if(alphaPre){
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             sa = *s--;
                             *d-- = sa;
                             if(sa != 255){
@@ -134,11 +131,11 @@
                     }
                     srcSurf->isAlphaPre = true;
                 }else{
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             sa = *s--;
                             if(sa == 0){
                                 *d-- = 0;
@@ -163,19 +160,20 @@
             {
                 unsigned char *src, *s, *dst, *d, sa;
 
-                offset = (w << 2) - 1;
-                src = (unsigned char *)srcDataPtr + offset;
-                dst = (unsigned char *)bmpDataPtr + offset;
+                src_stride = srcSurf->scanline_stride_byte;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride_byte;
-                dststride = w << 2;
+                src_offset = y * src_stride + ((x + w) << 2) - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
                 if(alphaPre){
-                    for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             sa = *s--;
                             *d-- = sa;
                             *d-- = *s--;
@@ -188,11 +186,11 @@
                     }
                     srcSurf->isAlphaPre = true;
                 }else{
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             sa = *s--;
                             *d-- = sa;
                             *d-- = DIV(sa, *s--);
@@ -209,18 +207,19 @@
             {
                 unsigned char *src, *s, *dst, *d;
 
-                offset = (w << 2) - 1;
-                src = (unsigned char *)srcDataPtr + offset;
-                dst = (unsigned char *)bmpDataPtr + offset;
+                src_stride = srcSurf->scanline_stride_byte;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride_byte;
-                dststride = w << 2;
- 
-                for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                src_offset = y * src_stride + ((x + w) << 2) - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
+
+                for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                     s = src;
                     d = dst;
 
-                    for(int x = w; x > 0 ; x--){
+                    for(int _x = w; _x > 0; _x--){
                         *d = 255;
                         *s--;
                         *(d - 3) = *s--;
@@ -236,19 +235,19 @@
             {
                 unsigned char *src, *s, *dst, *d;
 
-                offset = (w << 2) - 1;
-                unsigned int srcOffset = w * 3 - 1;
-                src = (unsigned char *)srcDataPtr + srcOffset;
-                dst = (unsigned char *)bmpDataPtr + offset;
+                src_stride = srcSurf->scanline_stride_byte;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride_byte;
-                dststride = w << 2;
+                src_offset = y * src_stride + (x + w) * 3 - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
-                for(int y = srcSurf->height; y > 0; y--, src += srcstride, dst += dststride){
+                for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                     s = src;
                     d = dst;
 
-                    for(int x = w; x > 0 ; x--){
+                    for(int _x = w; _x > 0; _x--){
                         *d-- = 255;
                         *d-- = *s--;
                         *d-- = *s--;
@@ -262,19 +261,20 @@
             {
                 unsigned char *src, *s, *dst, *d, a, r, g, b;
 
-                offset = (w << 2) - 1;
-                src = (unsigned char *)srcDataPtr + offset;
-                dst = (unsigned char *)bmpDataPtr + offset;
+                src_stride = srcSurf->scanline_stride_byte;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride_byte;
-                dststride = w << 2;
+                src_offset = y * src_stride + ((x + w) << 2) - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
                 if(alphaPre){
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             r = *s--;
                             g = *s--;
                             b = *s--;
@@ -294,11 +294,11 @@
                     }
                     srcSurf->isAlphaPre = true;
                 }else{
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             r = *s--;
                             g = *s--;
                             b = *s--;
@@ -325,19 +325,20 @@
             {
                 unsigned char *src, *s, *dst, *d, a, r, g, b;
 
-                offset = (w << 2) - 1;
-                src = (unsigned char *)srcDataPtr + offset;
-                dst = (unsigned char *)bmpDataPtr + offset;
+                src_stride = srcSurf->scanline_stride_byte;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride_byte;
-                dststride = w << 2;
+                src_offset = y * src_stride + ((x + w) << 2) - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
                 if(alphaPre){
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
  
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x =  w; _x > 0; _x--){
                             r = *s--;
                             g = *s--;
                             b = *s--;
@@ -353,11 +354,11 @@
                     }
                     srcSurf->isAlphaPre = true;
                 }else{
-                    for(int y = h; y > 0 ; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
   
-                        for(int x = w; x > 0 ; x--){
+                        for(int _x = w; _x > 0; _x--){
                             r = *s--;
                             g = *s--;
                             b = *s--;
@@ -385,14 +386,6 @@
                 unsigned char *dst, *d;
                 unsigned short *src, *s, pixel;
 
-                offset = (w << 2) - 1;
-                unsigned int srcOffset = w - 1;
-                src = (unsigned short *)srcDataPtr + srcOffset;
-                dst = (unsigned char *)bmpDataPtr + offset;
-
-                srcstride = srcSurf->scanline_stride;
-                dststride = w << 2;
-
                 unsigned int mr = srcSurf->max_red;
                 unsigned int mg = srcSurf->max_green;
                 unsigned int mb = srcSurf->max_red;
@@ -403,10 +396,18 @@
                 unsigned int gs = srcSurf->green_sht;
                 unsigned int bs = srcSurf->blue_sht;
 
-                for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                src_stride = srcSurf->scanline_stride;
+                dst_stride = srcSurf->width << 2;
+
+                src_offset = y * src_stride + x + w - 1;
+                dst_offset = y * dst_stride + ((x + w) << 2) - 1;
+                src = (unsigned short *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
+
+                for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                     d = dst;
                     s = src;
-                    for(int x = w; x > 0; x--){
+                    for(int _x = w; _x > 0; _x--){
                         pixel = *s--;
                         *d-- = 255;
                         *d-- = DIV(mb, ((pixel & rm) >> rs));
@@ -422,16 +423,18 @@
                 unsigned char *dst, *d, pixel;
                 unsigned short *src, *s;
 
-                src = (unsigned short *)srcDataPtr;
-                dst = (unsigned char *)bmpDataPtr;
+                src_stride = srcSurf->scanline_stride;
+                dst_stride = srcSurf->width << 2;
 
-                srcstride = srcSurf->scanline_stride;
-                dststride = w << 2;
+                src_offset = y * src_stride + (x << 1);
+                dst_offset = y * dst_stride + (x << 2);
+                src = (unsigned short *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
-                for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                     s = src;
                     d = dst;
-                    for(int x = w; x > 0; x--){
+                    for(int _x =  w; _x > 0; _x--){
                         pixel = (unsigned char)(*s++ / 257);
                         *d++ = pixel;
                         *d++ = pixel;
@@ -447,19 +450,21 @@
                 unsigned char *src, *s;
                 unsigned int *dst, *d, pixel, bitnum, elem, shift, bitMask;
 
-                src = (unsigned char *)srcDataPtr;
-                dst = (unsigned int *)bmpDataPtr;
-
-                srcstride = srcSurf->scanline_stride;
-                dststride = w;
-
                 unsigned int pixelBits = srcSurf->pixel_stride;
                 int *cm = srcSurf->colormap;
 
-                for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                src_stride = srcSurf->scanline_stride;
+                dst_stride = srcSurf->width;
+
+                src_offset = y * src_stride;
+                dst_offset = y * dst_stride + x;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned int *)bmpDataPtr + dst_offset;
+
+                for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                     d = dst;
 
-                    for(unsigned int x = 0; x < w; x++){
+                    for(int _x = 0; _x < w; _x++){
                         bitnum = x * pixelBits;
                         s = src + bitnum / 8;
                         elem = *s;
@@ -477,31 +482,33 @@
                 int transparency = srcSurf->transparency;
                 unsigned char *src, *s;
                 unsigned int *dst, *d, pixel, r, g, b, a;
-
-                unsigned int offset = w - 1;
-                src = (unsigned char *)srcDataPtr + offset;
-                dst = (unsigned int *)bmpDataPtr + offset;
-
-                srcstride = srcSurf->scanline_stride;
-                dststride = w;
                 int *cm = srcSurf->colormap;
                 int tp = srcSurf->transparent_pixel;
 
+                src_stride = srcSurf->scanline_stride;
+                dst_stride = srcSurf->width;
+
+                src_offset = y * src_stride + x + w - 1;
+                dst_offset = y * dst_stride + x + w - 1;
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned int *)bmpDataPtr + dst_offset;
+
+
                 if(transparency == GL_OPAQUE){
-                    for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0; x--){
+                        for(int _x = w; _x > 0; _x--){
                             *d-- = 0xff000000 | *(cm + *s--);
                         }
                     }
                 }else if(transparency == GL_BITMASK){
-                    for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0; x--){
+                        for(int _x = w; _x > 0; _x--){
                             pixel = *s--;
                             if(pixel != tp){
                                 *d-- = 0xff000000 | *(cm + pixel);
@@ -512,11 +519,11 @@
                         }
                     }
                 }else{
-                    for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                    for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                         s = src;
                         d = dst;
 
-                        for(int x = w; x > 0; x--){
+                        for(int _x = w; _x > 0; _x--){
                             pixel = *(cm + *s--);
                             a = (pixel >> 24) & 0xff;
                             if(alphaPre){
@@ -546,18 +553,19 @@
         case BYTE_GRAY:
             {
                 unsigned char *src, *s, *dst, *d, pixel;
+                src_stride = srcSurf->scanline_stride;
+                dst_stride = srcSurf->width << 2;
 
-                src = (unsigned char *)srcDataPtr;
-                dst = (unsigned char *)bmpDataPtr;
-
-                srcstride = srcSurf->scanline_stride;
-                dststride = w << 2;
+                src_offset = y * src_stride + x;
+                dst_offset = y * dst_stride + (x << 2);
+                src = (unsigned char *)srcDataPtr + src_offset;
+                dst = (unsigned char *)bmpDataPtr + dst_offset;
 
-                for(int y = h; y > 0; y--, src += srcstride, dst += dststride){
+                for(int _y = h; _y > 0; _y--, src += src_stride, dst += dst_stride){
                     s = src;
                     d = dst;
 
-                    for(int x = srcSurf->width; x > 0; x--){
+                    for(int _x = w; _x > 0; _x--){
                         pixel = *s++;
                         *d++ = pixel;
                         *d++ = pixel;
@@ -716,7 +724,7 @@
     SURFACE_STRUCTURE *surf = (SURFACE_STRUCTURE *)ptr;
     jlong cachePtr = 0;
     if(surf != NULL){
-        updateCache(surf, env, data, alphaPre != 0);
+        updateCache(surf, env, data, alphaPre != 0, 0, 0, surf->width, surf->height);
         cachePtr = (jlong)surf->bmpData;
     }
     return cachePtr;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h Sat Oct 27 12:34:30 2007
@@ -162,6 +162,6 @@
 int parseMask(unsigned int, int *, int *);
 int getShift(unsigned int);
 
-extern inline void updateCache(SURFACE_STRUCTURE *, JNIEnv *, jobject, bool);
+extern inline void updateCache(SURFACE_STRUCTURE *, JNIEnv *, jobject, bool, int, int, int, int);
 
 #endif

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.cpp Sat Oct 27 12:34:30 2007
@@ -39,14 +39,14 @@
 JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_GDISurface_dispose
 (JNIEnv *env, jobject obj, jlong surfDataPtr){
 
-    free((void *)surfDataPtr);
+    if(surfDataPtr) free((void *)surfDataPtr);
 }
 
 JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_GDIBlitter_bltBGImage
   (JNIEnv *env, jobject obj, jint srcX, jint srcY, jlong srcSurfStruct, jobject srcData, 
   jint dstX, jint dstY, jlong dstSurfStruct, jint width, jint height, 
-  jint bgcolor, jint compType, jfloat alpha, jdoubleArray matrix, 
-  jintArray clip, jint numVertex, jboolean invalidated){
+  jint bgcolor, jint compType, jfloat alpha, jdoubleArray matrix, jintArray clip, 
+  jint numVertex, jboolean invalidated, jintArray dirtyRegions, jint regCount){
 
       SURFACE_STRUCTURE *srcSurf = (SURFACE_STRUCTURE *)srcSurfStruct;
       SURFACE_STRUCTURE *dstSurf = (SURFACE_STRUCTURE *)dstSurfStruct;
@@ -69,7 +69,23 @@
       HBRUSH brush = CreateSolidBrush(RGB(r, g, b));
       SelectObject(tmpDC, brush);
       PatBlt(tmpDC, 0, 0, w, h, PATCOPY);
-      if(initBitmap(srcSurf, env, srcData, true)){
+      
+      int count;
+      int *regions;
+      if(dirtyRegions == 0){
+          regCount = 1;
+          regions = (int *)malloc(4 * sizeof(int));
+          regions[0] = 0;
+          regions[1] = 0;
+          regions[2] = srcSurf->width - 1;
+          regions[3] = srcSurf->height - 1;
+      } else {
+          count = regCount;
+          regions = (int *)malloc(count * sizeof(int));
+          env->GetIntArrayRegion(dirtyRegions, 1, count, regions);
+      }
+
+      if(initBitmap(srcSurf, env, srcData, true, regions, count)){
           BLENDFUNCTION bf;
           bf.AlphaFormat = AC_SRC_ALPHA;
           bf.BlendOp = AC_SRC_OVER;
@@ -184,8 +200,8 @@
 JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_GDIBlitter_bltImage
   (JNIEnv *env, jobject obj, jint srcX, jint srcY, jlong srcSurfStruct, jobject srcData, 
   jint dstX, jint dstY, jlong dstSurfStruct, jint width, jint height, 
-  jint compType, jfloat alpha, jdoubleArray matrix, 
-  jintArray clip, jint numVertex, jboolean invalidated){
+  jint compType, jfloat alpha, jdoubleArray matrix, jintArray clip, 
+  jint numVertex, jboolean invalidated, jintArray dirtyRegions, jint regCount){
 
       SURFACE_STRUCTURE *srcSurf = (SURFACE_STRUCTURE *)srcSurfStruct;
       SURFACE_STRUCTURE *dstSurf = (SURFACE_STRUCTURE *)dstSurfStruct;
@@ -196,9 +212,24 @@
       memset(&blitStruct, 0, sizeof(BLITSTRUCT));
 
       srcSurf->invalidated = invalidated != 0;
+      
+      int count;
+      int *regions;
+      if(dirtyRegions == 0){
+          regCount = 1;
+          regions = (int *)malloc(4 * sizeof(int));
+          regions[0] = 0;
+          regions[1] = 0;
+          regions[2] = srcSurf->width - 1;
+          regions[3] = srcSurf->height - 1;
+      } else {
+          count = regCount;
+          regions = (int *)malloc(count * sizeof(int));
+          env->GetIntArrayRegion(dirtyRegions, 1, count, regions);
+      }
 
-      if(!initBlitData(srcSurf, env, srcData, compType, srca, &blitStruct)){
-           return;
+      if(!initBlitData(srcSurf, env, srcData, compType, srca, &blitStruct, regions, count)){
+          return;
       }
 
       XFORM currentTransform, transform;
@@ -370,13 +401,29 @@
 JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_GDIBlitter_xorImage
   (JNIEnv *env, jobject obj, jint srcX, jint srcY, jlong srcSurfStruct, jobject srcData, 
   jint dstX, jint dstY, jlong dstSurfStruct, jint width, jint height, jint xorcolor, 
-  jdoubleArray matrix, jintArray clip, jint numVertex, jboolean invalidated){
+  jdoubleArray matrix, jintArray clip, jint numVertex, jboolean invalidated, 
+  jintArray dirtyRegions, jint regCount){
 
       SURFACE_STRUCTURE *srcSurf = (SURFACE_STRUCTURE *)srcSurfStruct;
       SURFACE_STRUCTURE *dstSurf = (SURFACE_STRUCTURE *)dstSurfStruct;
 
       srcSurf->invalidated = invalidated != 0;
-      if(!initBitmap(srcSurf, env, srcData, false)) return;
+
+      int count;
+      int *regions;
+      if(dirtyRegions == 0){
+          regCount = 1;
+          regions = (int *)malloc(4 * sizeof(int));
+          regions[0] = 0;
+          regions[1] = 0;
+          regions[2] = srcSurf->width - 1;
+          regions[3] = srcSurf->height - 1;
+      } else {
+          count = regCount;
+          regions = (int *)malloc(count * sizeof(int));
+          env->GetIntArrayRegion(dirtyRegions, 1, count, regions);
+      }
+      if(!initBitmap(srcSurf, env, srcData, true, regions, count)) return;
 
       BYTE r = (BYTE)((xorcolor >> 16) & 0xff);
       BYTE g = (BYTE)((xorcolor >> 8) & 0xff);
@@ -510,7 +557,7 @@
  }
 
 BOOL initBlitData
-(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, UINT compType, UCHAR srcConstAlpha, BLITSTRUCT *blitStruct){
+(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, UINT compType, UCHAR srcConstAlpha, BLITSTRUCT *blitStruct, int *dirtyRegions, int regCount){
 
     switch(compType){
         case COMPOSITE_CLEAR:
@@ -527,7 +574,7 @@
                 return true;
             }
             if(srcSurf->invalidated || srcSurf->isAlphaPre != false){
-                if(!initBitmap(srcSurf, env, srcData, false)) return false;
+                if(!initBitmap(srcSurf, env, srcData, false, dirtyRegions, regCount)) return false;
             }
             blitStruct->blitFunctintType = BIT_BLT;
             blitStruct->rastOp = SRCCOPY;
@@ -536,7 +583,7 @@
         case COMPOSITE_SRC_OVER:
         case COMPOSITE_SRC_ATOP:
             if(srcSurf->invalidated || srcSurf->isAlphaPre != true){
-                if(!initBitmap(srcSurf, env, srcData, true)) return false;
+                if(!initBitmap(srcSurf, env, srcData, true, dirtyRegions, regCount)) return false;
             }
             if(srcSurf->transparency != GL_OPAQUE || srcConstAlpha != 255){
                 blitStruct->blitFunctintType = ALPHA_BLEND;
@@ -581,17 +628,23 @@
 }
 
 BOOL initBitmap
-(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, bool alphaPre){
+(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, bool alphaPre, int *dirtyRegions, int regCount){
 
     HBITMAP srcBmp = srcSurf->bitmap;
     if(!srcBmp){
         return false;
     }
-    updateCache(srcSurf, env, srcData, alphaPre);
-    if(srcSurf->isTrueColor){
-        SetDIBits(srcSurf->srcDC, srcSurf->bitmap, 0, srcSurf->height, srcSurf->bmpData, (BITMAPINFO *)&srcSurf->bmpInfo, DIB_RGB_COLORS);
-    }else{
-        GdiFlush();
+    for(int i = 0; i < regCount;){
+        int x = dirtyRegions[i++];
+        int y = dirtyRegions[i++];
+        int w = dirtyRegions[i++] - x + 1;
+        int h = dirtyRegions[i++] - y + 1;
+        updateCache(srcSurf, env, srcData, alphaPre, x, y, w, h);
+        if(srcSurf->isTrueColor){
+            SetDIBits(srcSurf->srcDC, srcSurf->bitmap, srcSurf->height - y - h, h, (int *)srcSurf->bmpData + y * srcSurf->width, (BITMAPINFO *)&srcSurf->bmpInfo, DIB_RGB_COLORS);
+        }else{
+            GdiFlush();
+        }
     }
     return true;
 }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.h?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.h (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/GDIBlitter.h Sat Oct 27 12:34:30 2007
@@ -38,10 +38,11 @@
 void findNonExistColor(DWORD &, DWORD *, UINT);
 BOOL isRepeatColor(UINT , DWORD *, UINT);
 
+
 BOOL initBlitData(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, UINT compType, 
-                                UCHAR srcConstAlpha, BLITSTRUCT *blitStruct);
+                                UCHAR srcConstAlpha, BLITSTRUCT *blitStruct, int *, int);
 
-BOOL initBitmap(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, bool alphaPre);
+BOOL initBitmap(SURFACE_STRUCTURE *srcSurf, JNIEnv *env, jobject srcData, bool alphaPre, int *, int);
 
 void CompositeBlt(HDC, jint, jint, jint, jint, SURFACE_STRUCTURE *, void *, jint, jint, UINT, UCHAR, PXFORM, PXFORM);
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_GDIBlitter.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_GDIBlitter.h?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_GDIBlitter.h (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_GDIBlitter.h Sat Oct 27 12:34:30 2007
@@ -47,11 +47,11 @@
     jint, jint, jlong, jint, jint, jlong, jint, jint, jint, jdoubleArray, jintArray, jint);
 
 /*
- * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.xorImage(IIJLjava/lang/Object;IIJIII[D[IIZ)V
+ * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.xorImage(IIJLjava/lang/Object;IIJIII[D[IIZ[II)V
  */
 JNIEXPORT void JNICALL
 Java_org_apache_harmony_awt_gl_windows_GDIBlitter_xorImage(JNIEnv *, jobject, 
-    jint, jint, jlong, jobject, jint, jint, jlong, jint, jint, jint, jdoubleArray, jintArray, jint, jboolean);
+    jint, jint, jlong, jobject, jint, jint, jlong, jint, jint, jint, jdoubleArray, jintArray, jint, jboolean, jintArray, jint);
 
 /*
  * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.bltBitmap(IIJIIJIIIF[D[II)V
@@ -61,18 +61,18 @@
     jint, jint, jlong, jint, jint, jlong, jint, jint, jint, jfloat, jdoubleArray, jintArray, jint);
 
 /*
- * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.bltImage(IIJLjava/lang/Object;IIJIIIF[D[IIZ)V
+ * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.bltImage(IIJLjava/lang/Object;IIJIIIF[D[IIZ[II)V
  */
 JNIEXPORT void JNICALL
 Java_org_apache_harmony_awt_gl_windows_GDIBlitter_bltImage(JNIEnv *, jobject, 
-    jint, jint, jlong, jobject, jint, jint, jlong, jint, jint, jint, jfloat, jdoubleArray, jintArray, jint, jboolean);
+    jint, jint, jlong, jobject, jint, jint, jlong, jint, jint, jint, jfloat, jdoubleArray, jintArray, jint, jboolean, jintArray, jint);
 
 /*
- * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.bltBGImage(IIJLjava/lang/Object;IIJIIIIF[D[IIZ)V
+ * Method: org.apache.harmony.awt.gl.windows.GDIBlitter.bltBGImage(IIJLjava/lang/Object;IIJIIIIF[D[IIZ[II)V
  */
 JNIEXPORT void JNICALL
 Java_org_apache_harmony_awt_gl_windows_GDIBlitter_bltBGImage(JNIEnv *, jobject, 
-    jint, jint, jlong, jobject, jint, jint, jlong, jint, jint, jint, jint, jfloat, jdoubleArray, jintArray, jint, jboolean);
+    jint, jint, jlong, jobject, jint, jint, jlong, jint, jint, jint, jint, jfloat, jdoubleArray, jintArray, jint, jboolean, jintArray, jint);
 
 
 #ifdef __cplusplus

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JPEGDecoder.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JPEGDecoder.h?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JPEGDecoder.h (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JPEGDecoder.h Sat Oct 27 12:34:30 2007
@@ -33,7 +33,8 @@
 
 #include "exceptions.h"
 
-#define MAX_BUFFER 32768
+#define MIN_BUFFER 32768
+#define MAX_BUFFER 33554432
 
 jfieldID img_JPEG_imageWidthID;
 jfieldID img_JPEG_imageHeightID;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JpegDecoder.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JpegDecoder.c?rev=589194&r1=589193&r2=589194&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JpegDecoder.c (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/jpegdecoder/shared/JpegDecoder.c Sat Oct 27 12:34:30 2007
@@ -107,7 +107,10 @@
     cinfo->src->bytes_in_buffer = (size_t) srcmgr->valid_buffer_length;
 }
 
-GLOBAL(boolean) gl_jpeg_init_source_mgr(j_decompress_ptr cinfo) {
+GLOBAL(boolean) gl_jpeg_init_source_mgr(j_decompress_ptr cinfo, int bufferSize) {
+
+  int perfBufferSize;
+
   gl_jpeg_source_mgr* mgr = (gl_jpeg_source_mgr*) cinfo->src;
   // jpeg_source_mgr fields
   mgr->base.init_source = gl_jpeg_dummy_decompress;
@@ -116,7 +119,15 @@
     mgr->base.resync_to_restart = jpeg_resync_to_restart; // Use default
     mgr->base.term_source = gl_jpeg_dummy_decompress;
   
-  mgr->buffer_size = MAX_BUFFER;
+  perfBufferSize = bufferSize * 8;
+ 
+  if (perfBufferSize < MIN_BUFFER) {
+      mgr->buffer_size = MIN_BUFFER;
+  } else if (perfBufferSize > MAX_BUFFER){
+      mgr->buffer_size = MAX_BUFFER;
+  } else {
+      mgr->buffer_size = perfBufferSize;
+  }
   mgr->jpeg_buffer = malloc(mgr->buffer_size);
   if(!mgr->jpeg_buffer) {
     return FALSE;
@@ -162,7 +173,7 @@
   throwNewExceptionByName(env, "java/lang/OutOfMemoryError", "Out of memory");
 }
 
-GLOBAL(void) gl_decompress_struct_init(gl_decompress_struct** glDecompressPtr) {
+GLOBAL(void) gl_decompress_struct_init(gl_decompress_struct** glDecompressPtr, int bufferSize) {
   gl_decompress_struct* glDecompress = *glDecompressPtr;
 
   if(glDecompress == NULL) { // Allocate new decompress struct
@@ -186,7 +197,7 @@
 
   // Set up source manager
   glDecompress->decompress.src = &(glDecompress->srcMgr.base);
-  if(!gl_jpeg_init_source_mgr(&glDecompress->decompress)) { // Out of memory
+  if(!gl_jpeg_init_source_mgr(&glDecompress->decompress, bufferSize)) { // Out of memory
     free(glDecompress);
     *glDecompressPtr = NULL;
     return;
@@ -314,7 +325,7 @@
     (gl_decompress_struct*) ((IDATA)hglDecompress);
 
   if(glDecompress == NULL) {
-    gl_decompress_struct_init(&glDecompress);
+    gl_decompress_struct_init(&glDecompress, bytesInBuffer);
     if(glDecompress == NULL) { // Out of memory
       outOfMemory(env, obj, NULL);
       return 0;



Mime
View raw message