jdk/src/share/native/sun/java2d/opengl/OGLContext.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 888 c7009cf0001f
child 18516 1f7d58c5f2e7
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
     2
 * Copyright (c) 2004, 2008, 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 HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "sun_java2d_SunGraphics2D.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "jlong.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "OGLContext.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "OGLRenderQueue.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "OGLSurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "Region.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * The following methods are implemented in the windowing system (i.e. GLX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * and WGL) source files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
extern OGLContext *OGLSD_MakeOGLContextCurrent(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                                               OGLSDOps *srcOps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                                               OGLSDOps *dstOps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * This table contains the standard blending rules (or Porter-Duff compositing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * factors) used in glBlendFunc(), indexed by the rule constants from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * AlphaComposite class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
OGLBlendRule StdBlendRules[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    { GL_ZERO,                GL_ZERO                }, /* 0 - Nothing      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    { GL_ZERO,                GL_ZERO                }, /* 1 - RULE_Clear   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    { GL_ONE,                 GL_ZERO                }, /* 2 - RULE_Src     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    { GL_ONE,                 GL_ONE_MINUS_SRC_ALPHA }, /* 3 - RULE_SrcOver */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    { GL_ONE_MINUS_DST_ALPHA, GL_ONE                 }, /* 4 - RULE_DstOver */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    { GL_DST_ALPHA,           GL_ZERO                }, /* 5 - RULE_SrcIn   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    { GL_ZERO,                GL_SRC_ALPHA           }, /* 6 - RULE_DstIn   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    { GL_ONE_MINUS_DST_ALPHA, GL_ZERO                }, /* 7 - RULE_SrcOut  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    { GL_ZERO,                GL_ONE_MINUS_SRC_ALPHA }, /* 8 - RULE_DstOut  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    { GL_ZERO,                GL_ONE                 }, /* 9 - RULE_Dst     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    { GL_DST_ALPHA,           GL_ONE_MINUS_SRC_ALPHA }, /*10 - RULE_SrcAtop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    { GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA           }, /*11 - RULE_DstAtop */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    { GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA }, /*12 - RULE_AlphaXor*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
/** Evaluates to "front" or "back", depending on the value of buf. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define OGLC_ACTIVE_BUFFER_NAME(buf) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    (buf == GL_FRONT || buf == GL_COLOR_ATTACHMENT0_EXT) ? "front" : "back"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Initializes the viewport and projection matrix, effectively positioning
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * the origin at the top-left corner of the surface.  This allows Java 2D
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * coordinates to be passed directly to OpenGL, which is typically based on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * a bottom-right coordinate system.  This method also sets the appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * read and draw buffers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
OGLContext_SetViewport(OGLSDOps *srcOps, OGLSDOps *dstOps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    jint width = dstOps->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    jint height = dstOps->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    J2dTraceLn4(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                "OGLContext_SetViewport: w=%d h=%d read=%s draw=%s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                OGLC_ACTIVE_BUFFER_NAME(srcOps->activeBuffer),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                OGLC_ACTIVE_BUFFER_NAME(dstOps->activeBuffer));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    // set the viewport and projection matrix
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    j2d_glViewport(dstOps->xOffset, dstOps->yOffset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                   (GLsizei)width, (GLsizei)height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    j2d_glMatrixMode(GL_PROJECTION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    j2d_glLoadIdentity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    j2d_glOrtho(0.0, (GLdouble)width, (GLdouble)height, 0.0, -1.0, 1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    // set the active read and draw buffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    j2d_glReadBuffer(srcOps->activeBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    j2d_glDrawBuffer(dstOps->activeBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    // set the color mask to enable alpha channel only when necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    j2d_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, (GLboolean)!dstOps->isOpaque);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * Initializes the alpha channel of the current surface so that it contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * fully opaque alpha values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
OGLContext_InitAlphaChannel()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    GLboolean scissorEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_InitAlphaChannel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // it is possible for the scissor test to be enabled at this point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // if it is, disable it temporarily since it can affect the glClear() op
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    scissorEnabled = j2d_glIsEnabled(GL_SCISSOR_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    if (scissorEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        j2d_glDisable(GL_SCISSOR_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    // set the color mask so that we only affect the alpha channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    j2d_glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    // clear the color buffer so that the alpha channel is fully opaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    j2d_glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    j2d_glClear(GL_COLOR_BUFFER_BIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    // restore the color mask (as it was set in OGLContext_SetViewport())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    j2d_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    // re-enable scissor test, only if it was enabled earlier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    if (scissorEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        j2d_glEnable(GL_SCISSOR_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * Fetches the OGLContext associated with the given destination surface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * makes the context current for those surfaces, updates the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * viewport, and then returns a pointer to the OGLContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
OGLContext_SetSurfaces(JNIEnv *env, jlong pSrc, jlong pDst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    OGLSDOps *srcOps = (OGLSDOps *)jlong_to_ptr(pSrc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    OGLSDOps *dstOps = (OGLSDOps *)jlong_to_ptr(pDst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    OGLContext *oglc = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_SetSurfaces");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    if (srcOps == NULL || dstOps == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            "OGLContext_SetSurfaces: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  srctype=%d dsttype=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                srcOps->drawableType, dstOps->drawableType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    if (dstOps->drawableType == OGLSD_TEXTURE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            "OGLContext_SetSurfaces: texture cannot be used as destination");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    if (dstOps->drawableType == OGLSD_UNDEFINED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        // initialize the surface as an OGLSD_WINDOW
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (!OGLSD_InitOGLWindow(env, dstOps)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                "OGLContext_SetSurfaces: could not init OGL window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    // make the context current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    oglc = OGLSD_MakeOGLContextCurrent(env, srcOps, dstOps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            "OGLContext_SetSurfaces: could not make context current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    // update the viewport
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    OGLContext_SetViewport(srcOps, dstOps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    // perform additional one-time initialization, if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    if (dstOps->needsInit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (dstOps->isOpaque) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            // in this case we are treating the destination as opaque, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            // to do so, first we need to ensure that the alpha channel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            // is filled with fully opaque values (see 6319663)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            OGLContext_InitAlphaChannel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        dstOps->needsInit = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * Resets the current clip state (disables both scissor and depth tests).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
OGLContext_ResetClip(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_ResetClip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    j2d_glDisable(GL_SCISSOR_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    j2d_glDisable(GL_DEPTH_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * Sets the OpenGL scissor bounds to the provided rectangular clip bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
OGLContext_SetRectClip(OGLContext *oglc, OGLSDOps *dstOps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                       jint x1, jint y1, jint x2, jint y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    jint width = x2 - x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    jint height = y2 - y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    J2dTraceLn4(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                "OGLContext_SetRectClip: x=%d y=%d w=%d h=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                x1, y1, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    RETURN_IF_NULL(dstOps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    if ((width < 0) || (height < 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        // use an empty scissor rectangle when the region is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        width = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        height = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    j2d_glDisable(GL_DEPTH_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    j2d_glEnable(GL_SCISSOR_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    // the scissor rectangle is specified using the lower-left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    // origin of the clip region (in the framebuffer's coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    // space), so we must account for the x/y offsets of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    // destination surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    j2d_glScissor(dstOps->xOffset + x1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                  dstOps->yOffset + dstOps->height - (y1 + height),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                  width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 * Sets up a complex (shape) clip using the OpenGL depth buffer.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 * method prepares the depth buffer so that the clip Region spans can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 * be "rendered" into it.  The depth buffer is first cleared, then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * depth func is setup so that when we render the clip spans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 * nothing is rendered into the color buffer, but for each pixel that would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * be rendered, a non-zero value is placed into that location in the depth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
 * buffer.  With depth test enabled, pixels will only be rendered into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 * color buffer if the corresponding value at that (x,y) location in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
 * depth buffer differs from the incoming depth value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
OGLContext_BeginShapeClip(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_BeginShapeClip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    RESET_PREVIOUS_OP();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    j2d_glDisable(GL_SCISSOR_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    // enable depth test and clear depth buffer so that depth values are at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    // their maximum; also set the depth func to GL_ALWAYS so that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    // depth values of the clip spans are forced into the depth buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    j2d_glEnable(GL_DEPTH_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    j2d_glClearDepth(1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    j2d_glClear(GL_DEPTH_BUFFER_BIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    j2d_glDepthFunc(GL_ALWAYS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    // disable writes into the color buffer while we set up the clip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    j2d_glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    // save current transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    j2d_glMatrixMode(GL_MODELVIEW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    j2d_glPushMatrix();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    // use identity transform plus slight translation in the z-axis when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    // setting the clip spans; this will push the clip spans (which would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    // normally be at z=0) to the z=1 plane to give them some depth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    j2d_glLoadIdentity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    j2d_glTranslatef(0.0f, 0.0f, 1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
 * Finishes setting up the shape clip by resetting the depth func
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
 * so that future rendering operations will once again be written into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
 * color buffer (while respecting the clip set up in the depth buffer).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
OGLContext_EndShapeClip(OGLContext *oglc, OGLSDOps *dstOps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_EndShapeClip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    RETURN_IF_NULL(dstOps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    RESET_PREVIOUS_OP();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    // restore transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    j2d_glPopMatrix();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    // re-enable writes into the color buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    j2d_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, (GLboolean)!dstOps->isOpaque);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    // enable the depth test so that only fragments within the clip region
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    // (i.e. those fragments whose z-values are >= the values currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    // stored in the depth buffer) are rendered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    j2d_glDepthFunc(GL_GEQUAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 * Initializes the OpenGL state responsible for applying extra alpha.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
 * step is only necessary for any operation that uses glDrawPixels() or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
 * glCopyPixels() with a non-1.0f extra alpha value.  Since the source is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
 * always premultiplied, we apply the extra alpha value to both alpha and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
 * color components using GL_*_SCALE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
OGLContext_SetExtraAlpha(jfloat ea)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    J2dTraceLn1(J2D_TRACE_INFO, "OGLContext_SetExtraAlpha: ea=%f", ea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    j2d_glPixelTransferf(GL_ALPHA_SCALE, ea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    j2d_glPixelTransferf(GL_RED_SCALE, ea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    j2d_glPixelTransferf(GL_GREEN_SCALE, ea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    j2d_glPixelTransferf(GL_BLUE_SCALE, ea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
 * Resets all OpenGL compositing state (disables blending and logic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
 * operations).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
OGLContext_ResetComposite(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_ResetComposite");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    // disable blending and XOR mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    if (oglc->compState == sun_java2d_SunGraphics2D_COMP_ALPHA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        j2d_glDisable(GL_BLEND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    } else if (oglc->compState == sun_java2d_SunGraphics2D_COMP_XOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        j2d_glDisable(GL_COLOR_LOGIC_OP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        j2d_glDisable(GL_ALPHA_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    // set state to default values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    oglc->compState = sun_java2d_SunGraphics2D_COMP_ISCOPY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    oglc->extraAlpha = 1.0f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
 * Initializes the OpenGL blending state.  XOR mode is disabled and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * appropriate blend functions are setup based on the AlphaComposite rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 * constant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
OGLContext_SetAlphaComposite(OGLContext *oglc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                             jint rule, jfloat extraAlpha, jint flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    J2dTraceLn1(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                "OGLContext_SetAlphaComposite: flags=%d", flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    // disable XOR mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    if (oglc->compState == sun_java2d_SunGraphics2D_COMP_XOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        j2d_glDisable(GL_COLOR_LOGIC_OP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        j2d_glDisable(GL_ALPHA_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    // we can safely disable blending when:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    //   - comp is SrcNoEa or SrcOverNoEa, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    //   - the source is opaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    // (turning off blending can have a large positive impact on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    // performance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    if ((rule == RULE_Src || rule == RULE_SrcOver) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        (extraAlpha == 1.0f) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        (flags & OGLC_SRC_IS_OPAQUE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        J2dTraceLn1(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                    "  disabling alpha comp: rule=%d ea=1.0 src=opq", rule);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        j2d_glDisable(GL_BLEND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        J2dTraceLn2(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                    "  enabling alpha comp: rule=%d ea=%f", rule, extraAlpha);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        j2d_glEnable(GL_BLEND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        j2d_glBlendFunc(StdBlendRules[rule].src, StdBlendRules[rule].dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    // update state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    oglc->compState = sun_java2d_SunGraphics2D_COMP_ALPHA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    oglc->extraAlpha = extraAlpha;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
 * Initializes the OpenGL logic op state to XOR mode.  Blending is disabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
 * before enabling logic op mode.  The XOR pixel value will be applied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
 * later in the OGLContext_SetColor() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
OGLContext_SetXorComposite(OGLContext *oglc, jint xorPixel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    J2dTraceLn1(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                "OGLContext_SetXorComposite: xorPixel=%08x", xorPixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    // disable blending mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    if (oglc->compState == sun_java2d_SunGraphics2D_COMP_ALPHA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        j2d_glDisable(GL_BLEND);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    // enable XOR mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    j2d_glEnable(GL_COLOR_LOGIC_OP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    j2d_glLogicOp(GL_XOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    // set up the alpha test so that we discard transparent fragments (this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    // is primarily useful for rendering text in XOR mode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    j2d_glEnable(GL_ALPHA_TEST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    j2d_glAlphaFunc(GL_NOTEQUAL, 0.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    // update state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    oglc->compState = sun_java2d_SunGraphics2D_COMP_XOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    oglc->xorPixel = xorPixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    oglc->extraAlpha = 1.0f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
 * Resets the OpenGL transform state back to the identity matrix.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
OGLContext_ResetTransform(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_ResetTransform");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    j2d_glMatrixMode(GL_MODELVIEW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    j2d_glLoadIdentity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
 * Initializes the OpenGL transform state by setting the modelview transform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
 * using the given matrix parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
 * REMIND: it may be worthwhile to add serial id to AffineTransform, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
 *         could do a quick check to see if the xform has changed since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
 *         last time... a simple object compare won't suffice...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
OGLContext_SetTransform(OGLContext *oglc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                        jdouble m00, jdouble m10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                        jdouble m01, jdouble m11,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                        jdouble m02, jdouble m12)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_SetTransform");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    RETURN_IF_NULL(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    CHECK_PREVIOUS_OP(OGL_STATE_CHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    if (oglc->xformMatrix == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        size_t arrsize = 16 * sizeof(GLdouble);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        oglc->xformMatrix = (GLdouble *)malloc(arrsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        memset(oglc->xformMatrix, 0, arrsize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        oglc->xformMatrix[10] = 1.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        oglc->xformMatrix[15] = 1.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    // copy values from AffineTransform object into native matrix array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    oglc->xformMatrix[0] = m00;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    oglc->xformMatrix[1] = m10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    oglc->xformMatrix[4] = m01;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    oglc->xformMatrix[5] = m11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    oglc->xformMatrix[12] = m02;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    oglc->xformMatrix[13] = m12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    J2dTraceLn3(J2D_TRACE_VERBOSE, "  [%lf %lf %lf]",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                oglc->xformMatrix[0], oglc->xformMatrix[4],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                oglc->xformMatrix[12]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    J2dTraceLn3(J2D_TRACE_VERBOSE, "  [%lf %lf %lf]",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                oglc->xformMatrix[1], oglc->xformMatrix[5],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                oglc->xformMatrix[13]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    j2d_glMatrixMode(GL_MODELVIEW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    j2d_glLoadMatrixd(oglc->xformMatrix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
 * Creates a 2D texture of the given format and dimensions and returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
 * texture object identifier.  This method is typically used to create a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
 * temporary texture for intermediate work, such as in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
 * OGLContext_InitBlitTileTexture() method below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
GLuint
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
OGLContext_CreateBlitTexture(GLenum internalFormat, GLenum pixelFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                             GLuint width, GLuint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    GLuint texID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    GLint sp, sr, rl, align;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    GLclampf priority = 1.0f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_CreateBlitTexture");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    j2d_glGenTextures(1, &texID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    j2d_glBindTexture(GL_TEXTURE_2D, texID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    j2d_glPrioritizeTextures(1, &texID, &priority);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    OGLSD_RESET_TEXTURE_WRAP(GL_TEXTURE_2D);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    // save pixel store parameters (since this method could be invoked after
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    // the caller has already set up its pixel store parameters)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    j2d_glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &sp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    j2d_glGetIntegerv(GL_UNPACK_SKIP_ROWS, &sr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    j2d_glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    j2d_glGetIntegerv(GL_UNPACK_ALIGNMENT, &align);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    // set pixel store parameters to default values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    j2d_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    j2d_glTexImage2D(GL_TEXTURE_2D, 0, internalFormat,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                     width, height, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                     pixelFormat, GL_UNSIGNED_BYTE, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    // restore pixel store parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, sp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    j2d_glPixelStorei(GL_UNPACK_SKIP_ROWS, sr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    j2d_glPixelStorei(GL_UNPACK_ROW_LENGTH, rl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, align);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    return texID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
 * Initializes a small texture tile for use with tiled blit operations (see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
 * OGLBlitLoops.c and OGLMaskBlit.c for usage examples).  The texture ID for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
 * the tile is stored in the given OGLContext.  The tile is initially filled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
 * with garbage values, but the tile is updated as needed (via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
 * glTexSubImage2D()) with real RGBA values used in tiled blit situations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
 * The internal format for the texture is GL_RGBA8, which should be sufficient
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
 * for storing system memory surfaces of any known format (see PixelFormats
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
 * for a list of compatible surface formats).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
OGLContext_InitBlitTileTexture(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_InitBlitTileTexture");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    oglc->blitTextureID =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        OGLContext_CreateBlitTexture(GL_RGBA8, GL_RGBA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                                     OGLC_BLIT_TILE_SIZE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                                     OGLC_BLIT_TILE_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
 * Destroys the OpenGL resources associated with the given OGLContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
 * It is required that the native context associated with the OGLContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
 * be made current prior to calling this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
OGLContext_DestroyContextResources(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_DestroyContextResources");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    if (oglc->xformMatrix != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        free(oglc->xformMatrix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    if (oglc->blitTextureID != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        j2d_glDeleteTextures(1, &oglc->blitTextureID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
 * Returns JNI_TRUE if the given extension name is available for the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
 * GraphicsConfig; JNI_FALSE otherwise.  An extension is considered available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
 * if its identifier string is found amongst the space-delimited GL_EXTENSIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
 * string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
 * Adapted from the OpenGL Red Book, pg. 506.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
OGLContext_IsExtensionAvailable(const char *extString, char *extName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    jboolean ret = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    char *p = (char *)extString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    char *end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    if (extString == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        J2dTraceLn(J2D_TRACE_INFO, "OGLContext_IsExtensionAvailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            "OGLContext_IsExtensionAvailable: extension string is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    end = p + strlen(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    while (p < end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        size_t n = strcspn(p, " ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        if ((strlen(extName) == n) && (strncmp(extName, p, n) == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            ret = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        p += (n + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    J2dRlsTraceLn2(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                   "OGLContext_IsExtensionAvailable: %s=%s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                   extName, ret ? "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
 * Returns JNI_TRUE only if all of the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
 *   - the GL_EXT_framebuffer_object extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
 *   - FBO support has been enabled via the system property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
 *   - we can successfully create an FBO with depth capabilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
OGLContext_IsFBObjectExtensionAvailable(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                                        const char *extString)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    jboolean isFBObjectEnabled = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    GLuint fbobjectID, textureID, depthID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    jint width = 1, height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_IsFBObjectExtensionAvailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    // first see if the fbobject extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    if (!OGLContext_IsExtensionAvailable(extString,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                                         "GL_EXT_framebuffer_object"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    // next see if the fbobject system property has been enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    isFBObjectEnabled =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        JNU_GetStaticFieldByName(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                                 "sun/java2d/opengl/OGLSurfaceData",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                                 "isFBObjectEnabled", "Z").z;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    if (!isFBObjectEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            "OGLContext_IsFBObjectExtensionAvailable: disabled via flag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    // finally, create a dummy fbobject with depth capabilities to see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    // if this configuration is supported by the drivers/hardware
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    // (first we initialize a color texture object that will be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    // construct the dummy fbobject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    j2d_glGenTextures(1, &textureID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    j2d_glBindTexture(GL_TEXTURE_2D, textureID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    j2d_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                     width, height, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                     GL_RGB, GL_UNSIGNED_BYTE, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    j2d_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    // initialize framebuffer object using color texture created above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    if (!OGLSD_InitFBObject(&fbobjectID, &depthID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                            textureID, GL_TEXTURE_2D,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                            width, height))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            "OGLContext_IsFBObjectExtensionAvailable: fbobject unsupported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        j2d_glDeleteTextures(1, &textureID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    // delete the temporary resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    j2d_glDeleteTextures(1, &textureID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    j2d_glDeleteRenderbuffersEXT(1, &depthID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    j2d_glDeleteFramebuffersEXT(1, &fbobjectID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        "OGLContext_IsFBObjectExtensionAvailable: fbobject supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
 * Returns JNI_TRUE only if all of the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
 *   - the GL_ARB_fragment_shader extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
 *   - the LCD text shader codepath has been enabled via the system property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
 *   - the hardware supports the minimum number of texture units
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
OGLContext_IsLCDShaderSupportAvailable(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                                       jboolean fragShaderAvailable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    jboolean isLCDShaderEnabled = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    GLint maxTexUnits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_IsLCDShaderSupportAvailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    // first see if the fragment shader extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    if (!fragShaderAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    // next see if the lcdshader system property has been enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    isLCDShaderEnabled =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        JNU_GetStaticFieldByName(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                                 "sun/java2d/opengl/OGLSurfaceData",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                                 "isLCDShaderEnabled", "Z").z;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    if (!isLCDShaderEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            "OGLContext_IsLCDShaderSupportAvailable: disabled via flag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    // finally, check to see if the hardware supports the required number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    // of texture units
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    j2d_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &maxTexUnits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    if (maxTexUnits < 4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        J2dRlsTraceLn1(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
          "OGLContext_IsLCDShaderSupportAvailable: not enough tex units (%d)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
          maxTexUnits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        "OGLContext_IsLCDShaderSupportAvailable: LCD text shader supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
 * Returns JNI_TRUE only if all of the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
 *   - the GL_ARB_fragment_shader extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
 *   - the BufferedImageOp shader codepath has been enabled via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
 *     system property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
OGLContext_IsBIOpShaderSupportAvailable(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                                        jboolean fragShaderAvailable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    jboolean isBIOpShaderEnabled = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_IsBIOpShaderSupportAvailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    // first see if the fragment shader extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    if (!fragShaderAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    // next see if the biopshader system property has been enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    isBIOpShaderEnabled =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        JNU_GetStaticFieldByName(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                                 "sun/java2d/opengl/OGLSurfaceData",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                                 "isBIOpShaderEnabled", "Z").z;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    if (!isBIOpShaderEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            "OGLContext_IsBIOpShaderSupportAvailable: disabled via flag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * Note: In theory we should probably do some other checks here, like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * linking a sample shader to see if the hardware truly supports our
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * shader programs.  However, our current BufferedImageOp shaders were
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * designed to support first-generation shader-level hardware, so the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * assumption is that if our shaders work on those GPUs, then they'll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * work on newer ones as well.  Also, linking a fragment program can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * cost valuable CPU cycles, which is another reason to avoid these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * checks at startup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        "OGLContext_IsBIOpShaderSupportAvailable: BufferedImageOp shader supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
 * Returns JNI_TRUE only if all of the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
 *   - the GL_ARB_fragment_shader extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
 *   - the Linear/RadialGradientPaint shader codepath has been enabled via the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
 *     system property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
OGLContext_IsGradShaderSupportAvailable(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                                        jboolean fragShaderAvailable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    jboolean isGradShaderEnabled = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_IsGradShaderSupportAvailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    // first see if the fragment shader extension is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    if (!fragShaderAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    // next see if the gradshader system property has been enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    isGradShaderEnabled =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        JNU_GetStaticFieldByName(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                                 "sun/java2d/opengl/OGLSurfaceData",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                                 "isGradShaderEnabled", "Z").z;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    if (!isGradShaderEnabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            "OGLContext_IsGradShaderSupportAvailable: disabled via flag");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    J2dRlsTraceLn(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        "OGLContext_IsGradShaderSupportAvailable: Linear/RadialGradientPaint shader supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
 * Checks for the presence of the optional extensions used by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
 * the Java 2D OpenGL pipeline.  The given caps bitfield is updated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
 * to reflect the availability of these extensions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
OGLContext_GetExtensionInfo(JNIEnv *env, jint *caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    jint vcap = OGLC_VENDOR_OTHER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    const char *vendor = (char *)j2d_glGetString(GL_VENDOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    const char *e = (char *)j2d_glGetString(GL_EXTENSIONS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    jboolean fragShaderAvail =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        OGLContext_IsExtensionAvailable(e, "GL_ARB_fragment_shader");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_GetExtensionInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   855
    *caps |= CAPS_TEXNONSQUARE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    if (OGLContext_IsExtensionAvailable(e, "GL_ARB_multitexture")) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   857
        *caps |= CAPS_MULTITEXTURE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    if (OGLContext_IsExtensionAvailable(e, "GL_ARB_texture_non_power_of_two")){
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   860
        *caps |= CAPS_TEXNONPOW2;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   862
    // 6656574: Use of the GL_ARB_texture_rectangle extension by Java 2D
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   863
    // complicates any third-party libraries that try to interact with
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   864
    // the OGL pipeline (and we've run into driver bugs in the past related
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   865
    // to this extension), so for now we will disable its use by default (unless
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   866
    // forced). We will still make use of the GL_ARB_texture_non_power_of_two
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   867
    // extension when available, which is the better choice going forward
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   868
    // anyway.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   869
    if (OGLContext_IsExtensionAvailable(e, "GL_ARB_texture_rectangle") &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   870
        getenv("J2D_OGL_TEXRECT") != NULL)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   871
    {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   872
        *caps |= CAPS_EXT_TEXRECT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    if (OGLContext_IsFBObjectExtensionAvailable(env, e)) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   875
        *caps |= CAPS_EXT_FBOBJECT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    if (OGLContext_IsLCDShaderSupportAvailable(env, fragShaderAvail)) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   878
        *caps |= CAPS_EXT_LCD_SHADER | CAPS_PS20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
    if (OGLContext_IsBIOpShaderSupportAvailable(env, fragShaderAvail)) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   881
        *caps |= CAPS_EXT_BIOP_SHADER | CAPS_PS20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    if (OGLContext_IsGradShaderSupportAvailable(env, fragShaderAvail)) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   884
        *caps |= CAPS_EXT_GRAD_SHADER | CAPS_PS20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   886
    if (OGLContext_IsExtensionAvailable(e, "GL_NV_fragment_program")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   887
        // this is an Nvidia board, at least PS 2.0, but we can't
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   888
        // use the "max instructions" heuristic since GeForce FX
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   889
        // boards report 1024 even though they're only PS 2.0,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   890
        // so we'll check the following, which does imply PS 3.0
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   891
        if (OGLContext_IsExtensionAvailable(e, "GL_NV_fragment_program2")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   892
            *caps |= CAPS_PS30;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   893
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   894
    } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   895
        // for all other boards, we look at the "max instructions"
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   896
        // count reported by the GL_ARB_fragment_program extension
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   897
        // as a heuristic for detecting PS 3.0 compatible hardware
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   898
        if (OGLContext_IsExtensionAvailable(e, "GL_ARB_fragment_program")) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   899
            GLint instr;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   900
            j2d_glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   901
                                  GL_MAX_PROGRAM_INSTRUCTIONS_ARB, &instr);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   902
            if (instr > 512) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   903
                *caps |= CAPS_PS30;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   904
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   905
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   906
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    // stuff vendor descriptor in the upper bits of the caps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    if (vendor != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        if (strncmp(vendor, "ATI", 3) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            vcap = OGLC_VENDOR_ATI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        } else if (strncmp(vendor, "NVIDIA", 6) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            vcap = OGLC_VENDOR_NVIDIA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        } else if (strncmp(vendor, "Sun", 3) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            vcap = OGLC_VENDOR_SUN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   916
        // REMIND: new in 7 - check if needs fixing
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   917
        *caps |= ((vcap & OGLC_VCAP_MASK) << OGLC_VCAP_OFFSET);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
    }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   919
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
 * Returns JNI_TRUE if the given GL_VERSION string meets the minimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
 * requirements (>= 1.2); JNI_FALSE otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
OGLContext_IsVersionSupported(const unsigned char *versionstr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_IsVersionSupported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    if (versionstr == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            "OGLContext_IsVersionSupported: version string is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    // note that this check allows for OpenGL 2.x
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    return ((versionstr[0] == '1' && versionstr[2] >= '2') ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            (versionstr[0] >= '2'));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
 * Compiles and links the given fragment shader program.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
 * successful, this function returns a handle to the newly created shader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
 * program; otherwise returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
GLhandleARB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
OGLContext_CreateFragmentProgram(const char *fragmentShaderSource)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    GLhandleARB fragmentShader, fragmentProgram;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    GLint success;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    int infoLogLength = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_CreateFragmentProgram");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    // create the shader object and compile the shader source code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    fragmentShader = j2d_glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    j2d_glShaderSourceARB(fragmentShader, 1, &fragmentShaderSource, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    j2d_glCompileShaderARB(fragmentShader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    j2d_glGetObjectParameterivARB(fragmentShader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                                  GL_OBJECT_COMPILE_STATUS_ARB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                                  &success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    // print the compiler messages, if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    j2d_glGetObjectParameterivARB(fragmentShader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                                  GL_OBJECT_INFO_LOG_LENGTH_ARB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                                  &infoLogLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    if (infoLogLength > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        char infoLog[1024];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        j2d_glGetInfoLogARB(fragmentShader, 1024, NULL, infoLog);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        J2dRlsTraceLn2(J2D_TRACE_WARNING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            "OGLContext_CreateFragmentProgram: compiler msg (%d):\n%s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                       infoLogLength, infoLog);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    if (!success) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            "OGLContext_CreateFragmentProgram: error compiling shader");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        j2d_glDeleteObjectARB(fragmentShader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    // create the program object and attach it to the shader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    fragmentProgram = j2d_glCreateProgramObjectARB();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    j2d_glAttachObjectARB(fragmentProgram, fragmentShader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    // it is now safe to delete the shader object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    j2d_glDeleteObjectARB(fragmentShader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    // link the program
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    j2d_glLinkProgramARB(fragmentProgram);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    j2d_glGetObjectParameterivARB(fragmentProgram,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                                  GL_OBJECT_LINK_STATUS_ARB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                                  &success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    // print the linker messages, if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    j2d_glGetObjectParameterivARB(fragmentProgram,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                                  GL_OBJECT_INFO_LOG_LENGTH_ARB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                                  &infoLogLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
    if (infoLogLength > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        char infoLog[1024];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        j2d_glGetInfoLogARB(fragmentProgram, 1024, NULL, infoLog);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        J2dRlsTraceLn2(J2D_TRACE_WARNING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            "OGLContext_CreateFragmentProgram: linker msg (%d):\n%s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                       infoLogLength, infoLog);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    if (!success) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            "OGLContext_CreateFragmentProgram: error linking shader");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        j2d_glDeleteObjectARB(fragmentProgram);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    return fragmentProgram;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1018
/*
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1019
 * Class:     sun_java2d_opengl_OGLContext
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1020
 * Method:    getOGLIdString
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1021
 * Signature: ()Ljava/lang/String;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1022
 */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1023
JNIEXPORT jstring JNICALL Java_sun_java2d_opengl_OGLContext_getOGLIdString
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1024
  (JNIEnv *env, jclass oglcc)
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1025
{
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1026
    char *vendor, *renderer, *version;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1027
    char *pAdapterId;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1028
    jobject ret = NULL;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1029
    int len;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1030
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1031
    J2dTraceLn(J2D_TRACE_INFO, "OGLContext_getOGLIdString");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1032
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1033
    vendor = (char*)j2d_glGetString(GL_VENDOR);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1034
    if (vendor == NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1035
        vendor = "Unknown Vendor";
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1036
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1037
    renderer = (char*)j2d_glGetString(GL_RENDERER);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1038
    if (renderer == NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1039
        renderer = "Unknown Renderer";
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1040
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1041
    version = (char*)j2d_glGetString(GL_VERSION);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1042
    if (version == NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1043
        version = "unknown version";
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1044
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1045
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1046
    // 'vendor renderer (version)0'
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1047
    len = strlen(vendor) + 1 + strlen(renderer) + 1 + 1+strlen(version)+1 + 1;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1048
    pAdapterId = malloc(len);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1049
    if (pAdapterId != NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1050
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1051
        jio_snprintf(pAdapterId, len, "%s %s (%s)", vendor, renderer, version);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1052
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1053
        J2dTraceLn1(J2D_TRACE_VERBOSE, "  id=%s", pAdapterId);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1054
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1055
        ret = JNU_NewStringPlatform(env, pAdapterId);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1056
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1057
        free(pAdapterId);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1058
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1059
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1060
    return ret;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1061
}
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
  1062
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
#endif /* !HEADLESS */