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