jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
changeset 17679 a81555868357
parent 15504 c13b899e2b15
child 18253 4323a5fe8bc4
equal deleted inserted replaced
17678:ec24ad8455ec 17679:a81555868357
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    63 static GetRasInfoFunc X11SD_GetRasInfo;
    63 static GetRasInfoFunc X11SD_GetRasInfo;
    64 static UnlockFunc X11SD_Unlock;
    64 static UnlockFunc X11SD_Unlock;
    65 static DisposeFunc X11SD_Dispose;
    65 static DisposeFunc X11SD_Dispose;
    66 static GetPixmapBgFunc X11SD_GetPixmapWithBg;
    66 static GetPixmapBgFunc X11SD_GetPixmapWithBg;
    67 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
    67 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
    68 extern int J2DXErrHandler(Display *display, XErrorEvent *xerr);
       
    69 extern AwtGraphicsConfigDataPtr
    68 extern AwtGraphicsConfigDataPtr
    70     getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
    69     getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
    71 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
    70 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
    72 
    71 
    73 static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
    72 static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
   519 XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
   518 XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
   520                                    jint width, jint height)
   519                                    jint width, jint height)
   521 {
   520 {
   522     XImage *img = NULL;
   521     XImage *img = NULL;
   523     XShmSegmentInfo *shminfo;
   522     XShmSegmentInfo *shminfo;
       
   523     JNIEnv* env;
       
   524     jboolean xShmAttachResult;
   524 
   525 
   525     shminfo = malloc(sizeof(XShmSegmentInfo));
   526     shminfo = malloc(sizeof(XShmSegmentInfo));
   526     if (shminfo == NULL) {
   527     if (shminfo == NULL) {
   527         return NULL;
   528         return NULL;
   528     }
   529     }
   557         return NULL;
   558         return NULL;
   558     }
   559     }
   559 
   560 
   560     shminfo->readOnly = False;
   561     shminfo->readOnly = False;
   561 
   562 
   562     resetXShmAttachFailed();
   563     env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_2);
   563     EXEC_WITH_XERROR_HANDLER(J2DXErrHandler,
   564     xShmAttachResult = TryXShmAttach(env, awt_display, shminfo);
   564                              XShmAttach(awt_display, shminfo));
       
   565 
   565 
   566     /*
   566     /*
   567      * Once the XSync round trip has finished then we
   567      * Once the XSync round trip has finished then we
   568      * can get rid of the id so that this segment does not stick
   568      * can get rid of the id so that this segment does not stick
   569      * around after we go away, holding system resources.
   569      * around after we go away, holding system resources.
   570      */
   570      */
   571     shmctl(shminfo->shmid, IPC_RMID, 0);
   571     shmctl(shminfo->shmid, IPC_RMID, 0);
   572 
   572 
   573     if (isXShmAttachFailed() == JNI_TRUE) {
   573     if (xShmAttachResult == JNI_FALSE) {
   574         J2dRlsTraceLn1(J2D_TRACE_ERROR,
   574         J2dRlsTraceLn1(J2D_TRACE_ERROR,
   575                        "X11SD_SetupSharedSegment XShmAttach has failed: %s",
   575                        "X11SD_SetupSharedSegment XShmAttach has failed: %s",
   576                        strerror(errno));
   576                        strerror(errno));
   577         shmdt(shminfo->shmaddr);
   577         shmdt(shminfo->shmaddr);
   578         free((void *)shminfo);
   578         free((void *)shminfo);