< prev index next >

modules/javafx.graphics/src/main/native-prism-sw/JJavaSurface.c

Print this page
rev 10250 : imported patch 9-cpu-1701.patch


 108     jclass classHandle;
 109 
 110     if (fieldIdsInitialized) {
 111         return JNI_TRUE;
 112     }
 113 
 114     retVal = JNI_FALSE;
 115 
 116     classHandle = (*env)->GetObjectClass(env, objectHandle);
 117 
 118     if (initializeFieldIds(fieldIds, env, classHandle, surfaceFieldDesc)) {
 119         retVal = JNI_TRUE;
 120         fieldIdsInitialized = JNI_TRUE;
 121     }
 122 
 123     return retVal;
 124 }
 125 
 126 static void
 127 surface_acquire(AbstractSurface* surface, JNIEnv* env, jobject surfaceHandle) {




 128     ((JavaSurface *) surface)->dataHandle = (*env)->GetObjectField(env, surfaceHandle,
 129                                 ((JavaSurface *) surface)->javaArrayFieldID);













 130     surface->super.data =
 131         (void *)(*env)->GetPrimitiveArrayCritical(env, ((JavaSurface *) surface)->dataHandle, NULL);
 132     if (surface->super.data == NULL) {

 133         setMemErrorFlag();
 134     }
 135 }
 136 
 137 static void
 138 surface_release(AbstractSurface* surface, JNIEnv* env, jobject surfaceHandle) {

 139     (*env)->ReleasePrimitiveArrayCritical(env, ((JavaSurface *) surface)->dataHandle, surface->super.data, 0);
 140     ((JavaSurface *) surface)->dataHandle = NULL;
 141 }
 142 
 143 static void
 144 surface_cleanup(AbstractSurface* surface) {
 145     // do nothing
 146 }


 108     jclass classHandle;
 109 
 110     if (fieldIdsInitialized) {
 111         return JNI_TRUE;
 112     }
 113 
 114     retVal = JNI_FALSE;
 115 
 116     classHandle = (*env)->GetObjectClass(env, objectHandle);
 117 
 118     if (initializeFieldIds(fieldIds, env, classHandle, surfaceFieldDesc)) {
 119         retVal = JNI_TRUE;
 120         fieldIdsInitialized = JNI_TRUE;
 121     }
 122 
 123     return retVal;
 124 }
 125 
 126 static void
 127 surface_acquire(AbstractSurface* surface, JNIEnv* env, jobject surfaceHandle) {
 128     jint width = 0;
 129     jint height = 0;
 130     jint dataArrayLength = 0;
 131 
 132     ((JavaSurface *) surface)->dataHandle = (*env)->GetObjectField(env, surfaceHandle,
 133                                 ((JavaSurface *) surface)->javaArrayFieldID);
 134 
 135     dataArrayLength = (*env)->GetArrayLength(env, ((JavaSurface *) surface)->dataHandle);
 136 
 137     width = surface->super.width;
 138     height = surface->super.height;
 139     if (width < 0 || height < 0 || dataArrayLength / width < height) {
 140         // Set data to NULL indicating invalid width and height
 141         surface->super.data = NULL;
 142         ((JavaSurface *) surface)->dataHandle = NULL;
 143         JNI_ThrowNew(env, "java/lang/IllegalArgumentException", "Out of range access of buffer");
 144         return;
 145     }
 146 
 147     surface->super.data =
 148         (void *)(*env)->GetPrimitiveArrayCritical(env, ((JavaSurface *) surface)->dataHandle, NULL);
 149     if (surface->super.data == NULL) {
 150         ((JavaSurface *) surface)->dataHandle = NULL;
 151         setMemErrorFlag();
 152     }
 153 }
 154 
 155 static void
 156 surface_release(AbstractSurface* surface, JNIEnv* env, jobject surfaceHandle) {
 157     if (surface->super.data == NULL) return;
 158     (*env)->ReleasePrimitiveArrayCritical(env, ((JavaSurface *) surface)->dataHandle, surface->super.data, 0);
 159     ((JavaSurface *) surface)->dataHandle = NULL;
 160 }
 161 
 162 static void
 163 surface_cleanup(AbstractSurface* surface) {
 164     // do nothing
 165 }
< prev index next >