jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
author rkennke
Fri, 07 Aug 2009 18:31:11 +0200
changeset 3928 be186a33df9b
parent 2460 15e4d52f9ed4
child 5506 202f599c92aa
permissions -rw-r--r--
6795908: Refactor FontManager Reviewed-by: prr, igor
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    28
import java.awt.GraphicsConfiguration;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.Toolkit;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    32
import java.awt.peer.ComponentPeer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.File;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.ListIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.NoSuchElementException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.awt.DisplayChangedListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.SunDisplayChanger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.awt.windows.WFontConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.awt.windows.WPrinterJob;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.awt.windows.WToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.font.FontManager;
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
    46
import sun.font.FontManagerFactory;
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
    47
import sun.font.SunFontManager;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import sun.java2d.SunGraphicsEnvironment;
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    49
import sun.java2d.SurfaceManagerFactory;
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    50
import sun.java2d.WindowsSurfaceManagerFactory;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
    51
import sun.java2d.d3d.D3DGraphicsDevice;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import sun.java2d.windows.WindowsFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * This is an implementation of a GraphicsEnvironment object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * default local GraphicsEnvironment used by the Java Runtime Environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * for Windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @see GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @see GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
public class Win32GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    extends SunGraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        // Ensure awt is loaded already.  Also, this forces static init
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        // of WToolkit and Toolkit, which we depend upon
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        WToolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        // setup flags before initializing native layer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        WindowsFlags.initFlags();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        initDisplayWrapper();
557
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    73
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    74
        // Install correct surface manager factory.
800259d3792b 6675596: SurfaceManagerFactory should allow plugging in different implementations
tdv
parents: 550
diff changeset
    75
        SurfaceManagerFactory.setInstance(new WindowsSurfaceManagerFactory());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Noop function that just acts as an entry point for someone to force
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * a static initialization of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public static void init() {}
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();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    protected native int getDefaultScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public GraphicsDevice getDefaultScreenDevice() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        return getScreenDevices()[getDefaultScreen()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Returns the number of pixels per logical inch along the screen width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * In a system with multiple display monitors, this value is the same for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * all monitors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @returns number of pixels per logical inch in X direction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public native int getXResolution();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Returns the number of pixels per logical inch along the screen height.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * In a system with multiple display monitors, this value is the same for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * all monitors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @returns number of pixels per logical inch in Y direction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public native int getYResolution();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * ----DISPLAY CHANGE SUPPORT----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    // list of invalidated graphics devices (those which were removed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    private ArrayList<WeakReference<Win32GraphicsDevice>> oldDevices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * From DisplayChangeListener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Called from WToolkit and executed on the event thread when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * display settings are changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        // getNumScreens() will return the correct current number of screens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        GraphicsDevice newDevices[] = new GraphicsDevice[getNumScreens()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        GraphicsDevice oldScreens[] = screens;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        // go through the list of current devices and determine if they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        // could be reused, or will have to be replaced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        if (oldScreens != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            for (int i = 0; i < oldScreens.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                if (!(screens[i] instanceof Win32GraphicsDevice)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    // REMIND: can we ever have anything other than Win32GD?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                    assert (false) : oldScreens[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                Win32GraphicsDevice gd = (Win32GraphicsDevice)oldScreens[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                // devices may be invalidated from the native code when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                // display change happens (device add/removal also causes a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                // display change)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                if (!gd.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                    if (oldDevices == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                        oldDevices =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                            new ArrayList<WeakReference<Win32GraphicsDevice>>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                    oldDevices.add(new WeakReference<Win32GraphicsDevice>(gd));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                } else if (i < newDevices.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    // reuse the device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    newDevices[i] = gd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            oldScreens = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        // create the new devices (those that weren't reused)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        for (int i = 0; i < newDevices.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            if (newDevices[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                newDevices[i] = makeScreenDevice(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        // install the new array of devices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        // Note: no synchronization here, it doesn't matter if a thread gets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        // a new or an old array this time around
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        screens = newDevices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        for (GraphicsDevice gd : screens) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            if (gd instanceof DisplayChangedListener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                ((DisplayChangedListener)gd).displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        // re-invalidate all old devices. It's needed because those in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // may become "invalid" again - if the current default device is removed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        // for example. Also, they need to be notified about display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        // changes as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        if (oldDevices != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            int defScreen = getDefaultScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            for (ListIterator<WeakReference<Win32GraphicsDevice>> it =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    oldDevices.listIterator(); it.hasNext();)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                Win32GraphicsDevice gd = it.next().get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                if (gd != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    gd.invalidate(defScreen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    gd.displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    // no more references to this device, remove it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    it.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        // Reset the static GC for the (possibly new) default screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        WToolkit.resetGC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        // notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        // CachingSurfaceManagers) about the display change event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        displayChanger.notifyListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        // note: do not call super.displayChanged, we've already done everything
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * ----END DISPLAY CHANGE SUPPORT----
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Whether registerFontFile expects absolute or relative
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * font file names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    protected boolean useAbsoluteFontFileNames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    protected GraphicsDevice makeScreenDevice(int screennum) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   224
        GraphicsDevice device = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   225
        if (WindowsFlags.isD3DEnabled()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   226
            device = D3DGraphicsDevice.createDevice(screennum);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   227
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   228
        if (device == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   229
            device = new Win32GraphicsDevice(screennum);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   230
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   231
        return device;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    // Implements SunGraphicsEnvironment.createFontConfiguration.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    protected FontConfiguration createFontConfiguration() {
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   236
       FontConfiguration fc = new WFontConfiguration(SunFontManager.getInstance());
883
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   237
       fc.init();
c3e81f0acd3d 6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents: 557
diff changeset
   238
       return fc;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public FontConfiguration createFontConfiguration(boolean preferLocaleFonts,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                                     boolean preferPropFonts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   244
        return new WFontConfiguration(SunFontManager.getInstance(),
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   245
                preferLocaleFonts,preferPropFonts);
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   246
    }
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   247
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   248
    public boolean isDisplayLocal() {
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2460
diff changeset
   249
        return true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   251
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   252
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   253
    public boolean isFlipStrategyPreferred(ComponentPeer peer) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   254
        GraphicsConfiguration gc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   255
        if (peer != null && (gc = peer.getGraphicsConfiguration()) != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   256
            GraphicsDevice gd = gc.getDevice();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   257
            if (gd instanceof D3DGraphicsDevice) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   258
                return ((D3DGraphicsDevice)gd).isD3DEnabledOnDevice();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   259
            }
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
        return false;
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
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   264
    private static volatile boolean isDWMCompositionEnabled;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   265
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   266
     * 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
   267
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   268
     * @return true if dwm composition is enabled, false otherwise
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   269
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   270
    public static boolean isDWMCompositionEnabled() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   271
        return isDWMCompositionEnabled;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   272
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   273
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   274
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   275
     * 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
   276
     * 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
   277
     * 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
   278
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   279
     * 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
   280
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   281
     * @param enabled indicates the state of dwm composition
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   282
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   283
    private static void dwmCompositionChanged(boolean enabled) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   284
        isDWMCompositionEnabled = enabled;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 883
diff changeset
   285
    }
1724
a22a286aa16f 6748082: remove platform-specific code from SwingUtilities2.isDisplayLocal
tdv
parents: 889
diff changeset
   286
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   287
    /**
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   288
     * 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
   289
     *
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   290
     * @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
   291
     */
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 889
diff changeset
   292
    public static native boolean isVistaOS();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
}