harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r613858 [2/5] - in /harmony/enhanced/classlib/branches/java6: depends/build/ depends/libs/freebsd.x86/ depends/libs/linux.ia64/ depends/libs/linux.ppc32/ depends/libs/linux.ppc64/ depends/libs/linux.x86.libstdc++6/ depends/libs/linux.x86/ d...
Date Mon, 21 Jan 2008 11:55:41 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XBlitter.java Mon Jan 21 03:55:17 2008
@@ -36,375 +36,188 @@
 import org.apache.harmony.awt.nativebridge.linux.X11;
 import org.apache.harmony.awt.nativebridge.linux.X11Defs;
 
+import org.apache.harmony.awt.internal.nls.Messages;
+
 public class XBlitter implements Blitter {
+
     static final XBlitter inst = new XBlitter();
 
     public static XBlitter getInstance(){
         return inst;
     }
+    public void blit(int srcX, int srcY, Surface srcSurf, int dstX, int dstY,
+            Surface dstSurf, int width, int height, AffineTransform sysxform,
+            AffineTransform xform, Composite comp, Color bgcolor,
+            MultiRectArea clip) {
+
+        if(xform == null){
+            blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
+                    sysxform, comp, bgcolor, clip);
+        }else{
+            double scaleX = xform.getScaleX();
+            double scaleY = xform.getScaleY();
+            double scaledX = dstX / scaleX;
+            double scaledY = dstY / scaleY;
+            AffineTransform at = new AffineTransform();
+            at.setToTranslation(scaledX, scaledY);
+            xform.concatenate(at);
+            sysxform.concatenate(xform);
+            blit(srcX, srcY, srcSurf, 0, 0, dstSurf, width, height,
+                    sysxform, comp, bgcolor, clip);
+        }
+    }
 
