jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
author pchelko
Mon, 21 Jul 2014 21:41:11 +0400
changeset 25790 ca104ec6b3e7
parent 23304 bb48872f9326
permissions -rw-r--r--
8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c Reviewed-by: prr, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
17679
a81555868357 8005607: Recursion in J2DXErrHandler() Causes a Stack Overflow on Linux
alitvinov
parents: 15504
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1739
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1739
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1739
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1739
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1739
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "X11SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "Region.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/* Needed to define intptr_t */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "jni_util.h"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
    35
#include "jvm_md.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
static JDgaLibInfo DgaLibInfoStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
static JDgaLibInfo theJDgaInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
static JDgaLibInfo *pJDgaInfo = &DgaLibInfoStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * This file contains support code for loops using the SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * interface to talk to an X11 drawable from native code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
typedef struct _X11RIPrivate {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    jint                lockType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    jint                lockFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    XImage              *img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    int                 x, y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
} X11RIPrivate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
22597
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20425
diff changeset
    59
#define XSD_MAX(a,b) ((a) > (b) ? (a) : (b))
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20425
diff changeset
    60
#define XSD_MIN(a,b) ((a) < (b) ? (a) : (b))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
static LockFunc X11SD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
static GetRasInfoFunc X11SD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
static UnlockFunc X11SD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
static DisposeFunc X11SD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
static GetPixmapBgFunc X11SD_GetPixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 20425
diff changeset
    68
