src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 36874 jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLSurfaceData.java@09abfda883d2
child 58315 07556f8cd819
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
31661
a5cb86f2253b 7188942: Remove support of pbuffers in OGL Java2d pipeline
serb
parents: 31158
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 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.opengl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.AlphaComposite;
31158
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
    29
import java.awt.Composite;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsEnvironment;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    31
import java.awt.Rectangle;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Transparency;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.awt.SunHints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.image.PixelConverter;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    37
import sun.java2d.pipe.hw.AccelSurface;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.java2d.SunGraphics2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.java2d.SurfaceData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.java2d.SurfaceDataProxy;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    41
import sun.java2d.loops.CompositeType;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.java2d.loops.GraphicsPrimitive;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.java2d.loops.MaskFill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.java2d.loops.SurfaceType;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    45
import sun.java2d.pipe.ParallelogramPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    46
import sun.java2d.pipe.PixelToParallelogramConverter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import sun.java2d.pipe.RenderBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import sun.java2d.pipe.TextPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import static sun.java2d.pipe.BufferedOpCodes.*;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    50
import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * This class describes an OpenGL "surface", that is, a region of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * managed via OpenGL.  An OGLSurfaceData can be tagged with one of three
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * different SurfaceType objects for the purpose of registering loops, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * This diagram shows the hierarchy of OGL SurfaceTypes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *                               Any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *                             /     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *                 OpenGLSurface     OpenGLTexture
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *                      |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *               OpenGLSurfaceRTT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * OpenGLSurface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * This kind of surface can be rendered to using OpenGL APIs.  It is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * possible to copy an OpenGLSurface to another OpenGLSurface (or to itself).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * This is typically accomplished by calling MakeContextCurrent(dstSD, srcSD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * and then calling glCopyPixels() (although there are other techniques to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * achieve the same goal).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * OpenGLTexture
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * This kind of surface cannot be rendered to using OpenGL (in the same sense
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * as in OpenGLSurface).  However, it is possible to upload a region of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * to an OpenGLTexture object via glTexSubImage2D().  One can also copy a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * surface of type OpenGLTexture to an OpenGLSurface by binding the texture
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * to a quad and then rendering it to the destination surface (this process
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * is known as "texture mapping").
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * OpenGLSurfaceRTT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * This kind of surface can be thought of as a sort of hybrid between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * OpenGLSurface and OpenGLTexture, in that one can render to this kind of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * surface as if it were of type OpenGLSurface, but the process of copying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * this kind of surface to another is more like an OpenGLTexture.  (Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * "RTT" stands for "render-to-texture".)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * In addition to these SurfaceType variants, we have also defined some
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * constants that describe in more detail the type of underlying OpenGL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * surface.  This table helps explain the relationships between those
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * "type" constants and their corresponding SurfaceType:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * OGL Type          Corresponding SurfaceType
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * --------          -------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * WINDOW            OpenGLSurface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * TEXTURE           OpenGLTexture
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * FLIP_BACKBUFFER   OpenGLSurface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * FBOBJECT          OpenGLSurfaceRTT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    98
public abstract class OGLSurfaceData extends SurfaceData
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    99
    implements AccelSurface {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * OGL-specific surface types
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   103
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   104
     * @see sun.java2d.pipe.hw.AccelSurface
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   106
    public static final int FBOBJECT        = RT_TEXTURE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Pixel formats
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public static final int PF_INT_ARGB        = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    public static final int PF_INT_ARGB_PRE    = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public static final int PF_INT_RGB         = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public static final int PF_INT_RGBX        = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public static final int PF_INT_BGR         = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public static final int PF_INT_BGRX        = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public static final int PF_USHORT_565_RGB  = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public static final int PF_USHORT_555_RGB  = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public static final int PF_USHORT_555_RGBX = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public static final int PF_BYTE_GRAY       = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public static final int PF_USHORT_GRAY     = 10;
1723
4a616c1eac0b 6739267: D3D/OGL: add missing ThreeByteBgr to texture upload blit loop
tdv
parents: 1717
diff changeset
   122
    public static final int PF_3BYTE_BGR       = 11;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * SurfaceTypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private static final String DESC_OPENGL_SURFACE = "OpenGL Surface";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    private static final String DESC_OPENGL_SURFACE_RTT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        "OpenGL Surface (render-to-texture)";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    private static final String DESC_OPENGL_TEXTURE = "OpenGL Texture";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    static final SurfaceType OpenGLSurface =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        SurfaceType.Any.deriveSubType(DESC_OPENGL_SURFACE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                      PixelConverter.ArgbPre.instance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    static final SurfaceType OpenGLSurfaceRTT =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        OpenGLSurface.deriveSubType(DESC_OPENGL_SURFACE_RTT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    static final SurfaceType OpenGLTexture =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        SurfaceType.Any.deriveSubType(DESC_OPENGL_TEXTURE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /** This will be true if the fbobject system property has been enabled. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    private static boolean isFBObjectEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /** This will be true if the lcdshader system property has been enabled.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    private static boolean isLCDShaderEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /** This will be true if the biopshader system property has been enabled.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    private static boolean isBIOpShaderEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /** This will be true if the gradshader system property has been enabled.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private static boolean isGradShaderEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    private OGLGraphicsConfig graphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    protected int type;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   154
    // 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
   155
    // initialized
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   156
    private int nativeWidth, nativeHeight;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    protected static OGLRenderer oglRenderPipe;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   159
    protected static PixelToParallelogramConverter oglTxRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   160
    protected static ParallelogramPipe oglAAPgramPipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    protected static OGLTextRenderer oglTextPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    protected static OGLDrawImage oglImagePipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    protected native boolean initTexture(long pData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                                         boolean isOpaque, boolean texNonPow2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                         boolean texRect,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                         int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    protected native boolean initFBObject(long pData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                          boolean isOpaque, boolean texNonPow2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                          boolean texRect,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                                          int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    protected native boolean initFlipBackbuffer(long pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    private native int getTextureTarget(long pData);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   175
    private native int getTextureID(long pData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            // fbobject currently enabled by default; use "false" to disable
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 12047
diff changeset
   180
            String fbo = java.security.AccessController.doPrivileged(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                new sun.security.action.GetPropertyAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    "sun.java2d.opengl.fbobject"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            isFBObjectEnabled = !"false".equals(fbo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            // lcdshader currently enabled by default; use "false" to disable
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 12047
diff changeset
   186
            String lcd = java.security.AccessController.doPrivileged(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                new sun.security.action.GetPropertyAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    "sun.java2d.opengl.lcdshader"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            isLCDShaderEnabled = !"false".equals(lcd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            // biopshader currently enabled by default; use "false" to disable
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 12047
diff changeset
   192
            String biop = java.security.AccessController.doPrivileged(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                new sun.security.action.GetPropertyAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    "sun.java2d.opengl.biopshader"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            isBIOpShaderEnabled = !"false".equals(biop);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            // gradshader currently enabled by default; use "false" to disable
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 12047
diff changeset
   198
            String grad = java.security.AccessController.doPrivileged(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                new sun.security.action.GetPropertyAction(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                    "sun.java2d.opengl.gradshader"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            isGradShaderEnabled = !"false".equals(grad);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            oglImagePipe = new OGLDrawImage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            oglTextPipe = new OGLTextRenderer(rq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            oglRenderPipe = new OGLRenderer(rq);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (GraphicsPrimitive.tracingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                oglTextPipe = oglTextPipe.traceWrap();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   209
                //The wrapped oglRenderPipe will wrap the AA pipe as well...
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   210
                //oglAAPgramPipe = oglRenderPipe.traceWrap();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   212
            oglAAPgramPipe = oglRenderPipe.getAAParallelogramPipe();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   213
            oglTxRenderPipe =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   214
                new PixelToParallelogramConverter(oglRenderPipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   215
                                                  oglRenderPipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   216
                                                  1.0, 0.25, true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            OGLBlitLoops.register();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            OGLMaskFill.register();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            OGLMaskBlit.register();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    protected OGLSurfaceData(OGLGraphicsConfig gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                             ColorModel cm, int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        super(getCustomSurfaceType(type), cm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        this.graphicsConfig = gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        setBlitProxyKey(gc.getProxyKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public SurfaceDataProxy makeProxyFor(SurfaceData srcData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return OGLSurfaceDataProxy.createProxy(srcData, graphicsConfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Returns the appropriate SurfaceType corresponding to the given OpenGL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * surface type constant (e.g. TEXTURE -> OpenGLTexture).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    private static SurfaceType getCustomSurfaceType(int oglType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        switch (oglType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        case TEXTURE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            return OpenGLTexture;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        case FBOBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return OpenGLSurfaceRTT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            return OpenGLSurface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * Note: This should only be called from the QFT under the AWT lock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * This method is kept separate from the initSurface() method below just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * to keep the code a bit cleaner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    private void initSurfaceNow(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        boolean isOpaque = (getTransparency() == Transparency.OPAQUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        boolean success = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        case TEXTURE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            success = initTexture(getNativeOps(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                  isOpaque, isTexNonPow2Available(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                  isTexRectAvailable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                  width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        case FBOBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            success = initFBObject(getNativeOps(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                                   isOpaque, isTexNonPow2Available(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                                   isTexRectAvailable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                                   width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        case FLIP_BACKBUFFER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            success = initFlipBackbuffer(getNativeOps());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   285
        if (!success) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            throw new OutOfMemoryError("can't create offscreen surface");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Initializes the appropriate OpenGL offscreen surface based on the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * of the type parameter.  If the surface creation fails for any reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * an OutOfMemoryError will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    protected void initSurface(final int width, final int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            case TEXTURE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            case FBOBJECT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                // need to make sure the context is current before
31661
a5cb86f2253b 7188942: Remove support of pbuffers in OGL Java2d pipeline
serb
parents: 31158
diff changeset
   303
                // creating the texture or fbobject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                OGLContext.setScratchSurface(graphicsConfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            rq.flushAndInvokeNow(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                    initSurfaceNow(width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * Returns the OGLContext for the GraphicsConfig associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   323
    public final OGLContext getContext() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        return graphicsConfig.getContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * Returns the OGLGraphicsConfig associated with this surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    final OGLGraphicsConfig getOGLGraphicsConfig() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        return graphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * Returns one of the surface type constants defined above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   337
    public final int getType() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        return type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * If this surface is backed by a texture object, returns the target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * for that texture (either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * Otherwise, this method will return zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   346
    public final int getTextureTarget() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   347
        return getTextureTarget(getNativeOps());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   348
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   349
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   350
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   351
     * If this surface is backed by a texture object, returns the texture ID
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   352
     * for that texture.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   353
     * Otherwise, this method will return zero.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   354
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   355
    public final int getTextureID() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   356
        return getTextureID(getNativeOps());
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   357
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   358
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   359
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   360
     * Returns native resource of specified {@code resType} associated with
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   361
     * this surface.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   362
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   363
     * Specifically, for {@code OGLSurfaceData} this method returns the
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   364
     * the following:
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   365
     * <pre>
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   366
     * TEXTURE              - texture id
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   367
     * </pre>
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   368
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   369
     * Note: the resource 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
   370
     * thread.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   371
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   372
     * @return native resource of specified type or 0L if
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   373
     * 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
   374
     * @see sun.java2d.pipe.hw.AccelSurface#getNativeResource
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   375
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   376
    public long getNativeResource(int resType) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   377
        if (resType == TEXTURE) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   378
            return getTextureID();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   379
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   380
        return 0L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public Raster getRaster(int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        throw new InternalError("not implemented yet");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * For now, we can only render LCD text if:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *   - the fragment shader extension is available, and
31158
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   390
     *   - the source color is opaque, and
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   391
     *   - blending is SrcOverNoEa or disabled
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents: 888
diff changeset
   392
     *   - and the destination is opaque
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * Eventually, we could enhance the native OGL text rendering code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * and remove the above restrictions, but that would require significantly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * more code just to support a few uncommon cases.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    public boolean canRenderLCDText(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        return
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   400
            graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER) &&
31158
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   401
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE &&
1717
5d7c1102107a 6728834: D3D/OGL: LCD AA text becomes bold and blurred when rendering to a non-opaque destination
tdv
parents: 888
diff changeset
   402
            sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR &&
31158
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   403
            (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   404
             (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA && canHandleComposite(sg2d.composite)));
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   405
    }
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   406
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   407
    private boolean canHandleComposite(Composite c) {
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   408
        if (c instanceof AlphaComposite) {
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   409
            AlphaComposite ac = (AlphaComposite)c;
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   410
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   411
            return ac.getRule() == AlphaComposite.SRC_OVER && ac.getAlpha() >= 1f;
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   412
        }
062c7363dd12 8023794: [macosx] LCD Rendering hints seems not working without FRACTIONALMETRICS=ON
bae
parents: 25859
diff changeset
   413
        return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    public void validatePipe(SunGraphics2D sg2d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        TextPipe textpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        boolean validated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        // OGLTextRenderer handles both AA and non-AA text, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        // only works with the following modes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        // (Note: For LCD text we only enter this code path if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        // canRenderLCDText() has already validated that the mode is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        // CompositeType.SrcNoEa (opaque color), which will be subsumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        // by the CompositeType.SrcNoEa (any color) test below.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        if (/* CompositeType.SrcNoEa (any color) */
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   428
            (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   429
             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR)         ||
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            /* CompositeType.SrcOver (any color) */
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   432
            (sg2d.compositeState == SunGraphics2D.COMP_ALPHA   &&
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   433
             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
             (((AlphaComposite)sg2d.composite).getRule() ==
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   435
              AlphaComposite.SRC_OVER))                                 ||
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            /* CompositeType.Xor (any color) */
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   438
            (sg2d.compositeState == SunGraphics2D.COMP_XOR &&
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   439
             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            textpipe = oglTextPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            // do this to initialize textpipe correctly; we will attempt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            // to override the non-text pipes below
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            super.validatePipe(sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            textpipe = sg2d.textpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            validated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   450
        PixelToParallelogramConverter txPipe = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        OGLRenderer nonTxPipe = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   454
            if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   455
                if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                    txPipe = oglTxRenderPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    nonTxPipe = oglRenderPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                }
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   459
            } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                if (OGLPaints.isValid(sg2d)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    txPipe = oglTxRenderPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                    nonTxPipe = oglRenderPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                // custom paints handled by super.validatePipe() below
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        } else {
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   467
            if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   468
                if (graphicsConfig.isCapPresent(CAPS_PS30) &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   469
                    (sg2d.imageComp == CompositeType.SrcOverNoEa ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   470
                     sg2d.imageComp == CompositeType.SrcOver))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   471
                {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   472
                    if (!validated) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   473
                        super.validatePipe(sg2d);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   474
                        validated = true;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   475
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   476
                    PixelToParallelogramConverter aaConverter =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   477
                        new PixelToParallelogramConverter(sg2d.shapepipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   478
                                                          oglAAPgramPipe,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   479
                                                          1.0/8.0, 0.499,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   480
                                                          false);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   481
                    sg2d.drawpipe = aaConverter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   482
                    sg2d.fillpipe = aaConverter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   483
                    sg2d.shapepipe = aaConverter;
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   484
                } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   485
                    // 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
   486
                    txPipe = oglTxRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   487
                    nonTxPipe = oglRenderPipe;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   488
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            // other cases handled by super.validatePipe() below
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        if (txPipe != null) {
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   494
            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                sg2d.drawpipe = txPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                sg2d.fillpipe = txPipe;
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   497
            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                sg2d.drawpipe = txPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                sg2d.fillpipe = nonTxPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                sg2d.drawpipe = nonTxPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                sg2d.fillpipe = nonTxPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   504
            // 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
   505
            // will examine the shape and possibly perform an optimized
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   506
            // operation if it can be simplified.  The simplifications
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   507
            // will be valid for all STROKE and TRANSFORM types.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   508
            sg2d.shapepipe = txPipe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            if (!validated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                super.validatePipe(sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        // install the text pipe based on our earlier decision
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        sg2d.textpipe = textpipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        // always override the image pipe with the specialized OGL pipe
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        sg2d.imagepipe = oglImagePipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    protected MaskFill getMaskFill(SunGraphics2D sg2d) {
11080
7e18e343964e 7117914: Fix javac warnings in src/share/classes/sun/java2d
neugens
parents: 5506
diff changeset
   524
        if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
             * We can only accelerate non-Color MaskFill operations if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
             * all of the following conditions hold true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
             *   - there is an implementation for the given paintState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
             *   - the current Paint can be accelerated for this destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
             *   - multitexturing is available (since we need to modulate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
             *     the alpha mask texture with the paint texture)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
             * In all other cases, we return null, in which case the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
             * validation code will choose a more general software-based loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            if (!OGLPaints.isValid(sg2d) ||
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   537
                !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        return super.getMaskFill(sg2d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
36874
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   545
    @Override
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   546
    public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h,
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   547
                            int dx, int dy) {
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   548
        if (sg2d.compositeState >= SunGraphics2D.COMP_XOR) {
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   549
            return false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        }
36874
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   551
        oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);
09abfda883d2 8069348: SunGraphics2D.copyArea() does not properly work for scaled graphics in D3D
alexsch
parents: 31661
diff changeset
   552
        return true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    public void flush() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
            // make sure we have a current context before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            // disposing the native resources (e.g. texture object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            OGLContext.setScratchSurface(graphicsConfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            RenderBuffer buf = rq.getBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            rq.ensureCapacityAndAlignment(12, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            buf.putInt(FLUSH_SURFACE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            buf.putLong(getNativeOps());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            // this call is expected to complete synchronously, so flush now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            rq.flushNow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * Disposes the native resources associated with the given OGLSurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * (referenced by the pData parameter).  This method is invoked from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * the native Dispose() method from the Disposer thread when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * Java-level OGLSurfaceData object is about to go away.  Note that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * also pass a reference to the native GLX/WGLGraphicsConfigInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * (pConfigInfo) for the purposes of making a context current.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    static void dispose(long pData, long pConfigInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            // make sure we have a current context before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            // disposing the native resources (e.g. texture object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            OGLContext.setScratchSurface(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            RenderBuffer buf = rq.getBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            rq.ensureCapacityAndAlignment(12, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            buf.putInt(DISPOSE_SURFACE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            buf.putLong(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            // this call is expected to complete synchronously, so flush now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            rq.flushNow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    static void swapBuffers(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        rq.lock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            RenderBuffer buf = rq.getBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            rq.ensureCapacityAndAlignment(12, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            buf.putInt(SWAP_BUFFERS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            buf.putLong(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            rq.flushNow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            rq.unlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * Returns true if OpenGL textures can have non-power-of-two dimensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * when using the basic GL_TEXTURE_2D target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    boolean isTexNonPow2Available() {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   623
        return graphicsConfig.isCapPresent(CAPS_TEXNONPOW2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * Returns true if OpenGL textures can have non-power-of-two dimensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * when using the GL_TEXTURE_RECTANGLE_ARB target (only available when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * GL_ARB_texture_rectangle extension is present).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    boolean isTexRectAvailable() {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   632
        return graphicsConfig.isCapPresent(CAPS_EXT_TEXRECT);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   633
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   634
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   635
    public Rectangle getNativeBounds() {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   636
        OGLRenderQueue rq = OGLRenderQueue.getInstance();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   637
        rq.lock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   638
        try {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   639
            return new Rectangle(nativeWidth, nativeHeight);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   640
        } finally {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   641
            rq.unlock();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   642
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   644
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   645
    /**
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   646
     * Returns true if the surface is an on-screen window surface or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   647
     * a FBO texture attached to an on-screen CALayer.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   648
     *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   649
     * Needed by Mac OS X port.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   650
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   651
    boolean isOnScreen() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   652
        return getType() == WINDOW;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11080
diff changeset
   653
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
}