jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java
author henryjen
Thu, 05 Jun 2014 13:59:01 -0700
changeset 25192 4e2dc0f8702d
parent 22567 5816a47fa4dd
permissions -rw-r--r--
8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files 8044396: Fix raw and unchecked lint warnings in platform-specific sun.java2d.* Reviewed-by: darcy, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     1
/*
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 5506
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     4
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
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: 4209
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4209
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    10
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    15
 * accompanied this code).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    16
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4209
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4209
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4209
diff changeset
    23
 * questions.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    24
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    25
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    26
package sun.java2d.d3d;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    27
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    28
import java.awt.Dialog;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    29
import java.awt.DisplayMode;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    30
import java.awt.Frame;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    31
import java.awt.GraphicsConfiguration;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    32
import java.awt.Rectangle;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    33
import java.awt.Toolkit;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    34
import java.awt.Window;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    35
import java.awt.event.WindowAdapter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    36
import java.awt.event.WindowEvent;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    37
import java.awt.event.WindowListener;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    38
import java.awt.peer.WindowPeer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    39
import java.util.ArrayList;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    40
import sun.awt.Win32GraphicsDevice;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    41
import sun.awt.windows.WWindowPeer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    42
import sun.java2d.pipe.hw.ContextCapabilities;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    43
import sun.java2d.windows.WindowsFlags;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    44
import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    45
import sun.java2d.d3d.D3DContext.D3DContextCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    46
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    47
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    48
 * This class implements D3D-specific functionality, such as fullscreen
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    49
 * exclusive mode and display changes.  It is kept separate from
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    50
 * Win32GraphicsDevice to help avoid overburdening the parent class.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    51
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    52
public class D3DGraphicsDevice extends Win32GraphicsDevice {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    53
    private D3DContext context;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    54
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    55
    private static boolean d3dAvailable;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    56
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    57
    private ContextCapabilities d3dCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    58
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    59
    private static native boolean initD3D();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    60
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    61
    static {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    62
        // loading the library doesn't help because we need the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    63
        // toolkit thread running, so we have to call getDefaultToolkit()
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    64
        Toolkit.getDefaultToolkit();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    65
        d3dAvailable = initD3D();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    66
        if (d3dAvailable) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    67
            // we don't use pixel formats for the d3d pipeline
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    68
            pfDisabled = true;
3849
34469964aa98 6878481: Add performance counters in the JDK
mchung
parents: 887
diff changeset
    69
            sun.misc.PerfCounter.getD3DAvailable().set(1);
34469964aa98 6878481: Add performance counters in the JDK
mchung
parents: 887
diff changeset
    70
        } else {
34469964aa98 6878481: Add performance counters in the JDK
mchung
parents: 887
diff changeset
    71
            sun.misc.PerfCounter.getD3DAvailable().set(0);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    72
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    73
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    74
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    75
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    76
     * Used to construct a Direct3D-enabled GraphicsDevice.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    77
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    78
     * @return a D3DGraphicsDevice if it could be created
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    79
     * successfully, null otherwise.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    80
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    81
    public static D3DGraphicsDevice createDevice(int screen) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    82
        if (!d3dAvailable) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    83
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    84
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    85
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    86
        ContextCapabilities d3dCaps = getDeviceCaps(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    87
        // could not initialize the device successfully
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    88
        if ((d3dCaps.getCaps() & CAPS_DEVICE_OK) == 0) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    89
            if (WindowsFlags.isD3DVerbose()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    90
                System.out.println("Could not enable Direct3D pipeline on " +
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    91
                                   "screen " + screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    92
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    93
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    94
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    95
        if (WindowsFlags.isD3DVerbose()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    96
            System.out.println("Direct3D pipeline enabled on screen " + screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    97
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    98
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
    99
        D3DGraphicsDevice gd = new D3DGraphicsDevice(screen, d3dCaps);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   100
        return gd;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   101
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   102
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   103
    private static native int getDeviceCapsNative(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   104
    private static native String getDeviceIdNative(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   105
    private static ContextCapabilities getDeviceCaps(final int screen) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   106
        ContextCapabilities d3dCaps = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   107
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   108
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   109
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   110
            class Result {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   111
                int caps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   112
                String id;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   113
            };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   114
            final Result res = new Result();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   115
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   116
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   117
                    res.caps = getDeviceCapsNative(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   118
                    res.id = getDeviceIdNative(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   119
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   120
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   121
            d3dCaps = new D3DContextCaps(res.caps, res.id);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   122
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   123
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   124
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   125
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   126
        return d3dCaps != null ? d3dCaps : new D3DContextCaps(CAPS_EMPTY, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   127
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   128
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   129
    public final boolean isCapPresent(int cap) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   130
        return ((d3dCaps.getCaps() & cap) != 0);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   131
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   132
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   133
    private D3DGraphicsDevice(int screennum, ContextCapabilities d3dCaps) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   134
        super(screennum);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   135
        descString = "D3DGraphicsDevice[screen="+screennum;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   136
        this.d3dCaps = d3dCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   137
        context = new D3DContext(D3DRenderQueue.getInstance(), this);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   138
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   139
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   140
    public boolean isD3DEnabledOnDevice() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   141
        return isValid() && isCapPresent(CAPS_DEVICE_OK);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   142
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   143
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   144
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   145
     * Returns true if d3d pipeline has been successfully initialized.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   146
     * @return true if d3d pipeline is initialized, false otherwise
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   147
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   148
    public static boolean isD3DAvailable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   149
        return d3dAvailable;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   150
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   151
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   152
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   153
     * Return the owning Frame for a given Window.  Used in setFSWindow below
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   154
     * to set the properties of the owning Frame when a Window goes
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   155
     * into fullscreen mode.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   156
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   157
    private Frame getToplevelOwner(Window w) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   158
        Window owner = w;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   159
        while (owner != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   160
            owner = owner.getOwner();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   161
            if (owner instanceof Frame) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   162
                return (Frame) owner;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   163
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   164
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   165
        // could get here if passed Window is an owner-less Dialog
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   166
        return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   167
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   168
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   169
    private boolean fsStatus;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   170
    private Rectangle ownerOrigBounds = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   171
    private boolean ownerWasVisible;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   172
    private Window realFSWindow;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   173
    private WindowListener fsWindowListener;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   174
    private boolean fsWindowWasAlwaysOnTop;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   175
    private static native boolean enterFullScreenExclusiveNative(int screen,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   176
                                                                 long hwnd);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   177
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   178
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   179
    protected void enterFullScreenExclusive(final int screen, WindowPeer wp)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   180
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   181
        final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   182
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   183
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   184
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   185
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   186
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   187
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   188
                    long hwnd = wpeer.getHWnd();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   189
                    if (hwnd == 0l) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   190
                        // window is disposed
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   191
                        fsStatus = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   192
                        return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   193
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   194
                    fsStatus = enterFullScreenExclusiveNative(screen, hwnd);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   195
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   196
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   197
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   198
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   199
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   200
        if (!fsStatus) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   201
            super.enterFullScreenExclusive(screen, wp);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   202
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   203
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   204
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   205
    private static native boolean exitFullScreenExclusiveNative(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   206
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   207
    protected void exitFullScreenExclusive(final int screen, WindowPeer w) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   208
        if (fsStatus) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   209
            D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   210
            rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   211
            try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   212
                rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   213
                    public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   214
                        exitFullScreenExclusiveNative(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   215
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   216
                });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   217
            } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   218
                rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   219
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   220
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   221
            super.exitFullScreenExclusive(screen, w);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   222
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   223
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   224
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   225
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   226
     * WindowAdapter class for the full-screen frame, responsible for
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   227
     * restoring the devices. This is important to do because unless the device
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   228
     * is restored it will not go back into the FS mode once alt+tabbed out.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   229
     * This is a problem for windows for which we do not do any d3d-related
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   230
     * operations (like when we disabled on-screen rendering).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   231
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   232
     * REMIND: we create an instance per each full-screen device while a single
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   233
     * instance would suffice (but requires more management).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   234
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   235
    private static class D3DFSWindowAdapter extends WindowAdapter {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   236
        @Override
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 5506
diff changeset
   237
        @SuppressWarnings("static")
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   238
        public void windowDeactivated(WindowEvent e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   239
            D3DRenderQueue.getInstance().restoreDevices();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   240
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   241
        @Override
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 5506
diff changeset
   242
        @SuppressWarnings("static")
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   243
        public void windowActivated(WindowEvent e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   244
            D3DRenderQueue.getInstance().restoreDevices();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   245
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   246
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   247
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   248
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   249
    protected void addFSWindowListener(Window w) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   250
        // if the window is not a toplevel (has an owner) we have to use the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   251
        // real toplevel to enter the full-screen mode with (4933099).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   252
        if (!(w instanceof Frame) && !(w instanceof Dialog) &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   253
            (realFSWindow = getToplevelOwner(w)) != null)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   254
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   255
            ownerOrigBounds = realFSWindow.getBounds();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   256
            WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   257
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   258
            ownerWasVisible = realFSWindow.isVisible();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   259
            Rectangle r = w.getBounds();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   260
            // we use operations on peer instead of component because calling
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   261
            // them on component will take the tree lock
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   262
            fp.reshape(r.x, r.y, r.width, r.height);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   263
            fp.setVisible(true);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   264
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   265
            realFSWindow = w;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   266
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   267
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   268
        fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   269
        ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   270
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   271
        fsWindowListener = new D3DFSWindowAdapter();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   272
        realFSWindow.addWindowListener(fsWindowListener);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   273
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   274
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   275
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   276
    protected void removeFSWindowListener(Window w) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   277
        realFSWindow.removeWindowListener(fsWindowListener);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   278
        fsWindowListener = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   279
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   280
        /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   281
         * Bug 4933099: There is some funny-business to deal with when this
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   282
         * method is called with a Window instead of a Frame.  See 4836744
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   283
         * for more information on this.  One side-effect of our workaround
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   284
         * for the problem is that the owning Frame of a Window may end
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   285
         * up getting resized during the fullscreen process.  When we
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   286
         * return from fullscreen mode, we should resize the Frame to
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   287
         * its original size (just like the Window is being resized
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   288
         * to its original size in GraphicsDevice).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   289
         */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   290
        WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   291
        if (wpeer != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   292
            if (ownerOrigBounds != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   293
                // if the window went into fs mode before it was realized it
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   294
                // could have (0,0) dimensions
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   295
                if (ownerOrigBounds.width  == 0) ownerOrigBounds.width  = 1;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   296
                if (ownerOrigBounds.height == 0) ownerOrigBounds.height = 1;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   297
                wpeer.reshape(ownerOrigBounds.x,     ownerOrigBounds.y,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   298
                              ownerOrigBounds.width, ownerOrigBounds.height);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   299
                if (!ownerWasVisible) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   300
                    wpeer.setVisible(false);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   301
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   302
                ownerOrigBounds = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   303
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   304
            if (!fsWindowWasAlwaysOnTop) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   305
                wpeer.setAlwaysOnTop(false);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   306
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   307
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   308
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   309
        realFSWindow = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   310
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   311
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   312
    private static native DisplayMode getCurrentDisplayModeNative(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   313
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   314
    protected DisplayMode getCurrentDisplayMode(final int screen) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   315
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   316
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   317
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   318
            class Result {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   319
                DisplayMode dm = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   320
            };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   321
            final Result res = new Result();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   322
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   323
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   324
                    res.dm = getCurrentDisplayModeNative(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   325
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   326
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   327
            if (res.dm == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   328
                return super.getCurrentDisplayMode(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   329
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   330
            return res.dm;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   331
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   332
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   333
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   334
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   335
    private static native void configDisplayModeNative(int screen, long hwnd,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   336
                                                       int width, int height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   337
                                                       int bitDepth,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   338
                                                       int refreshRate);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   339
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   340
    protected void configDisplayMode(final int screen, final WindowPeer w,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   341
                                     final int width, final int height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   342
                                     final int bitDepth, final int refreshRate)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   343
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   344
        // we entered fs mode via gdi
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   345
        if (!fsStatus) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   346
            super.configDisplayMode(screen, w, width, height, bitDepth,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   347
                                    refreshRate);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   348
            return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   349
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   350
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   351
        final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   352
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   353
        // REMIND: we do this before we switch the display mode, so
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   354
        // the dimensions may be exceeding the dimensions of the screen,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   355
        // is this a problem?
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   356
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   357
        // update the bounds of the owner frame
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   358
        if (getFullScreenWindow() != realFSWindow) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   359
            Rectangle screenBounds = getDefaultConfiguration().getBounds();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   360
            wpeer.reshape(screenBounds.x, screenBounds.y, width, height);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   361
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   362
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   363
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   364
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   365
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   366
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   367
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   368
                    long hwnd = wpeer.getHWnd();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   369
                    if (hwnd == 0l) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   370
                        // window is disposed
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   371
                        return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   372
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   373
                    // REMIND: do we really need a window here?
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   374
                    // we should probably just use the current one
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   375
                    configDisplayModeNative(screen, hwnd, width, height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   376
                                            bitDepth, refreshRate);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   377
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   378
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   379
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   380
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   381
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   382
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   383
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   384
    private static native void enumDisplayModesNative(int screen,
25192
4e2dc0f8702d 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents: 22567
diff changeset
   385
                                                      ArrayList<DisplayMode> modes);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   386
    @Override
25192
4e2dc0f8702d 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents: 22567
diff changeset
   387
    protected void enumDisplayModes(final int screen, final ArrayList<DisplayMode> modes) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   388
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   389
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   390
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   391
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   392
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   393
                    enumDisplayModesNative(screen, modes);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   394
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   395
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   396
            if (modes.size() == 0) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   397
                modes.add(getCurrentDisplayModeNative(screen));
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   398
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   399
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   400
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   401
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   402
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   403
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   404
    private static native long getAvailableAcceleratedMemoryNative(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   405
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   406
    public int getAvailableAcceleratedMemory() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   407
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   408
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   409
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   410
            class Result {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   411
                long mem = 0L;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   412
            };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   413
            final Result res = new Result();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   414
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   415
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   416
                    res.mem = getAvailableAcceleratedMemoryNative(getScreen());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   417
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   418
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   419
            return (int)res.mem;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   420
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   421
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   422
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   423
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   424
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   425
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   426
    public GraphicsConfiguration[] getConfigurations() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   427
        if (configs == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   428
            if (isD3DEnabledOnDevice()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   429
                defaultConfig = getDefaultConfiguration();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   430
                if (defaultConfig != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   431
                    configs = new GraphicsConfiguration[1];
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   432
                    configs[0] = defaultConfig;
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents: 887
diff changeset
   433
                    return configs.clone();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   434
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   435
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   436
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   437
        return super.getConfigurations();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   438
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   439
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   440
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   441
    public GraphicsConfiguration getDefaultConfiguration() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   442
        if (defaultConfig == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   443
            if (isD3DEnabledOnDevice()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   444
                defaultConfig = new D3DGraphicsConfig(this);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   445
            } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   446
                defaultConfig = super.getDefaultConfiguration();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   447
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   448
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   449
        return defaultConfig;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   450
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   451
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   452
    private static native boolean isD3DAvailableOnDeviceNative(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   453
    // REMIND: this method is not used now, we use caps instead
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   454
    public static boolean isD3DAvailableOnDevice(final int screen) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   455
        if (!d3dAvailable) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   456
            return false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   457
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   458
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   459
        // REMIND: should we cache the result per device somehow,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   460
        // and then reset and retry it on display change?
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   461
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   462
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   463
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   464
            class Result {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   465
                boolean avail = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   466
            };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   467
            final Result res = new Result();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   468
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   469
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   470
                    res.avail = isD3DAvailableOnDeviceNative(screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   471
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   472
            });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   473
            return res.avail;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   474
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   475
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   476
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   477
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   478
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   479
    D3DContext getContext() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   480
        return context;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   481
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   482
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   483
    ContextCapabilities getContextCapabilities() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   484
        return d3dCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   485
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   486
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   487
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   488
    public void displayChanged() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   489
        super.displayChanged();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   490
        // REMIND: make sure this works when the device is lost and we don't
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   491
        // disable d3d too eagerly
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   492
        if (d3dAvailable) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   493
            d3dCaps = getDeviceCaps(getScreen());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   494
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   495
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   496
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   497
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   498
    protected void invalidate(int defaultScreen) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   499
        super.invalidate(defaultScreen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   500
        // REMIND: this is a bit excessive, isD3DEnabledOnDevice will return
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   501
        // false anyway because the device is invalid
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   502
        d3dCaps = new D3DContextCaps(CAPS_EMPTY, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   503
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents:
diff changeset
   504
}