< prev index next >

src/share/native/sun/java2d/opengl/OGLSurfaceData.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, 2012, 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
  23  * questions.
  24  */
  25 
  26 #ifndef HEADLESS
  27 
  28 #include <stdlib.h>
  29 
  30 #include "sun_java2d_opengl_OGLSurfaceData.h"
  31 
  32 #include "jlong.h"
  33 #include "jni_util.h"
  34 #include "OGLSurfaceData.h"
  35 
  36 /**
  37  * The following methods are implemented in the windowing system (i.e. GLX
  38  * and WGL) source files.
  39  */
  40 extern jlong OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo);
  41 extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo);
  42 extern void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo);
  43 
  44 void OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
  45 
  46 /**
  47  * This table contains the "pixel formats" for all system memory surfaces
  48  * that OpenGL is capable of handling, indexed by the "PF_" constants defined
  49  * in OGLSurfaceData.java.  These pixel formats contain information that is
  50  * passed to OpenGL when copying from a system memory ("Sw") surface to
  51  * an OpenGL "Surface" (via glDrawPixels()) or "Texture" (via glTexImage2D()).
  52  */
  53 OGLPixelFormat PixelFormats[] = {
  54     { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
  55       4, 1, 0,                                     }, /* 0 - IntArgb      */
  56     { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
  57       4, 1, 1,                                     }, /* 1 - IntArgbPre   */
  58     { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
  59       4, 0, 1,                                     }, /* 2 - IntRgb       */
  60     { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,


 576         if (oglsdo->fbobjectID != 0) {
 577             j2d_glDeleteFramebuffersEXT(1, &oglsdo->fbobjectID);
 578             oglsdo->fbobjectID = 0;
 579         }
 580     } else {
 581         // dispose windowing system resources (pbuffer, pixmap, etc)
 582         OGLSD_DestroyOGLSurface(env, oglsdo);
 583     }
 584 }
 585 
 586 /**
 587  * This is the implementation of the general DisposeFunc defined in
 588  * SurfaceData.h and used by the Disposer mechanism.  It first flushes all
 589  * native OpenGL resources and then frees any memory allocated within the
 590  * native OGLSDOps structure.
 591  */
 592 void
 593 OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
 594 {
 595     OGLSDOps *oglsdo = (OGLSDOps *)ops;
 596     jlong pConfigInfo = OGLSD_GetNativeConfigInfo(oglsdo);
 597 
 598     JNU_CallStaticMethodByName(env, NULL, "sun/java2d/opengl/OGLSurfaceData",
 599                                "dispose", "(JJ)V",
 600                                ptr_to_jlong(ops), pConfigInfo);



 601 }
 602 
 603 /**
 604  * This is the implementation of the general surface LockFunc defined in
 605  * SurfaceData.h.
 606  */
 607 jint
 608 OGLSD_Lock(JNIEnv *env,
 609            SurfaceDataOps *ops,
 610            SurfaceDataRasInfo *pRasInfo,
 611            jint lockflags)
 612 {
 613     JNU_ThrowInternalError(env, "OGLSD_Lock not implemented!");
 614     return SD_FAILURE;
 615 }
 616 
 617 /**
 618  * This is the implementation of the general GetRasInfoFunc defined in
 619  * SurfaceData.h.
 620  */


   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
  23  * questions.
  24  */
  25 
  26 #ifndef HEADLESS
  27 
  28 #include <stdlib.h>
  29 
  30 #include "sun_java2d_opengl_OGLSurfaceData.h"
  31 
  32 #include "jlong.h"
  33 #include "jni_util.h"
  34 #include "OGLSurfaceData.h"
  35 
  36 /**
  37  * The following methods are implemented in the windowing system (i.e. GLX
  38  * and WGL) source files.
  39  */

  40 extern jboolean OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo);
  41 extern void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo);
  42 
  43 void OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
  44 
  45 /**
  46  * This table contains the "pixel formats" for all system memory surfaces
  47  * that OpenGL is capable of handling, indexed by the "PF_" constants defined
  48  * in OGLSurfaceData.java.  These pixel formats contain information that is
  49  * passed to OpenGL when copying from a system memory ("Sw") surface to
  50  * an OpenGL "Surface" (via glDrawPixels()) or "Texture" (via glTexImage2D()).
  51  */
  52 OGLPixelFormat PixelFormats[] = {
  53     { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
  54       4, 1, 0,                                     }, /* 0 - IntArgb      */
  55     { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
  56       4, 1, 1,                                     }, /* 1 - IntArgbPre   */
  57     { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
  58       4, 0, 1,                                     }, /* 2 - IntRgb       */
  59     { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8,


 575         if (oglsdo->fbobjectID != 0) {
 576             j2d_glDeleteFramebuffersEXT(1, &oglsdo->fbobjectID);
 577             oglsdo->fbobjectID = 0;
 578         }
 579     } else {
 580         // dispose windowing system resources (pbuffer, pixmap, etc)
 581         OGLSD_DestroyOGLSurface(env, oglsdo);
 582     }
 583 }
 584 
 585 /**
 586  * This is the implementation of the general DisposeFunc defined in
 587  * SurfaceData.h and used by the Disposer mechanism.  It first flushes all
 588  * native OpenGL resources and then frees any memory allocated within the
 589  * native OGLSDOps structure.
 590  */
 591 void
 592 OGLSD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
 593 {
 594     OGLSDOps *oglsdo = (OGLSDOps *)ops;
 595     jobject graphicsConfig = oglsdo->graphicsConfig;
 596 
 597     JNU_CallStaticMethodByName(env, NULL, "sun/java2d/opengl/OGLSurfaceData",
 598                                "dispose",
 599                                "(JLsun/java2d/opengl/OGLGraphicsConfig;)V",
 600                                ptr_to_jlong(ops), graphicsConfig);
 601     (*env)->DeleteGlobalRef(env, graphicsConfig);
 602     oglsdo->graphicsConfig = NULL;
 603 }
 604 
 605 /**
 606  * This is the implementation of the general surface LockFunc defined in
 607  * SurfaceData.h.
 608  */
 609 jint
 610 OGLSD_Lock(JNIEnv *env,
 611            SurfaceDataOps *ops,
 612            SurfaceDataRasInfo *pRasInfo,
 613            jint lockflags)
 614 {
 615     JNU_ThrowInternalError(env, "OGLSD_Lock not implemented!");
 616     return SD_FAILURE;
 617 }
 618 
 619 /**
 620  * This is the implementation of the general GetRasInfoFunc defined in
 621  * SurfaceData.h.
 622  */


< prev index next >