-    public void blit(
-            int srcX, int srcY, Surface srcSurf,
-            int dstX, int dstY, Surface dstSurf,
-            int width, int height,
-            AffineTransform sysxform, AffineTransform xform,
-            Composite comp, Color bgcolor, MultiRectArea clip
-    ) {
-        int type = xform.getType();
-        switch (type) {
-            case AffineTransform.TYPE_TRANSLATION:
-                dstX += xform.getTranslateX();
-                dstY += xform.getTranslateY();
-            case AffineTransform.TYPE_IDENTITY:
-                 blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf,
-                         width, height, sysxform, comp, bgcolor, clip);
-                break;
-            default:
-                XSurface xDstSurf = (XSurface) dstSurf;
-
-                BufferedImage compIm;
-                int w = srcSurf.getWidth();
-                int h = srcSurf.getHeight();
-
-                if (!(srcSurf instanceof ImageSurface)) {
-                    compIm = xDstSurf.g2d.xConfig.createCompatibleImage(w, h);
-
-                    NativeImageBlitter.getInstance().blit(
-                            srcX, srcY, srcSurf,
-                            srcX, srcY,
-                            AwtImageBackdoorAccessor.getInstance().getImageSurface(compIm),
-                            w, h,
-                            AlphaComposite.Src, null, null
-                    );
-                } else {
-                    ColorModel cm = srcSurf.getColorModel();
-                    compIm = new BufferedImage(
-                            cm,
-                            srcSurf.getRaster(),
-                            cm.isAlphaPremultiplied(),
-                            null
-                    );
-                }
-
-                WritableRaster compRaster = compIm.getRaster();
-
-                AffineTransform at = (AffineTransform) sysxform.clone();
-                at.concatenate(xform);
-
-                // Want to transform without translation to fit into destination image
-                // Translation will be added then when blitting to final dest surface
-                dstX += at.getTranslateX();
-                dstY += at.getTranslateY();
-                AffineTransform untranslated =
-                        AffineTransform.getTranslateInstance(
-                                -at.getTranslateX(),
-                                -at.getTranslateY()
-                        );
-                untranslated.concatenate(at);
-
-                AffineTransformOp atop =
-                        new AffineTransformOp(untranslated, xDstSurf.g2d.getRenderingHints());
-
-                Rectangle r = atop.getBounds2D(compRaster).getBounds();
-                int tWidth = r.width;
-                int tHeight = r.height;
-
-                BufferedImage transformed;
-                if (compIm.getColorModel().getTransparency() == Transparency.OPAQUE) {
-                    transformed = xDstSurf.g2d.xConfig.createCompatibleImage(tWidth, tHeight);
-                } else {
-                    ColorModel cm = compIm.getColorModel();
-                    transformed =
-                            new BufferedImage(
-                                    cm,
-                                    compIm.getRaster().createCompatibleWritableRaster(
-                                            tWidth,
-                                            tHeight
-                                    ),
-                                    cm.isAlphaPremultiplied(),
-                                    null
-                            );
-                }
-
-                atop.filter(compIm, transformed);
-
-                if (dstX < 0){
-                    tWidth += dstX;
-                    dstX = 0;
-                }
+    public void blit(int srcX, int srcY, Surface srcSurf, int dstX, int dstY,
+            Surface dstSurf, int width, int height, AffineTransform sysxform, Composite comp,
+            Color bgcolor, MultiRectArea clip) {
+
+
+        if(srcSurf.isNativeDrawable()){
+            double matrix[] = null;
+            if(sysxform != null){
+                int type = sysxform.getType();
+                switch (type) {
+
+                    case AffineTransform.TYPE_TRANSLATION:
+                        dstX += sysxform.getTranslateX();
+                        dstY += sysxform.getTranslateY();
+                    case AffineTransform.TYPE_IDENTITY:
+                        break;
+
+                    default:
+                        matrix = new double[6];
+                        sysxform.getMatrix(matrix);
+                        Rectangle transDstBounds = JavaBlitter.getBounds2D(sysxform, new Rectangle(dstX, dstY, width, height)).getBounds();
+                        dstX = transDstBounds.x;
+                        dstY = transDstBounds.y;
+ 
+                        Rectangle transSrcBounds = JavaBlitter.getBounds2D(sysxform, new Rectangle(srcX, srcY, width, height)).getBounds();
+                        srcX = transSrcBounds.x;
+                        srcY = transSrcBounds.y;
+                        width = transSrcBounds.width;
+                        height = transSrcBounds.height;
 
-                if (dstY < 0){
-                    tHeight += dstY;
-                    dstY = 0;
                 }
 
-                blit(
-                        0, 0, AwtImageBackdoorAccessor.getInstance().getImageSurface(transformed),
-                        dstX, dstY, dstSurf,
-                        tWidth, tHeight,
-                        comp, bgcolor, clip
-                );
-        }
-    }
 
-    public void blit(
-            int srcX, int srcY, Surface srcSurf,
-            int dstX, int dstY, Surface dstSurf,
-            int width, int height,
-            AffineTransform sysxform,
-            Composite comp, Color bgcolor, MultiRectArea clip
-    ) {
-        int type = sysxform.getType();
-        switch (type) {
-            case AffineTransform.TYPE_TRANSLATION:
-            case AffineTransform.TYPE_IDENTITY:
-                 blit(
-                         srcX, srcY, srcSurf,
-                         dstX + (int) sysxform.getTranslateX(),
-                         dstY + (int) sysxform.getTranslateY(),
-                         dstSurf,
-                         width, height,
-                         comp, bgcolor, clip
-                 );
-                break;
-            default:
-                ColorModel cm = srcSurf.getColorModel();
-                WritableRaster compRaster = srcSurf.getRaster();
-                BufferedImage compIm = new BufferedImage(
-                        cm,
-                        compRaster,
-                        cm.isAlphaPremultiplied(),
-                        null
-                );
-
-                Rectangle transDstBounds = JavaBlitter.getBounds2D(sysxform, new Rectangle(dstX, dstY, width, height)).getBounds();
-                int tWidth = transDstBounds.width;
-                int tHeight = transDstBounds.height;
-                int tX = transDstBounds.x;
-                int tY = transDstBounds.y;
-
-                if(tWidth <= 0 || tHeight <= 0) return;
-                BufferedImage transformed = new BufferedImage(dstSurf.getWidth(), dstSurf.getHeight(), BufferedImage.TYPE_INT_ARGB);
-
-                Surface transfSurf = Surface.getImageSurface(transformed);
-                JavaBlitter.getInstance().blit(srcX, srcY, Surface.getImageSurface(compIm), 
-                        dstX, dstY, transfSurf, width, height, sysxform, AlphaComposite.Src, null, null);
-                blit(
-                        tX, tY, transfSurf,
-                        tX, tY, dstSurf,
-                        tWidth, tHeight,
-                        comp, bgcolor, clip
-                );
+            }
 
-        }
-    }
+            long dstSurfStruct = dstSurf.getSurfaceDataPtr();
+            long srcSurfStruct = srcSurf.getSurfaceDataPtr();
+            int clipRects[] = null;
+            int numVertex = 0;
+            if(clip != null){
+                clipRects = clip.rect;
+                numVertex = clipRects[0] - 1;
+            }
 
-    public void blit(
-            int srcX, int srcY, Surface srcSurf,
-            int dstX, int dstY, Surface dstSurf,
-            int width, int height,
-            Composite comp, Color bgcolor, MultiRectArea clip
-    ) {
-
-        if (clip == null) {
-            clip = new MultiRectArea(new Rectangle(dstX, dstY, width, height));
-        } else {
-            clip = new MultiRectArea(clip);
-        }
-        // XXX - todo - need to do smth with bgcolor
-        ColorModel srcCM = srcSurf.getColorModel();
-        XSurface xDstSurf = (XSurface) dstSurf;
-
-        if (srcSurf.isNativeDrawable() && srcCM.equals(dstSurf.getColorModel())) {
-            if (srcSurf instanceof XSurface) { // Blit from native to native
-                XSurface xSrcSurf = (XSurface) srcSurf;
-
-                XGraphics2D g2d = xDstSurf.g2d;
-
-                if (comp instanceof AlphaComposite) {
-                    switch (((AlphaComposite) comp).getRule()) {
-                        case AlphaComposite.SRC:
-                        case AlphaComposite.SRC_ATOP:
-                        case AlphaComposite.SRC_IN:
-                        case AlphaComposite.SRC_OVER:
-                            break; // GXCopy - is default
-                        case AlphaComposite.DST:
-                        case AlphaComposite.DST_ATOP:
-                        case AlphaComposite.DST_IN:
-                        case AlphaComposite.DST_OVER:
-                            g2d.setImageGCFunction(X11Defs.GXnoop);
-                            break;
-                        case AlphaComposite.SRC_OUT: // Clear
-                        case AlphaComposite.DST_OUT: // Clear
-                        case AlphaComposite.CLEAR:
-                        case AlphaComposite.XOR: // Clear
-                            g2d.setImageGCFunction(X11Defs.GXclear);
-                            break;
-                        default: // Do nothing
+            if(comp instanceof AlphaComposite){
+                AlphaComposite ac = (AlphaComposite) comp;
+                int compType = ac.getRule();
+                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;
+                    
+                    boolean hasBackground = false;
+                    int bgc = 0;
+
+                    if(bgcolor != null && srcSurf.getTransparency() != Transparency.OPAQUE){
+                        hasBackground = true;
+                        bgc = bgcolor.getRGB();
                     }
-                } else {
-                    imBlit(
-                            srcX, srcY, srcSurf,
-                            dstX, dstY, dstSurf,
-                            width, height,
-                            comp, bgcolor, clip
-                    );
-                    return;
-                }
-
-                // Get translated clip
-                makeClip(dstX, dstY, width, height, clip);
 
-                g2d.setXClip(clip, g2d.imageGC);
-                X11 x11 = X11.getInstance(); 
-                x11.XCopyArea(
-                        g2d.display,
-                        xSrcSurf.g2d.drawable, g2d.drawable,
-                        g2d.imageGC,
-                        srcX, srcY,
-                        width, height,
-                        dstX, dstY
-                );
-                x11.XFlush(g2d.display);
-                g2d.resetXClip(g2d.imageGC);
-
-                g2d.setImageGCFunction(X11Defs.GXcopy);
-            } else if (srcSurf.getSurfaceType() == BufferedImage.TYPE_CUSTOM) {
-                // source is custom image, slow blit
-                imBlit(
-                        srcX, srcY, srcSurf,
-                        dstX, dstY, dstSurf,
-                        width, height,
-                        comp, bgcolor, clip
-                );
-            } else { // source could be compatible image
-                int srcTransp = srcCM.getTransparency();
-                if (srcTransp == Transparency.OPAQUE) {
-                    if (comp instanceof AlphaComposite) {
-                        AlphaComposite acomp = (AlphaComposite) comp;
-                        if (
-                                acomp.getRule() == AlphaComposite.SRC ||
-                                (acomp.getAlpha() == 1 &&
-                                 (acomp.getRule() == AlphaComposite.SRC_OVER ||
-                                  acomp.getRule() == AlphaComposite.SRC_ATOP ||
-                                  acomp.getRule() == AlphaComposite.SRC_IN)
-                                )
-                        ) {
-                            // Get translated clip
-                            makeClip(dstX, dstY, width, height, clip);
-                            xDstSurf.putImage(
-                                    clip,
-                                    srcSurf.getRaster(),
-                                    dstX, dstY,
-                                    width, height
-                            );
-                        } else {
-                            imBlit(
-                                srcX, srcY, srcSurf,
-                                dstX, dstY, dstSurf,
-                                width, height,
-                                comp, bgcolor, clip
-                            );
-                        }
+                    synchronized(data){
+                        bltImage(srcX, srcY, srcSurfStruct, srcSurf.getData(),
+                             dstX, dstY, dstSurfStruct, width, height, 
+                             hasBackground, bgc, compType, alpha, matrix, 
+                             clipRects, numVertex, srcSurf.invalidated(), 
+                             dirtyRegions, regCount);
                     }
-
-                } else if (srcTransp == Transparency.BITMASK) {
-                    // todo - XXX - optimize here - use native clip mask
-                    imBlit(
-                        srcX, srcY, srcSurf,
-                        dstX, dstY, dstSurf,
-                        width, height,
-                        comp, bgcolor, clip
-                    );
-                } else { // have to compose in java - no native alpha composite
-                    imBlit(
-                        srcX, srcY, srcSurf,
-                        dstX, dstY, dstSurf,
-                        width, height,
-                        comp, bgcolor, clip
-                    );
-                }
+                    srcSurf.validate();
+                }else{
+                    bltPixmap(srcX, srcY, srcSurfStruct,
+                            dstX, dstY, dstSurfStruct,
+                            width, height, compType, alpha, matrix,
+                            clipRects, numVertex);
+                }
+            }else if(comp instanceof XORComposite){
+                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(), dirtyRegions, regCount);
+                    }
+                    srcSurf.validate();
+                }else{
+                    xorPixmap(srcX, srcY, srcSurfStruct,
+                            dstX, dstY, dstSurfStruct,
+                            width, height, xcomp.getXORColor().getRGB(), matrix,
+                            clipRects, numVertex);
+                }
+            }else{
+                // awt.17=Unknown Composite type : {0}
+                throw new IllegalArgumentException(Messages.getString("awt.17",  //$NON-NLS-1$
+                        comp.getClass()));
             }
-        } else {
-            imBlit(
-                    srcX, srcY, srcSurf,
-                    dstX, dstY, dstSurf,
-                    width, height,
-                    comp, bgcolor, clip
-            );
+        }else{
+            BufferedImage bi;
+            if(srcSurf.getTransparency() == Transparency.OPAQUE){
+                bi = new BufferedImage(srcSurf.getWidth(), srcSurf.getHeight(), BufferedImage.TYPE_INT_RGB);
+            }else{
+                bi = new BufferedImage(srcSurf.getWidth(), srcSurf.getHeight(), BufferedImage.TYPE_INT_ARGB);
+            }
+            Surface tmpSurf = AwtImageBackdoorAccessor.getInstance().getImageSurface(bi);
+            JavaBlitter.getInstance().blit(0, 0, srcSurf, 0, 0, tmpSurf,
+                    srcSurf.getWidth(), srcSurf.getHeight(),
+                    AlphaComposite.Src, null, null);
+            blit(srcX, srcY, tmpSurf, dstX, dstY, dstSurf,
+                    width, height, comp, bgcolor, clip);
         }
     }
 
-    private static void imBlit(
-            int srcX, int srcY, Surface srcSurf,
-            int dstX, int dstY, Surface dstSurf,
-            int width, int height,
-            Composite comp,
-            Color bgcolor,
-            MultiRectArea clip
-    ) {
-
-        if(dstX < 0){
-            width += dstX;
-            dstX = 0;
-        }
-
-        if(dstY < 0){
-            height += dstY;
-            dstY = 0;
-        }
-
-        if(width <= 0 || height <= 0) return;
+    // Native methods
 
-        XSurface xDstSurf = ((XSurface) dstSurf);
+    public void blit(int srcX, int srcY, Surface srcSurf, int dstX, int dstY,
+            Surface dstSurf, int width, int height,
+            Composite comp, Color bgcolor, MultiRectArea clip) {
 
-        boolean srcNoAlpha =
-                srcSurf.getColorModel().getTransparency() == Transparency.OPAQUE;
+        blit(srcX, srcY, srcSurf, dstX, dstY, dstSurf, width, height,
+                null, comp, bgcolor, clip);
+    }
 
-        if (comp instanceof AlphaComposite) {
-            AlphaComposite acomp = (AlphaComposite) comp;
-            if (
-                    acomp.getRule() == AlphaComposite.SRC ||
-                    (srcNoAlpha && acomp.getAlpha() == 1 &&
-                     (acomp.getRule() == AlphaComposite.SRC_OVER ||
-                      acomp.getRule() == AlphaComposite.SRC_ATOP ||
-                      acomp.getRule() == AlphaComposite.SRC_IN)
-                    )
-            ) {
-                xDstSurf.needServerData = false;
-            }
-        }
+    private native void bltImage(int srcX, int srcY, long srsSurfDataPtr,
+            Object srcData, int dstX, int dstY, long dstSurfDataPtr,
+            int width, int height, boolean hasBackground, int bgcolor, int compType,
+            float alpha, double matrix[], int clip[], int numVertex, 
+            boolean invalidated, int[] dirtyRegions, int regCount);
 
-        Rectangle2D roi = new Rectangle2D.Float(dstX, dstY, width, height); 
-        xDstSurf.setRoi(roi);
-        NativeImageBlitter.getInstance().blit(
-                srcX, srcY, srcSurf,
-                0, 0, xDstSurf.getImageSurface(),
-                width, height,
-                comp, bgcolor, null
-        );
-
-        if (xDstSurf.needServerData) {
-            xDstSurf.putImage(clip,
-                    (int) (roi.getX()),
-                    (int) (roi.getY()),
-                    (int) roi.getWidth(), 
-                    (int) roi.getHeight()
-            );
+    private native void bltPixmap(int srcX, int srcY, long srsSurfDataPtr,
+            int dstX, int dstY, long dstSurfDataPtr,
+            int width, int height, int compType,
+            float alpha, double matrix[], int clip[], int numVertex);
 
-        } else {
-            xDstSurf.putImage(clip, dstX, dstY, width, height);
-        }
+    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[] dirtyRegions, int regCount);
 
-        xDstSurf.needServerData = true;
-    }
-
-    private static void makeClip(
-            int dstX, int dstY,
-            int width, int height,
-            MultiRectArea clip
-    ) {
-        Rectangle destRect = new Rectangle(dstX, dstY, width, height);
-        clip.intersect(destRect);
-    }
+    private native void xorPixmap(int srcX, int srcY, long srsSurfDataPtr,
+            int dstX, int dstY, long dstSurfDataPtr,
+            int width, int height, int xorcolor, double matrix[],
+            int clip[], int numVertex);
 }
