Merge
authorlana
Tue, 04 Dec 2012 11:41:44 -0800
changeset 14660 7fc763673645
parent 14646 94eed98a7ecb (current diff)
parent 14659 cda39b3e7f15 (diff)
child 14704 e7924bf18a73
Merge
jdk/src/share/classes/sun/awt/TextureSizeConstraining.java
--- a/jdk/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java	Tue Dec 04 11:41:44 2012 -0800
@@ -714,7 +714,8 @@
 
             "PopupMenu.font", menuFont,
             "PopupMenu.background", menuBackgroundColor,
-            "PopupMenu.translucentBackground", translucentWhite,
+            // Fix for 7154516: make popups opaque
+            "PopupMenu.translucentBackground", white,
             "PopupMenu.foreground", menuForegroundColor,
             "PopupMenu.selectionBackground", menuSelectedBackgroundColor,
             "PopupMenu.selectionForeground", menuSelectedForegroundColor,
--- a/jdk/src/macosx/classes/sun/awt/CGraphicsConfig.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/awt/CGraphicsConfig.java	Tue Dec 04 11:41:44 2012 -0800
@@ -31,13 +31,16 @@
 
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.CGLLayer;
+import sun.lwawt.LWGraphicsConfig;
 import sun.lwawt.macosx.CPlatformView;
 
