jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
author tdv
Tue, 22 Jul 2008 11:24:32 -0700
changeset 888 c7009cf0001f
parent 887 0aab8d3fa11a
child 5506 202f599c92aa
permissions -rw-r--r--
6728492: typo in copyrights in some files touched by the d3d pipeline port Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
888
c7009cf0001f 6728492: typo in copyrights in some files touched by the d3d pipeline port
tdv
parents: 887
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <jlong.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "sun_java2d_opengl_GLXSurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "OGLRenderQueue.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "GLXGraphicsConfig.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "GLXSurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The methods in this file implement the native windowing system specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * layer (GLX) for the OpenGL-based Java 2D pipeline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
extern LockFunc       OGLSD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
extern GetRasInfoFunc OGLSD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
extern UnlockFunc     OGLSD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
extern DisposeFunc    OGLSD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
extern struct MComponentPeerIDs mComponentPeerIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    50
extern void
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    51
    OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    52
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
jboolean surfaceCreationFailed = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                              jobject peer, jlong aData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                                                       sizeof(OGLSDOps));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    oglsdo->privOps = glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    oglsdo->sdOps.Lock       = OGLSD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    oglsdo->sdOps.Unlock     = OGLSD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    oglsdo->sdOps.Dispose    = OGLSD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    oglsdo->drawableType = OGLSD_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    oglsdo->activeBuffer = GL_FRONT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    oglsdo->needsInit = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    if (peer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                                              "getContentWindow", "()J").j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        glxsdo->window = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    if (peer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        struct ComponentData *cdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        cdata = (struct ComponentData *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        if (cdata == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            JNU_ThrowNullPointerException(env, "Component data missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        if (cdata->widget == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            JNU_ThrowInternalError(env, "Widget is NULL in initOps");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        glxsdo->widget = cdata->widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        glxsdo->widget = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    glxsdo->configData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    if (glxsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        JNU_ThrowNullPointerException(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                 "Native GraphicsConfig data block missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    if (glxsdo->configData->glxInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        JNU_ThrowNullPointerException(env, "GLXGraphicsConfigInfo missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * This function disposes of any native windowing system resources associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * with this surface.  For instance, if the given OGLSDOps is of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    GLXSDOps *glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    if (oglsdo->drawableType == OGLSD_PBUFFER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        if (glxsdo->drawable != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            j2d_glXDestroyPbuffer(awt_display, glxsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            glxsdo->drawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    } else if (oglsdo->drawableType == OGLSD_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        // X Window is free'd later by AWT code...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * Makes the given context current to its associated "scratch" surface.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * the operation is successful, this method will return JNI_TRUE; otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * returns JNI_FALSE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
GLXSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    GLXCtxInfo *ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    J2dTraceLn(J2D_TRACE_INFO, "GLXSD_MakeCurrentToScratch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                      "GLXSD_MakeCurrentToScratch: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    ctxInfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    if (!j2d_glXMakeContextCurrent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                                   ctxInfo->scratchSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                   ctxInfo->scratchSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                   ctxInfo->context))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                      "GLXSD_MakeCurrentToScratch: could not make current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * Returns a pointer (as a jlong) to the native GLXGraphicsConfigInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * associated with the given OGLSDOps.  This method can be called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * shared code to retrieve the native GraphicsConfig data in a platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * independent manner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                      "OGLSD_GetNativeConfigInfo: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                      "OGLSD_GetNativeConfigInfo: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    if (glxsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                      "OGLSD_GetNativeConfigInfo: config data is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    return ptr_to_jlong(glxsdo->configData->glxInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * Makes the given GraphicsConfig's context current to its associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * "scratch" surface.  If there is a problem making the context current,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * this method will return NULL; otherwise, returns a pointer to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * OGLContext that is associated with the given GraphicsConfig.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    GLXGraphicsConfigInfo *glxInfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    if (glxInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                      "OGLSD_SetScratchContext: glx config info is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    oglc = glxInfo->context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    if (!GLXSD_MakeCurrentToScratch(env, oglc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        // the GL_EXT_framebuffer_object extension is present, so this call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        // will ensure that we are bound to the scratch pbuffer (and not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        // some other framebuffer object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * Makes a context current to the given source and destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 * surfaces.  If there is a problem making the context current, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
 * will return NULL; otherwise, returns a pointer to the OGLContext that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 * associated with the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    GLXSDOps *dstGLXOps = (GLXSDOps *)dstOps->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_MakeOGLContextCurrent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    oglc = dstGLXOps->configData->glxInfo->context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                      "OGLSD_MakeOGLContextCurrent: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    if (dstOps->drawableType == OGLSD_FBOBJECT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        OGLContext *currentContext = OGLRenderQueue_GetCurrentContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        // first make sure we have a current context (if the context isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // already current to some drawable, we will make it current to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // its scratch surface)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if (oglc != currentContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            if (!GLXSD_MakeCurrentToScratch(env, oglc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        // now bind to the fbobject associated with the destination surface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        // this means that all rendering will go into the fbobject destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        // (note that we unbind the currently bound texture first; this is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        // recommended procedure when binding an fbobject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        j2d_glBindTexture(dstOps->textureTarget, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        GLXSDOps *srcGLXOps = (GLXSDOps *)srcOps->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        GLXCtxInfo *ctxinfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        // make the context current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        if (!j2d_glXMakeContextCurrent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                                       dstGLXOps->drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                                       srcGLXOps->drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                       ctxinfo->context))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                "OGLSD_MakeOGLContextCurrent: could not make current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            // the GL_EXT_framebuffer_object extension is present, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            // must bind to the default (windowing system provided)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            // framebuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
 * This function initializes a native window surface and caches the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
 * bounds in the given OGLSDOps.  Returns JNI_TRUE if the operation was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
 * successful; JNI_FALSE otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    Window window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    XWindowAttributes attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    Widget widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_InitOGLWindow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                      "OGLSD_InitOGLWindow: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                      "OGLSD_InitOGLWindow: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    window = glxsdo->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    if (window == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                      "OGLSD_InitOGLWindow: window is invalid");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    XGetWindowAttributes(awt_display, window, &attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    oglsdo->width = attr.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    oglsdo->height = attr.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    widget = glxsdo->widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    if (widget == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        J2dTraceLn(J2D_TRACE_WARNING, "OGLSD_InitOGLWindow: widget is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    if (!XtIsRealized(widget)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                      "OGLSD_InitOGLWindow: widget is unrealized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    window = XtWindow(widget);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    oglsdo->width = widget->core.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    oglsdo->height = widget->core.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    oglsdo->drawableType = OGLSD_WINDOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    oglsdo->isOpaque = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    oglsdo->xOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    oglsdo->yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    glxsdo->drawable = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    glxsdo->xdrawable = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  created window: w=%d h=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                oglsdo->width, oglsdo->height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
GLXSD_BadAllocXErrHandler(Display *display, XErrorEvent *xerr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    int ret = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    if (xerr->error_code == BadAlloc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        surfaceCreationFailed = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        ret = (*xerror_saved_handler)(display, xerr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    (JNIEnv *env, jobject glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     jlong pData, jlong pConfigInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     jboolean isOpaque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    GLXGraphicsConfigInfo *glxinfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    GLXPbuffer pbuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    int attrlist[] = {GLX_PBUFFER_WIDTH, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                      GLX_PBUFFER_HEIGHT, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                      GLX_PRESERVED_CONTENTS, GL_FALSE, 0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    J2dTraceLn3(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                "GLXSurfaceData_initPbuffer: w=%d h=%d opq=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                width, height, isOpaque);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                      "GLXSurfaceData_initPbuffer: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                      "GLXSurfaceData_initPbuffer: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    if (glxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                      "GLXSurfaceData_initPbuffer: glx config info is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    attrlist[1] = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    attrlist[3] = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    surfaceCreationFailed = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    EXEC_WITH_XERROR_HANDLER(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        GLXSD_BadAllocXErrHandler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        pbuffer = j2d_glXCreatePbuffer(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                       glxinfo->fbconfig, attrlist));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    if ((pbuffer == 0) || surfaceCreationFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            "GLXSurfaceData_initPbuffer: could not create glx pbuffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    oglsdo->drawableType = OGLSD_PBUFFER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    oglsdo->isOpaque = isOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    oglsdo->width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    oglsdo->height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    oglsdo->xOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    oglsdo->yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    glxsdo->drawable = pbuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    glxsdo->xdrawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   466
    OGLSD_SetNativeDimensions(env, oglsdo, width, height);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   467
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
}
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
OGLSD_SwapBuffers(JNIEnv *env, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SwapBuffers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    if (window == 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                      "OGLSD_SwapBuffers: window is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    j2d_glXSwapBuffers(awt_display, (Window)window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
#endif /* !HEADLESS */