< prev index next >

src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c

Print this page




 253  * Signature: (Ljava/lang/Object;I)V
 254  */
 255 JNIEXPORT void JNICALL
 256 Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd,
 257                                            jobject peer,
 258                                            jobject graphicsConfig, jint depth)
 259 {
 260 #ifndef HEADLESS
 261     X11SDOps *xsdo = (X11SDOps*)SurfaceData_InitOps(env, xsd, sizeof(X11SDOps));
 262     jboolean hasException;
 263     if (xsdo == NULL) {
 264         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
 265         return;
 266     }
 267     xsdo->sdOps.Lock = X11SD_Lock;
 268     xsdo->sdOps.GetRasInfo = X11SD_GetRasInfo;
 269     xsdo->sdOps.Unlock = X11SD_Unlock;
 270     xsdo->sdOps.Dispose = X11SD_Dispose;
 271     xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
 272     xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;
 273     xsdo->widget = NULL;
 274     if (peer != NULL) {
 275         xsdo->drawable = JNU_CallMethodByName(env, &hasException, peer, "getWindow", "()J").j;
 276         if (hasException) {
 277             return;
 278         }
 279     } else {
 280         xsdo->drawable = 0;
 281     }
 282     xsdo->depth = depth;
 283     xsdo->dgaAvailable = dgaAvailable;
 284     xsdo->isPixmap = JNI_FALSE;
 285     xsdo->bitmask = 0;
 286     xsdo->bgPixel = 0;
 287     xsdo->isBgInitialized = JNI_FALSE;
 288 #ifdef MITSHM
 289     xsdo->shmPMData.shmSegInfo = NULL;
 290     xsdo->shmPMData.xRequestSent = JNI_FALSE;
 291     xsdo->shmPMData.pmSize = 0;
 292     xsdo->shmPMData.usingShmPixmap = JNI_FALSE;
 293     xsdo->shmPMData.pixmap = 0;


1070                       xpriv->img, 0, 0, x, y, w, h);
1071 #endif /* MITSHM */
1072 
1073             (*pJDgaInfo->pXRequestSent)(env, xsdo->dgaDev, drawable);
1074         }
1075         X11SD_DisposeOrCacheXImage(xpriv->img);
1076         xpriv->img = (XImage *)NULL;
1077     }
1078     /* the background pixel is not valid anymore */
1079     if (xpriv->lockFlags & SD_LOCK_WRITE) {
1080         xsdo->isBgInitialized = JNI_FALSE;
1081     }
1082     xpriv->lockType = X11SD_LOCK_UNLOCKED;
1083     AWT_UNLOCK();
1084 }
1085 
1086 static int
1087 X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
1088                  X11SDOps *xsdo)
1089 {
1090     Position x1=0, y1=0, x2=0, y2=0;
1091     int tmpx, tmpy;
1092     Window tmpchild;
1093 
1094     Window window = (Window)(xsdo->drawable); /* is always a Window */
1095     XWindowAttributes winAttr;
1096 
1097     Status status = XGetWindowAttributes(awt_display, window, &winAttr);
1098     if (status == 0) {
1099         /* Failure, X window no longer valid. */
1100         return FALSE;
1101     }
1102     if (!XTranslateCoordinates(awt_display, window,
1103                                RootWindowOfScreen(winAttr.screen),
1104                                0, 0, &tmpx, &tmpy, &tmpchild)) {
1105         return FALSE;
1106     }
1107 
1108     x1 = -(x1 + tmpx);
1109     y1 = -(y1 + tmpy);
1110 




 253  * Signature: (Ljava/lang/Object;I)V
 254  */
 255 JNIEXPORT void JNICALL
 256 Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd,
 257                                            jobject peer,
 258                                            jobject graphicsConfig, jint depth)
 259 {
 260 #ifndef HEADLESS
 261     X11SDOps *xsdo = (X11SDOps*)SurfaceData_InitOps(env, xsd, sizeof(X11SDOps));
 262     jboolean hasException;
 263     if (xsdo == NULL) {
 264         JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
 265         return;
 266     }
 267     xsdo->sdOps.Lock = X11SD_Lock;
 268     xsdo->sdOps.GetRasInfo = X11SD_GetRasInfo;
 269     xsdo->sdOps.Unlock = X11SD_Unlock;
 270     xsdo->sdOps.Dispose = X11SD_Dispose;
 271     xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
 272     xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;

 273     if (peer != NULL) {
 274         xsdo->drawable = JNU_CallMethodByName(env, &hasException, peer, "getWindow", "()J").j;
 275         if (hasException) {
 276             return;
 277         }
 278     } else {
 279         xsdo->drawable = 0;
 280     }
 281     xsdo->depth = depth;
 282     xsdo->dgaAvailable = dgaAvailable;
 283     xsdo->isPixmap = JNI_FALSE;
 284     xsdo->bitmask = 0;
 285     xsdo->bgPixel = 0;
 286     xsdo->isBgInitialized = JNI_FALSE;
 287 #ifdef MITSHM
 288     xsdo->shmPMData.shmSegInfo = NULL;
 289     xsdo->shmPMData.xRequestSent = JNI_FALSE;
 290     xsdo->shmPMData.pmSize = 0;
 291     xsdo->shmPMData.usingShmPixmap = JNI_FALSE;
 292     xsdo->shmPMData.pixmap = 0;


1069                       xpriv->img, 0, 0, x, y, w, h);
1070 #endif /* MITSHM */
1071 
1072             (*pJDgaInfo->pXRequestSent)(env, xsdo->dgaDev, drawable);
1073         }
1074         X11SD_DisposeOrCacheXImage(xpriv->img);
1075         xpriv->img = (XImage *)NULL;
1076     }
1077     /* the background pixel is not valid anymore */
1078     if (xpriv->lockFlags & SD_LOCK_WRITE) {
1079         xsdo->isBgInitialized = JNI_FALSE;
1080     }
1081     xpriv->lockType = X11SD_LOCK_UNLOCKED;
1082     AWT_UNLOCK();
1083 }
1084 
1085 static int
1086 X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
1087                  X11SDOps *xsdo)
1088 {
1089     short x1=0, y1=0, x2=0, y2=0;
1090     int tmpx, tmpy;
1091     Window tmpchild;
1092 
1093     Window window = (Window)(xsdo->drawable); /* is always a Window */
1094     XWindowAttributes winAttr;
1095 
1096     Status status = XGetWindowAttributes(awt_display, window, &winAttr);
1097     if (status == 0) {
1098         /* Failure, X window no longer valid. */
1099         return FALSE;
1100     }
1101     if (!XTranslateCoordinates(awt_display, window,
1102                                RootWindowOfScreen(winAttr.screen),
1103                                0, 0, &tmpx, &tmpy, &tmpchild)) {
1104         return FALSE;
1105     }
1106 
1107     x1 = -(x1 + tmpx);
1108     y1 = -(y1 + tmpy);
1109 


< prev index next >