jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DSurfaceData.java
author alexsch
Fri, 13 Nov 2015 05:02:26 -0800
changeset 34394 259d6e4e0978
parent 30948 0a0972d3b58d
child 36874 09abfda883d2
permissions -rw-r--r--
8073320: Windows HiDPI Graphics support Reviewed-by: flar, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
     2
 * Copyright (c) 2007, 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: 1723
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: 1723
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: 1723
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1723
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.d3d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.AlphaComposite;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    29
import java.awt.BufferCapabilities;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    30
import java.awt.Component;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GraphicsConfiguration;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    32
import java.awt.GraphicsDevice;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    33
import java.awt.GraphicsEnvironment;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Image;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    35
import java.awt.Rectangle;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Transparency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.image.ColorModel;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    38
import java.awt.image.DataBuffer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.image.DirectColorModel;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    40
import java.awt.image.Raster;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    41
import java.awt.image.SampleModel;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    42
import java.awt.image.SinglePixelPackedSampleModel;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.awt.SunHints;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    44
import sun.awt.image.DataBufferNative;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    45
import sun.awt.image.PixelConverter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.awt.image.SurfaceManager;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    47
import sun.awt.image.WritableRasterNative;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    48
import sun.awt.windows.WComponentPeer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    49
import sun.java2d.pipe.hw.AccelSurface;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import sun.java2d.InvalidPipeException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import sun.java2d.SunGraphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import sun.java2d.SurfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import sun.java2d.loops.GraphicsPrimitive;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    54
import sun.java2d.loops.MaskFill;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import sun.java2d.loops.SurfaceType;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    56
import sun.java2d.loops.CompositeType;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    57
import sun.java2d.pipe.ParallelogramPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    58
import sun.java2d.pipe.PixelToParallelogramConverter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    59
import sun.java2d.pipe.RenderBuffer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import sun.java2d.pipe.TextPipe;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    61
import static sun.java2d.pipe.BufferedOpCodes.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    62
import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    63
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    64
import sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    65
import java.awt.BufferCapabilities.FlipContents;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
    66
import java.awt.Dimension;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    67
import java.awt.Window;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
    68
import java.awt.geom.AffineTransform;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    69
import sun.awt.SunToolkit;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    70
import sun.awt.image.SunVolatileImage;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
    71
