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