+

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java Mon Jan 21 03:55:17 2008
@@ -66,10 +66,6 @@
     boolean xor_mode = false;
 
     boolean indexModel = false;
- 
-    static{
-        System.loadLibrary("gl");
-    }
 
     public XGraphics2D(long drawable, int tx, int ty, MultiRectArea clip) {
         super(tx, ty, clip);
@@ -101,6 +97,41 @@
         }
     }
 
+    public XGraphics2D(XVolatileImage image, int tx, int ty, int width, int height) {
+        this(image, tx, ty, new MultiRectArea(new Rectangle(width, height)));
+    }
+
+    public XGraphics2D(XVolatileImage image, int tx, int ty, MultiRectArea clip) {
+        super(tx, ty, clip);
+        drawable = image.getPixmap();
+        xConfig = (XGraphicsConfiguration) getDeviceConfiguration();
+        display = xConfig.dev.display;
+        gc = createGC(display, drawable);
+
+        X11.Visual visual = xConfig.info.get_visual();
+        xftDraw = createXftDraw(display, drawable, visual.lock());
+        visual.unlock();
+
+        imageGC = createGC(display, drawable);
+
+        //xSetForeground(argb); // Set default foregroung to black
+
+        blitter = XBlitter.getInstance();
+        Rectangle bounds = clip.getBounds();
+        dstSurf = image.getImageSurface();
+
+        if (!FontManager.IS_FONTLIB) {
+            jtr = DrawableTextRenderer.inst;
+        }
+
+        //setTransformedClip(clip);
+        setClip(clip);
+
+        if (xConfig.getColorModel() instanceof IndexColorModel) {
+            indexModel = true;
+        }
+    }
+
     public XGraphics2D(long drawable, int tx, int ty, int width, int height) {
         this(drawable, tx, ty, new MultiRectArea(new Rectangle(width, height)));
     }
@@ -214,6 +245,9 @@
             LinuxNativeFont.freeXftDrawNative(this.xftDraw);
             xftDraw = 0;
         }