import sun.awt.windows.WWindowPeer;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    72
import sun.java2d.ScreenUpdateManager;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    73
import sun.java2d.StateTracker;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    74
import sun.java2d.SurfaceDataProxy;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    75
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    77
/**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    78
 * This class describes a D3D "surface", that is, a region of pixels
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    79
 * managed via D3D.  An D3DSurfaceData can be tagged with one of three
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    80
 * different SurfaceType objects for the purpose of registering loops, etc.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    81
 * This diagram shows the hierarchy of D3D SurfaceTypes:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    82
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    83
 *                               Any
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    84
 *                             /     \
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    85
 *                    D3DSurface     D3DTexture
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    86
 *                         |
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    87
 *                   D3DSurfaceRTT
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    88
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    89
 * D3DSurface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    90
 * This kind of surface can be rendered to using D3D APIs.  It is also
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    91
 * possible to copy a D3DSurface to another D3DSurface (or to itself).
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
 * D3DTexture
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    94
 * This kind of surface cannot be rendered to using D3D (in the same sense
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    95
 * as in D3DSurface).  However, it is possible to upload a region of pixels
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    96
 * to a D3DTexture object via Lock/UnlockRect().  One can also copy a
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    97
 * surface of type D3DTexture to a D3DSurface by binding the texture
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    98
 * to a quad and then rendering it to the destination surface (this process
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    99
 * is known as "texture mapping").
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   100
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   101
 * D3DSurfaceRTT
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   102
 * This kind of surface can be thought of as a sort of hybrid between
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   103
 * D3DSurface and D3DTexture, in that one can render to this kind of
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   104
 * surface as if it were of type D3DSurface, but the process of copying
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   105
 * this kind of surface to another is more like a D3DTexture.  (Note that
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   106
 * "RTT" stands for "render-to-texture".)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   107
 *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   108
 * In addition to these SurfaceType variants, we have also defined some
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   109
 * constants that describe in more detail the type of underlying D3D
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   110
 * surface.  This table helps explain the relationships between those
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   111
 * "type" constants and their corresponding SurfaceType:
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
 * D3D Type          Corresponding SurfaceType
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   114
 * --------          -------------------------
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   115
 * RT_PLAIN          D3DSurface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   116
 * TEXTURE           D3DTexture
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   117
 * FLIP_BACKBUFFER   D3DSurface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   118
 * RT_TEXTURE        D3DSurfaceRTT
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   119
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   120
public class D3DSurfaceData extends SurfaceData implements AccelSurface {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   123
     * To be used with getNativeResource() only.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   124
     * @see #getNativeResource
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   126
    public static final int D3D_DEVICE_RESOURCE= 100;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   127
    /*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   128
     * Surface types.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   129
     * We use these surface types when copying from a sw surface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   130
     * to a surface or texture.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   132
    public static final int ST_INT_ARGB        = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   133
    public static final int ST_INT_ARGB_PRE    = 1;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   134
    public static final int ST_INT_ARGB_BM     = 2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   135
    public static final int ST_INT_RGB         = 3;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   136
    public static final int ST_INT_BGR         = 4;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   137
    public static final int ST_USHORT_565_RGB  = 5;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   138
    public static final int ST_USHORT_555_RGB  = 6;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   139
    public static final int ST_BYTE_INDEXED    = 7;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   140
    public static final int ST_BYTE_INDEXED_BM = 8;
1723
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 1717
diff changeset
   141
    public static final int ST_3BYTE_BGR       = 9;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   143
    /** Equals to D3DSWAPEFFECT_DISCARD */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   144
    public static final int SWAP_DISCARD       = 1;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   145
    /** Equals to D3DSWAPEFFECT_FLIP    */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   146
    public static final int SWAP_FLIP          = 2;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   147
    /** Equals to D3DSWAPEFFECT_COPY    */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   148
    public static final int SWAP_COPY          = 3;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   149
    /*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   150
     * SurfaceTypes
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   151
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   152
    private static final String DESC_D3D_SURFACE = "D3D Surface";
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   153
    private static final String DESC_D3D_SURFACE_RTT =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   154
        "D3D Surface (render-to-texture)";
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   155
    private static final String DESC_D3D_TEXTURE = "D3D Texture";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   157
    // REMIND: regarding ArgbPre??
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   158
    static final SurfaceType D3DSurface =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   159
        SurfaceType.Any.deriveSubType(DESC_D3D_SURFACE,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   160
                                      PixelConverter.ArgbPre.instance);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   161
    static final SurfaceType D3DSurfaceRTT =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   162
        D3DSurface.deriveSubType(DESC_D3D_SURFACE_RTT);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   163
    static final SurfaceType D3DTexture =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   164
        SurfaceType.Any.deriveSubType(DESC_D3D_TEXTURE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   166
    private int type;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   167
    private int width, height;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   168
    private final double scaleX;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   169
    private final double scaleY;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   170
    // these fields are set from the native code when the surface is
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   171
    // initialized
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   172
    private int nativeWidth, nativeHeight;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   173
    protected WComponentPeer peer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   174
    private Image offscreenImage;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   175
    protected D3DGraphicsDevice graphicsDevice;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   177
    private int swapEffect;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   178
    private VSyncType syncType;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   179
    private int backBuffersNum;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   181
    private WritableRasterNative wrn;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   183
    protected static D3DRenderer d3dRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   184
    protected static PixelToParallelogramConverter d3dTxRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   185
    protected static ParallelogramPipe d3dAAPgramPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   186
    protected static D3DTextRenderer d3dTextPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   187
    protected static D3DDrawImage d3dImagePipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   189
    private native boolean initTexture(long pData, boolean isRTT,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   190
                                       boolean isOpaque);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   191
    private native boolean initFlipBackbuffer(long pData, long pPeerData,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   192
                                              int numbuffers,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   193
                                              int swapEffect, int syncType);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   194
    private native boolean initRTSurface(long pData, boolean isOpaque);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   195
    private native void initOps(int screen, int width, int height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    static {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   198
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   199
        d3dImagePipe = new D3DDrawImage();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   200
        d3dTextPipe = new D3DTextRenderer(rq);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   201
        d3dRenderPipe = new D3DRenderer(rq);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   202
        if (GraphicsPrimitive.tracingEnabled()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   203
            d3dTextPipe = d3dTextPipe.traceWrap();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   204
            d3dRenderPipe = d3dRenderPipe.traceWrap();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   205
            //The wrapped d3dRenderPipe will wrap the AA pipe as well...
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   206
            //d3dAAPgramPipe = d3dRenderPipe.traceWrap();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   208
        d3dAAPgramPipe = d3dRenderPipe.getAAParallelogramPipe();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   209
        d3dTxRenderPipe =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   210
            new PixelToParallelogramConverter(d3dRenderPipe, d3dRenderPipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   211
                                              1.0, 0.25, true);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   212
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   213
        D3DBlitLoops.register();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   214
        D3DMaskFill.register();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   215
        D3DMaskBlit.register();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   216
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   218
    protected D3DSurfaceData(WComponentPeer peer, D3DGraphicsConfig gc,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   219
                             int width, int height, Image image,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   220
                             ColorModel cm, int numBackBuffers,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   221
                             int swapEffect, VSyncType vSyncType,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   222
                             int type)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   223
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   224
        super(getCustomSurfaceType(type), cm);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   225
        this.graphicsDevice = gc.getD3DDevice();
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   226
        this.scaleX = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleX();
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   227
        this.scaleY = type == TEXTURE ? 1 : graphicsDevice.getDefaultScaleY();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   228
        this.peer = peer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   229
        this.type = type;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   230
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   231
        if (scaleX == 1 && scaleY == 1) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   232
            this.width = width;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   233
            this.height = height;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   234
        } else if (peer instanceof WWindowPeer) {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   235
            Dimension scaledSize = ((WWindowPeer) peer).getScaledWindowSize();
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   236
            this.width = scaledSize.width;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   237
            this.height = scaledSize.height;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   238
        } else {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   239
            this.width = (int) Math.ceil(width * scaleX);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   240
            this.height = (int) Math.ceil(height * scaleY);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   241
        }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   242
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   243
        this.offscreenImage = image;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   244
        this.backBuffersNum = numBackBuffers;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   245
        this.swapEffect = swapEffect;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   246
        this.syncType = vSyncType;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   248
        initOps(graphicsDevice.getScreen(), this.width, this.height);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   249
        if (type == WINDOW) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   250
            // we put the surface into the "lost"
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   251
            // state; it will be restored by the D3DScreenUpdateManager
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   252
            // prior to rendering to it for the first time. This is done
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   253
            // so that vram is not wasted for surfaces never rendered to
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   254
            setSurfaceLost(true);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   255
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   256
            initSurface();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   258
        setBlitProxyKey(gc.getProxyKey());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    @Override
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   262
    public double getDefaultScaleX() {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   263
        return scaleX;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   264
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   265
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   266
    @Override
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   267
    public double getDefaultScaleY() {
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   268
        return scaleY;
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   269
    }
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   270
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   271
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   273
        return D3DSurfaceDataProxy.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   274
            createProxy(srcData,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   275
                        (D3DGraphicsConfig)graphicsDevice.getDefaultConfiguration());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   276
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   277
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   278
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   279
     * Creates a SurfaceData object representing the back buffer of a
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   280
     * double-buffered on-screen Window.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   281
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   282
    public static D3DSurfaceData createData(WComponentPeer peer, Image image) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   283
        D3DGraphicsConfig gc = getGC(peer);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   284
        if (gc == null || !peer.isAccelCapable()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   285
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   286
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   287
        BufferCapabilities caps = peer.getBackBufferCaps();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   288
        VSyncType vSyncType = VSYNC_DEFAULT;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   289
        if (caps instanceof ExtendedBufferCapabilities) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   290
            vSyncType = ((ExtendedBufferCapabilities)caps).getVSync();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   291
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   292
        Rectangle r = peer.getBounds();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   293
        BufferCapabilities.FlipContents flip = caps.getFlipContents();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   294
        int swapEffect;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   295
        if (flip == FlipContents.COPIED) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   296
            swapEffect = SWAP_COPY;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   297
        } else if (flip == FlipContents.PRIOR) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   298
            swapEffect = SWAP_FLIP;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   299
        } else { // flip == FlipContents.UNDEFINED || .BACKGROUND
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   300
            swapEffect = SWAP_DISCARD;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   301
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   302
        return new D3DSurfaceData(peer, gc, r.width, r.height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   303
                                  image, peer.getColorModel(),
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   304
                                  peer.getBackBuffersNum(),
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   305
                                  swapEffect, vSyncType, FLIP_BACKBUFFER);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    /**
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   309
     * Returns a WINDOW type of surface - a
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   310
     * swap chain which serves as an on-screen surface,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   311
     * handled by the D3DScreenUpdateManager.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   312
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   313
     * Note that the native surface is not initialized
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   314
     * when the surface is created to avoid using excessive
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   315
     * resources, and the surface is placed into the lost
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   316
     * state. It will be restored prior to any rendering
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   317
     * to it.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   319
     * @param peer peer for which the onscreen surface is to be created
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   320
     * @return a D3DWindowSurfaceData (flip chain) surface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   321
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   322
    public static D3DSurfaceData createData(WComponentPeer peer) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   323
        D3DGraphicsConfig gc = getGC(peer);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   324
        if (gc == null || !peer.isAccelCapable()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   325
            return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   326
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   327
        return new D3DWindowSurfaceData(peer, gc);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   328
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   329
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   330
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   331
     * Creates a SurfaceData object representing an off-screen buffer (either
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   332
     * a plain surface or Texture).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   334
    public static D3DSurfaceData createData(D3DGraphicsConfig gc,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   335
                                            int width, int height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   336
                                            ColorModel cm,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   337
                                            Image image, int type)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   339
        if (type == RT_TEXTURE) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   340
            boolean isOpaque = cm.getTransparency() == Transparency.OPAQUE;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   341
            int cap = isOpaque ? CAPS_RT_TEXTURE_OPAQUE : CAPS_RT_TEXTURE_ALPHA;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   342
            if (!gc.getD3DDevice().isCapPresent(cap)) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   343
                type = RT_PLAIN;
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
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   346
        D3DSurfaceData ret = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   347
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   348
            ret = new D3DSurfaceData(null, gc, width, height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   349
                                     image, cm, 0, SWAP_DISCARD, VSYNC_DEFAULT,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   350
                                     type);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   351
        } catch (InvalidPipeException ipe) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   352
            // try again - we might have ran out of vram, and rt textures
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   353
            // could take up more than a plain surface, so it might succeed
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   354
            if (type == RT_TEXTURE) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   355
                // If a RT_TEXTURE was requested do not attempt to create a
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   356
                // plain surface. (note that RT_TEXTURE can only be requested
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   357
                // from a VI so the cast is safe)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   358
                if (((SunVolatileImage)image).getForcedAccelSurfaceType() !=
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   359
                    RT_TEXTURE)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   360
                {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   361
                    type = RT_PLAIN;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   362
                    ret = new D3DSurfaceData(null, gc, width, height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   363
                                             image, cm, 0, SWAP_DISCARD,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   364
                                             VSYNC_DEFAULT, type);
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
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   367
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   368
        return ret;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    /**
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   372
     * Returns the appropriate SurfaceType corresponding to the given D3D
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   373
     * surface type constant (e.g. TEXTURE -> D3DTexture).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   375
    private static SurfaceType getCustomSurfaceType(int d3dType) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   376
        switch (d3dType) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   377
        case TEXTURE:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   378
            return D3DTexture;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   379
        case RT_TEXTURE:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   380
            return D3DSurfaceRTT;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   381
        default:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   382
            return D3DSurface;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   383
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   386
    private boolean initSurfaceNow() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   387
        boolean isOpaque = (getTransparency() == Transparency.OPAQUE);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   388
        switch (type) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   389
            case RT_PLAIN:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   390
                return initRTSurface(getNativeOps(), isOpaque);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   391
            case TEXTURE:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   392
                return initTexture(getNativeOps(), false/*isRTT*/, isOpaque);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   393
            case RT_TEXTURE:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   394
                return initTexture(getNativeOps(), true/*isRTT*/,  isOpaque);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   395
            // REMIND: we may want to pass the exact type to the native
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   396
            // level here so that we could choose the right presentation
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   397
            // interval for the frontbuffer (immediate vs v-synced)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   398
            case WINDOW:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   399
            case FLIP_BACKBUFFER:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   400
                return initFlipBackbuffer(getNativeOps(), peer.getData(),
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   401
                                          backBuffersNum, swapEffect,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   402
                                          syncType.id());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   403
            default:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   404
                return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   408
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   409
     * Initializes the appropriate D3D offscreen surface based on the value
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   410
     * of the type parameter.  If the surface creation fails for any reason,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   411
     * an OutOfMemoryError will be thrown.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   412
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   413
    protected void initSurface() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   414
        // any time we create or restore the surface, recreate the raster
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   415
        synchronized (this) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   416
            wrn = null;
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
        // REMIND: somewhere a puppy died
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   419
        class Status {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   420
            boolean success = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   421
        };
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   422
        final Status status = new Status();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   423
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   424
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   425
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   426
            rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   427
                public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   428
                    status.success = initSurfaceNow();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                }
