src/java.desktop/windows/classes/sun/java2d/opengl/WGLSurfaceData.java
author serb
Tue, 27 Aug 2019 04:43:01 -0700
changeset 58315 07556f8cd819
parent 47967 b69b22b7a9f9
permissions -rw-r--r--
8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts Reviewed-by: prr, avu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
31661
a5cb86f2253b 7188942: Remove support of pbuffers in OGL Java2d pipeline
serb
parents: 30948
diff changeset
     2
 * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2451
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: 2451
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: 2451
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2451
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2451
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.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Rectangle;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    34
import java.awt.geom.AffineTransform;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.ColorModel;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    36
import sun.awt.SunToolkit;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    37
import sun.awt.Win32GraphicsDevice;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.awt.windows.WComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.java2d.SurfaceData;
47967
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
    40
import sun.java2d.pipe.Region;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public abstract class WGLSurfaceData extends OGLSurfaceData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    protected WComponentPeer peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private WGLGraphicsConfig graphicsConfig;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    46
    protected double scaleX = 1;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    47
    protected double scaleY = 1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
58315
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47967
diff changeset
    49
    private native void initOps(OGLGraphicsConfig gc, long pConfigInfo,
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47967
diff changeset
    50
                                WComponentPeer peer, long hwnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                             ColorModel cm, int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        super(gc, cm, type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        this.peer = peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        this.graphicsConfig = gc;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    58
        Win32GraphicsDevice device = gc.getDevice();
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    59
        this.scaleX = type == TEXTURE ? 1 : device.getDefaultScaleX();
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    60
        this.scaleY = type == TEXTURE ? 1 : device.getDefaultScaleY();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        long pConfigInfo = gc.getNativeConfigInfo();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    63
        long hwnd = peer != null ? peer.getHWnd() : 0L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
58315
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47967
diff changeset
    65
        initOps(gc, pConfigInfo, peer, hwnd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    68
    @Override
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    69
    public double getDefaultScaleX() {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    70
        return scaleX;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    71
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    72
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    73
    @Override
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    74
    public double getDefaultScaleY() {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    75
        return scaleY;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    76
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
    77
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    public GraphicsConfiguration getDeviceConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return graphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Creates a SurfaceData object representing the primary (front) buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * of an on-screen Window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static WGLWindowSurfaceData createData(WComponentPeer peer) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    87
        // the OGL pipeline can render directly to the screen and interfere
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    88
        // with layered windows, which is why we don't allow accelerated
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    89
        // surfaces in this case
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 888
diff changeset
    90
        if (!peer.isAccelCapable() ||
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 888
diff changeset
    91
            !SunToolkit.isContainingTopLevelOpaque((Component)peer.getTarget()))
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    92
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    93
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    94
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        WGLGraphicsConfig gc = getGC(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return new WGLWindowSurfaceData(peer, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Creates a SurfaceData object representing the back buffer of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * double-buffered on-screen Window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public static WGLOffScreenSurfaceData createData(WComponentPeer peer,
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   104
                                                     Image image,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   105
                                                     int type)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   107
        // the OGL pipeline can render directly to the screen and interfere
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   108
        // with layered windows, which is why we don't allow accelerated
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   109
        // surfaces in this case
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 888
diff changeset
   110
        if (!peer.isAccelCapable() ||
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 888
diff changeset
   111
            !SunToolkit.isContainingTopLevelOpaque((Component)peer.getTarget()))
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   112
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   113
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   114
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        WGLGraphicsConfig gc = getGC(peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        Rectangle r = peer.getBounds();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   117
        if (type == FLIP_BACKBUFFER) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   118
            return new WGLOffScreenSurfaceData(peer, gc, r.width, r.height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   119
                                               image, peer.getColorModel(),
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   120
                                               type);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   121
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   122
            return new WGLVSyncOffScreenSurfaceData(peer, gc, r.width, r.height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   123
                                                    image, peer.getColorModel(),
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   124
                                                    type);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   125
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Creates a SurfaceData object representing an off-screen buffer (either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * a Pbuffer or Texture).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public static WGLOffScreenSurfaceData createData(WGLGraphicsConfig gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                                     int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                                     ColorModel cm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                                     Image image, int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return new WGLOffScreenSurfaceData(null, gc, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                                           image, cm, type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public static WGLGraphicsConfig getGC(WComponentPeer peer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            return (WGLGraphicsConfig)peer.getGraphicsConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            // REMIND: this should rarely (never?) happen, but what if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            //         default config is not WGL?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            GraphicsEnvironment env =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                GraphicsEnvironment.getLocalGraphicsEnvironment();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            GraphicsDevice gd = env.getDefaultScreenDevice();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            return (WGLGraphicsConfig)gd.getDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public static class WGLWindowSurfaceData extends WGLSurfaceData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        public WGLWindowSurfaceData(WComponentPeer peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                    WGLGraphicsConfig gc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            super(peer, gc, peer.getColorModel(), WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        public SurfaceData getReplacement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            return peer.getSurfaceData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            Rectangle r = peer.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            r.x = r.y = 0;
47967
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
   169
            r.width = Region.clipRound(r.width * scaleX);
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
   170
            r.height = Region.clipRound(r.height * scaleY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
         * Returns destination Component associated with this SurfaceData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        public Object getDestination() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            return peer.getTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   182
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   183
     * A surface which implements a v-synced flip back-buffer with COPIED
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   184
     * FlipContents.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   185
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   186
     * This surface serves as a back-buffer to the outside world, while
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   187
     * it is actually an offscreen surface. When the BufferStrategy this surface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   188
     * belongs to is showed, it is first copied to the real private
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   189
     * FLIP_BACKBUFFER, which is then flipped.
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
    public static class WGLVSyncOffScreenSurfaceData extends
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   192
        WGLOffScreenSurfaceData
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   193
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   194
        private WGLOffScreenSurfaceData flipSurface;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   195
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   196
        public WGLVSyncOffScreenSurfaceData(WComponentPeer peer,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   197
                                            WGLGraphicsConfig gc,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   198
                                            int width, int height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   199
                                            Image image, ColorModel cm,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   200
                                            int type)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   201
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   202
            super(peer, gc, width, height, image, cm, type);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   203
            flipSurface = WGLSurfaceData.createData(peer, image, FLIP_BACKBUFFER);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   204
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   205
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   206
        public SurfaceData getFlipSurface() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   207
            return flipSurface;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   208
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   209
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   210
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   211
        public void flush() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   212
            flipSurface.flush();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   213
            super.flush();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   214
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   215
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   216
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   217
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    public static class WGLOffScreenSurfaceData extends WGLSurfaceData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        private Image offscreenImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        private int width, height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        public WGLOffScreenSurfaceData(WComponentPeer peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                                       WGLGraphicsConfig gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                       int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                                       Image image, ColorModel cm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                       int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            super(peer, gc, cm, type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
47967
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
   231
            this.width = Region.clipRound(width * scaleX);
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
   232
            this.height = Region.clipRound(height * scaleY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            offscreenImage = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 31661
diff changeset
   235
            initSurface(this.width, this.height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        public SurfaceData getReplacement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return restoreContents(offscreenImage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            if (type == FLIP_BACKBUFFER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                Rectangle r = peer.getBounds();
47967
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
   245
                r.width = Region.clipRound(r.width * scaleX);
b69b22b7a9f9 8159142: [hidpi] Visible artifacts in sun/java2d/SunGraphics2D/DrawImageBilinear.java
pbansal
parents: 47216
diff changeset
   246
                r.height = Region.clipRound(r.height * scaleY);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                r.x = r.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                return new Rectangle(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
         * Returns destination Image associated with this SurfaceData.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        public Object getDestination() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            return offscreenImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   261
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   262
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   263
     * Updates the layered window with the contents of the surface.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   264
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   265
     * @param psdops pointer to the native ogl sd structure
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   266
     * @param peer pointer to the AwtWindow peer data
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   267
     * @param w width of the window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   268
     * @param h height of the window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   269
     * @see sun.awt.windows.TranslucentWindowPainter
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   270
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   271
    public static native boolean updateWindowAccelImpl(long psdops,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   272
                                                       WComponentPeer peer,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   273
                                                       int w, int h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
}