jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsEnvironment.java
author serb
Thu, 02 Mar 2017 17:18:23 +0300
changeset 44149 92b8963f6498
parent 34394 259d6e4e0978
permissions -rw-r--r--
8168307: Toolkit.getScreenSize() returns incorrect size on unix in multiscreen systems Reviewed-by: azvegint, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30938
35ae5c70d60e 8030087: Avoid public native methods in sun.awt packages
serb
parents: 25859
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
20434
19c5cdb0d7a2 8025652: [macos] build failed
malenkov
parents: 20433
diff changeset
    28
import java.awt.AWTError;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    29
import java.awt.GraphicsConfiguration;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsDevice;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    31
import java.awt.peer.ComponentPeer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.ListIterator;
30938
35ae5c70d60e 8030087: Avoid public native methods in sun.awt packages
serb
parents: 25859
diff changeset
    35
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.windows.WToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.java2d.SunGraphicsEnvironment;
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    38
import sun.java2d.SurfaceManagerFactory;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    39
import sun.java2d.WindowsSurfaceManagerFactory;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    40
import sun.java2d.d3d.D3DGraphicsDevice;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.java2d.windows.WindowsFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * This is an implementation of a GraphicsEnvironment object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * default local GraphicsEnvironment used by the Java Runtime Environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * for Windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @see GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @see GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
30938
35ae5c70d60e 8030087: Avoid public native methods in sun.awt packages
serb
parents: 25859
diff changeset
    52
public final class Win32GraphicsEnvironment extends SunGraphicsEnvironment {
35ae5c70d60e 8030087: Avoid public native methods in sun.awt packages
serb
parents: 25859
diff changeset
    53
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    54
    static final float debugScaleX;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    55
    static final float debugScaleY;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    56
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        // Ensure awt is loaded already.  Also, this forces static init
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        // of WToolkit and Toolkit, which we depend upon
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        WToolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        // setup flags before initializing native layer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        WindowsFlags.initFlags();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        initDisplayWrapper();
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    64
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    65
        // Install correct surface manager factory.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    66
        SurfaceManagerFactory.setInstance(new WindowsSurfaceManagerFactory());
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    67
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    68
        double sx = -1;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    69
        double sy = -1;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    70
        if (isUIScaleEnabled()) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    71
            sx = getScaleFactor("sun.java2d.win.uiScaleX");
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    72
            sy = getScaleFactor("sun.java2d.win.uiScaleY");
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    73
            if (sx <= 0 || sy <= 0) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    74
                double s = getDebugScale();
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    75
                sx = s;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    76
                sy = s;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    77
            }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    78
        }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    79
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    80
        debugScaleX = (float) sx;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 32491
diff changeset
    81
        debugScaleY = (float) sy;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Initializes native components of the graphics environment.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * includes everything from the native GraphicsDevice elements to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * the DirectX rendering layer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static native void initDisplay();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static boolean displayInitialized;      // = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public static void initDisplayWrapper() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (!displayInitialized) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            displayInitialized = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            initDisplay();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public Win32GraphicsEnvironment() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    protected native int getNumScreens();
