src/java.desktop/share/native/common/java2d/opengl/OGLSurfaceData.h
author serb
Tue, 27 Aug 2019 04:43:01 -0700
changeset 58315 07556f8cd819
parent 47216 71c04702a3d5
permissions -rw-r--r--
8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts Reviewed-by: prr, avu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58315
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2019, 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: 888
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: 888
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: 888
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
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
#ifndef OGLSurfaceData_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define OGLSurfaceData_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "java_awt_image_AffineTransformOp.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "sun_java2d_opengl_OGLSurfaceData.h"
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    31
#include "sun_java2d_pipe_hw_AccelSurface.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "J2D_GL/gl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "OGLFuncs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
typedef struct _OGLSDOps OGLSDOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * The OGLPixelFormat structure contains all the information OpenGL needs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * know when copying from or into a particular system memory image buffer (via
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * glDrawPixels(), glReadPixels, glTexSubImage2D(), etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *     GLenum format;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * The pixel format parameter used in glDrawPixels() and other similar calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Indicates the component ordering for each pixel (e.g. GL_BGRA).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *     GLenum type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The pixel data type parameter used in glDrawPixels() and other similar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * calls.  Indicates the data type for an entire pixel or for each component
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * in a pixel (e.g. GL_UNSIGNED_BYTE with GL_BGR means a pixel consists of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * 3 unsigned byte components, blue first, then green, then red;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * GL_UNSIGNED_INT_8_8_8_8_REV with GL_BGRA means a pixel consists of 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * unsigned integer comprised of four byte components, alpha first, then red,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * then green, then blue).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *     jint alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * The byte alignment parameter used in glPixelStorei(GL_UNPACK_ALIGNMENT).  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * value of 4 indicates that each pixel starts on a 4-byte aligned region in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * memory, and so on.  This alignment parameter helps OpenGL speed up pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * transfer operations by transferring memory in aligned blocks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *     jboolean hasAlpha;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * If true, indicates that this pixel format contains an alpha component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *     jboolean isPremult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * If true, indicates that this pixel format contains color components that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * have been pre-multiplied by their corresponding alpha component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    GLenum   format;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    GLenum   type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    jint     alignment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    jboolean hasAlpha;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    jboolean isPremult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
} OGLPixelFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * The OGLSDOps structure describes a native OpenGL surface and contains all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * information pertaining to the native surface.  Some information about
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * the more important/different fields:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *     void *privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * Pointer to native-specific (GLX, WGL, etc.) SurfaceData info, such as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * native Drawable handle and GraphicsConfig data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
58315
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47216
diff changeset
    88
 *     jobject graphicsConfig;;
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47216
diff changeset
    89
 * Strong reference to the OGLGraphicsConfig used by this OGLSurfaceData.
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47216
diff changeset
    90
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *     jint drawableType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * The surface type; can be any one of the surface type constants defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * below (OGLSD_WINDOW, OGLSD_TEXTURE, etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *     GLenum activeBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * Can be either GL_FRONT if this is the front buffer surface of an onscreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * window or a pbuffer surface, or GL_BACK if this is the backbuffer surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * of an onscreen window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *     jboolean isOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * If true, the surface should be treated as being fully opaque.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * the underlying surface (e.g. pbuffer) has an alpha channel and isOpaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * is true, then we should take appropriate action (i.e. call glColorMask()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * to disable writes into the alpha channel) to ensure that the surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * remains fully opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *     jboolean needsInit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * If true, the surface requires some one-time initialization, which should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * be performed after a context has been made current to the surface for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * the first time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *     jint x/yOffset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * The offset in pixels of the OpenGL viewport origin from the lower-left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * corner of the heavyweight drawable.  For example, a top-level frame on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * Windows XP has lower-left insets of (4,4).  The OpenGL viewport origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * would typically begin at the lower-left corner of the client region (inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * the frame decorations), but AWT/Swing will take the insets into account
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * when rendering into that window.  So in order to account for this, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * need to adjust the OpenGL viewport origin by an x/yOffset of (-4,-4).  On
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * X11, top-level frames typically don't have this insets issue, so their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * x/yOffset would be (0,0) (the same applies to pbuffers).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *     jint width/height;
31661
a5cb86f2253b 7188942: Remove support of pbuffers in OGL Java2d pipeline
serb
parents: 26751
diff changeset
   124
 * The cached surface bounds.  For offscreen surface types (OGLSD_FBOBJECT,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * OGLSD_TEXTURE, etc.) these values must remain constant.  Onscreen window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * surfaces (OGLSD_WINDOW, OGLSD_FLIP_BACKBUFFER, etc.) may have their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * bounds changed in response to a programmatic or user-initiated event, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * these values represent the last known dimensions.  To determine the true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * current bounds of this surface, query the native Drawable through the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * privOps field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *     GLuint textureID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * The texture object handle, as generated by glGenTextures().  If this value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * is zero, the texture has not yet been initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 *     jint textureWidth/Height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * The actual bounds of the texture object for this surface.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * GL_ARB_texture_non_power_of_two extension is not present, the dimensions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * of an OpenGL texture object must be a power-of-two (e.g. 64x32 or 128x512).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * The texture image that we care about has dimensions specified by the width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * and height fields in this OGLSDOps structure.  For example, if the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * to be stored in the texture has dimensions 115x47, the actual OpenGL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * texture we allocate will have dimensions 128x64 to meet the pow2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * restriction.  The image bounds within the texture can be accessed using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * floating point texture coordinates in the range [0.0,1.0].
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *     GLenum textureTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * The texture target of the texture object for this surface.  If this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * surface is not backed by a texture, this value is set to zero.  Otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * this value is GL_TEXTURE_RECTANGLE_ARB when the GL_ARB_texture_rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * extension is in use; if not, it is set to GL_TEXTURE_2D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *     GLint textureFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * The current filter state for this texture object (can be either GL_NEAREST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * or GL_LINEAR).  We cache this value here and check it before updating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * the filter state to avoid redundant calls to glTexParameteri() when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * filter state remains constant (see the OGLSD_UPDATE_TEXTURE_FILTER()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * macro below).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *     GLuint fbobjectID, depthID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * The object handles for the framebuffer object and depth renderbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * associated with this surface.  These fields are only used when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * drawableType is OGLSD_FBOBJECT, otherwise they are zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
struct _OGLSDOps {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    SurfaceDataOps               sdOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    void                         *privOps;
58315
07556f8cd819 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
serb
parents: 47216
diff changeset
   168
    jobject                      graphicsConfig;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    jint                         drawableType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    GLenum                       activeBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    jboolean                     isOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    jboolean                     needsInit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    jint                         xOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    jint                         yOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    jint                         width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    jint                         height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    GLuint                       textureID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    jint                         textureWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    jint                         textureHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    GLenum                       textureTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    GLint                        textureFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    GLuint                       fbobjectID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    GLuint                       depthID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * The following convenience macros are used when rendering rectangles (either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * a single rectangle, or a whole series of them).  To render a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * rectangle, simply invoke the GLRECT() macro.  To render a whole series of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * rectangles, such as spans in a complex shape, first invoke GLRECT_BEGIN(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * then invoke the appropriate inner loop macro (either XYXY or XYWH) for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * each rectangle, and finally invoke GLRECT_END() to notify OpenGL that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * vertex list is complete.  Care should be taken to avoid calling OpenGL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 * commands (besides GLRECT_BODY_*()) inside the BEGIN/END pair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#define GLRECT_BEGIN j2d_glBegin(GL_QUADS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
#define GLRECT_BODY_XYXY(x1, y1, x2, y2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        j2d_glVertex2i(x1, y1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        j2d_glVertex2i(x2, y1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        j2d_glVertex2i(x2, y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        j2d_glVertex2i(x1, y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
#define GLRECT_BODY_XYWH(x, y, w, h) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    GLRECT_BODY_XYXY(x, y, (x) + (w), (y) + (h))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
#define GLRECT_END j2d_glEnd()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
#define GLRECT(x, y, w, h) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        GLRECT_BEGIN; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        GLRECT_BODY_XYWH(x, y, w, h); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        GLRECT_END; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * These are shorthand names for the surface type constants defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * OGLSurfaceData.java.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   223
#define OGLSD_UNDEFINED       sun_java2d_pipe_hw_AccelSurface_UNDEFINED
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   224
#define OGLSD_WINDOW          sun_java2d_pipe_hw_AccelSurface_WINDOW
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   225
#define OGLSD_TEXTURE         sun_java2d_pipe_hw_AccelSurface_TEXTURE
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   226
#define OGLSD_FLIP_BACKBUFFER sun_java2d_pipe_hw_AccelSurface_FLIP_BACKBUFFER
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   227
#define OGLSD_FBOBJECT        sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * These are shorthand names for the filtering method constants used by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 * image transform methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
#define OGLSD_XFORM_DEFAULT 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#define OGLSD_XFORM_NEAREST_NEIGHBOR \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    java_awt_image_AffineTransformOp_TYPE_NEAREST_NEIGHBOR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#define OGLSD_XFORM_BILINEAR \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    java_awt_image_AffineTransformOp_TYPE_BILINEAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
 * Helper macros that update the current texture filter state only when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
 * it needs to be changed, which helps reduce overhead for small texturing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 * operations.  The filter state is set on a per-texture (not per-context)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 * basis; for example, it is possible for one texture to be using GL_NEAREST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * while another texture uses GL_LINEAR under the same context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
#define OGLSD_INIT_TEXTURE_FILTER(oglSDOps, filter)                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    do {                                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        j2d_glTexParameteri((oglSDOps)->textureTarget,                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                            GL_TEXTURE_MAG_FILTER, (filter));                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        j2d_glTexParameteri((oglSDOps)->textureTarget,                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                            GL_TEXTURE_MIN_FILTER, (filter));                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        (oglSDOps)->textureFilter = (filter);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
#define OGLSD_UPDATE_TEXTURE_FILTER(oglSDOps, filter)    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    do {                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        if ((oglSDOps)->textureFilter != (filter)) {     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            OGLSD_INIT_TEXTURE_FILTER(oglSDOps, filter); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * Convenience macros for setting the texture wrap mode for a given target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
 * The texture wrap mode should be reset to our default value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 * GL_CLAMP_TO_EDGE by calling OGLSD_RESET_TEXTURE_WRAP() when a texture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
 * is first created.  If another mode is needed (e.g. GL_REPEAT in the case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 * of TexturePaint acceleration), one can call the OGLSD_UPDATE_TEXTURE_WRAP()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * macro to easily set up the new wrap mode.  However, it is important to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 * restore the wrap mode back to its default value (by calling the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
 * OGLSD_RESET_TEXTURE_WRAP() macro) when the operation is finished.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#define OGLSD_UPDATE_TEXTURE_WRAP(target, wrap)                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    do {                                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        j2d_glTexParameteri((target), GL_TEXTURE_WRAP_S, (wrap)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        j2d_glTexParameteri((target), GL_TEXTURE_WRAP_T, (wrap)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#define OGLSD_RESET_TEXTURE_WRAP(target) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    OGLSD_UPDATE_TEXTURE_WRAP(target, GL_CLAMP_TO_EDGE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * Exported methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
jint OGLSD_Lock(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                jint lockflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
void OGLSD_GetRasInfo(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                      SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
void OGLSD_Unlock(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                  SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
void OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
   292
void OGLSD_Delete(JNIEnv *env, OGLSDOps *oglsdo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
jint OGLSD_NextPowerOfTwo(jint val, jint max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
jboolean OGLSD_InitFBObject(GLuint *fbobjectID, GLuint *depthID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                            GLuint textureID, GLenum textureTarget,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                            jint textureWidth, jint textureHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
#endif /* OGLSurfaceData_h_Included */