< prev index next >

src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c

Print this page
rev 13714 : 8146238: [macosx] Java2D Queue Flusher crash on OSX after switching between user accounts
Reviewed-by: prr, avu
   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  37  * The methods in this file implement the native windowing system specific
  38  * layer (GLX) for the OpenGL-based Java 2D pipeline.
  39  */
  40 
  41 #ifndef HEADLESS
  42 
  43 extern LockFunc       OGLSD_Lock;
  44 extern GetRasInfoFunc OGLSD_GetRasInfo;
  45 extern UnlockFunc     OGLSD_Unlock;
  46 extern DisposeFunc    OGLSD_Dispose;
  47 
  48 extern void
  49     OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
  50 
  51 jboolean surfaceCreationFailed = JNI_FALSE;
  52 
  53 #endif /* !HEADLESS */
  54 
  55 JNIEXPORT void JNICALL
  56 Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,

  57                                               jobject peer, jlong aData)
  58 {
  59 #ifndef HEADLESS
  60     GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
  61 
  62     if (glxsdo == NULL) {
  63         JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
  64         return;
  65     }
  66 
  67     OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
  68                                                        sizeof(OGLSDOps));
  69     if (oglsdo == NULL) {
  70         free(glxsdo);
  71         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
  72         return;
  73     }









  74 
  75     J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
  76 
  77     oglsdo->privOps = glxsdo;
  78 
  79     oglsdo->sdOps.Lock       = OGLSD_Lock;
  80     oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
  81     oglsdo->sdOps.Unlock     = OGLSD_Unlock;
  82     oglsdo->sdOps.Dispose    = OGLSD_Dispose;
  83 
  84     oglsdo->drawableType = OGLSD_UNDEFINED;
  85     oglsdo->activeBuffer = GL_FRONT;
  86     oglsdo->needsInit = JNI_TRUE;
  87 
  88     if (peer != NULL) {
  89         glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
  90                                               "getContentWindow", "()J").j;
  91     } else {
  92         glxsdo->window = 0;
  93     }


 148         J2dRlsTraceLn(J2D_TRACE_ERROR,
 149                       "GLXSD_MakeCurrentToScratch: context is null");
 150         return JNI_FALSE;
 151     }
 152 
 153     ctxInfo = (GLXCtxInfo *)oglc->ctxInfo;
 154     if (!j2d_glXMakeContextCurrent(awt_display,
 155                                    ctxInfo->scratchSurface,
 156                                    ctxInfo->scratchSurface,
 157                                    ctxInfo->context))
 158     {
 159         J2dRlsTraceLn(J2D_TRACE_ERROR,
 160                       "GLXSD_MakeCurrentToScratch: could not make current");
 161         return JNI_FALSE;
 162     }
 163 
 164     return JNI_TRUE;
 165 }
 166 
 167 /**
 168  * Returns a pointer (as a jlong) to the native GLXGraphicsConfigInfo
 169  * associated with the given OGLSDOps.  This method can be called from
 170  * shared code to retrieve the native GraphicsConfig data in a platform-
 171  * independent manner.
 172  */
 173 jlong
 174 OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
 175 {
 176     GLXSDOps *glxsdo;
 177 
 178     if (oglsdo == NULL) {
 179         J2dRlsTraceLn(J2D_TRACE_ERROR,
 180                       "OGLSD_GetNativeConfigInfo: ops are null");
 181         return 0L;
 182     }
 183 
 184     glxsdo = (GLXSDOps *)oglsdo->privOps;
 185     if (glxsdo == NULL) {
 186         J2dRlsTraceLn(J2D_TRACE_ERROR,
 187                       "OGLSD_GetNativeConfigInfo: glx ops are null");
 188         return 0L;
 189     }
 190 
 191     if (glxsdo->configData == NULL) {
 192         J2dRlsTraceLn(J2D_TRACE_ERROR,
 193                       "OGLSD_GetNativeConfigInfo: config data is null");
 194         return 0L;
 195     }
 196 
 197     return ptr_to_jlong(glxsdo->configData->glxInfo);
 198 }
 199 
 200 /**
 201  * Makes the given GraphicsConfig's context current to its associated
 202  * "scratch" surface.  If there is a problem making the context current,
 203  * this method will return NULL; otherwise, returns a pointer to the
 204  * OGLContext that is associated with the given GraphicsConfig.
 205  */
 206 OGLContext *
 207 OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
 208 {
 209     GLXGraphicsConfigInfo *glxInfo =
 210         (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
 211     OGLContext *oglc;
 212 
 213     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
 214 
 215     if (glxInfo == NULL) {
 216         J2dRlsTraceLn(J2D_TRACE_ERROR,
 217                       "OGLSD_SetScratchContext: glx config info is null");
 218         return NULL;
 219     }
 220 


   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  37  * The methods in this file implement the native windowing system specific
  38  * layer (GLX) for the OpenGL-based Java 2D pipeline.
  39  */
  40 
  41 #ifndef HEADLESS
  42 
  43 extern LockFunc       OGLSD_Lock;
  44 extern GetRasInfoFunc OGLSD_GetRasInfo;
  45 extern UnlockFunc     OGLSD_Unlock;
  46 extern DisposeFunc    OGLSD_Dispose;
  47 
  48 extern void
  49     OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
  50 
  51 jboolean surfaceCreationFailed = JNI_FALSE;
  52 
  53 #endif /* !HEADLESS */
  54 
  55 JNIEXPORT void JNICALL
  56 Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
  57                                               jobject gc,
  58                                               jobject peer, jlong aData)
  59 {
  60 #ifndef HEADLESS
  61     gc = (*env)->NewGlobalRef(env, gc);
  62     if (gc == NULL) {
  63         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");

  64         return;
  65     }
  66 
  67     OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
  68                                                        sizeof(OGLSDOps));
  69     if (oglsdo == NULL) {
  70         (*env)->DeleteGlobalRef(env, gc);
  71         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
  72         return;
  73     }
  74     // later the graphicsConfig will be used for deallocation of oglsdo
  75     oglsdo->graphicsConfig = gc;
  76 
  77     GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
  78 
  79     if (glxsdo == NULL) {
  80         JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
  81         return;
  82     }
  83 
  84     J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
  85 
  86     oglsdo->privOps = glxsdo;
  87 
  88     oglsdo->sdOps.Lock       = OGLSD_Lock;
  89     oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
  90     oglsdo->sdOps.Unlock     = OGLSD_Unlock;
  91     oglsdo->sdOps.Dispose    = OGLSD_Dispose;
  92 
  93     oglsdo->drawableType = OGLSD_UNDEFINED;
  94     oglsdo->activeBuffer = GL_FRONT;
  95     oglsdo->needsInit = JNI_TRUE;
  96 
  97     if (peer != NULL) {
  98         glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
  99                                               "getContentWindow", "()J").j;
 100     } else {
 101         glxsdo->window = 0;
 102     }


 157         J2dRlsTraceLn(J2D_TRACE_ERROR,
 158                       "GLXSD_MakeCurrentToScratch: context is null");
 159         return JNI_FALSE;
 160     }
 161 
 162     ctxInfo = (GLXCtxInfo *)oglc->ctxInfo;
 163     if (!j2d_glXMakeContextCurrent(awt_display,
 164                                    ctxInfo->scratchSurface,
 165                                    ctxInfo->scratchSurface,
 166                                    ctxInfo->context))
 167     {
 168         J2dRlsTraceLn(J2D_TRACE_ERROR,
 169                       "GLXSD_MakeCurrentToScratch: could not make current");
 170         return JNI_FALSE;
 171     }
 172 
 173     return JNI_TRUE;
 174 }
 175 
 176 /**

































 177  * Makes the given GraphicsConfig's context current to its associated
 178  * "scratch" surface.  If there is a problem making the context current,
 179  * this method will return NULL; otherwise, returns a pointer to the
 180  * OGLContext that is associated with the given GraphicsConfig.
 181  */
 182 OGLContext *
 183 OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
 184 {
 185     GLXGraphicsConfigInfo *glxInfo =
 186         (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
 187     OGLContext *oglc;
 188 
 189     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
 190 
 191     if (glxInfo == NULL) {
 192         J2dRlsTraceLn(J2D_TRACE_ERROR,
 193                       "OGLSD_SetScratchContext: glx config info is null");
 194         return NULL;
 195     }
 196 


< prev index next >