jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
author igor
Mon, 12 Jul 2010 13:16:28 -0700
changeset 5938 c93e51904f68
parent 5506 202f599c92aa
child 7668 d4a77089c587
permissions -rw-r--r--
6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these) Reviewed-by: prr Contributed-by: ohair <kelly.ohair@oracle.com>
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) 2003, 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
#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
5938
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
    68
    if (oglsdo == NULL) {
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
    69
        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
    70
        return;
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
    71
    }
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5506
diff changeset
    72
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    oglsdo->privOps = glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    oglsdo->sdOps.Lock       = OGLSD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    oglsdo->sdOps.Unlock     = OGLSD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    oglsdo->sdOps.Dispose    = OGLSD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    oglsdo->drawableType = OGLSD_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    oglsdo->activeBuffer = GL_FRONT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    oglsdo->needsInit = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    if (peer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                                              "getContentWindow", "()J").j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        glxsdo->window = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    if (peer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        struct ComponentData *cdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        cdata = (struct ComponentData *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        if (cdata == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            JNU_ThrowNullPointerException(env, "Component data missing");
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
        if (cdata->widget == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            JNU_ThrowInternalError(env, "Widget is NULL in initOps");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        glxsdo->widget = cdata->widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        glxsdo->widget = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    glxsdo->configData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    if (glxsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        JNU_ThrowNullPointerException(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                                 "Native GraphicsConfig data block missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    if (glxsdo->configData->glxInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        JNU_ThrowNullPointerException(env, "GLXGraphicsConfigInfo missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * This function disposes of any native windowing system resources associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * with this surface.  For instance, if the given OGLSDOps is of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    GLXSDOps *glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    if (oglsdo->drawableType == OGLSD_PBUFFER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        if (glxsdo->drawable != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            j2d_glXDestroyPbuffer(awt_display, glxsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            glxsdo->drawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    } else if (oglsdo->drawableType == OGLSD_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // X Window is free'd later by AWT code...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * Makes the given context current to its associated "scratch" surface.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * the operation is successful, this method will return JNI_TRUE; otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * returns JNI_FALSE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
GLXSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    GLXCtxInfo *ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    J2dTraceLn(J2D_TRACE_INFO, "GLXSD_MakeCurrentToScratch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                      "GLXSD_MakeCurrentToScratch: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    ctxInfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    if (!j2d_glXMakeContextCurrent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                                   ctxInfo->scratchSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                   ctxInfo->scratchSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                   ctxInfo->context))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                      "GLXSD_MakeCurrentToScratch: could not make current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * Returns a pointer (as a jlong) to the native GLXGraphicsConfigInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * associated with the given OGLSDOps.  This method can be called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * shared code to retrieve the native GraphicsConfig data in a platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 * independent manner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                      "OGLSD_GetNativeConfigInfo: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                      "OGLSD_GetNativeConfigInfo: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    if (glxsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                      "OGLSD_GetNativeConfigInfo: config data is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    return ptr_to_jlong(glxsdo->configData->glxInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * Makes the given GraphicsConfig's context current to its associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 * "scratch" surface.  If there is a problem making the context current,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * this method will return NULL; otherwise, returns a pointer to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 * OGLContext that is associated with the given GraphicsConfig.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    GLXGraphicsConfigInfo *glxInfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    if (glxInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                      "OGLSD_SetScratchContext: glx config info is null");
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
    oglc = glxInfo->context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    if (!GLXSD_MakeCurrentToScratch(env, oglc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        // the GL_EXT_framebuffer_object extension is present, so this call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        // will ensure that we are bound to the scratch pbuffer (and not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        // some other framebuffer object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 * Makes a context current to the given source and destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * surfaces.  If there is a problem making the context current, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 * will return NULL; otherwise, returns a pointer to the OGLContext that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * associated with the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    GLXSDOps *dstGLXOps = (GLXSDOps *)dstOps->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_MakeOGLContextCurrent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    oglc = dstGLXOps->configData->glxInfo->context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                      "OGLSD_MakeOGLContextCurrent: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    if (dstOps->drawableType == OGLSD_FBOBJECT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        OGLContext *currentContext = OGLRenderQueue_GetCurrentContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        // first make sure we have a current context (if the context isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        // already current to some drawable, we will make it current to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        // its scratch surface)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (oglc != currentContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            if (!GLXSD_MakeCurrentToScratch(env, oglc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        // now bind to the fbobject associated with the destination surface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        // this means that all rendering will go into the fbobject destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        // (note that we unbind the currently bound texture first; this is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        // recommended procedure when binding an fbobject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        j2d_glBindTexture(dstOps->textureTarget, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        GLXSDOps *srcGLXOps = (GLXSDOps *)srcOps->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        GLXCtxInfo *ctxinfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        // make the context current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        if (!j2d_glXMakeContextCurrent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                       dstGLXOps->drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                                       srcGLXOps->drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                                       ctxinfo->context))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                "OGLSD_MakeOGLContextCurrent: could not make current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            // the GL_EXT_framebuffer_object extension is present, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            // must bind to the default (windowing system provided)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            // framebuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
 * This function initializes a native window surface and caches the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
 * bounds in the given OGLSDOps.  Returns JNI_TRUE if the operation was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 * successful; JNI_FALSE otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    Window window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    XWindowAttributes attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    Widget widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_InitOGLWindow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                      "OGLSD_InitOGLWindow: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                      "OGLSD_InitOGLWindow: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    window = glxsdo->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    if (window == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                      "OGLSD_InitOGLWindow: window is invalid");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    XGetWindowAttributes(awt_display, window, &attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    oglsdo->width = attr.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    oglsdo->height = attr.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    widget = glxsdo->widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    if (widget == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        J2dTraceLn(J2D_TRACE_WARNING, "OGLSD_InitOGLWindow: widget is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    if (!XtIsRealized(widget)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                      "OGLSD_InitOGLWindow: widget is unrealized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    window = XtWindow(widget);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    oglsdo->width = widget->core.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    oglsdo->height = widget->core.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    oglsdo->drawableType = OGLSD_WINDOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    oglsdo->isOpaque = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    oglsdo->xOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    oglsdo->yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    glxsdo->drawable = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    glxsdo->xdrawable = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  created window: w=%d h=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                oglsdo->width, oglsdo->height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
GLXSD_BadAllocXErrHandler(Display *display, XErrorEvent *xerr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    int ret = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    if (xerr->error_code == BadAlloc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        surfaceCreationFailed = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        ret = (*xerror_saved_handler)(display, xerr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    (JNIEnv *env, jobject glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     jlong pData, jlong pConfigInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     jboolean isOpaque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    GLXGraphicsConfigInfo *glxinfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    GLXPbuffer pbuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    int attrlist[] = {GLX_PBUFFER_WIDTH, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                      GLX_PBUFFER_HEIGHT, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                      GLX_PRESERVED_CONTENTS, GL_FALSE, 0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    J2dTraceLn3(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                "GLXSurfaceData_initPbuffer: w=%d h=%d opq=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                width, height, isOpaque);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                      "GLXSurfaceData_initPbuffer: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                      "GLXSurfaceData_initPbuffer: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    if (glxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                      "GLXSurfaceData_initPbuffer: glx config info is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    attrlist[1] = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    attrlist[3] = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    surfaceCreationFailed = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    EXEC_WITH_XERROR_HANDLER(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        GLXSD_BadAllocXErrHandler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        pbuffer = j2d_glXCreatePbuffer(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                       glxinfo->fbconfig, attrlist));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    if ((pbuffer == 0) || surfaceCreationFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            "GLXSurfaceData_initPbuffer: could not create glx pbuffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    oglsdo->drawableType = OGLSD_PBUFFER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    oglsdo->isOpaque = isOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    oglsdo->width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    oglsdo->height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    oglsdo->xOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    oglsdo->yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    glxsdo->drawable = pbuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    glxsdo->xdrawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   471
    OGLSD_SetNativeDimensions(env, oglsdo, width, height);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   472
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
OGLSD_SwapBuffers(JNIEnv *env, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SwapBuffers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    if (window == 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                      "OGLSD_SwapBuffers: window is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    j2d_glXSwapBuffers(awt_display, (Window)window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
#endif /* !HEADLESS */