jdk/src/java.desktop/unix/native/libsunwjdga/dgalock.c
author hannesw
Sat, 02 Sep 2017 14:26:29 +0200
changeset 47205 6ddad446ba23
parent 25859 3317bb8137f4
permissions -rw-r--r--
8169233: LengthNotWritableFilter extraElements.remove(index) has no effect Reviewed-by: sundar, jlaskey Contributed-by: priya.lakshmi.muthuswamy@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 12047
diff changeset
     2
 * Copyright (c) 1998, 2012, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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
#if sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/* #define DGA_DEBUG */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#ifdef DGA_DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#define DEBUG_PRINT(x)  printf x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define DEBUG_PRINT(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <dga/dga.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include <unistd.h>     /* ioctl */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include <sys/mman.h>   /* mmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include <sys/visual_io.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/* X11 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include <X11/Xlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#include "jni.h"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
    47
#include "jvm_md.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#include "jdga.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "jdgadevice.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define min(x, y)       ((x) < (y) ? (x) : (y))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define max(x, y)       ((x) > (y) ? (x) : (y))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
typedef struct _SolarisDgaLibInfo SolarisDgaLibInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
struct _SolarisDgaLibInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /* The general (non-device specific) information */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    unsigned long       count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    Drawable            drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    Drawable            virtual_drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /* The device specific memory mapping information */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    SolarisJDgaDevInfo  *devInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    SolarisJDgaWinInfo  winInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
typedef Bool IsXineramaOnFunc(Display *display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
typedef Drawable GetVirtualDrawableFunc(Display *display, Drawable drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define MAX_CACHED_INFO 16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
static SolarisDgaLibInfo cachedInfo[MAX_CACHED_INFO];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
static jboolean needsSync = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#define MAX_FB_TYPES 16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
static SolarisJDgaDevInfo devicesInfo[MAX_FB_TYPES];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
static IsXineramaOnFunc *IsXineramaOn = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
static GetVirtualDrawableFunc GetVirtualDrawableStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
Drawable GetVirtualDrawableStub(Display *display, Drawable drawable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    return drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
static GetVirtualDrawableFunc * GetVirtualDrawable = GetVirtualDrawableStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
static void Solaris_DGA_XineramaInit(Display *display) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
    88
    void * handle = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    if (IsXineramaOn == NULL) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
    90
        handle = dlopen(JNI_LIB_NAME("xinerama"), RTLD_NOW);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
    91
        if (handle != NULL) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            void *sym = dlsym(handle, "IsXineramaOn");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            IsXineramaOn = (IsXineramaOnFunc *)sym;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (IsXineramaOn != 0 && (*IsXineramaOn)(display)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                sym = dlsym(handle, "GetVirtualDrawable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                if (sym != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    GetVirtualDrawable = (GetVirtualDrawableFunc *)sym;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                dlclose(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
static SolarisJDgaDevInfo * getDevInfo(Dga_drawable dgadraw) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    void *handle = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    struct vis_identifier visid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    int fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    char libName[64];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    SolarisJDgaDevInfo *curDevInfo = devicesInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    fd = dga_draw_devfd(dgadraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    if (ioctl(fd, VIS_GETIDENTIFIER, &visid) != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        /* check in the devices list */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        for (i = 0; (i < MAX_FB_TYPES) && (curDevInfo->visidName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
             i++, curDevInfo++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            if (strcmp(visid.name, curDevInfo->visidName) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                /* we already have such a device, return it */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                return curDevInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (i == MAX_FB_TYPES) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            /* we're out of slots, return NULL */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        strcpy(libName, "libjdga");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        strcat(libName, visid.name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        strcat(libName,".so");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        /* we use RTLD_NOW because of bug 4032715 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        handle = dlopen(libName, RTLD_NOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        if (handle != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            JDgaStatus ret = JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            void *sym = dlsym(handle, "SolarisJDgaDevOpen");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            if (sym != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                curDevInfo->majorVersion = JDGALIB_MAJOR_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                curDevInfo->minorVersion = JDGALIB_MINOR_VERSION;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                ret = (*(SolarisJDgaDevOpenFunc *)sym)(curDevInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            if (ret == JDGA_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                curDevInfo->visidName = strdup(visid.name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                return curDevInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            dlclose(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
mmap_dgaDev(SolarisDgaLibInfo *libInfo, Dga_drawable dgadraw)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    if (!libInfo->devInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        libInfo->devInfo = getDevInfo(dgadraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (!libInfo->devInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            return JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    return (*libInfo->devInfo->function->winopen)(&(libInfo->winInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
unmap_dgaDev(SolarisDgaLibInfo *pDevInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    DEBUG_PRINT(("winclose() called\n"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
   (*pDevInfo->devInfo->function->winclose)(&(pDevInfo->winInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
Solaris_DGA_Available(Display *display)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    Window root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    int screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    Dga_drawable dgaDrawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    SolarisJDgaDevInfo * devinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /* return true if any screen supports DGA and we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     have a library for this type of framebuffer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    for (screen = 0; screen < XScreenCount(display); screen++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        root = RootWindow(display, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        dgaDrawable = XDgaGrabDrawable(display, root);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        if (dgaDrawable != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            devinfo = getDevInfo(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            XDgaUnGrabDrawable(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            if (devinfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
static JDgaLibInitFunc          Solaris_DGA_LibInit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
static JDgaGetLockFunc          Solaris_DGA_GetLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
static JDgaReleaseLockFunc      Solaris_DGA_ReleaseLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
static JDgaXRequestSentFunc     Solaris_DGA_XRequestSent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
static JDgaLibDisposeFunc       Solaris_DGA_LibDispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
static int firstInitDone = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
#pragma weak JDgaLibInit = Solaris_DGA_LibInit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
static JDgaStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
Solaris_DGA_LibInit(JNIEnv *env, JDgaLibInfo *ppInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /* Note: DGA_INIT can be called multiple times according to docs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    DEBUG_PRINT(("DGA_INIT called\n"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    DGA_INIT();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    if (!Solaris_DGA_Available(ppInfo->display)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    Solaris_DGA_XineramaInit(ppInfo->display);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    ppInfo->pGetLock = Solaris_DGA_GetLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    ppInfo->pReleaseLock = Solaris_DGA_ReleaseLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    ppInfo->pXRequestSent = Solaris_DGA_XRequestSent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    ppInfo->pLibDispose = Solaris_DGA_LibDispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    return JDGA_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
static JDgaStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
Solaris_DGA_GetLock(JNIEnv *env, Display *display, void **dgaDev,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                        Drawable drawable, JDgaSurfaceInfo *pSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                        jint lox, jint loy, jint hix, jint hiy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    SolarisDgaLibInfo *pDevInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    SolarisDgaLibInfo *pCachedInfo = cachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    int vis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    int dlox, dloy, dhix, dhiy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    int type, site;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    unsigned long k;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    Drawable prev_virtual_drawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    Dga_drawable dgaDrawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    if (*dgaDev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (((SolarisDgaLibInfo *)(*dgaDev))->drawable != drawable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            *dgaDev = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    if (*dgaDev == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        pCachedInfo = cachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        for (i = 0 ; (i < MAX_CACHED_INFO) && (pCachedInfo->drawable) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
             i++, pCachedInfo++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            if (pCachedInfo->drawable == drawable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                *dgaDev = pCachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (*dgaDev == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            if (i < MAX_CACHED_INFO) { /* slot can be used for new info */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                 *dgaDev = pCachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                pCachedInfo = cachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                /* find the least used slot but does not handle an overflow of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                   the counter */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                for (i = 0, k = 0xffffffff; i < MAX_CACHED_INFO ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                     i++, pCachedInfo++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    if (k > pCachedInfo->count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                        k = pCachedInfo->count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                        *dgaDev = pCachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                    pCachedInfo->count = 0; /* reset all counters */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                pCachedInfo = *dgaDev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                if (pCachedInfo->winInfo.dgaDraw != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                    XDgaUnGrabDrawable(pCachedInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                pCachedInfo->winInfo.dgaDraw = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                /* the slot might be used for another device */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                pCachedInfo->devInfo = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    pDevInfo = *dgaDev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    pDevInfo->drawable = drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    prev_virtual_drawable = pDevInfo->virtual_drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    pDevInfo->virtual_drawable = GetVirtualDrawable(display, drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    if (pDevInfo->virtual_drawable == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        /* this usually means that the drawable is spanned across
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
           screens in xinerama mode - we can't handle this for now */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        return JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        /* check if the drawable has been moved to another screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
           since last time */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        if (pDevInfo->winInfo.dgaDraw != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            pDevInfo->virtual_drawable != prev_virtual_drawable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            XDgaUnGrabDrawable(pDevInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            pDevInfo->winInfo.dgaDraw = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    pDevInfo->count++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    if (pDevInfo->winInfo.dgaDraw == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        pDevInfo->winInfo.dgaDraw = XDgaGrabDrawable(display, pDevInfo->virtual_drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        if (pDevInfo->winInfo.dgaDraw == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            DEBUG_PRINT(("DgaGrabDrawable failed for 0x%08x\n", drawable));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            return JDGA_UNAVAILABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        type = dga_draw_type(pDevInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if (type != DGA_DRAW_PIXMAP &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            mmap_dgaDev(pDevInfo, pDevInfo->winInfo.dgaDraw) != JDGA_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            DEBUG_PRINT(("memory map failed for 0x%08x (depth = %d)\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                         drawable, dga_draw_depth(pDevInfo->winInfo.dgaDraw)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            XDgaUnGrabDrawable(pDevInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            pDevInfo->winInfo.dgaDraw = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            return JDGA_UNAVAILABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        type = dga_draw_type(pDevInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    if (needsSync) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        XSync(display, False);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        needsSync = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    dgaDrawable = pDevInfo->winInfo.dgaDraw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    DGA_DRAW_LOCK(dgaDrawable, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    site = dga_draw_site(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    if (type == DGA_DRAW_PIXMAP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        if (site == DGA_SITE_SYSTEM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            pDevInfo->winInfo.mapDepth = dga_draw_depth(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            pDevInfo->winInfo.mapAddr = dga_draw_address(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            dga_draw_bbox(dgaDrawable, &dlox, &dloy, &dhix, &dhiy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            pDevInfo->winInfo.mapWidth = dhix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            pDevInfo->winInfo.mapHeight = dhiy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            if (pDevInfo->winInfo.mapDepth == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                pDevInfo->winInfo.mapLineStride = dga_draw_linebytes(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                pDevInfo->winInfo.mapPixelStride = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                pDevInfo->winInfo.mapLineStride = dga_draw_linebytes(dgaDrawable)/4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                pDevInfo->winInfo.mapPixelStride = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            XDgaUnGrabDrawable(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            pDevInfo->winInfo.dgaDraw = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            return JDGA_UNAVAILABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        if (site == DGA_SITE_NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            DEBUG_PRINT(("zombie drawable = 0x%08x\n", dgaDrawable));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            DGA_DRAW_UNLOCK(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            unmap_dgaDev(pDevInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            XDgaUnGrabDrawable(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            pDevInfo->winInfo.dgaDraw = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            return JDGA_UNAVAILABLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        dga_draw_bbox(dgaDrawable, &dlox, &dloy, &dhix, &dhiy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    /* get the screen address of the drawable */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    dhix += dlox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    dhiy += dloy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    DEBUG_PRINT(("window at (%d, %d) => (%d, %d)\n", dlox, dloy, dhix, dhiy));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    pSurface->window.lox = dlox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    pSurface->window.loy = dloy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    pSurface->window.hix = dhix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    pSurface->window.hiy = dhiy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            /* translate rendering coordinates relative to device bbox */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    lox += dlox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    loy += dloy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    hix += dlox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    hiy += dloy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    DEBUG_PRINT(("render at (%d, %d) => (%d, %d)\n", lox, loy, hix, hiy));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    vis = dga_draw_visibility(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    switch (vis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    case DGA_VIS_UNOBSCURED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        pSurface->visible.lox = max(dlox, lox);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        pSurface->visible.loy = max(dloy, loy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        pSurface->visible.hix = min(dhix, hix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        pSurface->visible.hiy = min(dhiy, hiy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        DEBUG_PRINT(("unobscured vis at (%d, %d) => (%d, %d)\n",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                     pSurface->visible.lox,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                     pSurface->visible.loy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                     pSurface->visible.hix,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                     pSurface->visible.hiy));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    case DGA_VIS_PARTIALLY_OBSCURED: {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         * fix for #4305271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         * the dga_draw_clipinfo call returns the clipping bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
         * in short ints, but use only full size ints for all comparisons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        short *ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        int x0, y0, x1, y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        int cliplox, cliploy, cliphix, cliphiy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
         * iterate to find out whether the clipped blit draws to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
         * single clipping rectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        cliplox = cliphix = lox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        cliploy = cliphiy = loy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        ptr = dga_draw_clipinfo(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        while (*ptr != DGA_Y_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            y0 = *ptr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            y1 = *ptr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            DEBUG_PRINT(("DGA y range loy=%d hiy=%d\n", y0, y1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            if (y0 < loy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                y0 = loy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            if (y1 > hiy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                y1 = hiy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            while (*ptr != DGA_X_EOL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                x0 = *ptr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                x1 = *ptr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                DEBUG_PRINT(("  DGA x range lox=%d hix=%d\n", x0, x1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                if (x0 < lox) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                    x0 = lox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                if (x1 > hix) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                    x1 = hix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                if (x0 < x1 && y0 < y1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    if (cliploy == cliphiy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                /* First rectangle intersection */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                        cliplox = x0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                        cliploy = y0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                        cliphix = x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                        cliphiy = y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                                /* Can we merge this rect with previous? */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                        if (cliplox == x0 && cliphix == x1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                            cliploy <= y1 && cliphiy >= y0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                                /* X ranges match, Y ranges touch */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                /* => absorb the Y ranges together */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                                cliploy = min(cliploy, y0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                                cliphiy = max(cliphiy, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                            } else if (cliploy == y0 && cliphiy == y1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                       cliplox <= x1 && cliphix >= x0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                                    /* Y ranges match, X ranges touch */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                    /* => Absorb the X ranges together */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                                    cliplox = min(cliplox, x0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                                    cliphix = max(cliphix, x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                                    /* Assertion: any other combination */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                                    /* means non-rectangular intersect */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                    DGA_DRAW_UNLOCK(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                    return JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            ptr++; /* advance past DGA_X_EOL */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        DEBUG_PRINT(("DGA drawable fits\n"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        pSurface->visible.lox = cliplox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        pSurface->visible.loy = cliploy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        pSurface->visible.hix = cliphix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        pSurface->visible.hiy = cliphiy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    case DGA_VIS_FULLY_OBSCURED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        pSurface->visible.lox =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            pSurface->visible.hix = lox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        pSurface->visible.loy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            pSurface->visible.hiy = loy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        DEBUG_PRINT(("fully obscured vis\n"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        DEBUG_PRINT(("unknown visibility = %d!\n", vis));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        DGA_DRAW_UNLOCK(dgaDrawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        return JDGA_FAILED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    pSurface->basePtr = pDevInfo->winInfo.mapAddr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    pSurface->surfaceScan = pDevInfo->winInfo.mapLineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    pSurface->surfaceWidth = pDevInfo->winInfo.mapWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    pSurface->surfaceHeight = pDevInfo->winInfo.mapHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    pSurface->surfaceDepth = pDevInfo->winInfo.mapDepth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    return JDGA_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
static JDgaStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
Solaris_DGA_ReleaseLock(JNIEnv *env, void *dgaDev, Drawable drawable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    SolarisDgaLibInfo *pDevInfo = (SolarisDgaLibInfo *) dgaDev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    if (pDevInfo != 0 && pDevInfo->drawable == drawable &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        pDevInfo->winInfo.dgaDraw != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        DGA_DRAW_UNLOCK(pDevInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    return JDGA_SUCCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
Solaris_DGA_XRequestSent(JNIEnv *env, void *dgaDev, Drawable drawable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    needsSync = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
Solaris_DGA_LibDispose(JNIEnv *env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    SolarisDgaLibInfo *pCachedInfo = cachedInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    SolarisJDgaDevInfo *curDevInfo = devicesInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    for (i = 0 ; (i < MAX_CACHED_INFO) && (pCachedInfo->drawable) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
         i++, pCachedInfo++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        if (pCachedInfo->winInfo.dgaDraw != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            if (dga_draw_type(pCachedInfo->winInfo.dgaDraw) == DGA_DRAW_WINDOW &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                pCachedInfo->winInfo.mapDepth != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                unmap_dgaDev(pCachedInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            XDgaUnGrabDrawable(pCachedInfo->winInfo.dgaDraw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            pCachedInfo->winInfo.dgaDraw = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    for (i = 0; (i < MAX_FB_TYPES) && (curDevInfo->visidName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
         i++, curDevInfo++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        curDevInfo->function->devclose(curDevInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        free(curDevInfo->visidName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
#endif