jdk/src/java.desktop/windows/classes/sun/java2d/opengl/WGLGraphicsConfig.java
author darcy
Tue, 16 Dec 2014 09:57:33 -0800
changeset 28234 f694f2576719
parent 25859 3317bb8137f4
child 31661 a5cb86f2253b
permissions -rw-r--r--
8067092: Suppress windows-specific deprecation warnings in the java.desktop module Reviewed-by: prr, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
28234
f694f2576719 8067092: Suppress windows-specific deprecation warnings in the java.desktop module
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1730
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1730
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1730
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1730
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1730
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.java2d.opengl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.AWTException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.BufferCapabilities;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    30
import java.awt.BufferCapabilities.FlipContents;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    31
import java.awt.Color;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Graphics;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    34
import java.awt.Graphics2D;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.ImageCapabilities;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Transparency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.color.ColorSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.image.DataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.image.DirectColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.image.VolatileImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.awt.Win32GraphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.awt.Win32GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.awt.image.SunVolatileImage;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    45
import sun.awt.image.SurfaceManager;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.awt.windows.WComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import sun.java2d.Disposer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import sun.java2d.DisposerRecord;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    49
import sun.java2d.SunGraphics2D;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    50
import sun.java2d.Surface;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import sun.java2d.SurfaceData;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    52
import sun.java2d.pipe.hw.AccelSurface;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    53
import sun.java2d.pipe.hw.AccelTypedVolatileImage;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    54
import sun.java2d.pipe.hw.ContextCapabilities;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    55
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    56
import static sun.java2d.opengl.WGLSurfaceData.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    57
import sun.java2d.opengl.OGLContext.OGLContextCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    58
import sun.java2d.pipe.hw.AccelDeviceEventListener;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    59
import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    60
import sun.java2d.windows.GDIWindowSurfaceData;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
public class WGLGraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    extends Win32GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    implements OGLGraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected static boolean wglAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static ImageCapabilities imageCaps = new WGLImageCaps();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private BufferCapabilities bufferCaps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private long pConfigInfo;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    71
    private ContextCapabilities oglCaps;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private OGLContext context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private Object disposerReferent = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public static native int getDefaultPixFmt(int screennum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private static native boolean initWGL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static native long getWGLConfigInfo(int screennum, int visualnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private static native int getOGLCapabilities(long configInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        wglAvailable = initWGL();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
28234
f694f2576719 8067092: Suppress windows-specific deprecation warnings in the java.desktop module
darcy
parents: 25859
diff changeset
    84
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    protected WGLGraphicsConfig(Win32GraphicsDevice device, int visualnum,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    86
                                long configInfo, ContextCapabilities oglCaps)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        super(device, visualnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        this.pConfigInfo = configInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        this.oglCaps = oglCaps;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    91
        context = new OGLContext(OGLRenderQueue.getInstance(), this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        // add a record to the Disposer so that we destroy the native
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        // WGLGraphicsConfigInfo data when this object goes away
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        Disposer.addRecord(disposerReferent,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    96
                           new WGLGCDisposerRecord(pConfigInfo,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    97
                                                   device.getScreen()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public Object getProxyKey() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public SurfaceData createManagedSurface(int w, int h, int transparency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return WGLSurfaceData.createData(this, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                                         getColorModel(transparency),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                                         null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                         OGLSurfaceData.TEXTURE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public static WGLGraphicsConfig getConfig(Win32GraphicsDevice device,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                                              int pixfmt)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (!wglAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        long cfginfo = 0;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   119
        final String ids[] = new String[1];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            // getWGLConfigInfo() creates and destroys temporary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            // surfaces/contexts, so we should first invalidate the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            // Java-level context and flush the queue...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            OGLContext.invalidateCurrentContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            WGLGetConfigInfo action =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                new WGLGetConfigInfo(device.getScreen(), pixfmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            rq.flushAndInvokeNow(action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            cfginfo = action.getConfigInfo();
1730
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   131
            if (cfginfo != 0L) {
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   132
                OGLContext.setScratchSurface(cfginfo);
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   133
                rq.flushAndInvokeNow(new Runnable() {
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   134
                    public void run() {
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   135
                        ids[0] = OGLContext.getOGLIdString();
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   136
                    }
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   137
                });
2482c2865beb 6755274: 6u10b33 2d tests fails on sles10x64 with jvm crash
tdv
parents: 888
diff changeset
   138
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (cfginfo == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        int oglCaps = getOGLCapabilities(cfginfo);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   147
        ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   149
        return new WGLGraphicsConfig(device, pixfmt, cfginfo, caps);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * This is a small helper class that allows us to execute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * getWGLConfigInfo() on the queue flushing thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    private static class WGLGetConfigInfo implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        private int screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        private int pixfmt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        private long cfginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        private WGLGetConfigInfo(int screen, int pixfmt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            this.screen = screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            this.pixfmt = pixfmt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            cfginfo = getWGLConfigInfo(screen, pixfmt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        public long getConfigInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            return cfginfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public static boolean isWGLAvailable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return wglAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * Returns true if the provided capability bit is present for this config.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * See OGLContext.java for a list of supported capabilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   180
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public final boolean isCapPresent(int cap) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   182
        return ((oglCaps.getCaps() & cap) != 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   185
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public final long getNativeConfigInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return pConfigInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   190
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   191
     * {@inheritDoc}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   192
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   193
     * @see sun.java2d.pipe.hw.BufferedContextProvider#getContext
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   194
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   195
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public final OGLContext getContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        return context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    private static class WGLGCDisposerRecord implements DisposerRecord {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        private long pCfgInfo;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   202
        private int screen;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   203
        public WGLGCDisposerRecord(long pCfgInfo, int screen) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            this.pCfgInfo = pCfgInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        public void dispose() {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   207
            OGLRenderQueue rq = OGLRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   208
            rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   209
            try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   210
                rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   211
                    public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   212
                        AccelDeviceEventNotifier.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   213
                            eventOccured(screen,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   214
                                AccelDeviceEventNotifier.DEVICE_RESET);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   215
                        AccelDeviceEventNotifier.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   216
                            eventOccured(screen,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   217
                                AccelDeviceEventNotifier.DEVICE_DISPOSED);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   218
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   219
                });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   220
            } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   221
                rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   222
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            if (pCfgInfo != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                OGLRenderQueue.disposeGraphicsConfig(pCfgInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                pCfgInfo = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public synchronized void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        super.displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        // the context could hold a reference to a WGLSurfaceData, which in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        // turn has a reference back to this WGLGraphicsConfig, so in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        // for this instance to be disposed we need to break the connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            OGLContext.invalidateCurrentContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public ColorModel getColorModel(int transparency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        switch (transparency) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        case Transparency.OPAQUE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            // REMIND: once the ColorModel spec is changed, this should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            //         an opaque premultiplied DCM...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            return new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        case Transparency.BITMASK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            return new DirectColorModel(25, 0xff0000, 0xff00, 0xff, 0x1000000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        case Transparency.TRANSLUCENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            return new DirectColorModel(cs, 32,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                        0xff0000, 0xff00, 0xff, 0xff000000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                                        true, DataBuffer.TYPE_INT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        return ("WGLGraphicsConfig[dev="+screen+",pixfmt="+visual+"]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * The following methods are invoked from WComponentPeer.java rather
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * than having the Win32-dependent implementations hardcoded in that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * class.  This way the appropriate actions are taken based on the peer's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * GraphicsConfig, whether it is a Win32GraphicsConfig or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * WGLGraphicsConfig.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * Creates a new SurfaceData that will be associated with the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * WComponentPeer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    public SurfaceData createSurfaceData(WComponentPeer peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                                         int numBackBuffers)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   285
        SurfaceData sd = WGLSurfaceData.createData(peer);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   286
        if (sd == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   287
            sd = GDIWindowSurfaceData.createData(peer);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   288
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   289
        return sd;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * The following methods correspond to the multibuffering methods in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * WComponentPeer.java...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Checks that the requested configuration is natively supported; if not,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * an AWTException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public void assertOperationSupported(Component target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                                         int numBuffers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                         BufferCapabilities caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        throws AWTException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        if (numBuffers > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            throw new AWTException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                "Only double or single buffering is supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        BufferCapabilities configCaps = getBufferCapabilities();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        if (!configCaps.isPageFlipping()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            throw new AWTException("Page flipping is not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            throw new AWTException("FlipContents.PRIOR is not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * Creates a WGL-based backbuffer for the given peer and returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * image wrapper.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    public VolatileImage createBackBuffer(WComponentPeer peer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        Component target = (Component)peer.getTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        return new SunVolatileImage(target,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                                    target.getWidth(), target.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                                    Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * Performs the native WGL flip operation for the given target Component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public void flip(WComponentPeer peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                     Component target, VolatileImage backBuffer,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   338
                     int x1, int y1, int x2, int y2,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                     BufferCapabilities.FlipContents flipAction)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        if (flipAction == BufferCapabilities.FlipContents.COPIED) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   342
            SurfaceManager vsm = SurfaceManager.getManager(backBuffer);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   343
            SurfaceData sd = vsm.getPrimarySurfaceData();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   344
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   345
            if (sd instanceof WGLVSyncOffScreenSurfaceData) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   346
                WGLVSyncOffScreenSurfaceData vsd =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   347
                    (WGLVSyncOffScreenSurfaceData)sd;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   348
                SurfaceData bbsd = vsd.getFlipSurface();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   349
                Graphics2D bbg =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   350
                    new SunGraphics2D(bbsd, Color.black, Color.white, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   351
                try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   352
                    bbg.drawImage(backBuffer, 0, 0, null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   353
                } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   354
                    bbg.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   355
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   356
            } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   357
                Graphics g = peer.getGraphics();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   358
                try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   359
                    g.drawImage(backBuffer,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   360
                                x1, y1, x2, y2,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   361
                                x1, y1, x2, y2,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   362
                                null);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   363
                } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   364
                    g.dispose();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   365
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   366
                return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        } else if (flipAction == BufferCapabilities.FlipContents.PRIOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            // not supported by WGL...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        OGLSurfaceData.swapBuffers(peer.getData());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        if (flipAction == BufferCapabilities.FlipContents.BACKGROUND) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            Graphics g = backBuffer.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                g.setColor(target.getBackground());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                g.fillRect(0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                           backBuffer.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                           backBuffer.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    private static class WGLBufferCaps extends BufferCapabilities {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        public WGLBufferCaps(boolean dblBuf) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            super(imageCaps, imageCaps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                  dblBuf ? FlipContents.UNDEFINED : null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    public BufferCapabilities getBufferCapabilities() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        if (bufferCaps == null) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   398
            boolean dblBuf = isCapPresent(CAPS_DOUBLEBUFFERED);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            bufferCaps = new WGLBufferCaps(dblBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        return bufferCaps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    private static class WGLImageCaps extends ImageCapabilities {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        private WGLImageCaps() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            super(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        public boolean isTrueVolatile() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    public ImageCapabilities getImageCapabilities() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        return imageCaps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   417
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   418
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   419
     * {@inheritDoc}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   420
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   421
     * @see sun.java2d.pipe.hw.AccelGraphicsConfig#createCompatibleVolatileImage
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   422
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   423
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   424
    public VolatileImage
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   425
        createCompatibleVolatileImage(int width, int height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   426
                                      int transparency, int type)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   427
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   428
        if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   429
            transparency == Transparency.BITMASK)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   430
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   431
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   432
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   433
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   434
        if (type == FBOBJECT) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   435
            if (!isCapPresent(CAPS_EXT_FBOBJECT)) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   436
                return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   437
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   438
        } else if (type == PBUFFER) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   439
            boolean isOpaque = transparency == Transparency.OPAQUE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   440
            if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   441
                return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   442
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   443
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   444
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   445
        SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   446
                                                          transparency, type);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   447
        Surface sd = vi.getDestSurface();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   448
        if (!(sd instanceof AccelSurface) ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   449
            ((AccelSurface)sd).getType() != type)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   450
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   451
            vi.flush();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   452
            vi = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   453
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   454
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   455
        return vi;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   456
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   457
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   458
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   459
     * {@inheritDoc}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   460
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   461
     * @see sun.java2d.pipe.hw.AccelGraphicsConfig#getContextCapabilities
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   462
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   463
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   464
    public ContextCapabilities getContextCapabilities() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   465
        return oglCaps;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   466
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   467
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   468
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   469
    public void addDeviceEventListener(AccelDeviceEventListener l) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   470
        AccelDeviceEventNotifier.addListener(l, screen.getScreen());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   471
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   472
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   473
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   474
    public void removeDeviceEventListener(AccelDeviceEventListener l) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   475
        AccelDeviceEventNotifier.removeListener(l);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   476
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
}