harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r593146 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main: java/windows/org/apache/harmony/awt/gl/windows/ native/gl/windows/ native/gl/windows/include/
Date Thu, 08 Nov 2007 12:54:46 GMT
Author: apetrenko
Date: Thu Nov  8 04:54:45 2007
New Revision: 593146

URL: http://svn.apache.org/viewvc?rev=593146&view=rev
Log:
Initial version of GDI based Graphics2D class implementation
Part of HARMONY-5039

Added:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java   (with props)
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp   (with props)
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h   (with props)

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java?rev=593146&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java Thu Nov  8 04:54:45 2007
@@ -0,0 +1,593 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Vladimir A. Strigun
+ * @version $Revision$
+ */
+package org.apache.harmony.awt.gl.windows;
+
+import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.Paint;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import org.apache.harmony.awt.gl.CommonGraphics2D;
+import org.apache.harmony.awt.gl.MultiRectArea;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.NativeFont;
+import org.apache.harmony.awt.gl.font.fontlib.FLTextRenderer;
+import org.apache.harmony.awt.wtk.NativeWindow;
+
+
+/**
+ * Graphics2D implementation for Windows GDI library
+ *
+ */
+public class WinGDIGraphics2D extends CommonGraphics2D {
+    private NativeWindow nw = null;
+    private long hdc = 0;
+    private long gi = 0;
+
+    private final Dimension size;
+
+    GraphicsConfiguration config = null;
+
+    private WinVolatileImage img = null;
+
+    // These two flags shows are current Stroke and
+    // Paint transferred to native objects or not.
+    private boolean nativePen = false;
+    private boolean nativeBrush = false;
+
+    // This array is used for passing Path data to
+    // native code.
+    // It is not thread safe.
+    // But WTK guys think that Graphics should not
+    // be called from different threads
+    private float []pathArray = null;
+    private float []pathPoints = null;
+
+
+    static {
+        System.loadLibrary("gl"); //$NON-NLS-1$
+    }
+
+    public WinGDIGraphics2D(NativeWindow nw, int tx, int ty, MultiRectArea clip) {
+        super(tx, ty, clip);
+        this.nw = nw;
+
+        Rectangle b = clip.getBounds();
+        size = new Dimension(b.width, b.height);
+
+        gi = createGraphicsInfo(this.nw.getId(), tx, ty, b.width, b.height);
+        setTransformedClip(this.clip);        
+        if (!FontManager.IS_FONTLIB) {
+            jtr = GDITextRenderer.inst;
+        }
+        dstSurf = new GDISurface(gi);
+        blitter = GDIBlitter.getInstance();
+        setTransform(getTransform());
+    }
+
+    public WinGDIGraphics2D(NativeWindow nw, int tx, int ty, int width, int height) {
+        super(tx, ty);
+        this.nw = nw;
+
+        size = new Dimension(width, height);
+
+        gi = createGraphicsInfo(this.nw.getId(), tx, ty, width, height);
+        //setTransformedClip(this.clip);
+        if (!FontManager.IS_FONTLIB) {
+            jtr = GDITextRenderer.inst;
+        }
+        dstSurf = new GDISurface(gi);
+        blitter = GDIBlitter.getInstance();
+        if (debugOutput) {
+            System.err.println("WinGDIGraphics2D("+nw+", "+tx+", "+ty+", "+width+", "+height+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+        }
+        setTransform(getTransform());
+
+    }
+
+    public WinGDIGraphics2D(WinVolatileImage img, int width, int height) {
+        this(img, 0, width, height);
+    }
+
+    public WinGDIGraphics2D(WinVolatileImage img, long ogi, int width, int height) {
+        super();
+        size = new Dimension(width, height);
+        this.img = img;
+        if (ogi != 0) {
+            this.gi = copyImageInfo(ogi);
+        } else {
+            this.gi = copyImageInfo(img.gi);
+        }
+        setTransformedClip(this.clip);
+        dstSurf = img.getImageSurface();
+        blitter = GDIBlitter.getInstance();
+        if (!FontManager.IS_FONTLIB) {
+            jtr = GDITextRenderer.inst;
+        }        
+        setTransform(getTransform());
+    }
+
+    @Override
+    public void addRenderingHints(Map<?,?> hints) {
+        super.addRenderingHints(hints);
+        if (!FontManager.IS_FONTLIB) {
+            Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+            if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
+                NativeFont.setAntialiasing(gi,true);
+            } else {
+                NativeFont.setAntialiasing(gi,false);
+            }
+        }
+    }
+    
+    @Override
+    public void copyArea(int x, int y, int width, int height, int dx, int dy) {
+        copyArea(gi, x, y, width, height, dx, dy);
+    }
+
+    @Override
+    public Graphics create() {
+        if (debugOutput) {
+            System.err.println("WinGDIGraphics2D.create()"); //$NON-NLS-1$
+        }
+
+        WinGDIGraphics2D res = null;
+        if (img == null) {
+            res = new WinGDIGraphics2D(nw, origPoint.x, origPoint.y, size.width, size.height);
+        } else {
+            res = new WinGDIGraphics2D(img, gi, size.width, size.height);
+        }
+        copyInternalFields(res);
+        return res;
+    }
+
+    @Override
+    public GraphicsConfiguration getDeviceConfiguration() {
+        if (config == null) {
+            if (img == null) {
+                config = new WinGraphicsConfiguration(nw.getId(), getDC());
+            } else {
+                long hwnd = img.getHWND();
+                if(hwnd != 0){
+                    config = new WinGraphicsConfiguration(hwnd, getDC());
+                }else{
+                    config = img.getGraphicsConfiguration();
+                }
+            }
+        }
+
+        return config;
+    }
+
+    @Override
+    protected void fillMultiRectAreaPaint(MultiRectArea mra) {
+        if (nativeBrush) {
+            fillRects(gi, mra.rect, mra.rect[0]-1);
+        } else {
+            super.fillMultiRectAreaPaint(mra);
+        }
+    }
+
+
+
+
+    /***************************************************************************
+     *
+     *  Overriden methods
+     *
+     ***************************************************************************/
+
+    @Override
+    public void setColor(Color color) {
+        if (color == null) {
+            return;
+        }
+        super.setColor(color);
+        setSolidBrush(gi, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
+        nativeBrush = true;
+        setStroke(getStroke());
+    }
+
+
+    //REMARK: It seems that transfrom affects paints too
+    //REMARK: Think how to implement this
+    @Override
+    public void setPaint(Paint paint) {
+        if (paint == null)
+            return;
+            
+        if (paint instanceof Color) {
+            setColor((Color)paint);
+        } else {
+            this.paint = paint;
+            nativeBrush = false;
+            if (paint instanceof GradientPaint) {
+                GradientPaint p = (GradientPaint)paint;
+                if (!p.isCyclic()) {
+                    return;
+                }
+                Color c1 = p.getColor1();
+                Color c2 = p.getColor2();
+                Point2D p1 = transform.transform(p.getPoint1(), null);
+                Point2D p2 = transform.transform(p.getPoint2(), null);
+                setLinearGradientBrush(gi, (int)Math.round(p1.getX()), (int)Math.round(p1.getY()), c1.getRed(), c1.getGreen(), c1.getBlue(), c1.getAlpha(),
+                                           (int)Math.round(p2.getX()), (int)Math.round(p2.getY()), c2.getRed(), c2.getGreen(), c2.getBlue(), c2.getAlpha(), p.isCyclic());
+                nativeBrush = true;
+            }
+            setStroke(getStroke());
+        }
+    }
+
+    @Override
+    public void dispose() {
+        if (gi == 0) {
+            return;
+        }
+        if (dstSurf instanceof GDISurface) {
+            dstSurf.dispose();
+        }
+        disposeGraphicsInfo(gi);
+        gi = 0;
+        super.dispose();
+        if (debugOutput) {
+            System.err.println("WinGDIGraphics2D.dispose()"); //$NON-NLS-1$
+        }
+    }
+
+    @Override
+    public void drawGlyphVector(GlyphVector gv, float x, float y) {
+        jtr.drawGlyphVector(this, gv, x, y);
+    }
+
+    @Override
+    public void drawString(String str, float x, float y) {
+        jtr.drawString(this, str, x, y);
+    }
+
+    @Override
+    public void setStroke(Stroke stroke) {
+        super.setStroke(stroke);
+        nativePen = nativeBrush && stroke instanceof BasicStroke;
+        if (!nativePen) {
+            deletePen(gi);
+            return;
+        }
+
+        BasicStroke bs = (BasicStroke)stroke;
+        float []dash = bs.getDashArray();
+        if (dash != null && dash.length % 2 == 1) {
+            // If dash len is odd then we need to double the array           
+            float []newDash = new float[dash.length*2];
+            System.arraycopy(dash, 0, newDash, 0, dash.length);
+            System.arraycopy(dash, 0, newDash, dash.length, dash.length);
+            dash = newDash;
+        }
+        setPen(gi, bs.getLineWidth(), bs.getEndCap(), bs.getLineJoin(), bs.getMiterLimit(),
+                dash, (dash != null)?dash.length:0, bs.getDashPhase());
+    }
+
+    @Override
+    public void draw(Shape s) {
+        if (!nativePen) {
+            super.draw(s);
+            return;
+        }
+
+        PathIterator pi = s.getPathIterator(transform, 0.5);
+        int len = getPathArray(pi);
+        drawShape(gi, pathArray, len, pi.getWindingRule());
+    }
+
+    @Override
+    public void drawLine(int x1, int y1, int x2, int y2) {
+        if (!nativePen) {
+            super.drawLine(x1, y1, x2, y2);
+            return;
+        }
+
+        drawLine(gi, x1, y1, x2, y2);
+    }
+
+    @Override
+    public void drawRect(int x, int y, int width, int height) {
+        if (!nativePen) {
+            super.drawRect(x, y, width, height);
+            return;
+        }
+
+        drawRect(gi, x, y, width, height);
+    }
+
+    @Override
+    public void drawOval(int x, int y, int width, int height) {
+        if (!nativePen) {
+            super.drawOval(x, y, width, height);
+            return;
+        }
+
+        drawOval(gi, x, y, width, height);
+    }
+
+    @Override
+    public void fill(Shape s) {
+        if (!nativeBrush || composite != AlphaComposite.SrcOver) {
+            s = transform.createTransformedShape(s);
+            MultiRectArea mra = jsr.rasterize(s, 0.5);
+            super.fillMultiRectAreaPaint(mra);
+            return;
+        }
+
+        PathIterator pi = s.getPathIterator(transform, 0.5);
+        int len = getPathArray(pi);
+        fillShape(gi, pathArray, len, pi.getWindingRule());
+    }
+
+    @Override
+    public void fillRect(int x, int y, int width, int height) {
+        if (!nativeBrush || composite != AlphaComposite.SrcOver) {
+            Shape s = transform.createTransformedShape(new Rectangle(x, y, width, height));
+            MultiRectArea mra = jsr.rasterize(s, 0.5);
+            super.fillMultiRectAreaPaint(mra);
+            return;
+        }
+
+        fillRect(gi, x, y, width, height);
+    }
+
+    /**
+     * Sets native clip to specified area
+     * 
+     * @param clip Transformed clip to set
+     */
+    @Override
+    protected void setTransformedClip(MultiRectArea clip) {
+        super.setTransformedClip(clip);
+        if (gi == 0) {
+            return;
+        }
+        if (clip == null) {
+            resetClip(gi);
+        } else {
+            setClip(gi, clip.rect, clip.rect[0]-1);
+        }
+    }
+
+    /***************************************************************************
+    *
+    *  Transformation methods
+    *
+    ***************************************************************************/
+
+    @Override
+    public void setTransform(AffineTransform transform) {
+        super.setTransform(transform);
+        if (gi == 0) {
+            return;
+        }
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void rotate(double theta) {
+        super.rotate(theta);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void rotate(double theta, double x, double y) {
+        super.rotate(theta, x, y);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void scale(double sx, double sy) {
+        super.scale(sx, sy);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void shear(double shx, double shy) {
+        super.shear(shx, shy);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void transform(AffineTransform at) {
+        super.transform(at);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void translate(double tx, double ty) {
+        super.translate(tx, ty);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    @Override
+    public void translate(int tx, int ty) {
+        super.translate(tx, ty);
+
+        setNativeTransform(gi, matrix);
+    }
+
+    /***************************************************************************
+    *
+    *  Class specific methods
+    *
+    ***************************************************************************/
+
+    /**
+     * Returns handle to underlying device context
+     */
+    public long getDC() {
+        if (hdc == 0) {
+            hdc = getDC(gi);
+        }
+        return hdc;
+    }
+
+    /**
+     * Returns pointer to underlying native GraphicsInfo structure
+     *  
+     * @return Pointer to GraphicsInfo structure
+     */
+    public long getGraphicsInfo() {
+        return gi;
+    }
+
+   /***************************************************************************
+    *
+    *  Private methods
+    *
+    ***************************************************************************/
+    /**
+     * Converts PathIterator into array of int values. This array is
+     * stored in pathArray field.
+     * Array then used to pass Shape to native drawing routines
+     * 
+     * @param pi PathIterator recieved from Shape
+     * @return Number of result array elements.
+     */
+    private int getPathArray(PathIterator pi) {
+        if (pathArray == null) {
+            pathArray = new float[8192];
+            pathPoints = new float[6];
+        }
+
+        int i = 0;
+
+        while (!pi.isDone()) {
+            int seg = pi.currentSegment(pathPoints);
+            pathArray[i++] = seg;
+            switch (seg) {
+                case PathIterator.SEG_MOVETO:
+                case PathIterator.SEG_LINETO:
+                    pathArray[i++] = pathPoints[0];
+                    pathArray[i++] = pathPoints[1];
+                    break;
+                case PathIterator.SEG_CLOSE:
+                    break;
+            }
+            pi.next();
+        }
+        return i;
+    }
+
+    /***************************************************************************
+     *
+     *  Native methods
+     *
+     ***************************************************************************/
+
+
+    // Creates native GraphicsInfo structure
+    private native long createGraphicsInfo(long hwnd, int x, int y, int width, int height);
+    static native long createCompatibleImageInfo(long hwnd, int width, int height);
+    static native long createCompatibleImageInfo(byte[] bytes, int width, int height);
+    private native long copyImageInfo(long gi);
+
+    // Releases GraphicsInfo structure
+    static native void disposeGraphicsInfo(long gi);
+
+    private native void copyArea(long gi, int x, int y, int width, int height, int dx, int dy);
+    
+    // Methods to set solid and gradient brushes
+    private native void setSolidBrush(long gi, int r, int g, int b, int a);
+    private native void setLinearGradientBrush(long gi, int x1, int y1, int r1, int g1, int b1, int a1, int x2, int y2, int r2, int g2, int b2, int a2, boolean cyclic);
+    
+    // Fills specified rectangles by native brush
+    private native void fillRects(long gi, int []vertices, int len);
+
+    private native long getDC(long gi);
+
+    //Pen manipulation routins
+    private native boolean setPen(long gi, float lineWidth, int endCap, int lineJoin, float miterLimit, float[] dashArray, int dashLen, float dashPhase);
+    private native void deletePen(long gi);
+
+    // Draw/Fill Shape/GraphicsPath
+    private native void drawShape(long gi, float []path, int len, int winding);
+    private native void fillShape(long gi, float []path, int len, int winding);
+
+    // Draw native primitives
+    private native void drawLine(long gi, int x1, int y1, int x2, int y2);
+    private native void drawRect(long gi, int x, int y, int width, int height);
+    private native void drawOval(long gi, int x, int y, int width, int height);
+
+    // Fill native primitives
+    private native void fillRect(long gi, int x, int y, int width, int height);
+
+    @Override
+    public void setRenderingHint(RenderingHints.Key key, Object value) {
+        super.setRenderingHint(key,value);
+        if (!FontManager.IS_FONTLIB) {
+            Object val = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+            if (val == RenderingHints.VALUE_ANTIALIAS_ON) {
+                NativeFont.setAntialiasing(gi,true);
+            } else {
+                NativeFont.setAntialiasing(gi,false);
+            }
+        }
+    }
+
+    @Override
+    public void setRenderingHints(Map<?,?> hints) {
+        super.setRenderingHints(hints);
+        if (!FontManager.IS_FONTLIB) {
+            Object value = this.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+            if (value == RenderingHints.VALUE_ANTIALIAS_ON) {
+                NativeFont.setAntialiasing(gi,true);
+            } else {
+                NativeFont.setAntialiasing(gi,false);
+            }
+        }
+    }
+
+
+    // Set native clip
+    private native void setClip(long gi, int[] vertices, int len);
+    private native void resetClip(long gi);
+
+    // Update native affine transform matrix
+    private native void setNativeTransform(long gi, double[] matrix);
+
+
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp?rev=593146&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp Thu Nov  8 04:54:45 2007
@@ -0,0 +1,754 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Vladimir A. Strigun
+ * @version $Revision$
+ */
+#include <jni.h>
+
+#include <stdio.h>
+
+#include "gl_GDI.h"
+#include "java_awt_BasicStroke.h"
+#include "java_awt_geom_PathIterator.h"
+#include "org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h"
+
+static jclass classSystem = NULL;
+static jmethodID gcMethodID = NULL;
+
+/*
+ * This method is used when application runs out of GDI resources.
+ * Garbage collector should destroy unneeded classes and release some GDI resources
+ */
+static inline int runGC(JNIEnv *env) {
+    if (!classSystem || !gcMethodID) {
+        classSystem = env->FindClass("java/lang/System");
+        if (!classSystem)
+            return 0;
+        gcMethodID = env->GetStaticMethodID(classSystem, "gc", "()V");
+        if (!gcMethodID)
+            return 0;
+    }
+    
+    env->CallStaticVoidMethod(classSystem, gcMethodID);
+    return 1;
+}
+
+static jclass runtimeException = NULL;
+
+/*
+ * This methods throws RuntimeException with
+ * "Out of GDI resources." message
+ */
+static inline void throwRuntimeException(JNIEnv *env) {
+    if (!runtimeException) {
+        runtimeException = env->FindClass("java/lang/RuntimeException");
+    }
+    
+    env->ThrowNew(runtimeException, "Out of GDI resources.");
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    createGraphicsInfo
+ * Signature: (JIIII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createGraphicsInfo
+  (JNIEnv *env, jobject obj, jlong hwnd, jint x, jint y, jint width, jint height) {
+    //fprintf(stderr, "createGraphicsInfo\n");
+    GraphicsInfo *gi = (GraphicsInfo *) malloc(sizeof(GraphicsInfo));
+    
+    gi->hwnd = (HWND)hwnd;
+    gi->hdc = GetDC(gi->hwnd);
+    gi->hpen = NULL;
+    gi->hbrush = NULL;
+    //initialize default transform
+    XFORM xform; xform.eM11=1; xform.eM12=0;  xform.eM21=0;  xform.eM22=1;  xform.eDx=0;  xform.eDy=0;
+    gi->xform = xform;
+
+    return (jlong)gi;
+}
+
+/*
+ * Creates compatible GraphicsInfo structure for specified device context
+ */
+static inline GraphicsInfo *createCompatibleImageInfo(JNIEnv *env, HDC hdc, jint width, jint height) {
+    GraphicsInfo *gi = (GraphicsInfo *) malloc(sizeof(GraphicsInfo));
+
+       // To avoid issue of joint operation Windows NetMeeting and GL,
+       // we create HDC and Bitmap for Volatile Image which will compatible 
+       // HDC of the entire screen. It may leads to other issues on 
+       // multimonitor systems in the future.
+    
+    gi->hwnd = 0;
+    HDC dc = GetDC(NULL);
+    gi->hdc = CreateCompatibleDC(dc);
+    if (gi->hdc == NULL) {
+        // We are out of GDI resources
+        runGC(env);
+        gi->hdc = CreateCompatibleDC(dc);
+        if (gi->hdc == NULL)
+            throwRuntimeException(env);
+    }
+        
+    
+    // Creating bitmap and setting it to DC
+    gi->bmp = CreateCompatibleBitmap(dc, width, height);
+    if (gi->bmp == NULL) {
+        // We are out of GDI resources
+        runGC(env);
+        gi->bmp = CreateCompatibleBitmap(dc, width, height);
+        if (gi->bmp == NULL)
+            throwRuntimeException(env);
+    }
+    SelectObject(gi->hdc, gi->bmp);
+       ReleaseDC(NULL, dc);
+    
+    gi->hpen=NULL;
+    gi->hbrush=NULL;
+    gi->hrgn=NULL;
+
+    XFORM xform; xform.eM11=1; xform.eM12=0;  xform.eM21=0;  xform.eM22=1;  xform.eDx=0;  xform.eDy=0;
+    gi->xform = xform;
+    return gi; 
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    createCompatibleImageInfo
+ * Signature: (JII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createCompatibleImageInfo__JII
+  (JNIEnv *env, jclass clazz, jlong hwnd, jint width, jint height) {
+    HDC hdc = GetWindowDC((HWND)hwnd);
+    
+    GraphicsInfo *gi = createCompatibleImageInfo(env, hdc, width, height);
+
+    ReleaseDC((HWND)hwnd, hdc);
+    return (jlong)gi;
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    createCompatibleImageInfo
+ * Signature: ([BII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createCompatibleImageInfo___3BII
+  (JNIEnv *env, jclass clazz, jbyteArray ida, jint width, jint height) {
+    char *id = (char *)env->GetByteArrayElements(ida, NULL);
+    HDC hdc = CreateDC(NULL, id, NULL, NULL);
+    env->ReleaseByteArrayElements(ida, (jbyte *)id, JNI_ABORT);
+    
+    GraphicsInfo *gi = createCompatibleImageInfo(env, hdc, width, height);
+
+    DeleteDC(hdc);
+    return (jlong)gi;
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    copyImageInfo
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_copyImageInfo
+  (JNIEnv *env , jobject obj, jlong poriggi) {
+    GraphicsInfo *gi = (GraphicsInfo *) malloc(sizeof(GraphicsInfo));
+    GraphicsInfo *origgi = (GraphicsInfo *)poriggi;
+    
+    gi->hwnd = 0;
+    gi->hdc = origgi->hdc;
+    gi->bmp = 0;
+    gi->hpen = origgi->hpen;
+    gi->hbrush= origgi->hbrush;
+    XFORM xform; xform.eM11=origgi->xform.eM11; xform.eM12=origgi->xform.eM12;  xform.eM21=origgi->xform.eM21;  xform.eM22=origgi->xform.eM22;  xform.eDx=origgi->xform.eDx;  xform.eDy=origgi->xform.eDy;
+    gi->xform = xform;
+    gi->hrgn = NULL;
+
+    return (jlong)gi;
+}
+
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    disposeGraphicsInfo
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_disposeGraphicsInfo
+  (JNIEnv *env, jclass clazz, jlong pgi) {
+    GraphicsInfo *gi = (GraphicsInfo *)pgi;
+    
+    if (gi == 0)
+        return;
+
+    if(gi->hpen)
+        DeleteObject(gi->hpen);
+    if(gi->hrgn){
+        DeleteObject(gi->hrgn);
+    }
+    if(gi->hbrush)
+        DeleteObject(gi->hbrush);
+
+    // If hwnd and bmp are 0 then we should not destroy HDC 
+    // because it's a copy of VolatileImage
+    if (gi->hwnd != 0 || gi->bmp != 0) {    
+        if (gi->bmp)
+            DeleteObject(gi->bmp);
+        
+        if (gi->hwnd)
+            ReleaseDC(gi->hwnd, gi->hdc);
+        else
+            DeleteDC(gi->hdc);
+    }
+
+    free(gi);
+
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    copyArea
+ * Signature: (JIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_copyArea
+  (JNIEnv *env, jobject obj, jlong gip, jint x, jint y, jint width, jint height, jint dx, jint dy) 
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    int x1, y1;
+    x1 =(int)( x * gi->xform.eM11 + y * gi->xform.eM21 + gi->xform.eDx );
+    y1 =(int)( x * gi->xform.eM12 + y * gi->xform.eM22 + gi->xform.eDy );
+    BitBlt(gi->hdc, x1+dx, y1+dy, width, height, gi->hdc, x1, y1, SRCCOPY);
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setSolidBrush
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setSolidBrush
+  (JNIEnv *env, jobject obj, jlong pgi, jint r, jint g, jint b, jint a) {
+    //fprintf(stderr, "setSolidBrush\n");
+    GraphicsInfo *gi = (GraphicsInfo *)pgi;
+    
+    if (gi->hbrush)
+        DeleteObject(gi->hbrush);
+    gi->color=RGB(r,g,b);
+    gi->hbrush = CreateSolidBrush(RGB(r, g, b));
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setLinearGradientBrush
+ * Signature: (JIIIIIIIIIIIIZ)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setLinearGradientBrush
+  (JNIEnv *env, jobject obj, jlong pgi, jint x1, jint y1, jint r1, jint g1, jint b1, jint a1, jint x2, jint y2, jint r2, jint g2, jint b2, jint a2, jboolean cyclic) {
+    //fprintf(stderr, "setLinearGradientBrush\n");
+    GraphicsInfo *gi = (GraphicsInfo *)pgi;
+    printf("linearGradientBrush is not implemented yet\n");
+}  
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    fillRects
+ * Signature: (J[I)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_fillRects
+  (JNIEnv *env, jobject obj, jlong pgi, jintArray va, jint len) {
+    //fprintf(stderr, "fillRects: %d\n", len);
+    GraphicsInfo *gi = (GraphicsInfo *)pgi;
+    
+    if (len < 4)
+        return;
+
+    HDC hdc = gi->hdc;
+    SelectClipRgn(hdc, gi->hrgn);
+    jint *vertices = (jint *)malloc(sizeof(jint)*len);
+    env->GetIntArrayRegion(va, 1, len, vertices);
+    for (int i = 0; i < len; i += 4) {
+        int x = vertices[i];
+        int y = vertices[i+1];
+        int x1 = vertices[i+2];
+        int y1 = vertices[i+3];
+        HRGN hrgn = CreateRectRgn(x,y,x1,y1);
+        FillRgn(hdc, hrgn, gi->hbrush);
+        DeleteObject(hrgn);
+    }
+    free(vertices);
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    getDC
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_getDC
+  (JNIEnv *env, jobject obj, jlong gip) {
+    return (jlong)((GraphicsInfo *)gip)->hdc;
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setPen
+ * Signature: (JFIIF[FIF)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setPen
+  (JNIEnv *env, jobject obj, jlong gip, jfloat lineWidth, jint endCap, jint lineJoin, jfloat miterLimit, jfloatArray jdash, jint dashLen, jfloat dashPhase)
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    jboolean res = JNI_TRUE;
+    if(gi->hpen)
+        DeleteObject(gi->hpen);
+    if(dashLen == 0 && lineJoin == java_awt_BasicStroke_JOIN_MITER && endCap == java_awt_BasicStroke_CAP_SQUARE) {
+        gi->hpen = CreatePen(PS_SOLID, (int)lineWidth, gi->color);
+        return res;
+    }
+
+    DWORD penStyle;
+    penStyle = PS_GEOMETRIC;
+    LOGBRUSH lb;
+    if(dashLen == 0) {
+        lb.lbStyle = BS_SOLID; 
+    } else {
+        lb.lbStyle = PS_SOLID; 
+        penStyle |= PS_USERSTYLE;
+    }
+
+    switch (endCap) {
+        case java_awt_BasicStroke_CAP_BUTT:
+            penStyle |= PS_ENDCAP_FLAT;
+            break;
+
+        case java_awt_BasicStroke_CAP_SQUARE:
+            penStyle |= PS_ENDCAP_SQUARE;
+            break;
+
+        case java_awt_BasicStroke_CAP_ROUND:
+            penStyle |= PS_ENDCAP_ROUND;
+            break;
+    }
+
+    switch (lineJoin) {
+        case java_awt_BasicStroke_JOIN_BEVEL:
+            penStyle |= PS_JOIN_BEVEL;
+            break;
+
+        case java_awt_BasicStroke_JOIN_MITER:
+            penStyle |= PS_JOIN_MITER;
+            break;
+
+        case java_awt_BasicStroke_JOIN_ROUND:
+            penStyle |= PS_JOIN_ROUND;
+            break;
+    }
+
+    lb.lbColor = gi->color;
+
+    if (dashLen == 0) {
+        gi->hpen = ExtCreatePen(penStyle, (int)lineWidth, &lb, 0, NULL);
+        return res;
+    }
+    float *dash = (float *)env->GetPrimitiveArrayCritical(jdash, 0);
+    DWORD *dashes = new DWORD[dashLen];
+    for(int i=0; i<dashLen; i++)
+        dashes[i] = (DWORD)dash[i];
+    gi->hpen = ExtCreatePen(penStyle, (int)lineWidth, &lb, dashLen, dashes);
+    delete [] dashes;
+    env->ReleasePrimitiveArrayCritical(jdash, dash, JNI_ABORT);
+
+    return res;
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    deletePen
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_deletePen
+  (JNIEnv *env, jobject obj, jlong gip) 
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    if (gi->hpen)
+        DeleteObject(gi->hpen);
+    gi->hpen = NULL;
+}
+
+
+static inline void createGDIPath(JNIEnv *env, HDC dc, jfloatArray jpath, jint len, jint winding) 
+{
+    jfloat *path = (jfloat *)malloc(sizeof(jfloat)*len);
+    env->GetFloatArrayRegion(jpath, 0, len, path);
+
+    if(winding == java_awt_geom_PathIterator_WIND_EVEN_ODD)
+        SetPolyFillMode(dc, ALTERNATE);
+    else 
+        SetPolyFillMode(dc, WINDING);
+
+    BeginPath(dc);
+
+    float x1 = 0;
+    float y1 = 0;
+    float mx = 0;
+    float my = 0;
+    for (int i = 0; i < len; i++) {
+        int seg = (int)path[i];
+        switch (seg) {
+            case java_awt_geom_PathIterator_SEG_MOVETO:
+                x1 = path[i+1];
+                y1 = path[i+2];
+                mx = path[i+1];
+                my = path[i+2];
+                MoveToEx(dc, (int)x1, (int)y1, NULL);
+                i += 2;
+                break;
+            case java_awt_geom_PathIterator_SEG_LINETO:
+                LineTo(dc, (int)x1, (int)y1);
+                x1 = path[i+1];
+                y1 = path[i+2];
+                i += 2;
+                break;
+            case java_awt_geom_PathIterator_SEG_CLOSE:
+                LineTo(dc, (int)x1, (int)y1);
+                x1 = mx;
+                y1 = my;
+                CloseFigure(dc);
+                break;
+        }
+    }
+   
+   EndPath(dc);
+}    
+
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawShape
+ * Signature: (J[FI)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawShape
+  (JNIEnv *env, jobject obj, jlong gip, jfloatArray jpath, jint len, jint winding)
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+
+    HDC hdc = gi->hdc;
+    HGDIOBJ hPenOld = SelectObject(hdc, gi->hpen);
+    HGDIOBJ hBrushOld = SelectObject(hdc, gi->hbrush);
+    SelectClipRgn(hdc, gi->hrgn);
+    BeginPath(hdc);
+    createGDIPath(env, hdc, jpath, len, winding);
+    StrokePath(hdc);
+    SelectObject(hdc, hPenOld);
+    SelectObject(hdc, hBrushOld);
+    DeleteObject(hPenOld);
+    DeleteObject(hBrushOld);
+}
+
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    fillShape
+ * Signature: (J[FI)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_fillShape
+  (JNIEnv *env, jobject obj, jlong gip, jfloatArray jpath, jint len, jint winding)
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+
+    HDC hdc = gi->hdc;
+    HGDIOBJ hPenOld = SelectObject(hdc, gi->hpen);
+    HGDIOBJ hBrushOld = SelectObject(hdc, gi->hbrush);
+    SelectClipRgn(hdc, gi->hrgn);
+    BeginPath(hdc);
+    createGDIPath(env, hdc, jpath, len, winding);
+    FillPath(hdc);
+    SelectObject(hdc, hPenOld);
+    SelectObject(hdc, hBrushOld);
+    DeleteObject(hPenOld);
+    DeleteObject(hBrushOld);
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawLine
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine
+  (JNIEnv *env, jobject obj, jlong gip, jint x1, jint y1, jint x2, jint y2)
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    
+    HDC dc = gi->hdc;
+    HPEN oldPen = (HPEN)SelectObject(dc, gi->hpen);
+    HBRUSH oldBrush = (HBRUSH)SelectObject(dc, gi->hbrush);
+    XFORM currentTransform;
+      
+    SetGraphicsMode(dc, GM_ADVANCED);
+    GetWorldTransform(dc, &currentTransform);
+    SetWorldTransform(dc, &gi->xform);
+
+    SelectClipRgn(dc, gi->hrgn);
+    if (x1 == x2 && y1 == y2) {
+        MoveToEx(dc, x1, y1, NULL);
+        LineTo(dc, x1, y1);
+    } else {
+        MoveToEx(dc, x1, y1, NULL);
+        LineTo(dc, x2, y2);
+    }
+    SetWorldTransform(dc, &currentTransform);
+    SetGraphicsMode(dc, GM_COMPATIBLE);
+
+    SelectObject(dc,oldPen);
+    SelectObject(dc,oldBrush);
+    DeleteObject(oldPen);
+    DeleteObject(oldBrush);
+}
+
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawRect
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawRect
+  (JNIEnv *env, jobject obj, jlong gip, jint x, jint y, jint width, jint height)
+{
+    if (width == 0) {
+        Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine(env, obj, gip, x, y, x, y+height);
+        return;
+    } else if (height == 0) {
+        Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine(env, obj, gip, x, y, x+width, y);
+        return;
+    }
+   
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    HDC dc = gi->hdc;
+    HPEN oldPen = (HPEN)SelectObject(dc, gi->hpen);
+    HBRUSH oldBrush = (HBRUSH)SelectObject(dc, gi->hbrush);
+
+    XFORM currentTransform;
+    SetGraphicsMode(dc, GM_ADVANCED);
+    GetWorldTransform(dc, &currentTransform);
+    SetWorldTransform(dc, &gi->xform);
+
+    SelectClipRgn(dc, gi->hrgn);
+    BeginPath(dc);
+    MoveToEx(dc, x, y, NULL);
+    LineTo(dc, x+width, y);
+    LineTo(dc, x+width, y+height);
+    LineTo(dc, x, y+height);
+    LineTo(dc, x, y);
+    EndPath(dc);
+    StrokePath(dc);
+
+    SetWorldTransform(dc, &currentTransform);
+    SetGraphicsMode(dc, GM_COMPATIBLE);
+
+    SelectObject(dc,oldPen);
+    SelectObject(dc,oldBrush);
+    DeleteObject(oldPen);
+    DeleteObject(oldBrush);
+}
+
+
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawOval
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawOval
+  (JNIEnv *env, jobject obj, jlong gip, jint x, jint y, jint width, jint height)
+{
+    if (width == 0) {
+        Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine(env, obj, gip, x, y, x, y+height);
+        return;
+    } else if (height == 0) {
+        Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine(env, obj, gip, x, y, x+width, y);
+        return;
+    }
+
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    
+    HDC dc = gi->hdc;
+
+    HPEN oldPen = (HPEN)SelectObject(dc, gi->hpen);
+    HBRUSH  oldBrush = (HBRUSH)SelectObject(dc, gi->hbrush);
+
+    XFORM currentTransform;
+    SetGraphicsMode(dc, GM_ADVANCED);
+    GetWorldTransform(dc, &currentTransform);
+    SetWorldTransform(dc, &gi->xform);
+
+    SelectClipRgn(dc, gi->hrgn);
+    BeginPath(dc);
+    Ellipse(dc, x, y, x+width, y+height);
+    EndPath(dc);
+    StrokePath(dc);
+
+    SetWorldTransform(dc, &currentTransform);
+    SetGraphicsMode(dc, GM_COMPATIBLE);
+
+    SelectObject(dc,oldPen);
+    SelectObject(dc,oldBrush);
+    DeleteObject(oldPen);
+    DeleteObject(oldBrush);
+}
+
+
+
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    fillRect
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_fillRect
+  (JNIEnv *env, jobject obj, jlong gip, jint x, jint y, jint width, jint height)
+{
+    if (width == 0) {
+        Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine(env, obj, gip, x, y, x, y+height);
+        return;
+    } else if (height == 0) {
+        Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine(env, obj, gip, x, y, x+width, y);
+        return;
+    }
+    
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    
+    HDC dc = gi->hdc;
+
+    HPEN oldPen = (HPEN)SelectObject(dc, gi->hpen);
+    HBRUSH oldBrush = (HBRUSH)SelectObject(dc, gi->hbrush);
+
+    XFORM currentTransform;
+    SetGraphicsMode(dc, GM_ADVANCED);
+    GetWorldTransform(dc, &currentTransform);
+    SetWorldTransform(dc, &gi->xform);
+
+    SelectClipRgn(dc, gi->hrgn);
+    BeginPath(dc);
+    MoveToEx(dc, x, y, NULL);
+    LineTo(dc, x+width, y);
+    LineTo(dc, x+width, y+height);
+    LineTo(dc, x, y+height);
+    LineTo(dc, x, y);
+    EndPath(dc);
+    FillPath(dc);
+
+    SetWorldTransform(dc, &currentTransform);
+    SetGraphicsMode(dc, GM_COMPATIBLE);
+
+    SelectObject(dc,oldPen);
+    SelectObject(dc,oldBrush);
+    DeleteObject(oldPen);
+    DeleteObject(oldBrush);
+
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setClip
+ * Signature: (J[II)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setClip
+  (JNIEnv *env, jobject obj, jlong gip, jintArray va, jint len)
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+
+    HDC hdc = gi->hdc;
+
+    DeleteObject(gi->hrgn);
+    HRGN hrgn = CreateRectRgn(-10,-10,0,0);
+    if (len == 0) {
+        SelectClipRgn(hdc, hrgn);
+        gi->hrgn=hrgn;
+        DeleteObject(hrgn);
+        return;
+    }
+    if (len < 4) {
+        SelectClipRgn(hdc, NULL);
+        gi->hrgn = NULL;
+        DeleteObject(hrgn);
+        return;
+    }
+
+
+    jint *vertices = (jint *)malloc(sizeof(jint)*len);
+    env->GetIntArrayRegion(va, 1, len, vertices);
+
+    int x = vertices[0];
+    int y = vertices[1];
+    int x1 = vertices[2]+1;
+    int y1 = vertices[3]+1;
+
+    DeleteObject(hrgn);
+    gi->hrgn = CreateRectRgn(x, y, x1, y1);
+
+    SelectClipRgn(hdc, gi->hrgn);
+
+    for (int i = 4; i < len; i += 4) {
+        x = vertices[i];
+        y = vertices[i+1];
+        x1 = vertices[i+2]+1;
+        y1 = vertices[i+3]+1;
+
+        HRGN hrgn1 = CreateRectRgn(x, y, x1, y1);
+        CombineRgn(gi->hrgn, gi->hrgn, hrgn1, RGN_OR);
+        ExtSelectClipRgn(hdc, gi->hrgn, RGN_OR);
+        DeleteObject(hrgn1);
+    } 
+
+    free(vertices);
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    resetClip
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_resetClip
+  (JNIEnv *env, jobject obj, jlong gip)
+{
+    if (gip == 0)
+        return;
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    DeleteObject(gi->hrgn);
+    gi->hrgn = NULL;
+    SelectClipRgn(gi->hdc, NULL);
+}
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setNativeTransform
+ * Signature: (J[D)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setNativeTransform
+  (JNIEnv *env, jobject obj, jlong gip, jdoubleArray jMatrix)
+{
+    GraphicsInfo *gi = (GraphicsInfo *)gip;
+    double *matrix = env->GetDoubleArrayElements(jMatrix, NULL);
+    XFORM xForm;
+    xForm.eM11 = (FLOAT) matrix[0];
+    xForm.eM12 = (FLOAT) matrix[1];
+    xForm.eM21 = (FLOAT) matrix[2];
+    xForm.eM22 = (FLOAT) matrix[3];
+    xForm.eDx  = (FLOAT) matrix[4];
+    xForm.eDy  = (FLOAT) matrix[5];
+    gi->xform = xForm;
+    env->ReleaseDoubleArrayElements(jMatrix, matrix, JNI_ABORT);
+
+}
+

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.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_WinGDIGraphics2D.h?rev=593146&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h Thu Nov  8 04:54:45 2007
@@ -0,0 +1,235 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Alexey A. Petrenko
+ * @version $Revision$
+ */
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY INTEL IJH TOOL.
+ * Please be aware that all changes made to this file manually
+ * will be overwritten by the tool if it runs again.
+ */
+
+#include <jni.h>
+
+
+/* Header for class org.apache.harmony.awt.gl.windows.WinGDIGraphics2D */
+
+#ifndef _ORG_APACHE_HARMONY_AWT_GL_WINDOWS_WINGDIGRAPHICS2D_H
+#define _ORG_APACHE_HARMONY_AWT_GL_WINDOWS_WINGDIGRAPHICS2D_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Static final fields */
+
+#undef org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_debugOutput
+#define org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_debugOutput 0L
+
+
+/* Native methods */
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    gdiPlusStartup
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_gdiPlusStartup
+  (JNIEnv *, jclass);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    gdiPlusShutdown
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_gdiPlusShutdown
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    createGraphicsInfo
+ * Signature: (JIIII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createGraphicsInfo
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    createCompatibleImageInfo
+ * Signature: (JII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createCompatibleImageInfo__JII
+  (JNIEnv *, jclass, jlong, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    createCompatibleImageInfo
+ * Signature: ([BII)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createCompatibleImageInfo___3BII
+  (JNIEnv *, jclass, jbyteArray, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    copyImageInfo
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_copyImageInfo
+  (JNIEnv *, jobject, jlong);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    disposeGraphicsInfo
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_disposeGraphicsInfo
+  (JNIEnv *, jclass, jlong);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    copyArea
+ * Signature: (JIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_copyArea
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setSolidBrush
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setSolidBrush
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setLinearGradientBrush
+ * Signature: (JIIIIIIIIIIIIZ)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setLinearGradientBrush
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jboolean);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    fillRects
+ * Signature: (J[II)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_fillRects
+  (JNIEnv *, jobject, jlong, jintArray, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    getDC
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_getDC
+  (JNIEnv *, jobject, jlong);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setPen
+ * Signature: (JFIIF[FIF)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setPen
+  (JNIEnv *, jobject, jlong, jfloat, jint, jint, jfloat, jfloatArray, jint, jfloat);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    deletePen
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_deletePen
+  (JNIEnv *, jobject, jlong);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawShape
+ * Signature: (J[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawShape
+  (JNIEnv *, jobject, jlong, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    fillShape
+ * Signature: (J[FII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_fillShape
+  (JNIEnv *, jobject, jlong, jfloatArray, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawLine
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawLine
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawRect
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawRect
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    drawOval
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_drawOval
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    fillRect
+ * Signature: (JIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_fillRect
+  (JNIEnv *, jobject, jlong, jint, jint, jint, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setClip
+ * Signature: (J[II)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setClip
+  (JNIEnv *, jobject, jlong, jintArray, jint);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    resetClip
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_resetClip
+  (JNIEnv *, jobject, jlong);
+
+/*
+ * Class:     org_apache_harmony_awt_gl_windows_WinGDIGraphics2D
+ * Method:    setNativeTransform
+ * Signature: (J[D)V
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_setNativeTransform
+  (JNIEnv *, jobject, jlong, jdoubleArray);
+
+#ifdef __cplusplus
+}
+#endif
+#endif

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message