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