< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/java2d/opengl/CGLGraphicsConfig.m

Print this page
rev 54096 : 8259651: [macOS] Replace JNF_COCOA_ENTER/EXIT macros
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion


  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 #import "sun_java2d_opengl_CGLGraphicsConfig.h"
  27 
  28 #import "CGLGraphicsConfig.h"
  29 #import "CGLSurfaceData.h"
  30 #import "ThreadUtilities.h"

  31 
  32 #import <stdlib.h>
  33 #import <string.h>
  34 #import <ApplicationServices/ApplicationServices.h>
  35 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  36 
  37 #pragma mark -
  38 #pragma mark "--- Mac OS X specific methods for GL pipeline ---"
  39 
  40 /**
  41  * Disposes all memory and resources associated with the given
  42  * CGLGraphicsConfigInfo (including its native OGLContext data).
  43  */
  44 void
  45 OGLGC_DestroyOGLGraphicsConfig(jlong pConfigInfo)
  46 {
  47     J2dTraceLn(J2D_TRACE_INFO, "OGLGC_DestroyOGLGraphicsConfig");
  48 
  49     CGLGraphicsConfigInfo *cglinfo =
  50         (CGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
  51     if (cglinfo == NULL) {
  52         J2dRlsTraceLn(J2D_TRACE_ERROR,
  53                       "OGLGC_DestroyOGLGraphicsConfig: info is null");
  54         return;
  55     }


 177     return JNI_TRUE;
 178 }
 179 
 180 
 181 /**
 182  * Determines whether the CGL pipeline can be used for a given GraphicsConfig
 183  * provided its screen number and visual ID.  If the minimum requirements are
 184  * met, the native CGLGraphicsConfigInfo structure is initialized for this
 185  * GraphicsConfig with the necessary information (pixel format, etc.)
 186  * and a pointer to this structure is returned as a jlong.  If
 187  * initialization fails at any point, zero is returned, indicating that CGL
 188  * cannot be used for this GraphicsConfig (we should fallback on an existing
 189  * 2D pipeline).
 190  */
 191 JNIEXPORT jlong JNICALL
 192 Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
 193     (JNIEnv *env, jclass cglgc,
 194      jint displayID, jint pixfmt, jint swapInterval)
 195 {
 196   jlong ret = 0L;
 197   JNF_COCOA_ENTER(env);
 198   NSMutableArray * retArray = [NSMutableArray arrayWithCapacity:3];
 199   [retArray addObject: [NSNumber numberWithInt: (int)displayID]];
 200   [retArray addObject: [NSNumber numberWithInt: (int)pixfmt]];
 201   [retArray addObject: [NSNumber numberWithInt: (int)swapInterval]];
 202   if ([NSThread isMainThread]) {
 203       [GraphicsConfigUtil _getCGLConfigInfo: retArray];
 204   } else {
 205       [GraphicsConfigUtil performSelectorOnMainThread: @selector(_getCGLConfigInfo:) withObject: retArray waitUntilDone: YES];
 206   }
 207   NSNumber * num = (NSNumber *)[retArray objectAtIndex: 0];
 208   ret = (jlong)[num longValue];
 209   JNF_COCOA_EXIT(env);
 210   return ret;
 211 }
 212 
 213 
 214 
 215 @implementation GraphicsConfigUtil
 216 + (void) _getCGLConfigInfo: (NSMutableArray *)argValue {
 217     AWT_ASSERT_APPKIT_THREAD;
 218 
 219     jint displayID = (jint)[(NSNumber *)[argValue objectAtIndex: 0] intValue];
 220     jint swapInterval = (jint)[(NSNumber *)[argValue objectAtIndex: 2] intValue];
 221     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 222     [argValue removeAllObjects];
 223 
 224     J2dRlsTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo");
 225 
 226     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 227 
 228     if (sharedContext == NULL) {
 229 




  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 #import "sun_java2d_opengl_CGLGraphicsConfig.h"
  27 
  28 #import "CGLGraphicsConfig.h"
  29 #import "CGLSurfaceData.h"
  30 #import "ThreadUtilities.h"
  31 #import "JNIUtilities.h"
  32 
  33 #import <stdlib.h>
  34 #import <string.h>
  35 #import <ApplicationServices/ApplicationServices.h>

  36 
  37 #pragma mark -
  38 #pragma mark "--- Mac OS X specific methods for GL pipeline ---"
  39 
  40 /**
  41  * Disposes all memory and resources associated with the given
  42  * CGLGraphicsConfigInfo (including its native OGLContext data).
  43  */
  44 void
  45 OGLGC_DestroyOGLGraphicsConfig(jlong pConfigInfo)
  46 {
  47     J2dTraceLn(J2D_TRACE_INFO, "OGLGC_DestroyOGLGraphicsConfig");
  48 
  49     CGLGraphicsConfigInfo *cglinfo =
  50         (CGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
  51     if (cglinfo == NULL) {
  52         J2dRlsTraceLn(J2D_TRACE_ERROR,
  53                       "OGLGC_DestroyOGLGraphicsConfig: info is null");
  54         return;
  55     }


 177     return JNI_TRUE;
 178 }
 179 
 180 
 181 /**
 182  * Determines whether the CGL pipeline can be used for a given GraphicsConfig
 183  * provided its screen number and visual ID.  If the minimum requirements are
 184  * met, the native CGLGraphicsConfigInfo structure is initialized for this
 185  * GraphicsConfig with the necessary information (pixel format, etc.)
 186  * and a pointer to this structure is returned as a jlong.  If
 187  * initialization fails at any point, zero is returned, indicating that CGL
 188  * cannot be used for this GraphicsConfig (we should fallback on an existing
 189  * 2D pipeline).
 190  */
 191 JNIEXPORT jlong JNICALL
 192 Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
 193     (JNIEnv *env, jclass cglgc,
 194      jint displayID, jint pixfmt, jint swapInterval)
 195 {
 196   jlong ret = 0L;
 197   JNI_COCOA_ENTER(env);
 198   NSMutableArray * retArray = [NSMutableArray arrayWithCapacity:3];
 199   [retArray addObject: [NSNumber numberWithInt: (int)displayID]];
 200   [retArray addObject: [NSNumber numberWithInt: (int)pixfmt]];
 201   [retArray addObject: [NSNumber numberWithInt: (int)swapInterval]];
 202   if ([NSThread isMainThread]) {
 203       [GraphicsConfigUtil _getCGLConfigInfo: retArray];
 204   } else {
 205       [GraphicsConfigUtil performSelectorOnMainThread: @selector(_getCGLConfigInfo:) withObject: retArray waitUntilDone: YES];
 206   }
 207   NSNumber * num = (NSNumber *)[retArray objectAtIndex: 0];
 208   ret = (jlong)[num longValue];
 209   JNI_COCOA_EXIT(env);
 210   return ret;
 211 }
 212 
 213 
 214 
 215 @implementation GraphicsConfigUtil
 216 + (void) _getCGLConfigInfo: (NSMutableArray *)argValue {
 217     AWT_ASSERT_APPKIT_THREAD;
 218 
 219     jint displayID = (jint)[(NSNumber *)[argValue objectAtIndex: 0] intValue];
 220     jint swapInterval = (jint)[(NSNumber *)[argValue objectAtIndex: 2] intValue];
 221     JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
 222     [argValue removeAllObjects];
 223 
 224     J2dRlsTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getCGLConfigInfo");
 225 
 226     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 227 
 228     if (sharedContext == NULL) {
 229 


< prev index next >