-public class CGraphicsConfig extends GraphicsConfiguration {
+public abstract class CGraphicsConfig extends GraphicsConfiguration
+        implements LWGraphicsConfig {
+
     private final CGraphicsDevice device;
     private ColorModel colorModel;
 
-    public CGraphicsConfig(CGraphicsDevice device) {
+    protected CGraphicsConfig(CGraphicsDevice device) {
         this.device = device;
     }
 
@@ -84,88 +87,20 @@
         return new AffineTransform(xscale, 0.0, 0.0, yscale, 0.0, 0.0);
     }
 
-
-    /**
-     * The following methods are invoked from CToolkit.java and
-     * LWWindowPeer.java rather than having the native
-     * implementations hardcoded in those classes.  This way the appropriate
-     * actions are taken based on the peer's GraphicsConfig, whether it is
-     * an CGLGraphicsConfig or something else.
-     */
-
     /**
      * Creates a new SurfaceData that will be associated with the given
      * LWWindowPeer.
      */
-    public SurfaceData createSurfaceData(CPlatformView pView) {
-        throw new UnsupportedOperationException("not implemented");
-    }
+    public abstract SurfaceData createSurfaceData(CPlatformView pView);
 
     /**
      * Creates a new SurfaceData that will be associated with the given
      * CGLLayer.
      */
-    public SurfaceData createSurfaceData(CGLLayer layer) {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * Creates a new hidden-acceleration image of the given width and height
-     * that is associated with the target Component.
-     */
-    public Image createAcceleratedImage(Component target,
-                                        int width, int height)
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * The following methods correspond to the multibuffering methods in
-     * LWWindowPeer.java...
-     */
-
-    /**
-     * Attempts to create a native backbuffer for the given peer.  If
-     * the requested configuration is not natively supported, an AWTException
-     * is thrown.  Otherwise, if the backbuffer creation is successful, a
-     * handle to the native backbuffer is returned.
-     */
-    public long createBackBuffer(CPlatformView pView,
-                                 int numBuffers, BufferCapabilities caps)
-        throws AWTException
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    public void destroyBackBuffer(long backBuffer)
-        throws AWTException
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * Creates a VolatileImage that essentially wraps the target Component's
-     * backbuffer, using the provided backbuffer handle.
-     */
-    public VolatileImage createBackBufferImage(Component target,
-                                               long backBuffer)
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
-
-    /**
-     * Performs the native flip operation for the given target Component.
-     */
-    public void flip(CPlatformView delegate,
-                     Component target, VolatileImage xBackBuffer,
-                     int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction)
-    {
-        throw new UnsupportedOperationException("not implemented");
-    }
+    public abstract SurfaceData createSurfaceData(CGLLayer layer);
 
     @Override
-    public boolean isTranslucencyCapable() {
+    public final boolean isTranslucencyCapable() {
         //we know for sure we have capable config :)
         return true;
     }
--- a/jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java	Tue Dec 04 11:41:44 2012 -0800
@@ -27,7 +27,6 @@
 
 import java.awt.AWTException;
 import java.awt.BufferCapabilities;
-import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
@@ -48,13 +47,10 @@
 
 import sun.awt.CGraphicsConfig;
 import sun.awt.CGraphicsDevice;
-import sun.awt.TextureSizeConstraining;
 import sun.awt.image.OffScreenImage;
 import sun.awt.image.SunVolatileImage;
-import sun.awt.image.SurfaceManager;
 import sun.java2d.Disposer;
 import sun.java2d.DisposerRecord;
-import sun.java2d.SunGraphics2D;
 import sun.java2d.Surface;
 import sun.java2d.SurfaceData;
 import sun.java2d.opengl.OGLContext.OGLContextCaps;
@@ -63,18 +59,19 @@
 import sun.java2d.pipe.hw.ContextCapabilities;
 import static sun.java2d.opengl.OGLSurfaceData.*;
 import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
-import sun.java2d.opengl.CGLSurfaceData.CGLVSyncOffScreenSurfaceData;
 import sun.java2d.pipe.hw.AccelDeviceEventListener;
 import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
 
+import sun.lwawt.LWComponentPeer;
 import sun.lwawt.macosx.CPlatformView;
 
-public class CGLGraphicsConfig extends CGraphicsConfig
-    implements OGLGraphicsConfig, TextureSizeConstraining
+public final class CGLGraphicsConfig extends CGraphicsConfig
+    implements OGLGraphicsConfig
 {
-    //private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
+    //private static final int kOpenGLSwapInterval =
+    // RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
     private static final int kOpenGLSwapInterval = 0; // TODO
-    protected static boolean cglAvailable;
+    private static boolean cglAvailable;
     private static ImageCapabilities imageCaps = new CGLImageCaps();
 
     private int pixfmt;
@@ -82,7 +79,7 @@
     private long pConfigInfo;
     private ContextCapabilities oglCaps;
     private OGLContext context;
-    private Object disposerReferent = new Object();
+    private final Object disposerReferent = new Object();
 
     public static native int getDefaultPixFmt(int screennum);
     private static native boolean initCGL();
@@ -94,7 +91,7 @@
         cglAvailable = initCGL();
     }
 
-    protected CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
+    private CGLGraphicsConfig(CGraphicsDevice device, int pixfmt,
                                 long configInfo, ContextCapabilities oglCaps)
     {
         super(device);
@@ -170,11 +167,13 @@
      * Returns true if the provided capability bit is present for this config.
      * See OGLContext.java for a list of supported capabilities.
      */
-    public final boolean isCapPresent(int cap) {
+    @Override
+    public boolean isCapPresent(int cap) {
         return ((oglCaps.getCaps() & cap) != 0);
     }
 
-    public final long getNativeConfigInfo() {
+    @Override
+    public long getNativeConfigInfo() {
         return pConfigInfo;
     }
 
@@ -183,7 +182,8 @@
      *
      * @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
      */
-    public final OGLContext getContext() {
+    @Override
+    public OGLContext getContext() {
         return context;
     }
 
@@ -257,145 +257,83 @@
         return ("CGLGraphicsConfig[dev="+screen+",pixfmt="+pixfmt+"]");
     }
 
-
-    /**
-     * The following methods are invoked from ComponentModel.java rather
-     * than having the Mac OS X-dependent implementations hardcoded in that
-     * class.  This way the appropriate actions are taken based on the peer's
-     * GraphicsConfig, whether it is a CGraphicsConfig or a
-     * CGLGraphicsConfig.
-     */
-
-    /**
-     * Creates a new SurfaceData that will be associated with the given
-     * LWWindowPeer.
-     */
     @Override
     public SurfaceData createSurfaceData(CPlatformView pView) {
         return CGLSurfaceData.createData(pView);
     }
 
-    /**
-     * Creates a new SurfaceData that will be associated with the given
-     * CGLLayer.
-     */
     @Override
     public SurfaceData createSurfaceData(CGLLayer layer) {
         return CGLSurfaceData.createData(layer);
     }
 
-    /**
-     * Creates a new hidden-acceleration image of the given width and height
-     * that is associated with the target Component.
-     */
     @Override
     public Image createAcceleratedImage(Component target,
                                         int width, int height)
     {
         ColorModel model = getColorModel(Transparency.OPAQUE);
-        WritableRaster wr =
-            model.createCompatibleWritableRaster(width, height);
+        WritableRaster wr = model.createCompatibleWritableRaster(width, height);
         return new OffScreenImage(target, model, wr,
                                   model.isAlphaPremultiplied());
     }
 
-    /**
-     * The following methods correspond to the multibuffering methods in
-     * CWindowPeer.java...
-     */
-
-    /**
-     * Attempts to create a OGL-based backbuffer for the given peer.  If
-     * the requested configuration is not natively supported, an AWTException
-     * is thrown.  Otherwise, if the backbuffer creation is successful, a
-     * value of 1 is returned.
-     */
     @Override
-    public long createBackBuffer(CPlatformView pView,
-                                 int numBuffers, BufferCapabilities caps)
-        throws AWTException
-    {
-        if (numBuffers > 2) {
-            throw new AWTException(
-                "Only double or single buffering is supported");
+    public void assertOperationSupported(final int numBuffers,
+                                         final BufferCapabilities caps)
+            throws AWTException {
+        // Assume this method is never called with numBuffers != 2, as 0 is
+        // unsupported, and 1 corresponds to a SingleBufferStrategy which
+        // doesn't depend on the peer. Screen is considered as a separate
+        // "buffer".
+        if (numBuffers != 2) {
+            throw new AWTException("Only double buffering is supported");
         }
-        BufferCapabilities configCaps = getBufferCapabilities();
+        final BufferCapabilities configCaps = getBufferCapabilities();
         if (!configCaps.isPageFlipping()) {
             throw new AWTException("Page flipping is not supported");
         }
         if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
             throw new AWTException("FlipContents.PRIOR is not supported");
         }
-
-        // non-zero return value means backbuffer creation was successful
-        // (checked in CPlatformWindow.flip(), etc.)
-        return 1;
     }
 
-    /**
-     * Destroys the backbuffer object represented by the given handle value.
-     */
     @Override
-    public void destroyBackBuffer(long backBuffer) {
-    }
-
-    /**
-     * Creates a VolatileImage that essentially wraps the target Component's
-     * backbuffer (the provided backbuffer handle is essentially ignored).
-     */
-    @Override
-    public VolatileImage createBackBufferImage(Component target,
-                                               long backBuffer)
-    {
-        return new SunVolatileImage(target,
-                                    target.getWidth(), target.getHeight(),
-                                    Boolean.TRUE);
+    public Image createBackBuffer(final LWComponentPeer<?, ?> peer) {
+        final Rectangle r = peer.getBounds();
+        // It is possible for the component to have size 0x0, adjust it to
+        // be at least 1x1 to avoid IAE
+        final int w = Math.max(1, r.width);
+        final int h = Math.max(1, r.height);
+        final int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT
+                                                      : Transparency.OPAQUE;
+        return new SunVolatileImage(this, w, h, transparency, null);
     }
 
-    /**
-     * Performs the native OGL flip operation for the given target Component.
-     */
     @Override
-    public void flip(CPlatformView pView,
-                     Component target, VolatileImage xBackBuffer,
-                     int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction)
-    {
-        if (flipAction == BufferCapabilities.FlipContents.COPIED) {
-            SurfaceManager vsm = SurfaceManager.getManager(xBackBuffer);
-            SurfaceData sd = vsm.getPrimarySurfaceData();
+    public void destroyBackBuffer(final Image backBuffer) {
+        if (backBuffer != null) {
+            backBuffer.flush();
+        }
+    }
 
-            if (sd instanceof CGLVSyncOffScreenSurfaceData) {
-                CGLVSyncOffScreenSurfaceData vsd =
-                    (CGLVSyncOffScreenSurfaceData)sd;
-                SurfaceData bbsd = vsd.getFlipSurface();
-                Graphics2D bbg =
-                    new SunGraphics2D(bbsd, Color.black, Color.white, null);
-                try {
-                    bbg.drawImage(xBackBuffer, 0, 0, null);
-                } finally {
-                    bbg.dispose();
-                }
-            } else {
-                pView.drawImageOnPeer(xBackBuffer, x1, y1, x2, y2);
-                return;
-            }
-        } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
-            // not supported by CGL...
-            return;
+    @Override
+    public void flip(final LWComponentPeer<?, ?> peer, final Image backBuffer,
+                     final int x1, final int y1, final int x2, final int y2,
+                     final BufferCapabilities.FlipContents flipAction) {
+        final Graphics g = peer.getGraphics();
+        try {
+            g.drawImage(backBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
+        } finally {
+            g.dispose();
         }
-
-        OGLSurfaceData.swapBuffers(pView.getAWTView());
-
         if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
-            Graphics g = xBackBuffer.getGraphics();
+            final Graphics2D bg = (Graphics2D) backBuffer.getGraphics();
             try {
-                g.setColor(target.getBackground());
-                g.fillRect(0, 0,
-                           xBackBuffer.getWidth(),
-                           xBackBuffer.getHeight());
+                bg.setBackground(peer.getBackground());
+                bg.clearRect(0, 0, backBuffer.getWidth(null),
+                             backBuffer.getHeight(null));
             } finally {
-                g.dispose();
+                bg.dispose();
             }
         }
     }
@@ -429,15 +367,10 @@
         return imageCaps;
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
-     */
-    public VolatileImage
-        createCompatibleVolatileImage(int width, int height,
-                                      int transparency, int type)
-    {
+    @Override
+    public VolatileImage createCompatibleVolatileImage(int width, int height,
+                                                       int transparency,
+                                                       int type) {
         if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
             transparency == Transparency.BITMASK)
         {
@@ -473,15 +406,18 @@
      *
      * @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
      */
+    @Override
     public ContextCapabilities getContextCapabilities() {
         return oglCaps;
     }
 
+    @Override
     public void addDeviceEventListener(AccelDeviceEventListener l) {
         int screen = getDevice().getCoreGraphicsScreen();
         AccelDeviceEventNotifier.addListener(l, screen);
     }
 
+    @Override
     public void removeDeviceEventListener(AccelDeviceEventListener l) {
         AccelDeviceEventNotifier.removeListener(l);
     }
--- a/jdk/src/macosx/classes/sun/lwawt/LWCanvasPeer.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWCanvasPeer.java	Tue Dec 04 11:41:44 2012 -0800
@@ -26,12 +26,9 @@
 
 package sun.lwawt;
 
-import java.awt.AWTException;
-import java.awt.BufferCapabilities;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.GraphicsConfiguration;
-import java.awt.Image;
 import java.awt.peer.CanvasPeer;
 
 import javax.swing.JComponent;
@@ -42,35 +39,10 @@
     LWCanvasPeer(final T target, final PlatformComponent platformComponent) {
         super(target, platformComponent);
     }
-    // ---- PEER METHODS ---- //
-
-    @Override
-    public void createBuffers(int numBuffers, BufferCapabilities caps)
-            throws AWTException {
-        // TODO
-    }
-
-    @Override
-    public Image getBackBuffer() {
-        // TODO
-        return null;
-    }
-
-    @Override
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction) {
-        // TODO
-    }
-
-    @Override
-    public void destroyBuffers() {
-        // TODO
-    }
 
     @Override
     public final GraphicsConfiguration getAppropriateGraphicsConfiguration(
-            GraphicsConfiguration gc)
-    {
+            final GraphicsConfiguration gc) {
         // TODO
         return gc;
     }
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java	Tue Dec 04 11:41:44 2012 -0800
@@ -138,6 +138,11 @@
      */
     static final char WIDE_CHAR = '0';
 
+    /**
+     * The back buffer provide user with a BufferStrategy.
+     */
+    private Image backBuffer;
+
     private final class DelegateContainer extends Container {
         {
             enableEvents(0xFFFFFFFF);
@@ -389,6 +394,7 @@
     }
 
     protected void disposeImpl() {
+        destroyBuffers();
         LWContainerPeer cp = getContainerPeer();
         if (cp != null) {
             cp.removeChildPeer(this);
@@ -415,6 +421,12 @@
         return getWindowPeer().getGraphicsConfiguration();
     }
 
+
+    // Just a helper method
+    public final LWGraphicsConfig getLWGC() {
+        return (LWGraphicsConfig) getGraphicsConfiguration();
+    }
+
     /*
      * Overridden in LWWindowPeer to replace its surface
      * data and back buffer.
@@ -506,31 +518,45 @@
         return getGraphicsConfiguration().getColorModel();
     }
 
-    @Override
-    public void createBuffers(int numBuffers, BufferCapabilities caps)
-            throws AWTException {
-        throw new AWTException("Back buffers are only supported for " +
-                "Window or Canvas components.");
+    public boolean isTranslucent() {
+        // Translucent windows of the top level are supported only
+        return false;
     }
 
-    /*
-     * To be overridden in LWWindowPeer and LWCanvasPeer.
-     */
     @Override
-    public Image getBackBuffer() {
-        // Return null or throw AWTException?
-        return null;
+    public final void createBuffers(int numBuffers, BufferCapabilities caps)
+            throws AWTException {
+        getLWGC().assertOperationSupported(numBuffers, caps);
+        final Image buffer = getLWGC().createBackBuffer(this);
+        synchronized (getStateLock()) {
+            backBuffer = buffer;
+        }
     }
 
     @Override
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction) {
-        // Skip silently or throw AWTException?
+    public final Image getBackBuffer() {
+        synchronized (getStateLock()) {
+            if (backBuffer != null) {
+                return backBuffer;
+            }
+        }
+        throw new IllegalStateException("Buffers have not been created");
     }
 
     @Override
-    public void destroyBuffers() {
-        // Do nothing
+    public final void flip(int x1, int y1, int x2, int y2,
+                     BufferCapabilities.FlipContents flipAction) {
+        getLWGC().flip(this, getBackBuffer(), x1, y1, x2, y2, flipAction);
+    }
+
+    @Override
+    public final void destroyBuffers() {
+        final Image oldBB;
+        synchronized (getStateLock()) {
+            oldBB = backBuffer;
+            backBuffer = null;
+        }
+        getLWGC().destroyBackBuffer(oldBB);
     }
 
     // Helper method
@@ -642,7 +668,7 @@
         }
     }
 
-    protected final Color getBackground() {
+    public final Color getBackground() {
         synchronized (getStateLock()) {
             return background;
         }
@@ -982,19 +1008,17 @@
     }
 
     @Override
-    public Image createImage(ImageProducer producer) {
+    public final Image createImage(final ImageProducer producer) {
         return new ToolkitImage(producer);
     }
 
     @Override
-    public Image createImage(int w, int h) {
-        CGraphicsConfig gc = (CGraphicsConfig)getGraphicsConfiguration();
-        return gc.createAcceleratedImage(getTarget(), w, h);
+    public final Image createImage(final int width, final int height) {
+        return getLWGC().createAcceleratedImage(getTarget(), width, height);
     }
 
     @Override
-    public VolatileImage createVolatileImage(int w, int h) {
-        // TODO: is it a right/complete implementation?
+    public final VolatileImage createVolatileImage(final int w, final int h) {
         return new SunVolatileImage(getTarget(), w, h);
     }
 
@@ -1105,8 +1129,6 @@
      * of target.setLocation() or as a result of user actions (window is
      * dragged with mouse).
      *
-     * To be overridden in LWWindowPeer to update its GraphicsConfig.
-     *
      * This method could be called on the toolkit thread.
      */
     protected final void handleMove(final int x, final int y,
@@ -1122,13 +1144,19 @@
      * Called when this peer's size has been changed either as a result of
      * target.setSize() or as a result of user actions (window is resized).
      *
-     * To be overridden in LWWindowPeer to update its SurfaceData and
-     * GraphicsConfig.
-     *
      * This method could be called on the toolkit thread.
      */
     protected final void handleResize(final int w, final int h,
                                       final boolean updateTarget) {
+        Image oldBB = null;
+        synchronized (getStateLock()) {
+            if (backBuffer != null) {
+                oldBB = backBuffer;
+                backBuffer = getLWGC().createBackBuffer(this);
+            }
+        }
+        getLWGC().destroyBackBuffer(oldBB);
+
         if (updateTarget) {
             AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/macosx/classes/sun/lwawt/LWGraphicsConfig.java	Tue Dec 04 11:41:44 2012 -0800
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.lwawt;
+
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Component;
+import java.awt.Image;
+
+/**
+ * As lwawt can be used on different platforms with different graphic
+ * configurations, the general set of methods is necessary. This interface
+ * collects the methods that should be provided by GraphicsConfiguration,
+ * simplifying use by the LWAWT.
+ *
+ * @author Sergey Bylokhov
+ */
+public interface LWGraphicsConfig {
+
+    /*
+     * A GraphicsConfiguration must implements following methods to indicate
+     * that it imposes certain limitations on the maximum size of supported
+     * textures.
+     */
+
+    /**
+     * Returns the maximum width of any texture image. By default return {@code
+     * Integer.MAX_VALUE}.
+     */
+    int getMaxTextureWidth();
+
+    /**
+     * Returns the maximum height of any texture image. By default return {@code
+     * Integer.MAX_VALUE}.
+     */
+    int getMaxTextureHeight();
+
+    /*
+     * The following methods correspond to the multi-buffering methods in
+     * LWComponentPeer.java.
+     */
+
+    /**
+     * Checks that the requested configuration is natively supported; if not, an
+     * AWTException is thrown.
+     */
+    void assertOperationSupported(int numBuffers, BufferCapabilities caps)
+            throws AWTException;
+
+    /**
+     * Creates a back buffer for the given peer and returns the image wrapper.
+     */
+    Image createBackBuffer(LWComponentPeer<?, ?> peer);
+
+    /**
+     * Destroys the back buffer object.
+     */
+    void destroyBackBuffer(Image backBuffer);
+
+    /**
+     * Performs the native flip operation for the given target Component. Our
+     * flip is implemented through normal drawImage() to the graphic object,
+     * because of our components uses a graphic object of the container(in this
+     * case we also apply necessary constrains)
+     */
+    void flip(LWComponentPeer<?, ?> peer, Image backBuffer, int x1, int y1,
+              int x2, int y2, BufferCapabilities.FlipContents flipAction);
+
+    /**
+     * Creates a new hidden-acceleration image of the given width and height
+     * that is associated with the target Component.
+     */
+    Image createAcceleratedImage(Component target, int width, int height);
+}
--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Tue Dec 04 11:41:44 2012 -0800
@@ -27,7 +27,6 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.image.BufferedImage;
 import java.awt.peer.*;
 import java.util.List;
 
@@ -75,17 +74,6 @@
     private SurfaceData surfaceData;
     private final Object surfaceDataLock = new Object();
 
-    private int backBufferCount;
-    private BufferCapabilities backBufferCaps;
-
-    // The back buffer is used for two purposes:
-    // 1. To render all the lightweight peers
-    // 2. To provide user with a BufferStrategy
-    // Need to check if a single back buffer can be used for both
-// TODO: VolatileImage
-//    private VolatileImage backBuffer;
-    private volatile BufferedImage backBuffer;
-
     private volatile int windowState = Frame.NORMAL;
 
     // check that the mouse is over the window
@@ -227,7 +215,6 @@
         if (isGrabbing()) {
             ungrab();
         }
-        destroyBuffers();
         platformWindow.dispose();
         super.disposeImpl();
     }
@@ -258,8 +245,10 @@
     }
 
     @Override
-    public GraphicsConfiguration getGraphicsConfiguration() {
-        return graphicsConfig;
+    public final GraphicsConfiguration getGraphicsConfiguration() {
+        synchronized (getStateLock()) {
+            return graphicsConfig;
+        }
     }
 
     @Override
@@ -285,48 +274,6 @@
     }
 
     @Override
-    public void createBuffers(int numBuffers, BufferCapabilities caps)
-        throws AWTException
-    {
-        try {
-            // Assume this method is never called with numBuffers <= 1, as 0 is
-            // unsupported, and 1 corresponds to a SingleBufferStrategy which
-            // doesn't depend on the peer. Screen is considered as a separate
-            // "buffer", that's why numBuffers - 1
-            assert numBuffers > 1;
-
-            replaceSurfaceData(numBuffers - 1, caps, false);
-        } catch (InvalidPipeException z) {
-            throw new AWTException(z.toString());
-        }
-    }
-
-    @Override
-    public final Image getBackBuffer() {
-        synchronized (getStateLock()) {
-            return backBuffer;
-        }
-    }
-
-    @Override
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction)
-    {
-        platformWindow.flip(x1, y1, x2, y2, flipAction);
-    }
-
-    @Override
-    public final void destroyBuffers() {
-        final Image oldBB = getBackBuffer();
-        synchronized (getStateLock()) {
-            backBuffer = null;
-        }
-        if (oldBB != null) {
-            oldBB.flush();
-        }
-    }
-
-    @Override
     public void setBounds(int x, int y, int w, int h, int op) {
         if ((op & SET_CLIENT_SIZE) != 0) {
             // SET_CLIENT_SIZE is only applicable to window peers, so handle it here
@@ -343,16 +290,14 @@
             h = MINIMUM_HEIGHT;
         }
 
-        if (graphicsConfig instanceof TextureSizeConstraining) {
-            final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
-            final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
+        final int maxW = getLWGC().getMaxTextureWidth();
+        final int maxH = getLWGC().getMaxTextureHeight();
 
-            if (w > maxW) {
-                w = maxW;
-            }
-            if (h > maxH) {
-                h = maxH;
-            }
+        if (w > maxW) {
+            w = maxW;
+        }
+        if (h > maxH) {
+            h = maxH;
         }
 
         // Don't post ComponentMoved/Resized and Paint events
@@ -431,21 +376,14 @@
             min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
         }
 
-        final int maxW, maxH;
-        if (graphicsConfig instanceof TextureSizeConstraining) {
-            maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
-            maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
-        } else {
-            maxW = maxH = Integer.MAX_VALUE;
-        }
-
         final Dimension max;
         if (getTarget().isMaximumSizeSet()) {
             max = getTarget().getMaximumSize();
-            max.width = Math.min(max.width, maxW);
-            max.height = Math.min(max.height, maxH);
+            max.width = Math.min(max.width, getLWGC().getMaxTextureWidth());
+            max.height = Math.min(max.height, getLWGC().getMaxTextureHeight());
         } else {
-            max = new Dimension(maxW, maxH);
+            max = new Dimension(getLWGC().getMaxTextureWidth(),
+                                getLWGC().getMaxTextureHeight());
         }
 
         platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
@@ -1014,21 +952,10 @@
         replaceSurfaceData(true);
     }
 
-    private void replaceSurfaceData(boolean blit) {
-        replaceSurfaceData(backBufferCount, backBufferCaps, blit);
-    }
-
-    private void replaceSurfaceData(int newBackBufferCount,
-                                    BufferCapabilities newBackBufferCaps,
-                                    boolean blit) {
+    private void replaceSurfaceData(final boolean blit) {
         synchronized (surfaceDataLock) {
             final SurfaceData oldData = getSurfaceData();
             surfaceData = platformWindow.replaceSurfaceData();
-            // TODO: volatile image
-    //        VolatileImage oldBB = backBuffer;
-            BufferedImage oldBB = backBuffer;
-            backBufferCount = newBackBufferCount;
-            backBufferCaps = newBackBufferCaps;
             final Rectangle size = getSize();
             if (getSurfaceData() != null && oldData != getSurfaceData()) {
                 clearBackground(size.width, size.height);
@@ -1043,35 +970,6 @@
                 // This can only happen when this peer is being created
                 oldData.flush();
             }
-
-            // TODO: volatile image
-    //        backBuffer = (VolatileImage)delegate.createBackBuffer();
-            backBuffer = (BufferedImage) platformWindow.createBackBuffer();
-            if (backBuffer != null) {
-                Graphics g = backBuffer.getGraphics();
-                try {
-                    Rectangle r = getBounds();
-                    if (g instanceof Graphics2D) {
-                        ((Graphics2D) g).setComposite(AlphaComposite.Src);
-                    }
-                    g.setColor(nonOpaqueBackground);
-                    g.fillRect(0, 0, r.width, r.height);
-                    if (g instanceof SunGraphics2D) {
-                        SG2DConstraint((SunGraphics2D) g, getRegion());
-                    }
-                    if (!isTextured()) {
-                        g.setColor(getBackground());
-                        g.fillRect(0, 0, r.width, r.height);
-                    }
-                    if (oldBB != null) {
-                        // Draw the old back buffer to the new one
-                        g.drawImage(oldBB, 0, 0, null);
-                        oldBB.flush();
-                    }
-                } finally {
-                    g.dispose();
-                }
-            }
         }
     }
 
@@ -1092,14 +990,6 @@
         }
     }
 
-    public int getBackBufferCount() {
-        return backBufferCount;
-    }
-
-    public BufferCapabilities getBackBufferCaps() {
-        return backBufferCaps;
-    }
-
     /*
      * Request the window insets from the delegate and compares it
      * with the current one. This method is mostly called by the
--- a/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java	Tue Dec 04 11:41:44 2012 -0800
@@ -97,17 +97,6 @@
      */
     public SurfaceData replaceSurfaceData();
 
-    /*
-     * Creates a new image to serve as a back buffer.
-     */
-    public Image createBackBuffer();
-
-    /*
-     * Move the given part of the back buffer to the front buffer.
-     */
-    public void flip(int x1, int y1, int x2, int y2,
-                     BufferCapabilities.FlipContents flipAction);
-
     public void setModalBlocked(boolean blocked);
 
     public void toFront();
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java	Tue Dec 04 11:41:44 2012 -0800
@@ -31,12 +31,9 @@
 import sun.java2d.opengl.CGLLayer;
 import sun.java2d.SurfaceData;
 
-import sun.awt.CGraphicsConfig;
-import sun.awt.CGraphicsDevice;
 import sun.awt.CausedFocusEvent;
 
 import java.awt.*;
-import java.awt.BufferCapabilities.FlipContents;
 
 import sun.util.logging.PlatformLogger;
 
@@ -113,22 +110,6 @@
     }
 
     @Override
-    public Image createBackBuffer() {
-        Rectangle r = peer.getBounds();
-        Image im = null;
-        if (!r.isEmpty()) {
-            int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE;
-            im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
-        }
-        return im;
-    }
-
-    @Override
-    public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
-        throw new RuntimeException("Not implemented");
-    }
-
-    @Override
     public void setVisible(boolean visible) {}
 
     @Override
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Tue Dec 04 11:41:44 2012 -0800
@@ -26,7 +26,6 @@
 package sun.lwawt.macosx;
 
 import java.awt.*;
-import java.awt.image.VolatileImage;
 
 import sun.awt.CGraphicsConfig;
 import sun.lwawt.LWWindowPeer;
@@ -115,26 +114,6 @@
     // ----------------------------------------------------------------------
     // PAINTING METHODS
     // ----------------------------------------------------------------------
-
-    public void drawImageOnPeer(VolatileImage xBackBuffer, int x1, int y1, int x2, int y2) {
-        Graphics g = peer.getGraphics();
-        try {
-            g.drawImage(xBackBuffer, x1, y1, x2, y2, x1, y1, x2, y2, null);
-        } finally {
-            g.dispose();
-        }
-    }
-
-    public Image createBackBuffer() {
-        Rectangle r = peer.getBounds();
-        Image im = null;
-        if (!r.isEmpty()) {
-            int transparency = (isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT);
-            im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency);
-        }
-        return im;
-    }
-
     public SurfaceData replaceSurfaceData() {
         if (!LWCToolkit.getSunAwtDisableCALayers()) {
             surfaceData = windowLayer.replaceSurfaceData();
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Tue Dec 04 11:41:44 2012 -0800
@@ -25,7 +25,6 @@
 
 package sun.lwawt.macosx;
 
-import java.awt.BufferCapabilities.FlipContents;
 import java.awt.*;
 import java.awt.Dialog.ModalityType;
 import java.awt.event.*;
@@ -258,7 +257,7 @@
         validateSurface();
     }
 
-    protected int getInitialStyleBits() {
+    private int getInitialStyleBits() {
         // defaults style bits
         int styleBits = DECORATED | HAS_SHADOW | CLOSEABLE | MINIMIZABLE | ZOOMABLE | RESIZABLE;
 
@@ -285,7 +284,6 @@
             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
             styleBits = SET(styleBits, RESIZABLE, resizable);
             if (!resizable) {
-                styleBits = SET(styleBits, RESIZABLE, false);
                 styleBits = SET(styleBits, ZOOMABLE, false);
             }
         }
@@ -380,7 +378,7 @@
     }
 
     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
-    protected void setStyleBits(final int mask, final boolean value) {
+    private void setStyleBits(final int mask, final boolean value) {
         nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
     }
 
@@ -402,11 +400,6 @@
     }
 
     @Override // PlatformWindow
-    public Image createBackBuffer() {
-        return contentView.createBackBuffer();
-    }
-
-    @Override // PlatformWindow
     public void dispose() {
         if (owner != null) {
             CWrapper.NSWindow.removeChildWindow(owner.getNSWindowPtr(), getNSWindowPtr());
@@ -417,12 +410,6 @@
     }
 
     @Override // PlatformWindow
-    public void flip(int x1, int y1, int x2, int y2, FlipContents flipAction) {
-        // TODO: not implemented
-        (new RuntimeException("unimplemented")).printStackTrace();
-    }
-
-    @Override // PlatformWindow
     public FontMetrics getFontMetrics(Font f) {
         // TODO: not implemented
         (new RuntimeException("unimplemented")).printStackTrace();
@@ -668,15 +655,8 @@
     }
 
     @Override
-    public void setResizable(boolean resizable) {
+    public void setResizable(final boolean resizable) {
         setStyleBits(RESIZABLE, resizable);
-
-        // Re-apply the size constraints and the size to ensure the space
-        // occupied by the grow box is counted properly
-        peer.updateMinimumSize();
-
-        Rectangle bounds = peer.getBounds();
-        setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
     }
 
     @Override
@@ -889,7 +869,8 @@
         responder.handleWindowFocusEvent(gained, oppositePeer);
     }
 
-    private void deliverMoveResizeEvent(int x, int y, int width, int height) {
+    private void deliverMoveResizeEvent(int x, int y, int width, int height,
+                                        boolean byUser) {
         // when the content view enters the full-screen mode, the native
         // move/resize notifications contain a bounds smaller than
         // the whole screen and therefore we ignore the native notifications
@@ -901,7 +882,7 @@
         final Rectangle oldB = nativeBounds;
         nativeBounds = new Rectangle(x, y, width, height);
         peer.notifyReshape(x, y, width, height);
-        if (!oldB.getSize().equals(nativeBounds.getSize()) ) {
+        if (byUser && !oldB.getSize().equals(nativeBounds.getSize())) {
             flushBuffers();
         }
         //TODO validateSurface already called from notifyReshape
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m	Tue Dec 04 11:41:44 2012 -0800
@@ -160,6 +160,10 @@
         BOOL resizable = IS(bits, RESIZABLE);
         [self updateMinMaxSize:resizable];
         [self.nsWindow setShowsResizeIndicator:resizable];
+        // Zoom button should be disabled, if the window is not resizable,
+        // otherwise button should be restored to initial state.
+        BOOL zoom = resizable && IS(bits, ZOOMABLE);
+        [[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:zoom];
     }
 
     if (IS(mask, HAS_SHADOW)) {
@@ -445,12 +449,13 @@
 
     NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
 
-    static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V");
+    static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
     JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
                       (jint)frame.origin.x,
                       (jint)frame.origin.y,
                       (jint)frame.size.width,
-                      (jint)frame.size.height);
+                      (jint)frame.size.height,
+                      (jboolean)[self.nsWindow inLiveResize]);
     (*env)->DeleteLocalRef(env, platformWindow);
 }
 
@@ -784,7 +789,7 @@
 
         // calls methods on NSWindow to change other properties, based on the mask
         if (mask & MASK(_METHOD_PROP_BITMASK)) {
-            [window setPropertiesForStyleBits:bits mask:mask];
+            [window setPropertiesForStyleBits:newBits mask:mask];
         }
 
         window.styleBits = newBits;
--- a/jdk/src/share/classes/javax/swing/JColorChooser.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/JColorChooser.java	Tue Dec 04 11:41:44 2012 -0800
@@ -182,6 +182,7 @@
             dialog = new ColorChooserDialog((Dialog)window, title, modal, c, chooserPane,
                                             okListener, cancelListener);
         }
+        dialog.getAccessibleContext().setAccessibleDescription(title);
         return dialog;
     }
 
@@ -647,6 +648,7 @@
         buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
         JButton okButton = new JButton(okString);
         getRootPane().setDefaultButton(okButton);
+        okButton.getAccessibleContext().setAccessibleDescription(okString);
         okButton.setActionCommand("OK");
         okButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
@@ -659,6 +661,7 @@
         buttonPane.add(okButton);
 
         cancelButton = new JButton(cancelString);
+        cancelButton.getAccessibleContext().setAccessibleDescription(cancelString);
 
         // The following few lines are used to register esc to close the dialog
         Action cancelKeyAction = new AbstractAction() {
@@ -688,6 +691,7 @@
         buttonPane.add(cancelButton);
 
         JButton resetButton = new JButton(resetString);
+        resetButton.getAccessibleContext().setAccessibleDescription(resetString);
         resetButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                reset();
--- a/jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java	Tue Dec 04 11:41:44 2012 -0800
@@ -135,6 +135,7 @@
         String label = this.model.getText(this, "HexCode"); // NON-NLS: suffix
         boolean visible = label != null;
         this.text.setVisible(visible);
+        this.text.getAccessibleContext().setAccessibleDescription(label);
         this.label.setVisible(visible);
         if (visible) {
             this.label.setText(label);
--- a/jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/colorchooser/ColorPanel.java	Tue Dec 04 11:41:44 2012 -0800
@@ -37,6 +37,7 @@
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
+import javax.swing.JSpinner.DefaultEditor;
 
 final class ColorPanel extends JPanel implements ActionListener {
 
@@ -119,17 +120,26 @@
         int count = this.model.getCount();
         this.spinners[4].setVisible(count > 4);
         for (int i = 0; i < count; i++) {
+            String text = this.model.getLabel(this, i);
             Object object = this.spinners[i].getLabel();
             if (object instanceof JRadioButton) {
                 JRadioButton button = (JRadioButton) object;
-                button.setText(this.model.getLabel(this, i));
+                button.setText(text);
+                button.getAccessibleContext().setAccessibleDescription(text);
             }
             else if (object instanceof JLabel) {
                 JLabel label = (JLabel) object;
-                label.setText(this.model.getLabel(this, i));
+                label.setText(text);
             }
             this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
             this.spinners[i].setValue(this.values[i]);
+            this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
+            this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
+            DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
+            editor.getTextField().getAccessibleContext().setAccessibleName(text);
+            this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
+            this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
+            editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
         }
     }
 
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java	Tue Dec 04 11:41:44 2012 -0800
@@ -94,6 +94,7 @@
         tabbedPane = new JTabbedPane();
         tabbedPane.setName("ColorChooser.tabPane");
         tabbedPane.setInheritsPopupMenu(true);
+        tabbedPane.getAccessibleContext().setAccessibleDescription(tabbedPane.getName());
         singlePanel = new JPanel(new CenterLayout());
         singlePanel.setName("ColorChooser.panel");
         singlePanel.setInheritsPopupMenu(true);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java	Tue Dec 04 11:41:44 2012 -0800
@@ -1941,6 +1941,9 @@
                     for(int counter = beginRow + 1; counter <= endRow; counter++) {
                             testRect = getPathBounds(tree,
                                     getPathForRow(tree, counter));
+                        if (testRect == null) {
+                            return;
+                        }
                         if((testRect.y + testRect.height) > maxY)
                                 counter = endRow;
                             }
@@ -2069,7 +2072,7 @@
                 treeState.invalidatePathBounds(oldPath);
                 updateSize();
             }
-            else {
+            else if (editingBounds != null) {
                 editingBounds.x = 0;
                 editingBounds.width = tree.getSize().width;
                 tree.repaint(editingBounds);
@@ -2114,6 +2117,9 @@
                        tree.isPathSelected(path), tree.isExpanded(path),
                        treeModel.isLeaf(path.getLastPathComponent()), row);
                 Rectangle           nodeBounds = getPathBounds(tree, path);
+                if (nodeBounds == null) {
+                    return false;
+                }
 
                 editingRow = row;
 
@@ -2134,6 +2140,9 @@
                     // To make sure x/y are updated correctly, fetch
                     // the bounds again.
                     nodeBounds = getPathBounds(tree, path);
+                    if (nodeBounds == null) {
+                        return false;
+                    }
                 }
                 else
                     editorHasDifferentSize = false;
@@ -3570,7 +3579,7 @@
             if(pressedPath != null) {
                 Rectangle bounds = getPathBounds(tree, pressedPath);
 
-                if(e.getY() >= (bounds.y + bounds.height)) {
+                if (bounds == null || e.getY() >= (bounds.y + bounds.height)) {
                     return;
                 }
 
@@ -3832,6 +3841,10 @@
 
                     // And repaint
                     Rectangle newMinBounds = getPathBounds(tree, minPath);
+                    if (minBounds == null || newMinBounds == null) {
+                        return;
+                    }
+
                     if (indices.length == 1 &&
                             newMinBounds.height == minBounds.height) {
                         tree.repaint(0, minBounds.y, tree.getWidth(),
@@ -4466,27 +4479,28 @@
                     }
                 }
                 Rectangle            newRect = ui.getPathBounds(tree, newPath);
-
-                newRect.x = visRect.x;
-                newRect.width = visRect.width;
-                if(direction == -1) {
-                    newRect.height = visRect.height;
-                }
-                else {
-                    newRect.y -= (visRect.height - newRect.height);
-                    newRect.height = visRect.height;
+                if (newRect != null) {
+                    newRect.x = visRect.x;
+                    newRect.width = visRect.width;
+                    if(direction == -1) {
+                        newRect.height = visRect.height;
+                    }
+                    else {
+                        newRect.y -= (visRect.height - newRect.height);
+                        newRect.height = visRect.height;
+                    }
+
+                    if(addToSelection) {
+                        ui.extendSelection(newPath);
+                    }
+                    else if(changeSelection) {
+                        tree.setSelectionPath(newPath);
+                    }
+                    else {
+                        ui.setLeadSelectionPath(newPath, true);
+                    }
+                    tree.scrollRectToVisible(newRect);
                 }
-
-                if(addToSelection) {
-                    ui.extendSelection(newPath);
-                }
-                else if(changeSelection) {
-                    tree.setSelectionPath(newPath);
-                }
-                else {
-                    ui.setLeadSelectionPath(newPath, true);
-                }
-                tree.scrollRectToVisible(newRect);
             }
         }
 
--- a/jdk/src/share/classes/sun/awt/TextureSizeConstraining.java	Mon Dec 03 16:26:47 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.awt;
-
-/**
- * A GraphicsConfiguration implements the TextureSizeConstraining
- * interface to indicate that it imposes certain limitations on the
- * maximum size of supported textures.
- */
-public interface TextureSizeConstraining {
-
-    /**
-     * Returns the maximum width of any texture image.
-     */
-    public int getMaxTextureWidth();
-
-    /**
-     * Returns the maximum height of any texture image.
-     */
-    public int getMaxTextureHeight();
-
-}
--- a/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java	Tue Dec 04 11:41:44 2012 -0800
@@ -256,6 +256,7 @@
         if (getFileChooser().getControlButtonsAreShown()) {
             approveButton.setText(getApproveButtonText(getFileChooser()));
             approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser()));
+            approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser()));
         }
     }
 
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Tue Dec 04 11:41:44 2012 -0800
@@ -1332,6 +1332,15 @@
         return new XInputMethodDescriptor();
     }
 
+    /**
+     * Returns whether enableInputMethods should be set to true for peered
+     * TextComponent instances on this platform. True by default.
+     */
+    @Override
+    public boolean enableInputMethodsForTextComponent() {
+        return true;
+    }
+
     static int getMultiClickTime() {
         if (awt_multiclick_time == 0) {
             initializeMultiClickTime();
--- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	Tue Dec 04 11:41:44 2012 -0800
@@ -1260,13 +1260,15 @@
 
 JavaVM* jvm = NULL;
 static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
+    JNIEnv * env;
     if (jvm != NULL) {
-        JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
-                                          ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
-    } else {
-        return 0;
+        env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+        if (env) {
+            return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
+                                              ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
+        }
     }
+    return 0;
 }
 
 /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Frame/FrameSetSizeStressTest/FrameSetSizeStressTest.java	Tue Dec 04 11:41:44 2012 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Frame;
+
+/*
+  @test
+  @bug 7177173
+  @summary setBounds can cause StackOverflow in case of the considerable loading
+  @author Sergey Bylokhov
+*/
+public final class FrameSetSizeStressTest {
+
+    public static void main(final String[] args) {
+        final Frame frame = new Frame();
+        frame.setSize(200, 200);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+        for (int i = 0; i < 1000; ++i) {
+            frame.setSize(100, 100);
+            frame.setSize(200, 200);
+            frame.setSize(300, 300);
+        }
+        frame.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/8003830/bug8003830.java	Tue Dec 04 11:41:44 2012 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.EventQueue;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import javax.swing.JTree;
+import javax.swing.plaf.basic.BasicTreeUI;
+import javax.swing.tree.TreePath;
+
+
+/* Originally reported as NetBeans bug 222081.
+ *
+ * @test
+ * @bug 8003830
+ * @summary NullPointerException in BasicTreeUI.Actions when getPathBounds returns null
+ * @author Jaroslav Tulach
+ * @run main bug8003830
+ */
+
+public class bug8003830 implements Runnable {
+    public static void main(String[] args) throws Exception {
+        EventQueue.invokeAndWait(new bug8003830());
+    }
+    @Override
+    public void run() {
+        testNPEAtActionsPage();
+    }
+
+    public void testNPEAtActionsPage() {
+        JTree tree = new JTree();
+        BasicTreeUI ui = new NullReturningTreeUI();
+        tree.setUI(ui);
+        BasicTreeUI.TreePageAction tpa = ui.new TreePageAction(0, "down");
+        tpa.actionPerformed(new ActionEvent(tree, 0, ""));
+    }
+
+    private static final class NullReturningTreeUI extends BasicTreeUI {
+        @Override
+        public Rectangle getPathBounds(JTree tree, TreePath path) {
+            // the method can return null and callers have to be ready for
+            // that. Simulate the case by returning null for unknown reason.
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/dnd/7171812/JListWithScroll.java	Tue Dec 04 11:41:44 2012 -0800
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.dnd.Autoscroll;
+
+public class JListWithScroll<E> extends JList<E> implements Autoscroll {
+    private Insets scrollInsets;
+
+    public JListWithScroll(E[] listData) {
+        super(listData);
+        scrollInsets = new Insets(50, 50, 50, 50);
+    }
+
+    @Override
+    public Insets getAutoscrollInsets() {
+        return scrollInsets;
+    }
+
+    @Override
+    public void autoscroll(Point cursorLoc) {
+        JViewport viewport = getViewport();
+
+        if (viewport == null) {
+            return;
+        }
+
+        Point viewPos = viewport.getViewPosition();
+        int viewHeight = viewport.getExtentSize().height;
+        int viewWidth = viewport.getExtentSize().width;
+
+        if ((cursorLoc.y - viewPos.y) < scrollInsets.top) {
+            viewport.setViewPosition(new Point(viewPos.x, Math.max(viewPos.y - scrollInsets.top, 0)));
+        } else if (((viewPos.y + viewHeight) - cursorLoc.y) < scrollInsets.bottom) {
+            viewport.setViewPosition(
+                    new Point(viewPos.x, Math.min(viewPos.y + scrollInsets.bottom, this.getHeight() - viewHeight))
+            );
+        } else if ((cursorLoc.x - viewPos.x) < scrollInsets.left) {
+            viewport.setViewPosition(new Point(Math.max(viewPos.x - scrollInsets.left, 0), viewPos.y));
+        } else if (((viewPos.x + viewWidth) - cursorLoc.x) < scrollInsets.right) {
+            viewport.setViewPosition(
+                    new Point(Math.min(viewPos.x + scrollInsets.right, this.getWidth() - viewWidth), viewPos.y)
+            );
+        }
+
+    }
+
+    public JViewport getViewport() {
+        Component curComp = this;
+
+        while (!(curComp instanceof JViewport) && (curComp != null)) {
+            curComp = curComp.getParent();
+        }
+        if(curComp instanceof JViewport) {
+            return (JViewport) curComp;
+        } else {
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/dnd/7171812/bug7171812.java	Tue Dec 04 11:41:44 2012 -0800
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7171812
+   @summary [macosx] Views keep scrolling back to the drag position after DnD
+   @author Alexander Zuev
+   @run main bug7171812
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.*;
+import java.awt.dnd.*;
+import java.awt.event.InputEvent;
+import javax.swing.*;
+
+public class bug7171812 {
+    static JFrame mainFrame;
+    static String listData[];
+    static JListWithScroll<String> list;
+    static JScrollPane scrollPane;
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws Exception{
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                setupGUI();
+            }
+        });
+        toolkit.realSync();
+
+        Robot robot = new Robot();
+        robot.setAutoDelay(10);
+        robot.mouseMove(scrollPane.getLocationOnScreen().x + 5, scrollPane.getLocationOnScreen().y + 5);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        for(int offset = 5; offset < scrollPane.getHeight()-20; offset++) {
+            robot.mouseMove(scrollPane.getLocationOnScreen().x+5, scrollPane.getLocationOnScreen().y+offset);
+        }
+        for(int offset = 5; offset < 195; offset++) {
+            robot.mouseMove(scrollPane.getLocationOnScreen().x+offset, scrollPane.getLocationOnScreen().y+scrollPane.getHeight()-20);
+        }
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    if(scrollPane.getViewport().getViewPosition().getY() < 30) {
+                        throw new RuntimeException("Incorrect view position.");
+                    };
+                }
+            });
+        } catch (java.lang.reflect.InvocationTargetException ite) {
+            throw new RuntimeException("Test failed, scroll on drag doesn't work!");
+        }
+    }
+
+    public static void setupGUI() {
+        listData = new String[100];
+        for (int i=0; i<100; i++) {
+            listData[i] = "Long Line With Item "+i;
+        }
+        mainFrame = new JFrame("Rest frame");
+        mainFrame.setSize(300, 500);
+        mainFrame.setLayout(new BorderLayout());
+        list = new JListWithScroll(listData);
+        list.setDragEnabled(true);
+        list.setAutoscrolls(true);
+        final DropTarget dropTarget = new DropTarget(list, DnDConstants.ACTION_MOVE, new DropTargetListener() {
+            @Override
+            public void dragEnter(DropTargetDragEvent dtde) {
+                dragOver(dtde);
+            }
+
+            @Override
+            public void dragOver(DropTargetDragEvent dtde) {
+                dtde.acceptDrag(DnDConstants.ACTION_MOVE);
+            }
+
+            @Override
+            public void dropActionChanged(DropTargetDragEvent dtde) {
+            }
+
+            @Override
+            public void dragExit(DropTargetEvent dte) {
+            }
+
+            @Override
+            public void drop(DropTargetDropEvent dtde) {
+            }
+        }, true);
+        scrollPane = new JScrollPane(list);
+        mainFrame.add(scrollPane, BorderLayout.CENTER);
+        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        mainFrame.setLocation(100, 100);
+        mainFrame.setVisible(true);
+    }
+}
--- a/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java	Mon Dec 03 16:26:47 2012 +0400
+++ b/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java	Tue Dec 04 11:41:44 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6796710
+ * @bug 6796710 7124242
  * @summary Html content in JEditorPane is overlapping on swing components while resizing the application.
  * @library ../../../regtesthelpers
  * @build Util
@@ -31,11 +31,10 @@
    @run main bug6796710
  */
 
-import sun.awt.SunToolkit;
-
-import javax.swing.*;
 import java.awt.*;
 import java.awt.image.BufferedImage;
+import javax.swing.*;
+import sun.awt.SunToolkit;
 
 public class bug6796710 {
     // The page is inlined because we want to be sure that the JEditorPane filled synchronously
@@ -68,9 +67,12 @@
         robot = new Robot();
 
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 frame = new JFrame();
 
+                frame.setUndecorated(true);
+
                 pnBottom = new JPanel();
                 pnBottom.add(new JLabel("Some label"));
                 pnBottom.add(new JButton("A button"));
@@ -95,9 +97,13 @@
 
         ((SunToolkit) SunToolkit.getDefaultToolkit()).realSync();
 
+        // This delay should be added for MacOSX, realSync is not enough
+        Thread.sleep(1000);
+
         BufferedImage bufferedImage = getPnBottomImage();
 
         SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
             public void run() {
                 frame.setSize(400, 150);
             }