30938
35ae5c70d60e 8030087: Avoid public native methods in sun.awt packages
serb
parents: 25859
diff changeset
   103
    private native int getDefaultScreen();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public GraphicsDevice getDefaultScreenDevice() {
20433
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9234
diff changeset
   106
        GraphicsDevice[] screens = getScreenDevices();
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9234
diff changeset
   107
        if (screens.length == 0) {
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9234
diff changeset
   108
            throw new AWTError("no screen devices");
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9234
diff changeset
   109
        }
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9234
diff changeset
   110
        int index = getDefaultScreen();
f6d501f12376 7117595: ArrayIndexOutOfBoundsException in Win32GraphicsEnvironment if display is removed
malenkov
parents: 9234
diff changeset
   111
        return screens[0 < index && index < screens.length ? index : 0];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Returns the number of pixels per logical inch along the screen width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * In a system with multiple display monitors, this value is the same for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * all monitors.
32491
7b3783f9484d 8133807: java.desktop docs: replace some invalid "@returns" tags
avstepan
parents: 30938
diff changeset
   118
     * @return number of pixels per logical inch in X direction
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public native int getXResolution();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * Returns the number of pixels per logical inch along the screen height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * In a system with multiple display monitors, this value is the same for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * all monitors.
32491
7b3783f9484d 8133807: java.desktop docs: replace some invalid "@returns" tags
avstepan
parents: 30938
diff changeset
   125
     * @return number of pixels per logical inch in Y direction
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public native int getYResolution();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * ----DISPLAY CHANGE SUPPORT----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    // list of invalidated graphics devices (those which were removed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    private ArrayList<WeakReference<Win32GraphicsDevice>> oldDevices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * From DisplayChangeListener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Called from WToolkit and executed on the event thread when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * display settings are changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        // getNumScreens() will return the correct current number of screens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        GraphicsDevice newDevices[] = new GraphicsDevice[getNumScreens()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        GraphicsDevice oldScreens[] = screens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // go through the list of current devices and determine if they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        // could be reused, or will have to be replaced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if (oldScreens != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            for (int i = 0; i < oldScreens.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                if (!(screens[i] instanceof Win32GraphicsDevice)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                    // REMIND: can we ever have anything other than Win32GD?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                    assert (false) : oldScreens[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                Win32GraphicsDevice gd = (Win32GraphicsDevice)oldScreens[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                // devices may be invalidated from the native code when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                // display change happens (device add/removal also causes a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                // display change)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                if (!gd.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                    if (oldDevices == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                        oldDevices =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                            new ArrayList<WeakReference<Win32GraphicsDevice>>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                    oldDevices.add(new WeakReference<Win32GraphicsDevice>(gd));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                } else if (i < newDevices.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                    // reuse the device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    newDevices[i] = gd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            oldScreens = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        // create the new devices (those that weren't reused)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        for (int i = 0; i < newDevices.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            if (newDevices[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                newDevices[i] = makeScreenDevice(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // install the new array of devices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // Note: no synchronization here, it doesn't matter if a thread gets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // a new or an old array this time around
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        screens = newDevices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        for (GraphicsDevice gd : screens) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            if (gd instanceof DisplayChangedListener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                ((DisplayChangedListener)gd).displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        // re-invalidate all old devices. It's needed because those in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        // may become "invalid" again - if the current default device is removed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        // for example. Also, they need to be notified about display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        // changes as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (oldDevices != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            int defScreen = getDefaultScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            for (ListIterator<WeakReference<Win32GraphicsDevice>> it =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    oldDevices.listIterator(); it.hasNext();)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                Win32GraphicsDevice gd = it.next().get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                if (gd != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    gd.invalidate(defScreen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    gd.displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    // no more references to this device, remove it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    it.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        // notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        // CachingSurfaceManagers) about the display change event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        displayChanger.notifyListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        // note: do not call super.displayChanged, we've already done everything
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * ----END DISPLAY CHANGE SUPPORT----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    protected GraphicsDevice makeScreenDevice(int screennum) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   218
        GraphicsDevice device = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   219
        if (WindowsFlags.isD3DEnabled()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   220
            device = D3DGraphicsDevice.createDevice(screennum);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   221
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   222
        if (device == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   223
            device = new Win32GraphicsDevice(screennum);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   224
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   225
        return device;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   228
    public boolean isDisplayLocal() {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   229
        return true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   231
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   232
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   233
    public boolean isFlipStrategyPreferred(ComponentPeer peer) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   234
        GraphicsConfiguration gc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   235
        if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   236
            GraphicsDevice gd = gc.getDevice();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   237
            if (gd instanceof D3DGraphicsDevice) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   238
                return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   239
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   240
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   241
        return false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   242
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   243
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   244
    private static volatile boolean isDWMCompositionEnabled;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   245
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   246
     * Returns true if dwm composition is currently enabled, false otherwise.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   247
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   248
     * @return true if dwm composition is enabled, false otherwise
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   249
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   250
    public static boolean isDWMCompositionEnabled() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   251
        return isDWMCompositionEnabled;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   252
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   253
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   254
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   255
     * Called from the native code when DWM composition state changed.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   256
     * May be called multiple times during the lifetime of the application.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   257
     * REMIND: we may want to create a listener mechanism for this.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   258
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   259
     * Note: called on the Toolkit thread, no user code or locks are allowed.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   260
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   261
     * @param enabled indicates the state of dwm composition
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   262
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   263
    private static void dwmCompositionChanged(boolean enabled) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   264
        isDWMCompositionEnabled = enabled;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   265
    }
1724
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 889
diff changeset
   266
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   267
    /**
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   268
     * Used to find out if the OS is Windows Vista or later.
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   269
     *
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   270
     * @return {@code true} if the OS is Vista or later, {@code false} otherwise
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   271
     */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   272
    public static native boolean isVistaOS();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
}