src/solaris/native/sun/java2d/x11/X11SurfaceData.c

Print this page
rev 8822 : 8024854: PPC64: Basic changes and files to build the class library on AIX
Reviewed-by: alanb, prr, sla, chegar, michaelm, mullan, art
Contributed-by: luchsh@linux.vnet.ibm.com, spoole@linux.vnet.ibm.com, thomas.stuefe@sap.com


  39 #include <dlfcn.h>
  40 
  41 #ifndef HEADLESS
  42 static JDgaLibInfo DgaLibInfoStub;
  43 static JDgaLibInfo theJDgaInfo;
  44 static JDgaLibInfo *pJDgaInfo = &DgaLibInfoStub;
  45 
  46 
  47 /**
  48  * This file contains support code for loops using the SurfaceData
  49  * interface to talk to an X11 drawable from native code.
  50  */
  51 
  52 typedef struct _X11RIPrivate {
  53     jint                lockType;
  54     jint                lockFlags;
  55     XImage              *img;
  56     int                 x, y;
  57 } X11RIPrivate;
  58 
  59 #define MAX(a,b) ((a) > (b) ? (a) : (b))
  60 #define MIN(a,b) ((a) < (b) ? (a) : (b))
  61 
  62 static LockFunc X11SD_Lock;
  63 static GetRasInfoFunc X11SD_GetRasInfo;
  64 static UnlockFunc X11SD_Unlock;
  65 static DisposeFunc X11SD_Dispose;
  66 static GetPixmapBgFunc X11SD_GetPixmapWithBg;
  67 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
  68 extern AwtGraphicsConfigDataPtr
  69     getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
  70 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
  71 
  72 static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
  73                           X11SDOps *xsdo);
  74 static int X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
  75                             X11SDOps *xsdo);
  76 static void X11SD_SwapBytes(X11SDOps *xsdo, XImage *img, int depth, int bpp);
  77 static XImage * X11SD_GetImage(JNIEnv *env, X11SDOps *xsdo,
  78                                SurfaceDataBounds *bounds,
  79                                jint lockFlags);
  80 


1073     Window window = (Window)(xsdo->drawable); /* is always a Window */
1074     XWindowAttributes winAttr;
1075 
1076     Status status = XGetWindowAttributes(awt_display, window, &winAttr);
1077     if (status == 0) {
1078         /* Failure, X window no longer valid. */
1079         return FALSE;
1080     }
1081     if (!XTranslateCoordinates(awt_display, window,
1082                                RootWindowOfScreen(winAttr.screen),
1083                                0, 0, &tmpx, &tmpy, &tmpchild)) {
1084         return FALSE;
1085     }
1086 
1087     x1 = -(x1 + tmpx);
1088     y1 = -(y1 + tmpy);
1089 
1090     x2 = x1 + DisplayWidth(awt_display, xsdo->configData->awt_visInfo.screen);
1091     y2 = y1 + DisplayHeight(awt_display, xsdo->configData->awt_visInfo.screen);
1092 
1093     x1 = MAX(bounds->x1, x1);
1094     y1 = MAX(bounds->y1, y1);
1095     x2 = MIN(bounds->x2, x2);
1096     y2 = MIN(bounds->y2, y2);
1097     if ((x1 >= x2) || (y1 >= y2)) {
1098         return FALSE;
1099     }
1100     b->x1 = x1;
1101     b->y1 = y1;
1102     b->x2 = x2;
1103     b->y2 = y2;
1104 
1105     return TRUE;
1106 }
1107 
1108 /*
1109  * x1, y1, x2, y2 - our rectangle in the coord system of
1110  * the widget
1111  * px1, xy1, px2, py2 - current parent rect coords in the
1112  * same system
1113  */
1114 static int
1115 X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, X11SDOps *xsdo)
1116 {




  39 #include <dlfcn.h>
  40 
  41 #ifndef HEADLESS
  42 static JDgaLibInfo DgaLibInfoStub;
  43 static JDgaLibInfo theJDgaInfo;
  44 static JDgaLibInfo *pJDgaInfo = &DgaLibInfoStub;
  45 
  46 
  47 /**
  48  * This file contains support code for loops using the SurfaceData
  49  * interface to talk to an X11 drawable from native code.
  50  */
  51 
  52 typedef struct _X11RIPrivate {
  53     jint                lockType;
  54     jint                lockFlags;
  55     XImage              *img;
  56     int                 x, y;
  57 } X11RIPrivate;
  58 
  59 #define XSD_MAX(a,b) ((a) > (b) ? (a) : (b))
  60 #define XSD_MIN(a,b) ((a) < (b) ? (a) : (b))
  61 
  62 static LockFunc X11SD_Lock;
  63 static GetRasInfoFunc X11SD_GetRasInfo;
  64 static UnlockFunc X11SD_Unlock;
  65 static DisposeFunc X11SD_Dispose;
  66 static GetPixmapBgFunc X11SD_GetPixmapWithBg;
  67 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
  68 extern AwtGraphicsConfigDataPtr
  69     getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
  70 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
  71 
  72 static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
  73                           X11SDOps *xsdo);
  74 static int X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
  75                             X11SDOps *xsdo);
  76 static void X11SD_SwapBytes(X11SDOps *xsdo, XImage *img, int depth, int bpp);
  77 static XImage * X11SD_GetImage(JNIEnv *env, X11SDOps *xsdo,
  78                                SurfaceDataBounds *bounds,
  79                                jint lockFlags);
  80 


1073     Window window = (Window)(xsdo->drawable); /* is always a Window */
1074     XWindowAttributes winAttr;
1075 
1076     Status status = XGetWindowAttributes(awt_display, window, &winAttr);
1077     if (status == 0) {
1078         /* Failure, X window no longer valid. */
1079         return FALSE;
1080     }
1081     if (!XTranslateCoordinates(awt_display, window,
1082                                RootWindowOfScreen(winAttr.screen),
1083                                0, 0, &tmpx, &tmpy, &tmpchild)) {
1084         return FALSE;
1085     }
1086 
1087     x1 = -(x1 + tmpx);
1088     y1 = -(y1 + tmpy);
1089 
1090     x2 = x1 + DisplayWidth(awt_display, xsdo->configData->awt_visInfo.screen);
1091     y2 = y1 + DisplayHeight(awt_display, xsdo->configData->awt_visInfo.screen);
1092 
1093     x1 = XSD_MAX(bounds->x1, x1);
1094     y1 = XSD_MAX(bounds->y1, y1);
1095     x2 = XSD_MIN(bounds->x2, x2);
1096     y2 = XSD_MIN(bounds->y2, y2);
1097     if ((x1 >= x2) || (y1 >= y2)) {
1098         return FALSE;
1099     }
1100     b->x1 = x1;
1101     b->y1 = y1;
1102     b->x2 = x2;
1103     b->y2 = y2;
1104 
1105     return TRUE;
1106 }
1107 
1108 /*
1109  * x1, y1, x2, y2 - our rectangle in the coord system of
1110  * the widget
1111  * px1, xy1, px2, py2 - current parent rect coords in the
1112  * same system
1113  */
1114 static int
1115 X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, X11SDOps *xsdo)
1116 {