Merge
authoryan
Wed, 06 May 2009 09:37:34 -0700
changeset 11992b86dbc51d11
parent 1187 f8b061ea131c
parent 1198 b28b073e72b6
child 1200 0c6f5f1c58fd
Merge
     1.1 --- a/src/share/classes/java/awt/GraphicsDevice.java	Tue May 05 09:09:24 2009 -0700
     1.2 +++ b/src/share/classes/java/awt/GraphicsDevice.java	Wed May 06 09:37:34 2009 -0700
     1.3 @@ -282,7 +282,7 @@
     1.4                  w.setOpacity(1.0f);
     1.5              }
     1.6              Color bgColor = w.getBackground();
     1.7 -            if (bgColor.getAlpha() < 255) {
     1.8 +            if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
     1.9                  bgColor = new Color(bgColor.getRed(), bgColor.getGreen(),
    1.10                                      bgColor.getBlue(), 255);
    1.11                  w.setBackground(bgColor);
     2.1 --- a/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Tue May 05 09:09:24 2009 -0700
     2.2 +++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Wed May 06 09:37:34 2009 -0700
     2.3 @@ -530,6 +530,7 @@
     2.4                      sType = transparent ? X11SurfaceData.IntBgrX11_BM : X11SurfaceData.IntBgrX11;
     2.5                  }
     2.6              } else {
     2.7 +
     2.8                  throw new sun.java2d.InvalidPipeException("Unsupported bit " +
     2.9                                                            "depth/cm combo: " +
    2.10                                                            cm.getPixelSize()  +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java	Wed May 06 09:37:34 2009 -0700
     3.3 @@ -0,0 +1,83 @@
     3.4 +/*
     3.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    3.24 + * have any questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 6837004
    3.30 + * @summary Checks that non-opaque window can be made a fullscreen window
    3.31 + * @author Artem Ananiev
    3.32 + * @run main TranslucentWindow
    3.33 + */
    3.34 +
    3.35 +import java.awt.*;
    3.36 +import java.awt.geom.*;
    3.37 +
    3.38 +import static java.awt.GraphicsDevice.WindowTranslucency.*;
    3.39 +
    3.40 +import sun.awt.SunToolkit;
    3.41 +
    3.42 +public class TranslucentWindow {
    3.43 +    public static void main(String args[]) {
    3.44 +        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    3.45 +        GraphicsDevice gd = ge.getDefaultScreenDevice();
    3.46 +
    3.47 +        Frame f = new Frame("Test frame");
    3.48 +        f.setBounds(100, 100, 320, 240);
    3.49 +
    3.50 +        // First, check it can be made fullscreen window without any effects applied
    3.51 +        gd.setFullScreenWindow(f);
    3.52 +        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
    3.53 +
    3.54 +        gd.setFullScreenWindow(null);
    3.55 +        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
    3.56 +
    3.57 +        // Second, check if it applying any effects doesn't prevent the window
    3.58 +        // from going into the fullscreen mode
    3.59 +        if (gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT)) {
    3.60 +            f.setShape(new Ellipse2D.Float(0, 0, f.getWidth(), f.getHeight()));
    3.61 +        }
    3.62 +        if (gd.isWindowTranslucencySupported(TRANSLUCENT)) {
    3.63 +            f.setOpacity(0.5f);
    3.64 +        }
    3.65 +        if (gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT)) {
    3.66 +            f.setBackground(new Color(0, 0, 0, 128));
    3.67 +        }
    3.68 +        gd.setFullScreenWindow(f);
    3.69 +        ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
    3.70 +
    3.71 +        // Third, make sure all the effects are unset when entering the fullscreen mode
    3.72 +        if (f.getShape() != null) {
    3.73 +            throw new RuntimeException("Test FAILED: fullscreen window shape is not null");
    3.74 +        }
    3.75 +        if (Math.abs(f.getOpacity() - 1.0f) > 1e-4) {
    3.76 +            throw new RuntimeException("Test FAILED: fullscreen window opacity is not 1.0f");
    3.77 +        }
    3.78 +        Color bgColor = f.getBackground();
    3.79 +        if ((bgColor != null) && (bgColor.getAlpha() != 255)) {
    3.80 +            throw new RuntimeException("Test FAILED: fullscreen window background color is not opaque");
    3.81 +        }
    3.82 +
    3.83 +        f.dispose();
    3.84 +        System.out.println("Test PASSED");
    3.85 +    }
    3.86 +}