jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h
author prr
Mon, 22 Jul 2013 12:52:15 -0700
changeset 19006 fcda25164f7d
parent 11103 e156ce2c4a96
permissions -rw-r--r--
7196866: CTW fails on all Solaris platforms Reviewed-by: prr, jrose, twisti, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8356
diff changeset
     2
 * Copyright (c) 2000, 2011, 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
#include "SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "awt_p.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <jdga.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
11103
e156ce2c4a96 7115400: jdk 8 awt-gate build fails in headless toolkit on solaris.
serb
parents: 9035
diff changeset
    33
#ifdef HEADLESS
e156ce2c4a96 7115400: jdk 8 awt-gate build fails in headless toolkit on solaris.
serb
parents: 9035
diff changeset
    34
#include "GLXGraphicsConfig.h"
e156ce2c4a96 7115400: jdk 8 awt-gate build fails in headless toolkit on solaris.
serb
parents: 9035
diff changeset
    35
#endif
e156ce2c4a96 7115400: jdk 8 awt-gate build fails in headless toolkit on solaris.
serb
parents: 9035
diff changeset
    36
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
    37
#include <X11/extensions/Xrender.h>
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
    38
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * This include file contains support declarations for loops using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * X11 extended SurfaceData interface to talk to an X11 drawable from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * native code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define X11SDOps void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#else /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
typedef struct _X11SDOps X11SDOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * This function returns an X11 Drawable which transparent pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * (if there are any) were set to the specified color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * The env parameter should be the JNIEnv of the surrounding JNI context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * The xsdo parameter should be a pointer to the ops object upon which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * this function is being invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * The pixel parameter should be a color to which the transparent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * pixels of the image should be se set to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
typedef Drawable GetPixmapBgFunc(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                                 X11SDOps *xsdo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                                 jint pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * This function releases the lock set by GetPixmapBg
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * function of the indicated X11SDOps structure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * The env parameter should be the JNIEnv of the surrounding JNI context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * The ops parameter should be a pointer to the ops object upon which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * this function is being invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
typedef void ReleasePixmapBgFunc(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                 X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    XShmSegmentInfo     *shmSegInfo;    /* Shared Memory Segment Info */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    jint                bytesPerLine;   /* needed for ShMem lock */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    jboolean            xRequestSent;   /* true if x request is sent w/o XSync */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    jint                pmSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    jboolean            usingShmPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    Drawable            pixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    Drawable            shmPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    jint                numBltsSinceRead;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    jint                pixelsReadSinceBlt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    jint                pixelsReadThreshold;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    jint                numBltsThreshold;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
} ShmPixmapData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
struct _X11SDOps {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    SurfaceDataOps      sdOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    GetPixmapBgFunc     *GetPixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    ReleasePixmapBgFunc *ReleasePixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    jboolean            invalid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    jboolean            isPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    jobject             peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    Drawable            drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    Widget              widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    GC                  javaGC;        /* used for Java-level GC validation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    GC                  cachedGC;      /* cached for use in X11SD_Unlock() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    jint                depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    jint                pixelmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    JDgaSurfaceInfo     surfInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    AwtGraphicsConfigData *configData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    ColorData           *cData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    jboolean            dgaAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    void                *dgaDev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    Pixmap              bitmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    jint                bgPixel;       /* bg pixel for the pixmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    jboolean            isBgInitialized; /* whether the bg pixel is valid */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    jint                pmWidth;       /* width, height of the */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    jint                pmHeight;      /* pixmap */
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   119
    Picture             xrPic;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    ShmPixmapData       shmPMData;     /* data for switching between shm/nonshm pixmaps*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define X11SD_LOCK_UNLOCKED     0       /* surface is not locked */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define X11SD_LOCK_BY_NULL      1       /* surface locked for NOP */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#define X11SD_LOCK_BY_XIMAGE    2       /* surface locked by Get/PutImage */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#define X11SD_LOCK_BY_DGA       3       /* surface locked by DGA */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#define X11SD_LOCK_BY_SHMEM     4       /* surface locked by ShMemExt */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#ifdef MITSHM
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   132
XImage * X11SD_GetSharedImage       (X11SDOps *xsdo,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   133
                                     jint width, jint height,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   134
                                     jint maxWidth, jint maxHeight,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   135
                                     jboolean readBits);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
XImage * X11SD_CreateSharedImage    (X11SDOps *xsdo, jint width, jint height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
Drawable X11SD_CreateSharedPixmap   (X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
void     X11SD_DropSharedSegment    (XShmSegmentInfo *shminfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
void     X11SD_PuntPixmap           (X11SDOps *xsdo, jint width, jint height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
void     X11SD_UnPuntPixmap         (X11SDOps *xsdo);
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   141
jboolean X11SD_CachedXImageFits     (jint width, jint height,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   142
                                     jint maxWidth, jint maxHeight,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   143
                                     jint depth, jboolean readBits);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
XImage * X11SD_GetCachedXImage      (jint width, jint height, jboolean readBits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
#endif /* MITSHM */
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   146
jint     X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
void     X11SD_DisposeOrCacheXImage (XImage * image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
void     X11SD_DisposeXImage(XImage * image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
void     X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   152
jboolean XShared_initIDs(JNIEnv *env, jboolean allowShmPixmaps);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   153
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: 2
diff changeset
   154
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * This function returns a pointer to a native X11SDOps structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * for accessing the indicated X11 SurfaceData Java object.  It
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * verifies that the indicated SurfaceData object is an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * of X11SurfaceData before returning and will return NULL if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * wrong SurfaceData object is being accessed.  This function will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * throw the appropriate Java exception if it returns NULL so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * the caller can simply return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 * Note to callers:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 *      This function uses JNI methods so it is important that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *      caller not have any outstanding GetPrimitiveArrayCritical or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *      GetStringCritical locks which have not been released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 *      The caller may continue to use JNI methods after this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 *      is called since this function will not leave any outstanding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 *      JNI Critical locks unreleased.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
JNIEXPORT X11SDOps * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
X11SurfaceData_GetOps(JNIEnv *env, jobject sData);