887
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
            if (!status.success) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   432
                throw new InvalidPipeException("Error creating D3DSurface");
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
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   435
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   436
        }
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
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   439
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   440
     * Returns the D3DContext for the GraphicsConfig associated with this
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   441
     * surface.
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
    public final D3DContext getContext() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   444
        return graphicsDevice.getContext();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   445
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   446
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   447
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   448
     * Returns one of the surface type constants defined above.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   449
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   450
    public final int getType() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   451
        return type;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   452
    }
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
    private static native int  dbGetPixelNative(long pData, int x, int y);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   455
    private static native void dbSetPixelNative(long pData, int x, int y,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   456
                                                int pixel);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   457
    static class D3DDataBufferNative extends DataBufferNative {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   458
        int pixel;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   459
        protected D3DDataBufferNative(SurfaceData sData,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   460
                                      int type, int w, int h)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   461
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   462
            super(sData, type, w, h);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   463
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   464
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   465
        protected int getElem(final int x, final int y,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   466
                              final SurfaceData sData)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   467
        {
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   468
            if (sData.isSurfaceLost()) {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   469
                return 0;
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   470
            }
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   471
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   472
            int retPixel;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   473
            D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   474
            rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   475
            try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   476
                rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   477
                    public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   478
                        pixel = dbGetPixelNative(sData.getNativeOps(), x, y);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   480
                });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   481
            } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   482
                retPixel = pixel;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   483
                rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   484
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   485
            return retPixel;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   486
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   487
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   488
        protected void setElem(final int x, final int y, final int pixel,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   489
                               final SurfaceData sData)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   490
        {
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   491
            if (sData.isSurfaceLost()) {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   492
                  return;
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   493
            }
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   494
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   495
            D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   496
            rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   497
            try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   498
                rq.flushAndInvokeNow(new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   499
                    public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   500
                        dbSetPixelNative(sData.getNativeOps(), x, y, pixel);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   502
                });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   503
                sData.markDirty();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   504
            } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   505
                rq.unlock();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   510
    public synchronized Raster getRaster(int x, int y, int w, int h) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   511
        if (wrn == null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   512
            DirectColorModel dcm = (DirectColorModel)getColorModel();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   513
            SampleModel smHw;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   514
            int dataType = 0;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   515
            int scanStride = width;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
10778
679a05f08d57 6997116: The case automatically failed due to java.lang.ClassCastException.
bae
parents: 9035
diff changeset
   517
            if (dcm.getPixelSize() > 16) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   518
                dataType = DataBuffer.TYPE_INT;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   519
            } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   520
                // 15, 16
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   521
                dataType = DataBuffer.TYPE_USHORT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   523
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   524
            // note that we have to use the surface width and height here,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   525
            // not the passed w,h
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   526
            smHw = new SinglePixelPackedSampleModel(dataType, width, height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   527
                                                    scanStride, dcm.getMasks());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   528
            DataBuffer dbn = new D3DDataBufferNative(this, dataType,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   529
                                                     width, height);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   530
            wrn = WritableRasterNative.createNativeRaster(smHw, dbn);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   531
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   532
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   533
        return wrn;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   534
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   535
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   536
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   537
     * For now, we can only render LCD text if:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   538
     *   - the pixel shaders are available, and
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   539
     *   - blending is disabled, and
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   540
     *   - the source color is opaque
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents: 887
diff changeset
   541
     *   - and the destination is opaque
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   542
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   543
    public boolean canRenderLCDText(SunGraphics2D sg2d) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   544
        return
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   545
            graphicsDevice.isCapPresent(CAPS_LCD_SHADER) &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   546
            sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents: 887
