Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 7336 invoked from network); 30 Nov 2007 10:31:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Nov 2007 10:31:25 -0000 Received: (qmail 79221 invoked by uid 500); 30 Nov 2007 10:31:13 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 79202 invoked by uid 500); 30 Nov 2007 10:31:13 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 79193 invoked by uid 99); 30 Nov 2007 10:31:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Nov 2007 02:31:13 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Nov 2007 10:31:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2FFAC1A9842; Fri, 30 Nov 2007 02:31:04 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r599771 - 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: Fri, 30 Nov 2007 10:31:00 -0000 To: commits@harmony.apache.org From: apetrenko@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071130103104.2FFAC1A9842@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: apetrenko Date: Fri Nov 30 02:30:59 2007 New Revision: 599771 URL: http://svn.apache.org/viewvc?rev=599771&view=rev Log: Patch for HARMONY-5039 "[classlib][awt] GDI Graphics2D implementation" Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphicsDevice.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/windows/WinGDIGraphics2D.cpp harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/gl_GDIPlus.h harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/makefile Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java?rev=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/GDITextRenderer.java Fri Nov 30 02:30:59 2007 @@ -90,8 +90,8 @@ @SuppressWarnings("deprecation") public void drawNormalGlyphVector(Graphics2D g, GlyphVector gv, float x, float y) { - AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform(); - long hdc = ((WinGDIPGraphics2D)g).getDC(); + AffineTransform trans = ((WinGDIGraphics2D)g).getTransform(); + long hdc = ((WinGDIGraphics2D)g).getDC(); x += trans.getTranslateX(); y += trans.getTranslateY(); @@ -135,8 +135,8 @@ @SuppressWarnings("deprecation") public void drawCompositeGlyphVector(Graphics2D g, GlyphVector gv, float x, float y) { - AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform(); - long hdc = ((WinGDIPGraphics2D)g).getDC(); + AffineTransform trans = ((WinGDIGraphics2D)g).getTransform(); + long hdc = ((WinGDIGraphics2D)g).getDC(); x += (int)Math.round(trans.getTranslateX()); y += (int)Math.round(trans.getTranslateY()); @@ -194,7 +194,7 @@ */ @SuppressWarnings("deprecation") public void drawNormalString(Graphics2D g, String str, int x, int y) { - AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform(); + AffineTransform trans = ((WinGDIGraphics2D)g).getTransform(); x += (int)Math.round(trans.getTranslateX()); y += (int)Math.round(trans.getTranslateY()); @@ -202,8 +202,8 @@ WindowsFont wf = (WindowsFont)(g.getFont().getPeer()); long font = wf.getFontHandle(); - long gi = ((WinGDIPGraphics2D)g).getGraphicsInfo(); - long hdc = NativeFont.gdiPlusGetHDC(gi); + long gi = ((WinGDIGraphics2D)g).getGraphicsInfo(); + long hdc = ((WinGDIGraphics2D)g).getDC(); win32.SelectObject(hdc, font); @@ -237,7 +237,6 @@ String out = new String(chars, 0, j); win32.TextOutW(hdc, x, y - wf.getAscent(), out, j); - NativeFont.gdiPlusReleaseHDC(gi, hdc); } @@ -259,10 +258,10 @@ return; } - AffineTransform trans = ((WinGDIPGraphics2D)g).getTransform(); + AffineTransform trans = ((WinGDIGraphics2D)g).getTransform(); - long gi = ((WinGDIPGraphics2D)g).getGraphicsInfo(); - long hdc = NativeFont.gdiPlusGetHDC(gi); + long gi = ((WinGDIGraphics2D)g).getGraphicsInfo(); + long hdc = ((WinGDIGraphics2D)g).getDC(); x += (int)Math.round(trans.getTranslateX()); y += (int)Math.round(trans.getTranslateY()); @@ -320,7 +319,6 @@ win32.TextOutW(hdc, xOffset, yOffset, str.substring(start, start + count), count); - NativeFont.gdiPlusReleaseHDC(gi, hdc); } } Modified: 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=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIGraphics2D.java Fri Nov 30 02:30:59 2007 @@ -143,11 +143,13 @@ 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); } + */ } } @@ -342,9 +344,7 @@ @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); + super.fill(s); return; } @@ -356,9 +356,7 @@ @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); + super.fillRect(x, y, width, height); return; } @@ -520,6 +518,7 @@ // Creates native GraphicsInfo structure private native long createGraphicsInfo(long hwnd, int x, int y, int width, int height); + private native long createGraphicsInfoFor(long hdc, char pageUnit); 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); @@ -559,11 +558,13 @@ 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); } + */ } } @@ -572,11 +573,13 @@ 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); } + */ } } Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java?rev=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java Fri Nov 30 02:30:59 2007 @@ -49,18 +49,22 @@ Insets ins = nw.getInsets(); if (WinGraphicsDevice.useOpenGL) { return new OGLGraphics2D(nw, tx - ins.left, ty - ins.top, clip); - } else { - return new WinGDIPGraphics2D(nw, tx - ins.left, ty - ins.top, clip); } + if (WinGraphicsDevice.useGDI) { + return new WinGDIGraphics2D(nw, tx - ins.left, ty - ins.top, clip); + } + return new WinGDIPGraphics2D(nw, tx - ins.left, ty - ins.top, clip); } public Graphics2D getGraphics2D(NativeWindow nw, int tx, int ty, int width, int height) { Insets ins = nw.getInsets(); if (WinGraphicsDevice.useOpenGL) { return new OGLGraphics2D(nw, tx - ins.left, ty - ins.top, width, height); - } else { - return new WinGDIPGraphics2D(nw, tx - ins.left, ty - ins.top, width, height); } + if (WinGraphicsDevice.useGDI) { + return new WinGDIGraphics2D(nw, tx - ins.left, ty - ins.top, width, height); + } + return new WinGDIPGraphics2D(nw, tx - ins.left, ty - ins.top, width, height); } public GraphicsEnvironment createGraphicsEnvironment(WindowFactory wf) { Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphicsDevice.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphicsDevice.java?rev=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphicsDevice.java (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphicsDevice.java Fri Nov 30 02:30:59 2007 @@ -53,9 +53,12 @@ private byte []idBytes = null; static boolean useOpenGL; + static boolean useGDI; static { String opengl = System.getProperty("java2d.opengl"); //$NON-NLS-1$ + String gdi = System.getProperty("java2d.gdi"); //$NON-NLS-1$ useOpenGL = opengl != null && opengl.equals("true"); //$NON-NLS-1$ + useGDI = gdi != null && gdi.equals("true"); //$NON-NLS-1$ }; public WinGraphicsDevice(int left, int top, int right, int bottom, String id, boolean primary) { 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=599771&r1=599770&r2=599771&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 Fri Nov 30 02:30:59 2007 @@ -59,7 +59,10 @@ hwnd = nw.getId(); this.width = width; this.height = height; - gi = WinGDIPGraphics2D.createCompatibleImageInfo(hwnd, width, height); + if(WinGraphicsDevice.useGDI) + gi = WinGDIGraphics2D.createCompatibleImageInfo(hwnd, width, height); + else + gi = WinGDIPGraphics2D.createCompatibleImageInfo(hwnd, width, height); surface = new BitmapSurface(gi , width, height); } @@ -73,7 +76,10 @@ this.gc = gc; this.width = width; this.height = height; - gi = WinGDIPGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); + if(WinGraphicsDevice.useGDI) + gi = WinGDIGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); + else + gi = WinGDIPGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); surface = new BitmapSurface(gi , width, height); } @@ -86,11 +92,19 @@ public Graphics2D createGraphics() { if (gi == 0) { if (hwnd != 0 && gc == null) { - gi = WinGDIPGraphics2D.createCompatibleImageInfo(hwnd, width, height); + if(WinGraphicsDevice.useGDI) + gi = WinGDIGraphics2D.createCompatibleImageInfo(hwnd, width, height); + else + gi = WinGDIPGraphics2D.createCompatibleImageInfo(hwnd, width, height); } else if (hwnd == 0 && gc != null) { - gi = WinGDIPGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); + if(WinGraphicsDevice.useGDI) + gi = WinGDIGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); + else + gi = WinGDIPGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); } } + if(WinGraphicsDevice.useGDI) + return new WinGDIGraphics2D(this, width, height); return new WinGDIPGraphics2D(this, width, height); } @@ -120,7 +134,10 @@ return IMAGE_OK; } - gi = WinGDIPGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); + if(WinGraphicsDevice.useGDI) + gi = WinGDIGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); + else + gi = WinGDIPGraphics2D.createCompatibleImageInfo(((WinGraphicsDevice)gc.getDevice()).getIDBytes(), width, height); return IMAGE_RESTORED; } @@ -153,7 +170,10 @@ @Override public void flush() { if (gi != 0) { - WinGDIPGraphics2D.disposeGraphicsInfo(gi); + if(WinGraphicsDevice.useGDI) + WinGDIGraphics2D.disposeGraphicsInfo(gi); + else + WinGDIPGraphics2D.disposeGraphicsInfo(gi); gi = 0; } if (surface != null) surface.dispose(); Modified: 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=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/WinGDIGraphics2D.cpp Fri Nov 30 02:30:59 2007 @@ -22,7 +22,7 @@ #include -#include "gl_GDI.h" +#include "gl_GDIPlus.h" #include "java_awt_BasicStroke.h" #include "java_awt_geom_PathIterator.h" #include "org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h" @@ -79,11 +79,30 @@ //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; + gi->gclip = CreateRectRgn(x,y,x+width,y+height); return (jlong)gi; } /* + * Class: org_apache_harmony_awt_gl_windows_WinGDIGraphics2D + * Method: createGraphicsInfoFor + * Signature: (JC)J + */ +JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createGraphicsInfoFor + (JNIEnv * env, jobject obj, jlong hdc, jchar pageUnit) { + GraphicsInfo * gi = (GraphicsInfo *) malloc(sizeof(GraphicsInfo)); + + gi->hdc = (HDC) hdc; + 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) { @@ -124,6 +143,9 @@ XFORM xform; xform.eM11=1; xform.eM12=0; xform.eM21=0; xform.eM22=1; xform.eDx=0; xform.eDy=0; gi->xform = xform; + gi->gclip = CreateRectRgn(0, 0, width, height); + SelectClipRgn(gi->hdc, gi->gclip); + return gi; } @@ -177,6 +199,7 @@ 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; + gi->gclip = origgi->gclip; return (jlong)gi; } @@ -199,6 +222,9 @@ if(gi->hrgn){ DeleteObject(gi->hrgn); } + if(gi->gclip){ + DeleteObject(gi->gclip); + } if(gi->hbrush) DeleteObject(gi->hbrush); @@ -727,7 +753,7 @@ GraphicsInfo *gi = (GraphicsInfo *)gip; DeleteObject(gi->hrgn); gi->hrgn = NULL; - SelectClipRgn(gi->hdc, NULL); + SelectClipRgn(gi->hdc, gi->gclip); } /* Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/gl_GDIPlus.h URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/gl_GDIPlus.h?rev=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/gl_GDIPlus.h (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/gl_GDIPlus.h Fri Nov 30 02:30:59 2007 @@ -36,6 +36,13 @@ HBITMAP bmp; Matrix *matrix; Region *clip; + + HPEN hpen; + HBRUSH hbrush; + COLORREF color; + XFORM xform; + HRGN hrgn; + HRGN gclip; } GraphicsInfo; typedef struct _GLBITMAPINFO{ Modified: 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=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/include/org_apache_harmony_awt_gl_windows_WinGDIGraphics2D.h Fri Nov 30 02:30:59 2007 @@ -71,6 +71,14 @@ /* * Class: org_apache_harmony_awt_gl_windows_WinGDIGraphics2D + * Method: createGraphicsInfoFor + * Signature: (JC)J + */ +JNIEXPORT jlong JNICALL Java_org_apache_harmony_awt_gl_windows_WinGDIGraphics2D_createGraphicsInfoFor + (JNIEnv *, jobject, jlong, jchar); + +/* + * Class: org_apache_harmony_awt_gl_windows_WinGDIGraphics2D * Method: createCompatibleImageInfo * Signature: (JII)J */ Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/makefile URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/makefile?rev=599771&r1=599770&r2=599771&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/makefile (original) +++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/gl/windows/makefile Fri Nov 30 02:30:59 2007 @@ -29,6 +29,7 @@ BUILDFILES = \ BitmapSurface.obj \ GDIBlitter.obj \ + WinGDIGraphics2D.obj \ WinGDIPGraphics2D.obj \ WinGraphicsEnvironment.obj \ WinThemeGraphics.obj \