+
+        if(dstSurf instanceof XSurface) 
+            dstSurf.dispose();
 
         if (gc != 0) {
             freeGC(display, gc);

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XSurface.java Mon Jan 21 03:55:17 2008
@@ -32,255 +32,55 @@
 import org.apache.harmony.awt.gl.*;
 
 public class XSurface extends Surface {
-    private static final X11 x11 = X11.getInstance();
-
-    //int width, height; // XXX - todo - use from superclass
-
-    XGraphics2D g2d;
-
-    private BufferedImage lastSnapshot = null;
-    boolean needServerData = true;
-
-    private Rectangle2D roi; // Rectangle of interest
-
-    private ImageSurface imageSurface;
-
-    // Cached parameters for XCreateImage
-    boolean cachedXCIParams = false;
-    int depthXCI;
-    int offsetXCI;
-    int formatXCI;
-    int bitmapPadXCI;
-    int bytesPerLineXCI;
-
 
     XSurface(XGraphics2D g2d, int width, int height) {
-        this.g2d = g2d;
+        surfaceDataPtr = createSurfData(g2d.display, g2d.drawable, g2d.imageGC, g2d.xConfig.info.lock(), width, height);
+        g2d.xConfig.info.unlock();
         this.width = width;
         this.height = height;
-        roi = new Rectangle2D.Float(0, 0, width, height);
-    }
-
-    void setRoi(Rectangle2D roi) {
-        this.roi = roi;
-    }
-
-    public ColorModel getColorModel() {
-        return g2d.xConfig.getColorModel();
     }
-
-    public WritableRaster getRaster() {
-        if (needServerData) {
-            long pixmap = x11.XCreatePixmap(
-                    g2d.display,
-                    x11.XRootWindow(g2d.display, g2d.xConfig.dev.screen),
-                    (int) roi.getWidth(), (int) roi.getHeight(),
-                    g2d.xConfig.info.get_depth()
-            );
-
-            x11.XCopyArea(
-                    g2d.display,
-                    g2d.drawable,
-                    pixmap,
-                    g2d.imageGC,
-                    (int) roi.getX(),
-                    (int) roi.getY(),
-                    (int) roi.getWidth(), (int) roi.getHeight(),
-                    0, 0
-            );
-
-            if (!cachedXCIParams) {
-                long xImagePtr = x11.XGetImage(
-                        g2d.display,
-                        pixmap,
-                        0, 0,
-                        1, 1,
-                        ~(0L), // All bits set to 1, should be same as XAllPlanes() result
-                        X11Defs.ZPixmap
-                );
-
-                if (xImagePtr == 0) // Check obtained XImage pointer
-                    return null;
-
-                X11.XImage xTmpImage = x11.createXImage(xImagePtr);
-                depthXCI = xTmpImage.get_depth();
-                formatXCI = xTmpImage.get_format();
-                offsetXCI = xTmpImage.get_xoffset();
-                bitmapPadXCI = xTmpImage.get_bitmap_pad();
-                bytesPerLineXCI = xTmpImage.get_bytes_per_line();
-                xTmpImage.get_f().destroy_image(xTmpImage);
-
-                cachedXCIParams = true;
-            }
-
-            X11.Visual visual = g2d.xConfig.info.get_visual();
-
-            long xImagePtr = x11.XCreateImage(
-                    g2d.display,
-                    visual.lock(),
-                    depthXCI,
-                    formatXCI,
-                    offsetXCI,
-                    Utils.memaccess.malloc(height*width*bytesPerLineXCI),
-                    width, height,
-                    bitmapPadXCI,
-                    0
-            );
-            visual.unlock();
-
-            X11.XImage xImage = x11.createXImage(xImagePtr);
-            xImage.set_byte_order(X11Defs.LSBFirst);
-
-            xImage = x11.XGetSubImage(
-                    g2d.display,
-                    pixmap,
-                    0, 0,
-                    (int) roi.getWidth(), (int) roi.getHeight(),
-                    ~(0L), // All bits set to 1, should be same as XAllPlanes() result
-                    X11Defs.ZPixmap,
-                    xImage, 0, 0
-            );
-            x11.XFreePixmap(g2d.display, pixmap);
-            lastSnapshot = XVolatileImage.biFromXImage(xImage, g2d.xConfig);
-
-            // Cleanup
-            xImage.get_f().destroy_image(xImage);
-        } else {
-            lastSnapshot = g2d.xConfig.createCompatibleImage(width, height);
-        }
-
-        return lastSnapshot.getRaster();
-    }
-
-    void putImage(MultiRectArea clip, int x, int y, int width, int height) {
-        putImage(
-                clip,
-                lastSnapshot.getRaster(),
-                x, y, width, height 
-        );
-    }
-
-    void putImage(
-            MultiRectArea clip, Raster r,
-            int dstX, int dstY,
-            int dstWidth, int dstHeight
-    ) {
-        if (r == null) // Just blit last snapshot
-            r = lastSnapshot.getRaster();
-
-        Object data;
-        AwtImageBackdoorAccessor dbAccess = AwtImageBackdoorAccessor.getInstance();
-        data = dbAccess.getData(r.getDataBuffer());
-        LockedArray lockedData = Utils.arraccess.lockArrayShort(data);
-
-        SampleModel sm = r.getSampleModel();
-        int scanlineStride;
-        if (sm instanceof ComponentSampleModel) {
-            scanlineStride = ((ComponentSampleModel) sm).getScanlineStride();
-        } else if (sm instanceof SinglePixelPackedSampleModel) {
-            scanlineStride = ((SinglePixelPackedSampleModel) sm).getScanlineStride();
-        } else if (sm instanceof MultiPixelPackedSampleModel) {
-            scanlineStride = ((MultiPixelPackedSampleModel) sm).getScanlineStride();
-        } else {
-            return;
-        }
-
-        int pad;
-        if (data instanceof byte[]) {
-            pad = 8;
-        } else if (data instanceof short[]) {
-            pad = 16;
-            scanlineStride *= 2;
-        } else if (data instanceof int[]) {
-            pad = 32;
-            scanlineStride *= 4;
-        } else {
+    @Override
+    public void dispose() {
+        if (surfaceDataPtr == 0) {
             return;
         }
-
-        X11.Visual visual = g2d.xConfig.info.get_visual();
-
-        long xImagePtr = x11.XCreateImage(
-                g2d.display,
-                visual.lock(),
-                g2d.xConfig.info.get_depth(),
-                X11Defs.ZPixmap,
-                0,
-                lockedData.getAddress(),
-                r.getWidth(),
-                r.getHeight(),
-                pad,
-                scanlineStride
-        );
-        visual.unlock();
-
-        g2d.setXClip(clip, g2d.imageGC);
-
-        X11.XImage xImage = x11.createXImage(xImagePtr);
-        xImage.set_byte_order(X11Defs.LSBFirst); // Set byte order explicitly
-
-        x11.XPutImage(
-                g2d.display,
-                g2d.drawable,
-                g2d.imageGC,
-                xImagePtr,
-                0, 0,
-                dstX, dstY,
-                dstWidth, dstHeight
-        );
-
-        g2d.resetXClip(g2d.imageGC);
-
-        lockedData.release();
-
-        xImage.set_data(NativeBridge.getInstance().createInt8Pointer(0, true));
-        xImage.get_f().destroy_image(xImage);
-    }
-
-    public void dispose() {
-        return;
-    }
-
-    public XGraphics2D getGraphics() {
-        return g2d;
-    }
-
-    /*
-    public int getWidth() { // XXX - todo - use from superclass
-        return this.width;
-    }
-
-    public int getHeight() { // XXX - todo - use from superclass
-        return this.height;
+        
+        dispose(surfaceDataPtr);
+        surfaceDataPtr = 0;
     }
-    */
 
+    @Override
     public long lock() {
         return 0;
     }
 
+    @Override
     public void unlock() {
+
+    }
+
+    @Override
+    public ColorModel getColorModel() {
+        return null;
     }
 
-    public boolean isNativeDrawable() {
-        return true;
+    @Override
+    public WritableRaster getRaster() {
+        return null;
     }
 
+    @Override
     public int getSurfaceType() {
-        return BufferedImage.TYPE_CUSTOM;
+        return 0;
     }
 
+    @Override
     public Surface getImageSurface() {
-        if (imageSurface == null) {
-            imageSurface = new ImageSurface(getColorModel(), getRaster());
-        } else {
-            imageSurface.setRaster(getRaster());
-        }
-
-        return imageSurface;
+        return this;
     }
 
-    protected void finalize() throws Throwable {
-        imageSurface.dispose();
-    }
+    private native long createSurfData(long display, long drawable, long gc, long visual_info, int width, int height);
+
+    private native void dispose(long structPtr);
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XVolatileImage.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XVolatileImage.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XVolatileImage.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XVolatileImage.java Mon Jan 21 03:55:17 2008
@@ -39,7 +39,7 @@
 
     private long pixmap;
     private XGraphicsConfiguration xconf;
-    private XGraphics2D lastGraphics = null;
+    Surface surface;
 
     int width, height;
 
@@ -54,6 +54,9 @@
                 w, h,
                 xconf.info.get_depth()
         );
+
+        surface = new PixmapSurface(display, pixmap, xconf.info.lock(), w, h);
+        xconf.info.unlock();
     }
 
     public long getPixmap() {
@@ -73,8 +76,7 @@
     }
 
     public Graphics2D createGraphics() {
-        lastGraphics = new XGraphics2D(pixmap, 0, 0, width, height);
-        return lastGraphics;
+        return new XGraphics2D(this, 0, 0, width, height);
     }
 
     public int validate(GraphicsConfiguration graphicsConfiguration) {
@@ -278,13 +280,11 @@
     }
 
     public void finalize() {
+        surface.dispose();
         x11.XFreePixmap(xconf.dev.display, pixmap);
     }
 
     public Surface getImageSurface() {
-        if (lastGraphics == null)
-            createGraphics();
-
-        return lastGraphics.getSurface();
+        return surface;
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java Mon Jan 21 03:55:17 2008
@@ -43,7 +43,7 @@
     private static final X11 x11 = X11.getInstance();
     private static final NativeBridge bridge = NativeBridge.getInstance();
 
-    private final XServerConnection xConnection = new XServerConnection(x11);
+    private final XServerConnection xConnection = XServerConnection.getInstance();
     private final long display = xConnection.getDisplay();
     private final int screen = xConnection.getScreen();
     final WindowManager wm;

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/XServerConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/XServerConnection.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/XServerConnection.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/unix/org/apache/harmony/awt/wtk/linux/XServerConnection.java Mon Jan 21 03:55:17 2008
@@ -31,8 +31,10 @@
 
     private final X11 x11;
 
-    public XServerConnection(X11 x11) {
-        this.x11 = x11;
+    private static XServerConnection instance = new XServerConnection();
+
+    private XServerConnection() {
+        this.x11 = X11.getInstance();;
         display = x11.XOpenDisplay(0); //0 - we use default display only
         if (display == 0) {
             String name = System.getProperty("DISPLAY"); //$NON-NLS-1$
@@ -40,7 +42,15 @@
             throw new InternalError(Messages.getString("awt.0F", //$NON-NLS-1$ 
                     (name != null ? name : ""))); //$NON-NLS-1$
         }
+
         screen = x11.XDefaultScreen(display);
+
+        System.loadLibrary("gl");
+        init(display, screen);
+    }
+
+    public static XServerConnection getInstance(){
+        return instance;
     }
 
     public void close() {
@@ -54,4 +64,6 @@
     public int getScreen() {
         return screen;
     }
+
+    private native void init(long display, int screen);
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.cpp Mon Jan 21 03:55:17 2008
@@ -83,6 +83,10 @@
             {
                 unsigned int *src, *dst;
 
+#ifdef unix
+                unsigned int *s, *d;
+#endif
+
                 src_stride = srcSurf->scanline_stride;
                 dst_stride = srcSurf->width;
 
@@ -92,7 +96,16 @@
                 dst = (unsigned int *)bmpDataPtr + dst_offset;
 
                 for(int _y = 0; _y < h; _y++, src += src_stride, dst += dst_stride){
+#ifdef _WIN32
                     memcpy(dst, src, w * sizeof(int));
+#endif
+
+#ifdef unix
+                    s = src, d = dst;
+                    for(int _x = 0; _x < w; _x++, s++, d++){
+                        *d = 0xff000000 | *s;
+                    }
+#endif
                 }
             }
             break;
@@ -668,10 +681,11 @@
                     env->ReleasePrimitiveArrayCritical(bandOffsets, p, 0);
                     break;
             }
-            surf->bmp_byte_stride = surf->width << 2;
             surf->invalidated = true;
+            surf->bmp_byte_stride = surf->width << 2;
 
 #ifdef _WIN32
+
             surf->bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
             surf->bmpInfo.bmiHeader.biWidth = surf->width;
             surf->bmpInfo.bmiHeader.biHeight = -surf->height;

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/SurfaceDataStructure.h Mon Jan 21 03:55:17 2008
@@ -27,9 +27,11 @@
 #include <jni.h>
 
 #ifdef _WIN32
-
 #include "gl_GDIPlus.h"
+#endif
 
+#ifdef unix
+#include "XSurfaceInfo.h"
 #endif
 
 // Color Space constants
@@ -146,7 +148,7 @@
     bool isAlphaPre;
 
 #ifdef _WIN32
-    // VolataileImage
+    // WinVolataileImage
     GraphicsInfo *gi;
     GLBITMAPINFO bmpInfo;
 
@@ -154,6 +156,16 @@
     HDC srcDC;
     DWORD rtc;
     BOOL isTrueColor;
+#endif
+
+#ifdef unix
+    // XVolatileImage
+    XImage *ximage;
+
+    Display *display;
+    Drawable drawable;
+    GC gc;
+    XVisualInfo *visual_info;
 #endif
 
 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/blitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/blitter.cpp?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/blitter.cpp (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/shared/blitter.cpp Mon Jan 21 03:55:17 2008
@@ -1489,6 +1489,94 @@
 
 #endif
 
+#ifdef unix
+          if(!srcSurf->ximage){
+              if(XImageByteOrder(srcSurf->display) == LSBFirst){
+                  srcSurf->ximage = XGetImage(srcSurf->display, srcSurf->drawable, 0, 0, 
+                     srcSurf->width, srcSurf->height, ~(0L), ZPixmap);
+              }else{
+                  XImage *tmp = XGetImage(srcSurf->display, srcSurf->drawable, 0, 0, 
+                      1, 1, ~(0L), ZPixmap);
+
+                  srcSurf->ximage = XCreateImage(srcSurf->display, srcSurf->visual_info->visual,
+                      tmp->depth, tmp->format, tmp->xoffset, (char *)malloc(tmp->width * tmp->height * tmp->bytes_per_line),
+                      srcSurf->width, srcSurf->height, tmp->bitmap_pad, 0);
+
+                  XDestroyImage(tmp);
+ 
+                  srcSurf->ximage->byte_order = LSBFirst;
+
+                  XGetSubImage(srcSurf->display, srcSurf->drawable, 0, 0, 
+                      srcSurf->width, srcSurf->height, ~(0L), ZPixmap, srcSurf->ximage, 0, 0);
+              }
+              srcSurf->scanline_stride_byte = srcSurf->ximage->bytes_per_line;
+
+              char *info = (char *)srcSurf->visual_info;
+              int visual_class = (int)*((int *)(info + sizeof(Visual *) + sizeof(VisualID) + sizeof(int) + sizeof(unsigned int)));
+              int bpp = srcSurf->ximage->bits_per_pixel;
+
+              switch(visual_class){ 
+              case TrueColor:
+              case DirectColor:
+                  if(bpp == 32){
+                      srcSurf->scanline_stride = srcSurf->scanline_stride_byte >> 2;
+                      if(srcSurf->visual_info->red_mask == 0xff0000 && srcSurf->visual_info->green_mask == 0xff00 &&
+                          srcSurf->visual_info->blue_mask == 0xff){
+ 
+                          srcSurf->ss_type = INT_RGB;
+                          srcSurf->red_mask = 0xff0000;
+                          srcSurf->green_mask = 0xff00;
+                          srcSurf->blue_mask = 0xff;
+                      } else if (srcSurf->visual_info->red_mask == 0xff && srcSurf->visual_info->green_mask == 0xff00 &&
+                          srcSurf->visual_info->blue_mask == 0xff0000){
+
+                          srcSurf->ss_type = INT_BGR;
+                          srcSurf->red_mask = 0xff;
+                          srcSurf->green_mask = 0xff00;
+                          srcSurf->blue_mask = 0xff0000;
+                      } else {
+                          srcSurf->ss_type = -1;
+                      }
+                  }else if(bpp == 16){
+                      srcSurf->scanline_stride = srcSurf->scanline_stride_byte >> 1;
+                      if(srcSurf->visual_info->red_mask == 0x7c00 && srcSurf->visual_info->green_mask == 0x03e0 &&
+                          srcSurf->visual_info->blue_mask == 0x1f){
+
+                          srcSurf->ss_type = USHORT_555;
+                          srcSurf->red_mask = 0x7c00;
+                          srcSurf->green_mask = 0x03e0;
+                          srcSurf->blue_mask = 0x1f;
+                      } else if (srcSurf->visual_info->red_mask == 0xf800 && srcSurf->visual_info->green_mask == 0x07e0 &&
+                          srcSurf->visual_info->blue_mask == 0x1f){
+
+                          srcSurf->ss_type = USHORT_565;
+                          srcSurf->red_mask = 0xf800;
+                          srcSurf->green_mask = 0x07e0;
+                          srcSurf->blue_mask = 0x1f;
+                      } else {
+                          srcSurf->ss_type = -1;
+                      }
+                  }else{
+                          srcSurf->ss_type = -1;
+                  }
+                  break;
+              case StaticGray:
+              case PseudoColor:
+              case GrayScale:
+              case StaticColor: 
+                  // TODO: Need to implement parsing of others visual types
+                  srcSurf->ss_type = -1;
+                  break;
+              default:
+                  srcSurf->ss_type = -1;
+              }
+          } else {
+                 XGetSubImage(srcSurf->display, srcSurf->drawable, 0, 0, 
+                     srcSurf->width, srcSurf->height, ~(0L), ZPixmap, srcSurf->ximage, 0, 0);
+          }
+          srcDataPtr = srcSurf->ximage->data;
+#endif
+          srcType = srcSurf->ss_type;
       }else{
           srcDataPtr = env->GetPrimitiveArrayCritical((jarray)srcData, 0);
       }

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/XGraphics2D.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/XGraphics2D.cpp?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/XGraphics2D.cpp (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/XGraphics2D.cpp Mon Jan 21 03:55:17 2008
@@ -26,6 +26,7 @@
 #include <X11/Xutil.h>
 #include <X11/Xos.h>
 
+#include "XSurfaceInfo.h"
 #include "org_apache_harmony_awt_gl_linux_XGraphics2D.h"
 
 JNIEXPORT jlong JNICALL 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/exports.txt?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/exports.txt (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/exports.txt Mon Jan 21 03:55:17 2008
@@ -32,3 +32,12 @@
 Java_org_apache_harmony_awt_gl_linux_XGraphics2D_setForeground
 Java_org_apache_harmony_awt_gl_linux_XGraphics2D_setFunction
 Java_org_apache_harmony_awt_gl_linux_XGraphics2D_setStroke
+Java_org_apache_harmony_awt_gl_linux_XSurface_createSurfData
+Java_org_apache_harmony_awt_gl_linux_XSurface_dispose
+Java_org_apache_harmony_awt_gl_linux_PixmapSurface_createSurfData
+Java_org_apache_harmony_awt_gl_linux_PixmapSurface_dispose
+Java_org_apache_harmony_awt_gl_linux_XBlitter_bltImage
+Java_org_apache_harmony_awt_gl_linux_XBlitter_bltPixmap
+Java_org_apache_harmony_awt_gl_linux_XBlitter_xorImage
+Java_org_apache_harmony_awt_gl_linux_XBlitter_xorPixmap
+Java_org_apache_harmony_awt_wtk_linux_XServerConnection_init

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/makefile?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/makefile (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/gl/unix/makefile Mon Jan 21 03:55:17 2008
@@ -25,6 +25,8 @@
   $(SHAREDSUB)/LUTTables.o \
   $(SHAREDSUB)/pngdecoder.o \
   $(SHAREDSUB)/SurfaceDataStructure.o \
+  gl.o \
+  XBlitter.o \
   XGraphics2D.o \
   libpng.a
 
@@ -36,7 +38,7 @@
 	$(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
 	$(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
 
-OSLIBS += $(STDCLIBS)
+OSLIBS += $(STDCLIBS) $(XLIBS)
 
 DLLNAME=../libgl$(HY_SHLIB_SUFFIX)
 EXPNAME=HYGL_0.1

Modified: harmony/enhanced/classlib/branches/java6/modules/instrument/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/instrument/build.xml?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/instrument/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/instrument/build.xml Mon Jan 21 03:55:17 2008
@@ -37,15 +37,6 @@
         </or>
     </fileset>
     
-    <condition property="iculib.zip" 
-        value="${depends.oss}/icu4c-3.4-harmony-windows.x86_64.zip"
-        else="${depends.oss}/icu4c-3.4-harmony.zip">
-        <and>
-            <isset property="is.windows"/>
-            <isset property="is.x86_64"/>
-        </and>
-    </condition>
-
     <property name="instrument.exclude.file" location="${hy.hdk}/build/instrument.exclude" />
 
     <target name="build" depends="compile-java, copy-resources, build-jar" />
@@ -64,16 +55,6 @@
     <!-- internal target for local and global test run sequence -->
     <target name="-test-module" depends="build, compile-tests, prepare-exclude, run-tests" />
 
-    <target name="overlay-oss">
-        <mkdir dir="${hy.instrument.src.main.native}/icu4c/unicode" />
-        <unzip src="${iculib.zip}" dest="${hy.instrument.src.main.native}/icu4c/unicode" />
-        <chmod dir="${hy.instrument.src.main.native}/icu4c/unicode" perm="ugo+r" />
-    </target>
-    
-    <target name="clean-overlay-oss">
-        <delete dir="${hy.instrument.src.main.native}/icu4c" quiet="true" />
-    </target>
-    
     <!-- Build native code -->
     <target name="build-native" >
         <make dir="${hy.instrument.src.main.native}/instrument/${hy.os.family}" />

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/.classpath
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/.classpath?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/.classpath (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/.classpath Mon Jan 21 03:55:17 2008
@@ -1,19 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry output="bin/main" kind="src" path="src/main/java"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/api/windows"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/api/common"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/api/unix"/>
-	<classpathentry output="bin/main" kind="src" path="src/main/resources"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/resources"/>
-    <classpathentry output="bin/test" kind="src" path="src/test/impl/windows"/>
-    <classpathentry output="bin/test" kind="src" path="src/test/impl/common"/>
-    <classpathentry output="bin/test" kind="src" path="src/test/impl/unix"/>
+	<classpathentry kind="src" output="bin/main" path="src/main/java"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/api/windows"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/api/common"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/api/unix"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/resources"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/impl/windows"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/impl/common"/>
+	<classpathentry kind="src" output="bin/test" path="src/test/impl/unix"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
 		<accessrules>
 			<accessrule kind="accessible" pattern="**/*"/>
 		</accessrules>
 	</classpathentry>
-	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
+	<classpathentry kind="var" path="JUNIT_HOME/junit.jar" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
 	<classpathentry kind="output" path="bin/main"/>
 </classpath>

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.common Mon Jan 21 03:55:17 2008
@@ -1,2 +1,7 @@
-tests/api/java/net/URLClassLoaderTest.java
-tests/api/java/net/ExcludedProxyTest.java
+org/apache/harmony/luni/tests/java/net/URLClassLoaderTest.java
+org/apache/harmony/luni/tests/java/net/ExcludedProxyTest.java
+org/apache/harmony/luni/tests/java/util/CurrencyTest.java
+org/apache/harmony/luni/tests/java/util/FormatterTest.java
+org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
+org/apache/harmony/luni/tests/java/util/LocaleTest.java
+org/apache/harmony/luni/tests/java/util/ScannerTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.drl?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.drl Mon Jan 21 03:55:17 2008
@@ -1,5 +1,5 @@
 org/apache/harmony/luni/tests/java/lang/ThreadTest.java
-tests/api/java/net/SocketTest.java
+org/apache/harmony/luni/tests/java/net/SocketTest.java
 
 # HARMONY-4043 (was duplicate HARMONY-4753)
 org/apache/harmony/luni/tests/java/lang/SecurityManager2Test.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.ibm?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86.ibm Mon Jan 21 03:55:17 2008
@@ -1,4 +1,4 @@
-tests/api/java/util/PropertiesTest.java
+org/apache/harmony/luni/tests/java/util/PropertiesTest.java
 org/apache/harmony/luni/tests/java/lang/SecurityManager2Test.java
 org/apache/harmony/luni/tests/java/lang/PackageTest.java
 org/apache/harmony/luni/tests/java/lang/PackageTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86_64.drl?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86_64.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.linux.x86_64.drl Mon Jan 21 03:55:17 2008
@@ -1,7 +1,7 @@
 org/apache/harmony/luni/tests/java/net/InetAddressTest.java
 org/apache/harmony/luni/tests/java/lang/ThreadTest.java
-tests/api/java/net/SocketTest.java
-tests/api/java/net/MulticastSocketTest.java
+org/apache/harmony/luni/tests/java/net/SocketTest.java
+org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java
 
 # HARMONY-4043 (was duplicate HARMONY-4753)
 org/apache/harmony/luni/tests/java/lang/SecurityManager2Test.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86.ibm
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86.ibm?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86.ibm (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86.ibm Mon Jan 21 03:55:17 2008
@@ -1,3 +1,3 @@
-tests/api/java/util/PropertiesTest.java
+org/apache/harmony/luni/tests/java/util/PropertiesTest.java
 org/apache/harmony/luni/tests/java/lang/SecurityManager2Test.java
 org/apache/harmony/luni/tests/java/lang/PackageTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86_64.drl
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86_64.drl?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86_64.drl (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/make/exclude.windows.x86_64.drl Mon Jan 21 03:55:17 2008
@@ -1,5 +1,5 @@
-tests/api/java/net/MulticastSocketTest.java
-tests/api/java/util/ArrayListTest.java
+org/apache/harmony/luni/tests/java/net/MulticastSocketTest.java
+org/apache/harmony/luni/tests/java/util/ArrayListTest.java
 
 # HARMONY-4043 (was duplicate HARMONY-4753)
 org/apache/harmony/luni/tests/java/lang/SecurityManager2Test.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Calendar.java Mon Jan 21 03:55:17 2008
@@ -156,11 +156,13 @@
 	 */
 	protected Calendar(TimeZone timezone, Locale locale) {
 		this(timezone);
-		ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
-		setFirstDayOfWeek(((Integer) bundle.getObject("First_Day")).intValue()); //$NON-NLS-1$
-		setMinimalDaysInFirstWeek(((Integer) bundle.getObject("Minimal_Days")) //$NON-NLS-1$
-				.intValue());
+        com.ibm.icu.util.Calendar icuCalendar = com.ibm.icu.util.Calendar
+                .getInstance(com.ibm.icu.util.SimpleTimeZone
+                        .getTimeZone(timezone.getID()), locale);
+        setFirstDayOfWeek(icuCalendar.getFirstDayOfWeek());
+        setMinimalDaysInFirstWeek(icuCalendar.getMinimalDaysInFirstWeek());
 	}
+
 
 	/**
 	 * Adds the specified amount to a Calendar field.

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Collections.java Mon Jan 21 03:55:17 2008
@@ -1840,7 +1840,7 @@
         if (!(list instanceof RandomAccess)) {
             Object[] array = list.toArray();
             for (int i = array.length - 1; i > 0; i--) {
-                int index = random.nextInt() % (i + 1);
+                int index = random.nextInt(i + 1);
                 if (index < 0) {
                     index = -index;
                 }
@@ -1859,7 +1859,7 @@
         } else {
             List<Object> rawList = (List<Object>) list;
             for (int i = rawList.size() - 1; i > 0; i--) {
-                int index = random.nextInt() % (i + 1);
+                int index = random.nextInt(i + 1);
                 if (index < 0) {
                     index = -index;
                 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java Mon Jan 21 03:55:17 2008
@@ -19,8 +19,6 @@
 
 import java.io.Serializable;
 
-import org.apache.harmony.luni.util.Msg;
-
 /**
  * This class represents a currency as identified in the ISO 4217 currency
  * codes.
@@ -33,10 +31,6 @@
 
     private String currencyCode;
 
-    private static String currencyVars = "EURO, HK, PREEURO"; //$NON-NLS-1$
-
-    private transient int defaultFractionDigits;
-
     /**
      * @param currencyCode
      */
@@ -60,20 +54,7 @@
         Currency currency = codesToCurrencies.get(currencyCode);
 
         if (currency == null) {
-            ResourceBundle bundle = Locale.getBundle(
-                    "ISO4CurrenciesToDigits", Locale.getDefault()); //$NON-NLS-1$
             currency = new Currency(currencyCode);
-
-            String defaultFractionDigits = null;
-            try {
-                defaultFractionDigits = bundle.getString(currencyCode);
-            } catch (MissingResourceException e) {
-                throw new IllegalArgumentException(
-                        org.apache.harmony.luni.util.Msg.getString(
-                                "K0322", currencyCode)); //$NON-NLS-1$
-            }
-            currency.defaultFractionDigits = Integer
-                    .parseInt(defaultFractionDigits);
             codesToCurrencies.put(currencyCode, currency);
         }
 
@@ -91,21 +72,11 @@
      *             if the locale's country is not a supported ISO 3166 Country
      */
     public static Currency getInstance(Locale locale) {
-        String country = locale.getCountry();
-        String variant = locale.getVariant();
-        if (!variant.equals("") && currencyVars.indexOf(variant) > -1) { //$NON-NLS-1$
-            country = country + "_" + variant; //$NON-NLS-1$
-        }
-
-        ResourceBundle bundle = Locale.getBundle(
-                "ISO4Currencies", Locale.getDefault()); //$NON-NLS-1$
-        String currencyCode = null;
-        try {
-            currencyCode = bundle.getString(country);
-        } catch (MissingResourceException e) {
-            throw new IllegalArgumentException(Msg.getString(
-                    "K0323", locale.toString())); //$NON-NLS-1$
+        com.ibm.icu.util.Currency currency = com.ibm.icu.util.Currency.getInstance(locale);
+        if(currency == null) {
+            return null;
         }
+        String currencyCode = currency.getCurrencyCode();
 
         if (currencyCode.equals("None")) { //$NON-NLS-1$
             return null;
@@ -161,35 +132,7 @@
         if (locale.getCountry().equals("")) { //$NON-NLS-1$
             return currencyCode;
         }
-
-        // check in the Locale bundle first, if the local has the same currency
-        ResourceBundle bundle = Locale.getBundle("Locale", locale); //$NON-NLS-1$
-        if (((String) bundle.getObject("IntCurrencySymbol")) //$NON-NLS-1$
-                .equals(currencyCode)) {
-            return (String) bundle.getObject("CurrencySymbol"); //$NON-NLS-1$
-        }
-
-        // search for a Currency bundle
-        bundle = null;
-        try {
-            bundle = Locale.getBundle("Currency", locale); //$NON-NLS-1$
-        } catch (MissingResourceException e) {
-            return currencyCode;
-        }
-
-        // is the bundle found for a different country? (for instance the
-        // default locale's currency bundle)
-        if (!bundle.getLocale().getCountry().equals(locale.getCountry())) {
-            return currencyCode;
-        }
-
-        // check if the currency bundle for this locale
-        // has an entry for this currency
-        String result = (String) bundle.handleGetObject(currencyCode);
-        if (result != null) {
-            return result;
-        }
-        return currencyCode;
+        return com.ibm.icu.util.Currency.getInstance(currencyCode).getSymbol(locale);
     }
 
     /**
@@ -200,7 +143,7 @@
      * @return the default number of fraction digits for this currency
      */
     public int getDefaultFractionDigits() {
-        return defaultFractionDigits;
+        return com.ibm.icu.util.Currency.getInstance(currencyCode).getDefaultFractionDigits();
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Locale.java Mon Jan 21 03:55:17 2008
@@ -24,14 +24,12 @@
 import java.io.ObjectStreamField;
 import java.io.Serializable;
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import org.apache.harmony.luni.internal.locale.Country;
-import org.apache.harmony.luni.internal.locale.Language;
 import org.apache.harmony.luni.util.PriviAction;
-import org.apache.harmony.luni.util.Util;
+
+import com.ibm.icu.util.ULocale;
 
 /**
  * Locale represents a language/country/variant combination. It is an identifier
@@ -180,6 +178,8 @@
     private transient String languageCode;
     private transient String variantCode;
 
+    private transient ULocale uLocale;
+
 	/**
 	 * Constructs a default which is used during static initialization of the
 	 * default for the platform.
@@ -226,7 +226,14 @@
         if (language == null || country == null || variant == null) {
             throw new NullPointerException();
         }
-        languageCode = Util.toASCIILowerCase(language);
+        if(language.length() == 0 && country.length() == 0){
+            languageCode = "";
+            countryCode = "";
+            variantCode = variant;
+            return;
+        }
+        this.uLocale = new ULocale(language, country, variant);
+        languageCode = uLocale.getLanguage();
         // Map new language codes to the obsolete language
         // codes so the correct resource bundles will be used.
         if (languageCode.equals("he")) {//$NON-NLS-1$
@@ -238,9 +245,9 @@
         }
 
         // countryCode is defined in ASCII character set
-        countryCode = Util.toASCIIUpperCase(country);
+        countryCode = uLocale.getCountry();
 
-        variantCode = variant;
+        variantCode = uLocale.getVariant();
     }
 
 	/**
@@ -377,16 +384,13 @@
 	 * @return an array of Locale
 	 */
 	public static Locale[] getAvailableLocales() {
-		if (availableLocales == null) {
-            availableLocales = AccessController
-                    .doPrivileged(new PrivilegedAction<Locale[]>() {
-                        public Locale[] run() {
-                            return find("org/apache/harmony/luni/internal/locale/Locale_"); //$NON-NLS-1$
+		ULocale[] ulocales =  ULocale.getAvailableLocales();
+        Locale[] locales = new Locale[ulocales.length];
+        for (int i = 0; i < locales.length; i++) {
+            locales[i] = ulocales[i].toLocale();
                         }
-                    });
+        return locales;
         }
-		return availableLocales.clone();
-	}
 
 	/**
 	 * Gets the country code for this Locale.
@@ -427,25 +431,8 @@
 	 * @return a country name
 	 */
 	public String getDisplayCountry(Locale locale) {
-		if (countryCode.length() == 0) {
-            return countryCode;
+		return ULocale.forLocale(this).getDisplayCountry(ULocale.forLocale(locale));
         }
-		try {
-			// First try the specified locale
-			ResourceBundle bundle = getBundle("Country", locale); //$NON-NLS-1$
-			String result = (String) bundle.handleGetObject(countryCode);
-			if (result != null) {
-                return result;
-            }
-			// Now use the default locale
-			if (locale != Locale.getDefault()) {
-                bundle = getBundle("Country", Locale.getDefault()); //$NON-NLS-1$
-            }
-			return bundle.getString(countryCode);
-		} catch (MissingResourceException e) {
-			return countryCode;
-		}
-	}
 
 	/**
 	 * Gets the full language name in the default Locale for the language code
@@ -468,25 +455,8 @@
 	 * @return a language name
 	 */
 	public String getDisplayLanguage(Locale locale) {
-		if (languageCode.length() == 0) {
-            return languageCode;
+        return ULocale.forLocale(this).getDisplayLanguage(ULocale.forLocale(locale));
         }
-		try {
-			// First try the specified locale
-			ResourceBundle bundle = getBundle("Language", locale); //$NON-NLS-1$
-			String result = (String) bundle.handleGetObject(languageCode);
-			if (result != null) {
-                return result;
-            }
-			// Now use the default locale
-			if (locale != Locale.getDefault()) {
-                bundle = getBundle("Language", Locale.getDefault()); //$NON-NLS-1$
-            }
-			return bundle.getString(languageCode);
-		} catch (MissingResourceException e) {
-			return languageCode;
-		}
-	}
 
 	/**
 	 * Gets the full language, country, and variant names in the default Locale
@@ -556,32 +526,8 @@
 	 * @return a variant name
 	 */
 	public String getDisplayVariant(Locale locale) {
-		if (variantCode.length() == 0) {
-            return variantCode;
+        return ULocale.forLocale(this).getDisplayVariant(ULocale.forLocale(locale));
         }
-		ResourceBundle bundle;
-		try {
-			bundle = getBundle("Variant", locale); //$NON-NLS-1$
-		} catch (MissingResourceException e) {
-			return variantCode.replace('_', ',');
-		}
-
-		StringBuffer result = new StringBuffer();
-		StringTokenizer tokens = new StringTokenizer(variantCode, "_"); //$NON-NLS-1$
-		while (tokens.hasMoreTokens()) {
-			String code, variant = tokens.nextToken();
-			try {
-				code = bundle.getString(variant);
-			} catch (MissingResourceException e) {
-				code = variant;
-			}
-			result.append(code);
-			if (tokens.hasMoreTokens()) {
-                result.append(',');
-            }
-		}
-		return result.toString();
-	}
 
 	/**
 	 * Gets the three letter ISO country code which corresponds to the country
@@ -593,12 +539,8 @@
 	 *                when there is no matching three letter ISO country code
 	 */
 	public String getISO3Country() throws MissingResourceException {
-		if (countryCode.length() == 0) {
-            return ""; //$NON-NLS-1$
+        return ULocale.forLocale(this).getISO3Country();
         }
-		ResourceBundle bundle = getBundle("ISO3Countries", this); //$NON-NLS-1$
-		return bundle.getString(countryCode);
-	}
 
 	/**
 	 * Gets the three letter ISO language code which corresponds to the language
@@ -610,12 +552,8 @@
 	 *                when there is no matching three letter ISO language code
 	 */
 	public String getISO3Language() throws MissingResourceException {
-		if (languageCode.length() == 0) {
-            return ""; //$NON-NLS-1$
+        return ULocale.forLocale(this).getISO3Language();
         }
-		ResourceBundle bundle = getBundle("ISO3Languages", this); //$NON-NLS-1$
-		return bundle.getString(languageCode);
-	}
 
 	/**
 	 * Gets the list of two letter ISO country codes which can be used as the
@@ -624,19 +562,8 @@
 	 * @return an array of String
 	 */
 	public static String[] getISOCountries() {
-        ListResourceBundle bundle = new Country();
-
-        // To initialize the table
-        Enumeration<String> keys = bundle.getKeys(); 
-        int size = bundle.table.size();
-        String[] result = new String[size];
-        int index = 0;
-        while (keys.hasMoreElements()) {
-            String element = keys.nextElement();
-            result[index++] = element;
+        return ULocale.getISOCountries();
         }
-        return result;
-    }
 
 	/**
 	 * Gets the list of two letter ISO language codes which can be used as the
@@ -645,16 +572,8 @@
 	 * @return an array of String
 	 */
 	public static String[] getISOLanguages() {
-		ListResourceBundle bundle = new Language();
-        Enumeration<String> keys = bundle.getKeys(); // to initialize the
-                                                        // table
-		String[] result = new String[bundle.table.size()];
-		int index = 0;
-		while (keys.hasMoreElements()) {
-            result[index++] = keys.nextElement();
+        return ULocale.getISOLanguages();
         }
-		return result;
-	}
 
 	/**
 	 * Gets the language code for this Locale.
@@ -732,17 +651,6 @@
 			result.append(variantCode);
 		}
 		return result.toString();
-	}
-
-	static ResourceBundle getBundle(final String clName, final Locale locale) {
-        return AccessController
-                .doPrivileged(new PrivilegedAction<ResourceBundle>() {
-					public ResourceBundle run() {
-                        return ResourceBundle.getBundle(
-                                "org.apache.harmony.luni.internal.locale." //$NON-NLS-1$
-								+ clName, locale);
-					}
-				});
 	}
 
 	private static final ObjectStreamField[] serialPersistentFields = {

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/SimpleTimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/SimpleTimeZone.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/SimpleTimeZone.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/SimpleTimeZone.java Mon Jan 21 03:55:17 2008
@@ -69,6 +69,10 @@
 
     private int dstSavings = 3600000;
 
+    private transient com.ibm.icu.util.TimeZone icuTZ;
+
+    private boolean isSimple;
+
     /**
      * Constructs a new SimpleTimeZone using the specified offset for standard
      * time from GMT and the specified time zone ID.
@@ -81,6 +85,12 @@
     public SimpleTimeZone(int offset, String name) {
         setID(name);
         rawOffset = offset;
+        icuTZ = com.ibm.icu.util.TimeZone.getTimeZone(name);
+        if (icuTZ instanceof com.ibm.icu.util.SimpleTimeZone) {
+            isSimple = true;
+            icuTZ.setRawOffset(offset);
+        }
+        useDaylight = icuTZ.useDaylightTime();
     }
 
     /**
@@ -159,7 +169,17 @@
     public SimpleTimeZone(int offset, String name, int startMonth,
             int startDay, int startDayOfWeek, int startTime, int endMonth,
             int endDay, int endDayOfWeek, int endTime, int daylightSavings) {
-        this(offset, name);
+        icuTZ = com.ibm.icu.util.TimeZone.getTimeZone(name);
+        if (icuTZ instanceof com.ibm.icu.util.SimpleTimeZone) {
+            isSimple = true;
+            com.ibm.icu.util.SimpleTimeZone tz = (com.ibm.icu.util.SimpleTimeZone)icuTZ;
+            tz.setRawOffset(offset);
+            tz.setStartRule(startMonth, startDay, startDayOfWeek, startTime);
+            tz.setEndRule(endMonth, endDay, endDayOfWeek, endTime);
+            tz.setDSTSavings(daylightSavings);
+        }
+        setID(name);
+        rawOffset = offset;
         if (daylightSavings <= 0) {
             throw new IllegalArgumentException(Msg.getString(
                     "K00e9", daylightSavings)); //$NON-NLS-1$
@@ -168,6 +188,8 @@
 
         setStartRule(startMonth, startDay, startDayOfWeek, startTime);
         setEndRule(endMonth, endDay, endDayOfWeek, endTime);
+        
+        useDaylight = daylightSavings > 0 || icuTZ.useDaylightTime();
     }
 
     /**
@@ -312,123 +334,7 @@
         if (month != Calendar.FEBRUARY || day != 29 || !isLeapYear(year)) {
             checkDay(month, day);
         }
-
-        if (!useDaylightTime() || era != GregorianCalendar.AD
-                || year < startYear) {
-            return rawOffset;
-        }
-        if (endMonth < startMonth) {
-            if (month > endMonth && month < startMonth) {
-                return rawOffset;
-            }
-        } else {
-            if (month < startMonth || month > endMonth) {
-                return rawOffset;
-            }
-        }
-
-        int ruleDay = 0, daysInMonth, firstDayOfMonth = mod7(dayOfWeek - day);
-        if (month == startMonth) {
-            switch (startMode) {
-            case DOM_MODE:
-                ruleDay = startDay;
-                break;
-            case DOW_IN_MONTH_MODE:
-                if (startDay >= 0) {
-                    ruleDay = mod7(startDayOfWeek - firstDayOfMonth) + 1
-                            + (startDay - 1) * 7;
-                } else {
-                    daysInMonth = GregorianCalendar.DaysInMonth[startMonth];
-                    if (startMonth == Calendar.FEBRUARY && isLeapYear(year)) {
-                        daysInMonth += 1;
-                    }
-                    ruleDay = daysInMonth
-                            + 1
-                            + mod7(startDayOfWeek
-                                    - (firstDayOfMonth + daysInMonth))
-                            + startDay * 7;
-                }
-                break;
-            case DOW_GE_DOM_MODE:
-                ruleDay = startDay
-                        + mod7(startDayOfWeek
-                                - (firstDayOfMonth + startDay - 1));
-                break;
-            case DOW_LE_DOM_MODE:
-                ruleDay = startDay
-                        + mod7(startDayOfWeek
-                                - (firstDayOfMonth + startDay - 1));
-                if (ruleDay != startDay) {
-                    ruleDay -= 7;
-                }
-                break;
-            }
-            if (ruleDay > day || ruleDay == day && time < startTime) {
-                return rawOffset;
-            }
-        }
-
-        int ruleTime = endTime - dstSavings;
-        int nextMonth = (month + 1) % 12;
-        if (month == endMonth || (ruleTime < 0 && nextMonth == endMonth)) {
-            switch (endMode) {
-            case DOM_MODE:
-                ruleDay = endDay;
-                break;
-            case DOW_IN_MONTH_MODE:
-                if (endDay >= 0) {
-                    ruleDay = mod7(endDayOfWeek - firstDayOfMonth) + 1
-                            + (endDay - 1) * 7;
-                } else {
-                    daysInMonth = GregorianCalendar.DaysInMonth[endMonth];
-                    if (endMonth == Calendar.FEBRUARY && isLeapYear(year)) {
-                        daysInMonth++;
-                    }
-                    ruleDay = daysInMonth
-                            + 1
-                            + mod7(endDayOfWeek
-                                    - (firstDayOfMonth + daysInMonth)) + endDay
-                            * 7;
-                }
-                break;
-            case DOW_GE_DOM_MODE:
-                ruleDay = endDay
-                        + mod7(endDayOfWeek - (firstDayOfMonth + endDay - 1));
-                break;
-            case DOW_LE_DOM_MODE:
-                ruleDay = endDay
-                        + mod7(endDayOfWeek - (firstDayOfMonth + endDay - 1));
-                if (ruleDay != endDay) {
-                    ruleDay -= 7;
-                }
-                break;
-            }
-
-            int ruleMonth = endMonth;
-            if (ruleTime < 0) {
-                int changeDays = 1 - (ruleTime / 86400000);
-                ruleTime = (ruleTime % 86400000) + 86400000;
-                ruleDay -= changeDays;
-                if (ruleDay <= 0) {
-                    if (--ruleMonth < Calendar.JANUARY) {
-                        ruleMonth = Calendar.DECEMBER;
-                    }
-                    ruleDay += GregorianCalendar.DaysInMonth[ruleMonth];
-                    if (ruleMonth == Calendar.FEBRUARY && isLeapYear(year)) {
-                        ruleDay++;
-                    }
-                }
-            }
-
-            if (month == ruleMonth) {
-                if (ruleDay < day || ruleDay == day && time >= ruleTime) {
-                    return rawOffset;
-                }
-            } else if (nextMonth != ruleMonth) {
-                return rawOffset;
-            }
-        }
-        return rawOffset + dstSavings;
+        return icuTZ.getOffset(era, year, month, day, dayOfWeek, time);
     }
 
     /**
@@ -442,13 +348,7 @@
      */
     @Override
     public int getOffset(long time) {
-        if (!useDaylightTime()) {
-            return rawOffset;
-        }
-        if (daylightSavings == null) {
-            daylightSavings = new GregorianCalendar(this);
-        }
-        return daylightSavings.getOffset(time + rawOffset);
+        return icuTZ.getOffset(time);
     }
 
     /**
@@ -521,15 +421,7 @@
      */
     @Override
     public boolean inDaylightTime(Date time) {
-        // check for null pointer
-        long millis = time.getTime();
-        if (!useDaylightTime()) {
-            return false;
-        }
-        if (daylightSavings == null) {
-            daylightSavings = new GregorianCalendar(this);
-        }
-        return daylightSavings.getOffset(millis + rawOffset) != rawOffset;
+        return icuTZ.inDaylightTime(time);
     }
 
     private boolean isLeapYear(int year) {
@@ -539,11 +431,6 @@
         return year % 4 == 0;
     }
 
-    private int mod7(int num1) {
-        int rem = num1 % 7;
-        return (num1 < 0 && rem < 0) ? 7 + rem : rem;
-    }
-
     /**
      * Sets the daylight savings offset in milliseconds for this SimpleTimeZone.
      * 
@@ -627,6 +514,10 @@
         endDayOfWeek = 0; // Initialize this value for hasSameRules()
         endTime = time;
         setEndMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month,
+                    dayOfMonth, time);
+        }
     }
 
     /**
@@ -650,6 +541,10 @@
         endDayOfWeek = dayOfWeek;
         endTime = time;
         setEndMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, day,
+                    dayOfWeek, time);
+        }
     }
 
     /**
@@ -675,6 +570,10 @@
         endDayOfWeek = -dayOfWeek;
         endTime = time;
         setEndMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setEndRule(month, day,
+                    dayOfWeek, time, after);
+        }
     }
 
     /**
@@ -738,6 +637,10 @@
         startDayOfWeek = 0; // Initialize this value for hasSameRules()
         startTime = time;
         setStartMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month,
+                    dayOfMonth, time);
+        }
     }
 
     /**
@@ -761,6 +664,10 @@
         startDayOfWeek = dayOfWeek;
         startTime = time;
         setStartMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, day,
+                    dayOfWeek, time);
+        }
     }
 
     /**
@@ -786,6 +693,10 @@
         startDayOfWeek = -dayOfWeek;
         startTime = time;
         setStartMode();
+        if (isSimple) {
+            ((com.ibm.icu.util.SimpleTimeZone) icuTZ).setStartRule(month, day,
+                    dayOfWeek, time, after);
+        }
     }
 
     /**

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java?rev=613858&r1=613857&r2=613858&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TimeZone.java Mon Jan 21 03:55:17 2008
@@ -19,6 +19,7 @@
 
 import java.io.Serializable;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.DateFormatSymbols;
 
 import org.apache.harmony.luni.util.PriviAction;
@@ -447,6 +448,7 @@
      */
     public static synchronized void setDefault(TimeZone timezone) {
         if (timezone != null) {
+            setICUDefaultTimeZone(timezone);
             Default = timezone;
             return;
         }
@@ -484,6 +486,28 @@
             // if property user.timezone is set in command line (with -D option)
             Default = getTimeZone(zone);
         }
+        setICUDefaultTimeZone(Default);
+    }
+
+    private static void setICUDefaultTimeZone(TimeZone timezone) {
+        final com.ibm.icu.util.TimeZone icuTZ = com.ibm.icu.util.TimeZone
+                .getTimeZone(timezone.getID());
+
+        AccessController
+                .doPrivileged(new PrivilegedAction<java.lang.reflect.Field>() {
+                    public java.lang.reflect.Field run() {
+                        java.lang.reflect.Field field = null;
+                        try {
+                            field = com.ibm.icu.util.TimeZone.class
+                                    .getDeclaredField("defaultZone");
+                            field.setAccessible(true);
+                            field.set("defaultZone", icuTZ);
+                        } catch (Exception e) {
+                            return null;
+                        }
+                        return field;
+                    }
+                });
     }
 
     /**



Mime
View raw message