extern int XShmAttachXErrHandler(Display *display, XErrorEvent *xerr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
extern AwtGraphicsConfigDataPtr
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
    72
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                          X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
static int X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                            X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
static void X11SD_SwapBytes(X11SDOps *xsdo, XImage *img, int depth, int bpp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
static XImage * X11SD_GetImage(JNIEnv *env, X11SDOps *xsdo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                               SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                               jint lockFlags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
extern jfieldID validID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
static int nativeByteOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
static jboolean dgaAvailable = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
static jboolean useDGAWithPixmaps = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
static jclass xorCompClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
jint useMitShmExt = CANT_USE_MITSHM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
jint useMitShmPixmaps = CANT_USE_MITSHM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
jint forceSharedPixmaps = JNI_FALSE;
18184
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
    92
int mitShmPermissionMask = MITSHM_PERM_OWNER;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
/* Cached shared image, one for all surface datas. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
static XImage * cachedXImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
    99
jboolean XShared_initIDs(JNIEnv *env, jboolean allowShmPixmaps)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   100
{
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   101
#ifndef HEADLESS
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   102
   union {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   103
        char c[4];
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   104
        int i;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   105
    } endian;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   106
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   107
    endian.i = 0xff000000;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   108
    nativeByteOrder = (endian.c[0]) ? MSBFirst : LSBFirst;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   109
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   110
    dgaAvailable = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   111
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   112
    cachedXImage = NULL;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   113
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   114
    if (sizeof(X11RIPrivate) > SD_RASINFO_PRIVATE_SIZE) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   115
        JNU_ThrowInternalError(env, "Private RasInfo structure too large!");
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   116
        return JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   117
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   118
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   119
#ifdef MITSHM
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   120
    if (getenv("NO_AWT_MITSHM") == NULL &&
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   121
        getenv("NO_J2D_MITSHM") == NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   122
        char * force;
18184
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   123
        char * permission = getenv("J2D_MITSHM_PERMISSION");
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   124
        if (permission != NULL) {
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   125
            if (strcmp(permission, "common") == 0) {
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   126
                mitShmPermissionMask = MITSHM_PERM_COMMON;
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   127
            }
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   128
        }
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   129
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   130
        TryInitMITShm(env, &useMitShmExt, &useMitShmPixmaps);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   131
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   132
        if(allowShmPixmaps) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   133
          useMitShmPixmaps = (useMitShmPixmaps == CAN_USE_MITSHM);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   134
          force = getenv("J2D_PIXMAPS");
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   135
          if (force != NULL) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   136
              if (useMitShmPixmaps && (strcmp(force, "shared") == 0)) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   137
                  forceSharedPixmaps = JNI_TRUE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   138
              } else if (strcmp(force, "server") == 0) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   139
                  useMitShmPixmaps = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   140
              }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   141
          }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   142
        }else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   143
          useMitShmPixmaps = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   144
        }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   145
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   146
#endif /* MITSHM */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   147
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   148
#endif /* !HEADLESS */
15504
c13b899e2b15 8005052: [parfait] #416 X11SurfaceData.c UNINITIALISED OR MISSING RETURN VALUE
jgodinez
parents: 12171
diff changeset
   149
c13b899e2b15 8005052: [parfait] #416 X11SurfaceData.c UNINITIALISED OR MISSING RETURN VALUE
jgodinez
parents: 12171
diff changeset
   150
    return JNI_TRUE;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   151
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   152
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   153
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * Signature: (Ljava/lang/Class;Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
Java_sun_java2d_x11_X11SurfaceData_initIDs(JNIEnv *env, jclass xsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                                           jclass XORComp, jboolean tryDGA)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
#ifndef HEADLESS
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   164
  if(XShared_initIDs(env, JNI_TRUE))
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   165
  {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    void *lib = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    xorCompClass = (*env)->NewGlobalRef(env, XORComp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    if (tryDGA && (getenv("NO_J2D_DGA") == NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /* we use RTLD_NOW because of bug 4032715 */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 11093
diff changeset
   172
        lib = dlopen(JNI_LIB_NAME("sunwjdga"), RTLD_NOW);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   174
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    if (lib != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        JDgaStatus ret = JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        void *sym = dlsym(lib, "JDgaLibInit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (sym != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            theJDgaInfo.display = awt_display;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            ret = (*(JDgaLibInitFunc *)sym)(env, &theJDgaInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (ret == JDGA_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            pJDgaInfo = &theJDgaInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            dgaAvailable = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            useDGAWithPixmaps = (getenv("USE_DGA_PIXMAPS") != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            dlclose(lib);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            lib = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   193
  }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * Method:    isDrawableValid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
JNIEXPORT jboolean JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   203
Java_sun_java2d_x11_XSurfaceData_isDrawableValid(JNIEnv *env, jobject this)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    jboolean ret = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    X11SDOps *xsdo = X11SurfaceData_GetOps(env, this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    if (xsdo->drawable != 0 || X11SD_InitWindow(env, xsdo) == SD_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        ret = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
/*
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   221
 * Class: sun_java2d_x11_X11SurfaceData
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   222
 * Method: isShmPMAvailable
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   223
 * Signature: ()Z
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   224
 */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   225
JNIEXPORT jboolean JNICALL
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   226
Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable(JNIEnv *env, jobject this)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   227
{
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   228
#if defined(HEADLESS) || !defined(MITSHM)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   229
    return JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   230
#else
20425
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 18253
diff changeset
   231
    return (jboolean)useMitShmPixmaps;
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   232
#endif /* HEADLESS, MITSHM */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   233
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   234
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   235
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 * Method:    isDgaAvailable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
#if defined(HEADLESS) || defined(__linux__)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    return dgaAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * Method:    initOps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * Signature: (Ljava/lang/Object;I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
JNIEXPORT void JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   256
Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                           jobject peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                                           jobject graphicsConfig, jint depth)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    X11SDOps *xsdo = (X11SDOps*)SurfaceData_InitOps(env, xsd, sizeof(X11SDOps));
20425
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 18253
diff changeset
   262
    jboolean hasException;
5938
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5580
diff changeset
   263
    if (xsdo == NULL) {
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5580
diff changeset
   264
        JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5580
diff changeset
   265
        return;
c93e51904f68 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these)
igor
parents: 5580
diff changeset
   266
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    xsdo->sdOps.Lock = X11SD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    xsdo->sdOps.GetRasInfo = X11SD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    xsdo->sdOps.Unlock = X11SD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    xsdo->sdOps.Dispose = X11SD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    xsdo->widget = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    if (peer != NULL) {
20425
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 18253
diff changeset
   275
        xsdo->drawable = JNU_CallMethodByName(env, &hasException, peer, "getWindow", "()J").j;
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 18253
diff changeset
   276
        if (hasException) {
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 18253
diff changeset
   277
            return;
5964c0fc5cc0 8025294: [parfait] JNI-related warnings from b107 for jdk.src.solaris.native.sun.java2d.x11
jchen
parents: 18253
diff changeset
   278
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        xsdo->drawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    xsdo->depth = depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    xsdo->dgaAvailable = dgaAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    xsdo->isPixmap = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    xsdo->bitmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    xsdo->bgPixel = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    xsdo->isBgInitialized = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    xsdo->shmPMData.shmSegInfo = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    xsdo->shmPMData.xRequestSent = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    xsdo->shmPMData.pmSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    xsdo->shmPMData.usingShmPixmap = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    xsdo->shmPMData.pixmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    xsdo->shmPMData.shmPixmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    xsdo->shmPMData.numBltsSinceRead = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    xsdo->shmPMData.pixelsReadSinceBlt = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    xsdo->shmPMData.numBltsThreshold = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    xsdo->configData = (AwtGraphicsConfigDataPtr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        JNU_GetLongFieldAsPtr(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                              graphicsConfig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                              x11GraphicsConfigIDs.aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    if (xsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        JNU_ThrowNullPointerException(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                                      "Native GraphicsConfig data block missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    if (depth > 12) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        xsdo->pixelmask = (xsdo->configData->awt_visInfo.red_mask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                           xsdo->configData->awt_visInfo.green_mask |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                           xsdo->configData->awt_visInfo.blue_mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    } else if (depth == 12) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        xsdo->pixelmask = 0xfff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        xsdo->pixelmask = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   318
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   319
    xsdo->xrPic = None;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
 * Method:    flushNativeSurface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
JNIEXPORT void JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   329
Java_sun_java2d_x11_XSurfaceData_flushNativeSurface(JNIEnv *env, jobject xsd)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    SurfaceDataOps *ops = SurfaceData_GetOps(env, xsd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    if (ops != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        X11SD_Dispose(env, ops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
JNIEXPORT X11SDOps * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
X11SurfaceData_GetOps(JNIEnv *env, jobject sData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    SurfaceDataOps *ops = SurfaceData_GetOps(env, sData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    if (ops != NULL && ops->Lock != X11SD_Lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        SurfaceData_ThrowInvalidPipeException(env, "not an X11 SurfaceData");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        ops = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    return (X11SDOps *) ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
 * Method for disposing X11SD-specific data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
X11SD_Dispose(JNIEnv *env, SurfaceDataOps *ops)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /* ops is assumed non-null as it is checked in SurfaceData_DisposeOps */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    X11SDOps * xsdo = (X11SDOps*)ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    xsdo->invalid = JNI_TRUE;
8507
78ea3ec4877b 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5
ceisserer
parents: 8356
diff changeset
   369
78ea3ec4877b 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5
ceisserer
parents: 8356
diff changeset
   370
    if (xsdo->xrPic != None) {
78ea3ec4877b 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5
ceisserer
parents: 8356
diff changeset
   371
        XRenderFreePicture(awt_display, xsdo->xrPic);
78ea3ec4877b 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5
ceisserer
parents: 8356
diff changeset
   372
        xsdo->xrPic = None;
78ea3ec4877b 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5
ceisserer
parents: 8356
diff changeset
   373
     }
78ea3ec4877b 6974985: Jave2Demo threw exceptions when xrender enabled in OEL5.5
ceisserer
parents: 8356
diff changeset
   374
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    if (xsdo->isPixmap == JNI_TRUE && xsdo->drawable != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        if (xsdo->shmPMData.shmSegInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            X11SD_DropSharedSegment(xsdo->shmPMData.shmSegInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            xsdo->shmPMData.shmSegInfo = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        if (xsdo->shmPMData.pixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            XFreePixmap(awt_display, xsdo->shmPMData.pixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            xsdo->shmPMData.pixmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (xsdo->shmPMData.shmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            XFreePixmap(awt_display, xsdo->shmPMData.shmPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            xsdo->shmPMData.shmPixmap = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        XFreePixmap(awt_display, xsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        xsdo->drawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    if (xsdo->bitmask != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        XFreePixmap(awt_display, xsdo->bitmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        xsdo->bitmask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    if (xsdo->javaGC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        XFreeGC(awt_display, xsdo->javaGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        xsdo->javaGC = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    if (xsdo->cachedGC != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        XFreeGC(awt_display, xsdo->cachedGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        xsdo->cachedGC = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   406
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   407
    if(xsdo->xrPic != None) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   408
      XRenderFreePicture(awt_display, xsdo->xrPic);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   409
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   410
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
 * Method:    setInvalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
JNIEXPORT void JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   420
Java_sun_java2d_x11_XSurfaceData_setInvalid(JNIEnv *env, jobject xsd)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    X11SDOps *xsdo = (X11SDOps *) SurfaceData_GetOps(env, xsd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    if (xsdo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        xsdo->invalid = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   431
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   432
jboolean XShared_initSurface(JNIEnv *env, X11SDOps *xsdo, jint depth, jint width, jint height, jlong drawable)
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   433
{
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   434
#ifndef HEADLESS
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   435
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   436
    if (drawable != (jlong)0) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   437
        /* Double-buffering */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   438
        xsdo->drawable = drawable;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   439
        xsdo->isPixmap = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   440
    } else {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   441
        xsdo->isPixmap = JNI_TRUE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   442
        /* REMIND: workaround for bug 4420220 on pgx32 boards:
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   443
           don't use DGA with pixmaps unless USE_DGA_PIXMAPS is set.
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   444
         */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   445
        xsdo->dgaAvailable = useDGAWithPixmaps;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   446
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   447
        xsdo->pmWidth = width;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   448
        xsdo->pmHeight = height;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   449
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   450
#ifdef MITSHM
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   451
        xsdo->shmPMData.pmSize = width * height * depth;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   452
        xsdo->shmPMData.pixelsReadThreshold = width * height / 8;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   453
        if (forceSharedPixmaps) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   454
            AWT_LOCK();
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   455
            xsdo->drawable = X11SD_CreateSharedPixmap(xsdo);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   456
            AWT_UNLOCK();
25790
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   457
            JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   458
            if (xsdo->drawable) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   459
                xsdo->shmPMData.usingShmPixmap = JNI_TRUE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   460
                xsdo->shmPMData.shmPixmap = xsdo->drawable;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   461
                return JNI_TRUE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   462
            }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   463
        }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   464
#endif /* MITSHM */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   465
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   466
        AWT_LOCK();
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   467
        xsdo->drawable =
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   468
            XCreatePixmap(awt_display,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   469
                          RootWindow(awt_display,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   470
                                     xsdo->configData->awt_visInfo.screen),
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   471
                          width, height, depth);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   472
        AWT_UNLOCK();
25790
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   473
        JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   474
#ifdef MITSHM
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   475
        xsdo->shmPMData.usingShmPixmap = JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   476
        xsdo->shmPMData.pixmap = xsdo->drawable;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   477
#endif /* MITSHM */
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   478
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   479
    if (xsdo->drawable == 0) {
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   480
        JNU_ThrowOutOfMemoryError(env,
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   481
                                  "Can't create offscreen surface");
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   482
        return JNI_FALSE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   483
    }
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   484
15504
c13b899e2b15 8005052: [parfait] #416 X11SurfaceData.c UNINITIALISED OR MISSING RETURN VALUE
jgodinez
parents: 12171
diff changeset
   485
#endif /* !HEADLESS */
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   486
    return JNI_TRUE;
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   487
}
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   488
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   489
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
 * Method:    initSurface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
Java_sun_java2d_x11_X11SurfaceData_initSurface(JNIEnv *env, jclass xsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                                               jint depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                               jint width, jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                                               jlong drawable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    X11SDOps *xsdo = X11SurfaceData_GetOps(env, xsd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    if (xsdo->configData->awt_cmap == (Colormap)NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        awtJNI_CreateColorData(env, xsdo->configData, 1);
25790
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   509
        JNU_CHECK_EXCEPTION(env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /* color_data will be initialized in awtJNI_CreateColorData for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
       8-bit visuals */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    xsdo->cData = xsdo->configData->color_data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   515
    XShared_initSurface(env, xsdo, depth, width, height, drawable);
23304
bb48872f9326 8035287: gcc warnings compiling various libraries files
mikael
parents: 22600
diff changeset
   516
    xsdo->xrPic = None;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
void X11SD_DropSharedSegment(XShmSegmentInfo *shminfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    if (shminfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        XShmDetach(awt_display, shminfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        shmdt(shminfo->shmaddr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
/*      REMIND: we don't need shmctl(shminfo->shmid, IPC_RMID, 0); here. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
/*      Check X11SD_CreateSharedImage() for the explanation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
XImage* X11SD_CreateSharedImage(X11SDOps *xsdo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                                   jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    XImage *img = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    XShmSegmentInfo *shminfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    shminfo = malloc(sizeof(XShmSegmentInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    if (shminfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    memset(shminfo, 0, sizeof(XShmSegmentInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    img = XShmCreateImage(awt_display, xsdo->configData->awt_visInfo.visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                          xsdo->depth, ZPixmap, NULL, shminfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                          width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        free((void *)shminfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    shminfo->shmid =
18184
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   554
        shmget(IPC_PRIVATE, height * img->bytes_per_line,
75811cab0180 8001034: Memory management improvements
bae
parents: 15504
diff changeset
   555
               IPC_CREAT|mitShmPermissionMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    if (shminfo->shmid < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        J2dRlsTraceLn1(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                       "X11SD_SetupSharedSegment shmget has failed: %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                       strerror(errno));
12170
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   560
        free((void *)shminfo);
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   561
        XDestroyImage(img);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    if (shminfo->shmaddr == ((char *) -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        shmctl(shminfo->shmid, IPC_RMID, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        J2dRlsTraceLn1(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                       "X11SD_SetupSharedSegment shmat has failed: %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                       strerror(errno));
12170
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   571
        free((void *)shminfo);
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   572
        XDestroyImage(img);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    shminfo->readOnly = False;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 20425
diff changeset
   578
    resetXShmAttachFailed();
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 20425
diff changeset
   579
    EXEC_WITH_XERROR_HANDLER(XShmAttachXErrHandler,
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 20425
diff changeset
   580
                             XShmAttach(awt_display, shminfo));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * Once the XSync round trip has finished then we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * can get rid of the id so that this segment does not stick
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * around after we go away, holding system resources.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    shmctl(shminfo->shmid, IPC_RMID, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
21939
5169fd314636 8025775: JNI warnings in TryXShmAttach
alitvinov
parents: 20425
diff changeset
   589
    if (isXShmAttachFailed() == JNI_TRUE) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        J2dRlsTraceLn1(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                       "X11SD_SetupSharedSegment XShmAttach has failed: %s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                       strerror(errno));
12170
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   593
        shmdt(shminfo->shmaddr);
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   594
        free((void *)shminfo);
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
   595
        XDestroyImage(img);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    img->data = shminfo->shmaddr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    img->obdata = (char *)shminfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    return img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
XImage* X11SD_GetSharedImage(X11SDOps *xsdo, jint width, jint height,
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   606
                             jint maxWidth, jint maxHeight, jboolean readBits)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    XImage * retImage = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    if (cachedXImage != NULL &&
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   610
        X11SD_CachedXImageFits(width, height, maxWidth, maxHeight,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   611
                               xsdo->depth, readBits)) {
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   612
        /* sync so previous data gets flushed */
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   613
        XSync(awt_display, False);
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   614
        retImage = cachedXImage;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   615
        cachedXImage = (XImage *)NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    } else if (width * height * xsdo->depth > 0x10000) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        retImage = X11SD_CreateSharedImage(xsdo, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    return retImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
Drawable X11SD_CreateSharedPixmap(X11SDOps *xsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    XShmSegmentInfo *shminfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    XImage *img = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    Drawable pixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    int scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    int width = xsdo->pmWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    int height = xsdo->pmHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    if (xsdo->shmPMData.pmSize < 0x10000) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        /* only use shared mem pixmaps for relatively big images */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    /* need to create shared(!) image to get bytes_per_line */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    img = X11SD_CreateSharedImage(xsdo, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    scan = img->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    shminfo = (XShmSegmentInfo*)img->obdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    XFree(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    pixmap =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        XShmCreatePixmap(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                         RootWindow(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                                    xsdo->configData->awt_visInfo.screen),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                         shminfo->shmaddr, shminfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                         width, height, xsdo->depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    if (pixmap == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        X11SD_DropSharedSegment(shminfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    xsdo->shmPMData.shmSegInfo = shminfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    xsdo->shmPMData.bytesPerLine = scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    return pixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
void X11SD_PuntPixmap(X11SDOps *xsdo, jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    if (useMitShmPixmaps != CAN_USE_MITSHM || forceSharedPixmaps) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    /* we wouldn't be here if it's a shared pixmap, so no check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * for !usingShmPixmap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    xsdo->shmPMData.numBltsSinceRead = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    xsdo->shmPMData.pixelsReadSinceBlt += width * height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    if (xsdo->shmPMData.pixelsReadSinceBlt >
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        xsdo->shmPMData.pixelsReadThreshold) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        if (!xsdo->shmPMData.shmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            xsdo->shmPMData.shmPixmap =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                X11SD_CreateSharedPixmap(xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        if (xsdo->shmPMData.shmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            GC xgc = XCreateGC(awt_display, xsdo->shmPMData.shmPixmap, 0L, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            if (xgc != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                xsdo->shmPMData.usingShmPixmap = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                xsdo->drawable = xsdo->shmPMData.shmPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                XCopyArea(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                          xsdo->shmPMData.pixmap, xsdo->drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                          0, 0, xsdo->pmWidth, xsdo->pmHeight, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                xsdo->shmPMData.xRequestSent = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                XFreeGC(awt_display, xgc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
void X11SD_UnPuntPixmap(X11SDOps *xsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    if (useMitShmPixmaps != CAN_USE_MITSHM || forceSharedPixmaps) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    xsdo->shmPMData.pixelsReadSinceBlt = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    if (xsdo->shmPMData.numBltsSinceRead >=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        xsdo->shmPMData.numBltsThreshold)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        if (xsdo->shmPMData.usingShmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            if (!xsdo->shmPMData.pixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                xsdo->shmPMData.pixmap =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                    XCreatePixmap(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                                  RootWindow(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                                             xsdo->configData->awt_visInfo.screen),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                                  xsdo->pmWidth, xsdo->pmHeight, xsdo->depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            if (xsdo->shmPMData.pixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
                GC xgc = XCreateGC(awt_display, xsdo->shmPMData.pixmap, 0L, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                if (xgc != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                    xsdo->drawable = xsdo->shmPMData.pixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    XCopyArea(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                              xsdo->shmPMData.shmPixmap, xsdo->drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                              0, 0, xsdo->pmWidth, xsdo->pmHeight, 0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                    XFreeGC(awt_display, xgc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                    xsdo->shmPMData.xRequestSent = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                    xsdo->shmPMData.usingShmPixmap = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                    xsdo->shmPMData.numBltsThreshold *= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        xsdo->shmPMData.numBltsSinceRead++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
 * Determines if the cached image can be used for current operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
 * If the image is to be used to be read into by XShmGetImage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
 * it must be close enough to avoid excessive reading from the screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
 * otherwise it should just be at least the size requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
 */
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   740
jboolean X11SD_CachedXImageFits(jint width, jint height, jint maxWidth,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   741
                                jint maxHeight, jint depth, jboolean readBits)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /* we assume here that the cached image exists */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    jint imgWidth = cachedXImage->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    jint imgHeight = cachedXImage->height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    if (imgWidth < width || imgHeight < height || depth != cachedXImage->depth)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        /* doesn't fit if any of the cached image dimensions is smaller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
           or the depths are different */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    if (!readBits) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        /* Not reading from this image, so any image at least of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
           size requested will do */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   759
    if ((imgWidth < width + 64) && (imgHeight < height + 64)
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   760
         && imgWidth <= maxWidth && imgHeight <= maxHeight)
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   761
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        /* Cached image's width/height shouldn't be more than 64 pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
         * larger than requested, because the region in XShmGetImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
         * can't be specified and we don't want to read too much.
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   765
         * Furthermore it has to be smaller than maxWidth/Height
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   766
         * so drawables are not read out of bounds.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
   775
jint X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    if (xsdo->isPixmap == JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    xsdo->cData = xsdo->configData->color_data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    return SD_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
static jint X11SD_Lock(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                       SurfaceDataOps *ops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                       SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                       jint lockflags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    X11SDOps *xsdo = (X11SDOps *) ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    X11RIPrivate *xpriv = (X11RIPrivate *) &(pRasInfo->priv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    int ret = SD_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    if (xsdo->invalid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        SurfaceData_ThrowInvalidPipeException(env, "bounds changed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    xsdo->cData = xsdo->configData->color_data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    if (xsdo->drawable == 0 && X11SD_InitWindow(env, xsdo) == SD_FAILURE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    if ((lockflags & SD_LOCK_LUT) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        (xsdo->cData == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         xsdo->cData->awt_icmLUT == NULL))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        AWT_UNLOCK();
25790
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   811
        if (!(*env)->ExceptionCheck(env))
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   812
        {
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   813
             JNU_ThrowNullPointerException(env, "colormap lookup table");
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   814
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
    if ((lockflags & SD_LOCK_INVCOLOR) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        (xsdo->cData == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
         xsdo->cData->img_clr_tbl == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
         xsdo->cData->img_oda_red == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
         xsdo->cData->img_oda_green == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
         xsdo->cData->img_oda_blue == NULL))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        AWT_UNLOCK();
25790
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   825
        if (!(*env)->ExceptionCheck(env))
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   826
        {
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   827
             JNU_ThrowNullPointerException(env, "inverse colormap lookup table");
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   828
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    if ((lockflags & SD_LOCK_INVGRAY) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        (xsdo->cData == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
         xsdo->cData->pGrayInverseLutData == NULL))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        AWT_UNLOCK();
25790
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   836
        if (!(*env)->ExceptionCheck(env))
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   837
        {
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   838
            JNU_ThrowNullPointerException(env, "inverse gray lookup table");
ca104ec6b3e7 8046884: JNI exception pending in jdk/src/solaris/native/sun/java2d/x11: X11PMPLitLoops.c, X11SurfaceData.c
pchelko
parents: 23304
diff changeset
   839
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        return SD_FAILURE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    if (xsdo->dgaAvailable && (lockflags & (SD_LOCK_RD_WR))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        int dgaret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        dgaret = (*pJDgaInfo->pGetLock)(env, awt_display, &xsdo->dgaDev,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                                        xsdo->drawable, &xsdo->surfInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                                        pRasInfo->bounds.x1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                                        pRasInfo->bounds.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                                        pRasInfo->bounds.x2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                                        pRasInfo->bounds.y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        if (dgaret == JDGA_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            int wx = xsdo->surfInfo.window.lox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            int wy = xsdo->surfInfo.window.loy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            pRasInfo->bounds.x1 = xsdo->surfInfo.visible.lox - wx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
            pRasInfo->bounds.y1 = xsdo->surfInfo.visible.loy - wy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            pRasInfo->bounds.x2 = xsdo->surfInfo.visible.hix - wx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            pRasInfo->bounds.y2 = xsdo->surfInfo.visible.hiy - wy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            xpriv->lockType = X11SD_LOCK_BY_DGA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            xpriv->lockFlags = lockflags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            return SD_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        } else if (dgaret == JDGA_UNAVAILABLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            xsdo->dgaAvailable = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    if (lockflags & SD_LOCK_RD_WR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        if (lockflags & SD_LOCK_FASTEST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
            ret = SD_SLOWLOCK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        xpriv->lockType = X11SD_LOCK_BY_XIMAGE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        if (xsdo->isPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
            if (xsdo->shmPMData.usingShmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                xpriv->lockType = X11SD_LOCK_BY_SHMEM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            if (pRasInfo->bounds.x1 < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                pRasInfo->bounds.x1 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            if (pRasInfo->bounds.y1 < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                pRasInfo->bounds.y1 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            if (pRasInfo->bounds.x2 > xsdo->pmWidth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                pRasInfo->bounds.x2 = xsdo->pmWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            if (pRasInfo->bounds.y2 > xsdo->pmHeight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                pRasInfo->bounds.y2 = xsdo->pmHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        /* They didn't lock for anything - we won't give them anything */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        xpriv->lockType = X11SD_LOCK_BY_NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    xpriv->lockFlags = lockflags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    xpriv->img = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    /* AWT_UNLOCK() called in Unlock */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
static void X11SD_GetRasInfo(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                             SurfaceDataOps *ops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                             SurfaceDataRasInfo *pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
    X11SDOps *xsdo = (X11SDOps *) ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
    X11RIPrivate *xpriv = (X11RIPrivate *) &(pRasInfo->priv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
    jint lockFlags = xpriv->lockFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    jint depth = xsdo->depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    int mult = xsdo->configData->pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    if (xsdo->dgaAvailable &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        xpriv->lockType == X11SD_LOCK_BY_XIMAGE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        (lockFlags & SD_LOCK_FASTEST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        /* Try one more time to use DGA (now with smaller bounds)... */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        int dgaret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        dgaret = (*pJDgaInfo->pGetLock)(env, awt_display, &xsdo->dgaDev,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                                        xsdo->drawable, &xsdo->surfInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                                        pRasInfo->bounds.x1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                                        pRasInfo->bounds.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                                        pRasInfo->bounds.x2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                                        pRasInfo->bounds.y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        if (dgaret == JDGA_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            int wx = xsdo->surfInfo.window.lox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            int wy = xsdo->surfInfo.window.loy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            pRasInfo->bounds.x1 = xsdo->surfInfo.visible.lox - wx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            pRasInfo->bounds.y1 = xsdo->surfInfo.visible.loy - wy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            pRasInfo->bounds.x2 = xsdo->surfInfo.visible.hix - wx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            pRasInfo->bounds.y2 = xsdo->surfInfo.visible.hiy - wy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            xpriv->lockType = X11SD_LOCK_BY_DGA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        } else if (dgaret == JDGA_UNAVAILABLE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            xsdo->dgaAvailable = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    if (xpriv->lockType == X11SD_LOCK_BY_DGA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        int scan = xsdo->surfInfo.surfaceScan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        int wx = xsdo->surfInfo.window.lox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        int wy = xsdo->surfInfo.window.loy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        pRasInfo->rasBase =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            (void *)(((uintptr_t) xsdo->surfInfo.basePtr) + (scan*wy + wx) * mult);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        pRasInfo->pixelStride = mult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        pRasInfo->scanStride = scan * mult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    } else if (xpriv->lockType == X11SD_LOCK_BY_SHMEM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        if (xsdo->shmPMData.xRequestSent == JNI_TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            /* need to sync before using shared mem pixmap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
             if any x calls were issued for this pixmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            xsdo->shmPMData.xRequestSent = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        xpriv->x = pRasInfo->bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        xpriv->y = pRasInfo->bounds.y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        pRasInfo->rasBase = xsdo->shmPMData.shmSegInfo->shmaddr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        pRasInfo->pixelStride = mult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        pRasInfo->scanStride = xsdo->shmPMData.bytesPerLine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    } else if (xpriv->lockType == X11SD_LOCK_BY_XIMAGE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        int x, y, w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        x = pRasInfo->bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        y = pRasInfo->bounds.y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        w = pRasInfo->bounds.x2 - x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        h = pRasInfo->bounds.y2 - y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        xpriv->img = X11SD_GetImage(env, xsdo, &pRasInfo->bounds, lockFlags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        if (xpriv->img) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            int scan = xpriv->img->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            xpriv->x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            xpriv->y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            pRasInfo->rasBase = xpriv->img->data - x * mult - y * scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            pRasInfo->pixelStride = mult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            pRasInfo->scanStride = scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            pRasInfo->rasBase = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            pRasInfo->pixelStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
            pRasInfo->scanStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        /* They didn't lock for anything - we won't give them anything */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        pRasInfo->rasBase = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
        pRasInfo->pixelStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        pRasInfo->pixelBitOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        pRasInfo->scanStride = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
    if (lockFlags & SD_LOCK_LUT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
        pRasInfo->lutBase = (jint *) xsdo->cData->awt_icmLUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        pRasInfo->lutSize = xsdo->cData->awt_numICMcolors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        pRasInfo->lutBase = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        pRasInfo->lutSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    if (lockFlags & SD_LOCK_INVCOLOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
        pRasInfo->invColorTable = xsdo->cData->img_clr_tbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        pRasInfo->redErrTable = xsdo->cData->img_oda_red;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        pRasInfo->grnErrTable = xsdo->cData->img_oda_green;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
        pRasInfo->bluErrTable = xsdo->cData->img_oda_blue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        pRasInfo->invColorTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        pRasInfo->redErrTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        pRasInfo->grnErrTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        pRasInfo->bluErrTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    if (lockFlags & SD_LOCK_INVGRAY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        pRasInfo->invGrayTable = xsdo->cData->pGrayInverseLutData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        pRasInfo->invGrayTable = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
static void X11SD_Unlock(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                         SurfaceDataOps *ops,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                         SurfaceDataRasInfo *pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    X11SDOps *xsdo = (X11SDOps *) ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    X11RIPrivate *xpriv = (X11RIPrivate *) &(pRasInfo->priv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
    if (xpriv->lockType == X11SD_LOCK_BY_DGA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        (*pJDgaInfo->pReleaseLock)(env, xsdo->dgaDev, xsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    } else if (xpriv->lockType == X11SD_LOCK_BY_XIMAGE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
               xpriv->img != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        if (xpriv->lockFlags & SD_LOCK_WRITE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            int x = xpriv->x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            int y = xpriv->y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            int w = pRasInfo->bounds.x2 - x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            int h = pRasInfo->bounds.y2 - y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            Drawable drawable = xsdo->drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            GC xgc = xsdo->cachedGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            if (xgc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                xsdo->cachedGC = xgc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                    XCreateGC(awt_display, drawable, 0L, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            if (xpriv->img->byte_order != nativeByteOrder) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                /* switching bytes back in 24 and 32 bpp cases. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                /* For 16 bit XLib will switch for us.          */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                if (xsdo->depth > 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                    X11SD_SwapBytes(xsdo, xpriv->img, xsdo->depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                        xsdo->configData->awtImage->wsImageFormat.bits_per_pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            if (xpriv->img->obdata != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                XShmPutImage(awt_display, drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                             xpriv->img, 0, 0, x, y, w, h, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                XFlush(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                XPutImage(awt_display, drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                          xpriv->img, 0, 0, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            if (xsdo->shmPMData.usingShmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                xsdo->shmPMData.xRequestSent = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            XPutImage(awt_display, drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                      xpriv->img, 0, 0, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            (*pJDgaInfo->pXRequestSent)(env, xsdo->dgaDev, drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        X11SD_DisposeOrCacheXImage(xpriv->img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        xpriv->img = (XImage *)NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
    /* the background pixel is not valid anymore */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    if (xpriv->lockFlags & SD_LOCK_WRITE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        xsdo->isBgInitialized = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    xpriv->lockType = X11SD_LOCK_UNLOCKED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                 X11SDOps *xsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
    Position x1=0, y1=0, x2=0, y2=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    int tmpx, tmpy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    Window tmpchild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    Window window = (Window)(xsdo->drawable); /* is always a Window */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
    XWindowAttributes winAttr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    Status status = XGetWindowAttributes(awt_display, window, &winAttr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    if (status == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        /* Failure, X window no longer valid. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
    if (!XTranslateCoordinates(awt_display, window,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                               RootWindowOfScreen(winAttr.screen),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                               0, 0, &tmpx, &tmpy, &tmpchild)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    x1 = -(x1 + tmpx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    y1 = -(y1 + tmpy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    x2 = x1 + DisplayWidth(awt_display, xsdo->configData->awt_visInfo.screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    y2 = y1 + DisplayHeight(awt_display, xsdo->configData->awt_visInfo.screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
22597
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20425
diff changeset
  1105
    x1 = XSD_MAX(bounds->x1, x1);
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20425
diff changeset
  1106
    y1 = XSD_MAX(bounds->y1, y1);
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20425
diff changeset
  1107
    x2 = XSD_MIN(bounds->x2, x2);
7515a991bb37 8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents: 20425
diff changeset
  1108
    y2 = XSD_MIN(bounds->y2, y2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
    if ((x1 >= x2) || (y1 >= y2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
    b->x1 = x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    b->y1 = y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    b->x2 = x2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    b->y2 = y2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
 * x1, y1, x2, y2 - our rectangle in the coord system of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
 * the widget
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
 * px1, xy1, px2, py2 - current parent rect coords in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
 * same system
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, X11SDOps *xsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
X11SD_SwapBytes(X11SDOps *xsdo, XImage * img, int depth, int bpp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    int lengthInBytes = img->height * img->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    switch (depth) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    case 12:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    case 15:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
    case 16:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
            /* AB -> BA */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            unsigned short *d = (unsigned short *)img->data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
            unsigned short t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
            for (i = 0; i < lengthInBytes/2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                t = *d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                *d++ = (t >> 8) | (t << 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
            img->byte_order = nativeByteOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
            img->bitmap_bit_order = nativeByteOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
    case 24:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
            /* ABC -> CBA */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
            if (bpp == 24) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                // 4517321: Only swap if we have a "real" ThreeByteBgr
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                // visual (denoted by a red_mask of 0xff).  Due to ambiguity
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                // in the X11 spec, it appears that the swap is not required
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                // on Linux configurations that use 24 bits per pixel (denoted
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                // by a red_mask of 0xff0000).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
                if (xsdo->configData->awt_visInfo.red_mask == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                    int scan = img->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                    unsigned char *d = (unsigned char *) img->data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                    unsigned char *d1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                    unsigned int t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                    int j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                    for (i = 0; i < img->height; i++, d += scan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                        d1 = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                        for (j = 0; j < img->width; j++, d1 += 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                            /* not obvious opt from XLib src */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
                            t = d1[0]; d1[0] = d1[2]; d1[2] = t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        /* FALL THROUGH for 32-bit case */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    case 32:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
            /* ABCD -> DCBA */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
            unsigned int *d = (unsigned int *) img->data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
            unsigned int t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
            for (i = 0; i < lengthInBytes/4; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
                t = *d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                *d++ = ((t >> 24) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
                        ((t >> 8) & 0xff00) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                        ((t & 0xff00) << 8) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                        (t << 24));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
static XImage * X11SD_GetImage(JNIEnv *env, X11SDOps *xsdo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
                               SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                               jint lockFlags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
{
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1202
    int x, y, w, h, maxWidth, maxHeight;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    int scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    XImage * img = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    Drawable drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
    int depth = xsdo->depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    int mult = xsdo->configData->pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    int pad = (mult == 3) ? 32 : mult * 8; // pad must be 8, 16, or 32
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    jboolean readBits = lockFlags & SD_LOCK_NEED_PIXELS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    x = bounds->x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
    y = bounds->y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
    w = bounds->x2 - x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
    h = bounds->y2 - y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    if (useMitShmExt == CAN_USE_MITSHM) {
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1218
        if (xsdo->isPixmap) {
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1219
            if (readBits) {
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1220
                X11SD_PuntPixmap(xsdo, w, h);
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1221
            }
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1222
            maxWidth = xsdo->pmWidth;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1223
            maxHeight = xsdo->pmHeight;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1224
        } else {
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1225
            XWindowAttributes winAttr;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1226
            if (XGetWindowAttributes(awt_display,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1227
                                     (Window) xsdo->drawable, &winAttr) != 0) {
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1228
                maxWidth = winAttr.width;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1229
                maxHeight = winAttr.height;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1230
           } else {
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1231
                /* XGWA failed which isn't a good thing. Defaulting to using
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1232
                 * x,y means that after the subtraction of these we will use
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1233
                 * w=0, h=0 which is a reasonable default on such a failure.
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1234
                 */
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1235
                maxWidth = x;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1236
                maxHeight = y;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1237
           }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        }
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1239
        maxWidth -= x;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1240
        maxHeight -= y;
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1241
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
  1242
        img = X11SD_GetSharedImage(xsdo, w, h, maxWidth, maxHeight, readBits);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
    drawable = xsdo->drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
    if (readBits) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        if (img != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
            if (!XShmGetImage(awt_display, drawable, img, x, y, -1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
                X11SD_DisposeOrCacheXImage(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
                img = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
            img = XGetImage(awt_display, drawable, x, y, w, h, -1, ZPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
            if (img != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                img->obdata = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
        img = XGetImage(awt_display, drawable, x, y, w, h, -1, ZPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            SurfaceDataBounds temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
            img = XCreateImage(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
                               xsdo->configData->awt_visInfo.visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                               depth, ZPixmap, 0, NULL, w, h, pad, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
            if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
            scan = img->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            img->data = malloc(h * scan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
            if (img->data == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
                XFree(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
            if (xsdo->isPixmap == JNI_FALSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
                X11SD_ClipToRoot(&temp, bounds, xsdo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                XImage * temp_image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                temp_image = XGetImage(awt_display, drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                                       temp.x1, temp.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                                       temp.x2 - temp.x1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                                       temp.y2 - temp.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                                       -1, ZPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                if (temp_image == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
                    XGrabServer(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
                    if (X11SD_FindClip(&temp, bounds, xsdo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
                        temp_image =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
                            XGetImage(awt_display, drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                                      temp.x1, temp.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
                                      temp.x2 - temp.x1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
                                      temp.y2 - temp.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
                                      -1, ZPixmap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
                    XUngrabServer(awt_display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
                    /* Workaround for bug 5039226 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
                    XSync(awt_display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
                if (temp_image != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
                    int temp_scan, bytes_to_copy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
                    char * img_addr, * temp_addr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
                    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
                    img_addr = img->data +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
                        (temp.y1 - y) * scan + (temp.x1 - x) * mult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
                    temp_scan = temp_image->bytes_per_line;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
                    temp_addr = temp_image->data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
                    bytes_to_copy = (temp.x2 - temp.x1) * mult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
                    for (i = temp.y1; i < temp.y2; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
                        memcpy(img_addr, temp_addr, bytes_to_copy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
                        img_addr += scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
                        temp_addr += temp_scan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
                    XDestroyImage(temp_image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
            img->obdata = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
        if (depth > 8 && img->byte_order != nativeByteOrder) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
            X11SD_SwapBytes(xsdo, img, depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
                xsdo->configData->awtImage->wsImageFormat.bits_per_pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
         * REMIND: This might be better to move to the Lock function
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
         * to avoid lengthy I/O pauses inside what may be a critical
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
         * section.  This will be more critical when SD_LOCK_READ is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
         * implemented.  Another solution is to cache the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
         * to avoid reading for every operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
        if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
            img = XCreateImage(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
                               xsdo->configData->awt_visInfo.visual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
                               depth, ZPixmap, 0, NULL, w, h, pad, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
            if (img == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
            img->data = malloc(h * img->bytes_per_line);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
            if (img->data == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
                XFree(img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
            img->obdata = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
            if (img->byte_order != nativeByteOrder &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
                (depth == 15 || depth == 16 || depth == 12)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
                /* bytes will be swapped by XLib. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
                img->byte_order = nativeByteOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
                img->bitmap_bit_order = nativeByteOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    return img;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
void X11SD_DisposeOrCacheXImage(XImage * image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    /* REMIND: might want to check if the new image worth caching. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
    /* Cache only shared images. Passed image is assumed to be non-null. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    if (image->obdata != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
        if (cachedXImage != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
            X11SD_DisposeXImage(cachedXImage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
        cachedXImage = image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
        X11SD_DisposeXImage(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
void X11SD_DisposeXImage(XImage * image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
    if (image != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
        if (image->obdata != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
            X11SD_DropSharedSegment((XShmSegmentInfo*)image->obdata);
12170
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
  1380
            image->obdata = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
#endif /* MITSHM */
12170
bdd7741e16de 7151427: Fix the potential memory leak in error handling code in X11SurfaceData.c
littlee
parents: 11093
diff changeset
  1383
        XDestroyImage(image);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
static JDgaStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
    GetLockStub(JNIEnv *env, Display *display, void **dgaDev,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
                Drawable d, JDgaSurfaceInfo *pSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
                jint lox, jint loy, jint hix, jint hiy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
    return JDGA_UNAVAILABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
static JDgaStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
    ReleaseLockStub(JNIEnv *env, void *dgaDev, Drawable d)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    return JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    XRequestSentStub(JNIEnv *env, void *dgaDev, Drawable d)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
    LibDisposeStub(JNIEnv *env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
static JDgaLibInfo DgaLibInfoStub = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
    NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    GetLockStub,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
    ReleaseLockStub,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
    XRequestSentStub,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
    LibDisposeStub,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
void X11SD_LibDispose(JNIEnv *env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
    AWT_LOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
    if (pJDgaInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
        pJDgaInfo->pLibDispose(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
        pJDgaInfo = &DgaLibInfoStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
    AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
    if (xsdo->shmPMData.usingShmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        xsdo->shmPMData.xRequestSent = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
    (*pJDgaInfo->pXRequestSent)(env, xsdo->dgaDev, xsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    awt_output_flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
 * Sets transparent pixels in the pixmap to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
 * the specified solid background color and returns it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
 * Doesn't update source pixmap unless the color of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
 * transparent pixels is different from the specified color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
 * Note: The AWT lock must be held by the current thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
 * while calling into this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
static Drawable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
X11SD_GetPixmapWithBg(JNIEnv *env, X11SDOps *xsdo, jint pixel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
    /* assert AWT_CHECK_HAVE_LOCK(); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
    if (xsdo->invalid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        SurfaceData_ThrowInvalidPipeException(env, "bounds changed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
    /* the image doesn't have transparency, just return it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
    if (xsdo->bitmask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
        /* don't need to unlock here, the caller will unlock through
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
           the release call */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
        return xsdo->drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
    /* Check if current color of the transparent pixels is different
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
       from the specified one */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
    if (xsdo->isBgInitialized == JNI_FALSE || xsdo->bgPixel != pixel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
        GC srcGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        GC bmGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
        if (xsdo->drawable == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
        bmGC = XCreateGC(awt_display, xsdo->bitmask, 0, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
        if (bmGC == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        /* invert the bitmask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
        XSetFunction(awt_display, bmGC, GXxor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
        XSetForeground(awt_display, bmGC, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
        XFillRectangle(awt_display, xsdo->bitmask, bmGC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
                       0, 0, xsdo->pmWidth, xsdo->pmHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
        srcGC = XCreateGC(awt_display, xsdo->drawable, 0L, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
        if (srcGC == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
            XFreeGC(awt_display, bmGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
            AWT_UNLOCK();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
        /* set transparent pixels in the source pm to the bg color */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
        XSetClipMask(awt_display, srcGC, xsdo->bitmask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
        XSetForeground(awt_display, srcGC, pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
        XFillRectangle(awt_display, xsdo->drawable, srcGC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
                       0, 0, xsdo->pmWidth, xsdo->pmHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
        /* invert the mask back */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
        XFillRectangle(awt_display, xsdo->bitmask, bmGC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
                       0, 0, xsdo->pmWidth, xsdo->pmHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
        XFreeGC(awt_display, bmGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
        XFreeGC(awt_display, srcGC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        xsdo->bgPixel = pixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
        xsdo->isBgInitialized = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
    return xsdo->drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
X11SD_ReleasePixmapWithBg(JNIEnv *env, X11SDOps *xsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
    if (xsdo->shmPMData.usingShmPixmap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
        xsdo->shmPMData.xRequestSent = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
 * Method:    XCreateGC
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
 * Signature: (I)J
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
JNIEXPORT jlong JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
  1534
Java_sun_java2d_x11_XSurfaceData_XCreateGC
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
    (JNIEnv *env, jclass xsd, jlong pXSData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
    jlong ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
    X11SDOps *xsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XCreateGC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
    xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
    xsdo->javaGC = XCreateGC(awt_display, xsdo->drawable, 0, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
    ret = (jlong) xsdo->javaGC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
#else /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
    ret = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
 * Method:    XResetClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
 * Signature: (JIIIILsun/java2d/pipe/Region;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
JNIEXPORT void JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
  1564
Java_sun_java2d_x11_XSurfaceData_XResetClip
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
    (JNIEnv *env, jclass xsd, jlong xgc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XResetClip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
    XSetClipMask(awt_display, (GC) xgc, None);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
 * Method:    XSetClip
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
 * Signature: (JIIIILsun/java2d/pipe/Region;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
JNIEXPORT void JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
  1579
Java_sun_java2d_x11_XSurfaceData_XSetClip
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
    (JNIEnv *env, jclass xsd, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
     jint x1, jint y1, jint x2, jint y2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
     jobject complexclip)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
    int numrects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
    XRectangle rects[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
    XRectangle *pRect = rects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetClip");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
    numrects = RegionToYXBandedRectangles(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
            x1, y1, x2, y2, complexclip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
            &pRect, 256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    XSetClipRectangles(awt_display, (GC) xgc, 0, 0, pRect, numrects, YXBanded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
    if (pRect != rects) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
        free(pRect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
 * Method:    XSetCopyMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
    (JNIEnv *env, jclass xsd, jlong xgc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetCopyMode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
    XSetFunction(awt_display, (GC) xgc, GXcopy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
 * Method:    XSetXorMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
 * Signature: (J)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
Java_sun_java2d_x11_X11SurfaceData_XSetXorMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
    (JNIEnv *env, jclass xr, jlong xgc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetXorMode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
    XSetFunction(awt_display, (GC) xgc, GXxor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
 * Method:    XSetForeground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
 * Signature: (JI)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
Java_sun_java2d_x11_X11SurfaceData_XSetForeground
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
    (JNIEnv *env, jclass xsd, jlong xgc, jint pixel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetForeground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
    XSetForeground(awt_display, (GC) xgc, pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
 * Class:     sun_java2d_x11_X11SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
 * Method:    XSetGraphicsExposures
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
 * Signature: (JZ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
JNIEXPORT void JNICALL
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 1739
diff changeset
  1654
Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
    (JNIEnv *env, jclass xsd, jlong xgc, jboolean needExposures)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
    J2dTraceLn(J2D_TRACE_INFO, "in X11SurfaceData_XSetGraphicsExposures");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
    XSetGraphicsExposures(awt_display, (GC) xgc, needExposures ? True : False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
}