jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
changeset 17679 a81555868357
parent 15629 a041f5885d90
child 18754 3db51db1e3d5
equal deleted inserted replaced
17678:ec24ad8455ec 17679:a81555868357
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    46 extern DisposeFunc    OGLSD_Dispose;
    46 extern DisposeFunc    OGLSD_Dispose;
    47 
    47 
    48 extern void
    48 extern void
    49     OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
    49     OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
    50 
    50 
    51 jboolean surfaceCreationFailed = JNI_FALSE;
       
    52 
       
    53 #endif /* !HEADLESS */
    51 #endif /* !HEADLESS */
    54 
    52 
    55 JNIEXPORT void JNICALL
    53 JNIEXPORT void JNICALL
    56 Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
    54 Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
    57                                               jobject peer, jlong aData)
    55                                               jobject peer, jlong aData)
   347                 oglsdo->width, oglsdo->height);
   345                 oglsdo->width, oglsdo->height);
   348 
   346 
   349     return JNI_TRUE;
   347     return JNI_TRUE;
   350 }
   348 }
   351 
   349 
   352 static int
       
   353 GLXSD_BadAllocXErrHandler(Display *display, XErrorEvent *xerr)
       
   354 {
       
   355     int ret = 0;
       
   356     if (xerr->error_code == BadAlloc) {
       
   357         surfaceCreationFailed = JNI_TRUE;
       
   358     } else {
       
   359         ret = (*xerror_saved_handler)(display, xerr);
       
   360     }
       
   361     return ret;
       
   362 }
       
   363 
       
   364 JNIEXPORT jboolean JNICALL
   350 JNIEXPORT jboolean JNICALL
   365 Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
   351 Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
   366     (JNIEnv *env, jobject glxsd,
   352     (JNIEnv *env, jobject glxsd,
   367      jlong pData, jlong pConfigInfo,
   353      jlong pData, jlong pConfigInfo,
   368      jboolean isOpaque,
   354      jboolean isOpaque,
   374     GLXSDOps *glxsdo;
   360     GLXSDOps *glxsdo;
   375     GLXPbuffer pbuffer;
   361     GLXPbuffer pbuffer;
   376     int attrlist[] = {GLX_PBUFFER_WIDTH, 0,
   362     int attrlist[] = {GLX_PBUFFER_WIDTH, 0,
   377                       GLX_PBUFFER_HEIGHT, 0,
   363                       GLX_PBUFFER_HEIGHT, 0,
   378                       GLX_PRESERVED_CONTENTS, GL_FALSE, 0};
   364                       GLX_PRESERVED_CONTENTS, GL_FALSE, 0};
       
   365     jboolean errorOccurredFlag;
       
   366     jobject errorHandlerRef;
   379 
   367 
   380     J2dTraceLn3(J2D_TRACE_INFO,
   368     J2dTraceLn3(J2D_TRACE_INFO,
   381                 "GLXSurfaceData_initPbuffer: w=%d h=%d opq=%d",
   369                 "GLXSurfaceData_initPbuffer: w=%d h=%d opq=%d",
   382                 width, height, isOpaque);
   370                 width, height, isOpaque);
   383 
   371 
   401     }
   389     }
   402 
   390 
   403     attrlist[1] = width;
   391     attrlist[1] = width;
   404     attrlist[3] = height;
   392     attrlist[3] = height;
   405 
   393 
   406     surfaceCreationFailed = JNI_FALSE;
   394     errorOccurredFlag = JNI_FALSE;
   407     EXEC_WITH_XERROR_HANDLER(
   395     EXEC_WITH_XERROR_HANDLER(env, "sun/awt/X11/XErrorHandler$GLXBadAllocHandler",
   408         GLXSD_BadAllocXErrHandler,
   396         "()Lsun/awt/X11/XErrorHandler$GLXBadAllocHandler;", JNI_TRUE,
   409         pbuffer = j2d_glXCreatePbuffer(awt_display,
   397         errorHandlerRef, errorOccurredFlag,
   410                                        glxinfo->fbconfig, attrlist));
   398         pbuffer = j2d_glXCreatePbuffer(awt_display, glxinfo->fbconfig, attrlist));
   411     if ((pbuffer == 0) || surfaceCreationFailed) {
   399 
       
   400     if ((pbuffer == 0) || errorOccurredFlag) {
   412         J2dRlsTraceLn(J2D_TRACE_ERROR,
   401         J2dRlsTraceLn(J2D_TRACE_ERROR,
   413             "GLXSurfaceData_initPbuffer: could not create glx pbuffer");
   402             "GLXSurfaceData_initPbuffer: could not create glx pbuffer");
   414         return JNI_FALSE;
   403         return JNI_FALSE;
   415     }
   404     }
   416 
   405