diff changeset
   547
            sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR   &&
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents: 887
diff changeset
   548
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   549
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   550
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   551
    /**
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   552
     * If acceleration should no longer be used for this surface.
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   553
     * This implementation flags to the manager that it should no
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   554
     * longer attempt to re-create a D3DSurface.
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   555
     */
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   556
    void disableAccelerationForSurface() {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   557
        if (offscreenImage != null) {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   558
            SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   559
            if (sm instanceof D3DVolatileSurfaceManager) {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   560
                setSurfaceLost(true);
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   561
                ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   562
            }
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   563
        }
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   564
    }
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   565
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   566
    public void validatePipe(SunGraphics2D sg2d) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   567
        TextPipe textpipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   568
        boolean validated = false;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   569
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   570
        // REMIND: the D3D pipeline doesn't support XOR!, more
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   571
        // fixes will be needed below. For now we disable D3D rendering
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   572
        // for the surface which had any XOR rendering done to.
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   573
        if (sg2d.compositeState >= SunGraphics2D.COMP_XOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   574
            super.validatePipe(sg2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   575
            sg2d.imagepipe = d3dImagePipe;
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   576
            disableAccelerationForSurface();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   577
            return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   578
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   579
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   580
        // D3DTextRenderer handles both AA and non-AA text, but
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   581
        // only works with the following modes:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   582
        // (Note: For LCD text we only enter this code path if
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   583
        // canRenderLCDText() has already validated that the mode is
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   584
        // CompositeType.SrcNoEa (opaque color), which will be subsumed
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   585
        // by the CompositeType.SrcNoEa (any color) test below.)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   586
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   587
        if (/* CompositeType.SrcNoEa (any color) */
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   588
            (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   589
             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR)        ||
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   590
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   591
            /* CompositeType.SrcOver (any color) */
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   592
            (sg2d.compositeState == SunGraphics2D.COMP_ALPHA    &&
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   593
             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   594
             (((AlphaComposite)sg2d.composite).getRule() ==
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   595
              AlphaComposite.SRC_OVER))                       ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   596
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   597
            /* CompositeType.Xor (any color) */
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   598
            (sg2d.compositeState == SunGraphics2D.COMP_XOR &&
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   599
             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR))
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   600
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   601
            textpipe = d3dTextPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   602
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   603
            // do this to initialize textpipe correctly; we will attempt
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   604
            // to override the non-text pipes below
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   605
            super.validatePipe(sg2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   606
            textpipe = sg2d.textpipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   607
            validated = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   608
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   609
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   610
        PixelToParallelogramConverter txPipe = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   611
        D3DRenderer nonTxPipe = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   612
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   613
        if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   614
            if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   615
                if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   616
                    txPipe = d3dTxRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   617
                    nonTxPipe = d3dRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   618
                }
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   619
            } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   620
                if (D3DPaints.isValid(sg2d)) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   621
                    txPipe = d3dTxRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   622
                    nonTxPipe = d3dRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   623
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   624
                // custom paints handled by super.validatePipe() below
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   626
        } else {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   627
            if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   628
                if (graphicsDevice.isCapPresent(CAPS_AA_SHADER) &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   629
                    (sg2d.imageComp == CompositeType.SrcOverNoEa ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   630
                     sg2d.imageComp == CompositeType.SrcOver))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   631
                {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   632
                    if (!validated) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   633
                        super.validatePipe(sg2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   634
                        validated = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   635
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   636
                    PixelToParallelogramConverter aaConverter =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   637
                        new PixelToParallelogramConverter(sg2d.shapepipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   638
                                                          d3dAAPgramPipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   639
                                                          1.0/8.0, 0.499,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   640
                                                          false);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   641
                    sg2d.drawpipe = aaConverter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   642
                    sg2d.fillpipe = aaConverter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   643
                    sg2d.shapepipe = aaConverter;
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   644
                } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   645
                    // install the solid pipes when AA and XOR are both enabled
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   646
                    txPipe = d3dTxRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   647
                    nonTxPipe = d3dRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   648
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   649
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   650
            // other cases handled by super.validatePipe() below
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   651
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   652
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   653
        if (txPipe != null) {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   654
            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   655
                sg2d.drawpipe = txPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   656
                sg2d.fillpipe = txPipe;
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   657
            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   658
                sg2d.drawpipe = txPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   659
                sg2d.fillpipe = nonTxPipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   661
                sg2d.drawpipe = nonTxPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   662
                sg2d.fillpipe = nonTxPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   663
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   664
            // Note that we use the transforming pipe here because it
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   665
            // will examine the shape and possibly perform an optimized
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   666
            // operation if it can be simplified.  The simplifications
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   667
            // will be valid for all STROKE and TRANSFORM types.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   668
            sg2d.shapepipe = txPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   669
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   670
            if (!validated) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   671
                super.validatePipe(sg2d);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   674
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   675
        // install the text pipe based on our earlier decision
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   676
        sg2d.textpipe = textpipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   677
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   678
        // always override the image pipe with the specialized D3D pipe
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   679
        sg2d.imagepipe = d3dImagePipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   680
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   681
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   682
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   683
    protected MaskFill getMaskFill(SunGraphics2D sg2d) {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   684
        if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   685
            /*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   686
             * We can only accelerate non-Color MaskFill operations if
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   687
             * all of the following conditions hold true:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   688
             *   - there is an implementation for the given paintState
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   689
             *   - the current Paint can be accelerated for this destination
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   690
             *   - multitexturing is available (since we need to modulate
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   691
             *     the alpha mask texture with the paint texture)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   692
             *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   693
             * In all other cases, we return null, in which case the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   694
             * validation code will choose a more general software-based loop.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   695
             */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   696
            if (!D3DPaints.isValid(sg2d) ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   697
                !graphicsDevice.isCapPresent(CAPS_MULTITEXTURE))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   698
            {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   699
                return null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   700
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   701
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   702
        return super.getMaskFill(sg2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   703
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   704
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   705
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   706
    public boolean copyArea(SunGraphics2D sg2d,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   707
                            int x, int y, int w, int h, int dx, int dy)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   708
    {
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   709
        if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   710
            sg2d.compositeState < SunGraphics2D.COMP_XOR)
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   711
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   712
            x += sg2d.transX;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   713
            y += sg2d.transY;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   714
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   715
            d3dRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   716
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   717
            return true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   718
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   719
        return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    @Override
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   723
    public void flush() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   724
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   725
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   726
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   727
            RenderBuffer buf = rq.getBuffer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   728
            rq.ensureCapacityAndAlignment(12, 4);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   729
            buf.putInt(FLUSH_SURFACE);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   730
            buf.putLong(getNativeOps());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   731
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   732
            // this call is expected to complete synchronously, so flush now
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   733
            rq.flushNow();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   734
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   735
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   736
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   737
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   738
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   739
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   740
     * Disposes the native resources associated with the given D3DSurfaceData
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   741
     * (referenced by the pData parameter).  This method is invoked from
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   742
     * the native Dispose() method from the Disposer thread when the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   743
     * Java-level D3DSurfaceData object is about to go away.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   744
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   745
    static void dispose(long pData) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   746
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   747
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   748
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   749
            RenderBuffer buf = rq.getBuffer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   750
            rq.ensureCapacityAndAlignment(12, 4);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   751
            buf.putInt(DISPOSE_SURFACE);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   752
            buf.putLong(pData);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   753
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   754
            // this call is expected to complete synchronously, so flush now
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   755
            rq.flushNow();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   756
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   757
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   758
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   759
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   761
    static void swapBuffers(D3DSurfaceData sd,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   762
                            final int x1, final int y1,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   763
                            final int x2, final int y2)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   764
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   765
        long pData = sd.getNativeOps();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   766
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   767
        // swapBuffers can be called from the toolkit thread by swing, we
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   768
        // should detect this and prevent the deadlocks
22567
5816a47fa4dd 8032047: Fix static lint warnings in client libraries
darcy
parents: 10778
diff changeset
   769
        if (D3DRenderQueue.isRenderQueueThread()) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   770
            if (!rq.tryLock()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   771
                // if we could not obtain the lock, repaint the area
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   772
                // that was supposed to be swapped, and no-op this swap
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   773
                final Component target = (Component)sd.getPeer().getTarget();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   774
                SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   775
                    public void run() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   776
                        target.repaint(x1, y1, x2, y2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   777
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   778
                });
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   779
                return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   781
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   782
            rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   783
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   784
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   785
            RenderBuffer buf = rq.getBuffer();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   786
            rq.ensureCapacityAndAlignment(28, 4);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   787
            buf.putInt(SWAP_BUFFERS);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   788
            buf.putLong(pData);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   789
            buf.putInt(x1);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   790
            buf.putInt(y1);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   791
            buf.putInt(x2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   792
            buf.putInt(y2);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   793
            rq.flushNow();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   794
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   795
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   796
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   797
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   798
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   799
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   800
     * Returns destination Image associated with this SurfaceData.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   801
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   802
    public Object getDestination() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   803
        return offscreenImage;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   804
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   806
    public Rectangle getBounds() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   807
        if (type == FLIP_BACKBUFFER || type == WINDOW) {
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   808
            double scaleX = getDefaultScaleX();
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   809
            double scaleY = getDefaultScaleY();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   810
            Rectangle r = peer.getBounds();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   811
            r.x = r.y = 0;
34394
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   812
            r.width = (int) Math.ceil(r.width * scaleX);
259d6e4e0978 8073320: Windows HiDPI Graphics support
alexsch
parents: 30948
diff changeset
   813
            r.height = (int) Math.ceil(r.height * scaleY);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   814
            return r;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   816
            return new Rectangle(width, height);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   818
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   819
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   820
    public Rectangle getNativeBounds() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   821
        D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   822
        // need to lock to make sure nativeWidth and Height are consistent
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   823
        // since they are set from the render thread from the native
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   824
        // level
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   825
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   826
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   827
            // REMIND: use xyoffsets?
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   828
            return new Rectangle(nativeWidth, nativeHeight);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   829
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   830
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   831
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   832
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   833
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   835
    public GraphicsConfiguration getDeviceConfiguration() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   836
        return graphicsDevice.getDefaultConfiguration();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   837
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   838
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   839
    public SurfaceData getReplacement() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   840
        return restoreContents(offscreenImage);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   841
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   842
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   843
    private static D3DGraphicsConfig getGC(WComponentPeer peer) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   844
        GraphicsConfiguration gc;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   845
        if (peer != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   846
            gc =  peer.getGraphicsConfiguration();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   847
        } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   848
            GraphicsEnvironment env =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   849
                    GraphicsEnvironment.getLocalGraphicsEnvironment();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   850
            GraphicsDevice gd = env.getDefaultScreenDevice();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   851
            gc = gd.getDefaultConfiguration();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   852
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   853
        return (gc instanceof D3DGraphicsConfig) ? (D3DGraphicsConfig)gc : null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    /**
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   857
     * Attempts to restore the surface by initializing the native data
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   859
    void restoreSurface() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   860
        initSurface();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   861
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   862
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   863
    WComponentPeer getPeer() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   864
        return peer;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   865
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   866
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   867
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   868
     * We need to let the surface manager know that the surface is lost so
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   869
     * that for example BufferStrategy.contentsLost() returns correct result.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   870
     * Normally the status of contentsLost is set in validate(), but in some
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   871
     * cases (like Swing's buffer per window) we intentionally don't call
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   872
     * validate from the toolkit thread but only check for the BS status.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   873
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   874
    @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   875
    public void setSurfaceLost(boolean lost) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   876
        super.setSurfaceLost(lost);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   877
        if (lost && offscreenImage != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   878
            SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   879
            sm.acceleratedSurfaceLost();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   883
    private static native long getNativeResourceNative(long sdops, int resType);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   884
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   885
     * Returns a pointer to the native resource of specified {@code resType}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   886
     * associated with this surface.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   887
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   888
     * Specifically, for {@code D3DSurfaceData} this method returns pointers of
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   889
     * the following:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   890
     * <pre>
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   891
     * TEXTURE              - (IDirect3DTexture9*)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   892
     * RT_TEXTURE, RT_PLAIN - (IDirect3DSurface9*)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   893
     * FLIP_BACKBUFFER      - (IDirect3DSwapChain9*)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   894
     * D3D_DEVICE_RESOURCE  - (IDirect3DDevice9*)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   895
     * </pre>
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   896
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   897
     * Multiple resources may be available for some types (i.e. for render to
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   898
     * texture one could retrieve both a destination surface by specifying
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   899
     * RT_TEXTURE, and a texture by using TEXTURE).
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   900
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   901
     * Note: the pointer returned by this method is only valid on the rendering
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   902
     * thread.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   903
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   904
     * @return pointer to the native resource of specified type or 0L if
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   905
     * such resource doesn't exist or can not be retrieved.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   906
     * @see sun.java2d.pipe.hw.AccelSurface#getNativeResource
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   907
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   908
    public long getNativeResource(int resType) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   909
        return getNativeResourceNative(getNativeOps(), resType);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   912
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   913
     * Class representing an on-screen d3d surface. Since d3d can't
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   914
     * render to the screen directly, it is implemented as a swap chain,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   915
     * controlled by D3DScreenUpdateManager.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   916
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   917
     * @see D3DScreenUpdateManager
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   918
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   919
    public static class D3DWindowSurfaceData extends D3DSurfaceData {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   920
        StateTracker dirtyTracker;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   921
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   922
        public D3DWindowSurfaceData(WComponentPeer peer,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   923
                                    D3DGraphicsConfig gc)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   924
        {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   925
            super(peer, gc,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   926
                  peer.getBounds().width, peer.getBounds().height,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   927
                  null, peer.getColorModel(), 1, SWAP_COPY, VSYNC_DEFAULT,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   928
                  WINDOW);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   929
            dirtyTracker = getStateTracker();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   930
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   931
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   932
        /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   933
         * {@inheritDoc}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   934
         *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   935
         * Overridden to use ScreenUpdateManager to obtain the replacement
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   936
         * surface.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   937
         *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   938
         * @see sun.java2d.ScreenUpdateManager#getReplacementScreenSurface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   939
         */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   940
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   941
        public SurfaceData getReplacement() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   942
            ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   943
            return mgr.getReplacementScreenSurface(peer, this);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   944
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   945
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   946
        /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   947
         * Returns destination Component associated with this SurfaceData.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   948
         */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   949
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   950
        public Object getDestination() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   951
            return peer.getTarget();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   952
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   953
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   954
        @Override
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   955
        void disableAccelerationForSurface() {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   956
            // for on-screen surfaces we need to make sure a backup GDI surface is
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   957
            // is used until a new one is set (which may happen during a resize). We
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   958
            // don't want the screen update maanger to replace the surface right way
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   959
            // because it causes repainting issues in Swing, so we invalidate it,
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   960
            // this will prevent SUM from issuing a replaceSurfaceData call.
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   961
            setSurfaceLost(true);
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   962
            invalidate();
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   963
            flush();
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   964
            peer.disableAcceleration();
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   965
            ScreenUpdateManager.getInstance().dropScreenSurface(this);
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   966
        }
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   967
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   968
        @Override
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   969
        void restoreSurface() {
7748
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   970
            if (!peer.isAccelCapable()) {
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   971
                throw new InvalidPipeException("Onscreen acceleration " +
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   972
                                               "disabled for this surface");
26e6f5fc1bdb 6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents: 5506
diff changeset
   973
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   974
            Window fsw = graphicsDevice.getFullScreenWindow();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   975
            if (fsw != null && fsw != peer.getTarget()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   976
                throw new InvalidPipeException("Can't restore onscreen surface"+
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   977
                                               " when in full-screen mode");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   978
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   979
            super.restoreSurface();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   980
            // if initialization was unsuccessful, an IPE will be thrown
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   981
            // and the surface will remain lost
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   982
            setSurfaceLost(false);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   983
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   984
            // This is to make sure the render target is reset after this
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   985
            // surface is restored. The reason for this is that sometimes this
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   986
            // surface can be restored from multiple threads (the screen update
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   987
            // manager's thread and app's rendering thread) at the same time,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   988
            // and when that happens the second restoration will create the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   989
            // native resource which will not be set as render target because
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   990
            // the BufferedContext's validate method will think that since the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   991
            // surface data object didn't change then the current render target
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   992
            // is correct and no rendering will appear on the screen.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   993
            D3DRenderQueue rq = D3DRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   994
            rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   995
            try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   996
                getContext().invalidateContext();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   997
            } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   998
                rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   999
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1000
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1001
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1002
        public boolean isDirty() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1003
            return !dirtyTracker.isCurrent();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1004
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1005
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1006
        public void markClean() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1007
            dirtyTracker = getStateTracker();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1008
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1010
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1011
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1012
     * 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
  1013
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1014
     * @param pd3dsd pointer to the D3DSDOps structure
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1015
     * @param pData pointer to the AwtWindow peer data
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1016
     * @param w width of the window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1017
     * @param h height of the window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1018
     * @see sun.awt.windows.TranslucentWindowPainter
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1019
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1020
    public static native boolean updateWindowAccelImpl(long pd3dsd, long pData,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1021
                                                       int w, int h);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
}