jdk/src/solaris/native/sun/java2d/x11/X11Renderer.c
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 20425 5964c0fc5cc0
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2000, 2006, 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 "sun_java2d_x11_X11Renderer.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "X11SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "SpanIterator.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "ProcessPath.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <jlong.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define POLYTEMPSIZE    (int)(256 / sizeof(XPoint))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define ABS(n)          (((n) < 0) ? -(n) : (n))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#define MAX_SHORT 32767
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define MIN_SHORT (-32768)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define CLAMP_TO_SHORT(x) (((x) > MAX_SHORT)                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
                           ? MAX_SHORT                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                           : ((x) < MIN_SHORT)                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                               ? MIN_SHORT                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
                               : (x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define CLAMP_TO_USHORT(x)  (((x) > 65535) ? 65535 : ((x) < 0) ? 0 : (x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define DF_MAX_XPNTS 256
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    Drawable drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    GC      gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    XPoint  *pPoints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    XPoint  dfPoints[DF_MAX_XPNTS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    jint    npoints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    jint    maxpoints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
} XDrawHandlerData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define XDHD_INIT(PTR, _GC, DRAWABLE)                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    do {                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        (PTR)->pPoints = (PTR)->dfPoints;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        (PTR)->npoints = 0;                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        (PTR)->maxpoints = DF_MAX_XPNTS;                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        (PTR)->gc = (_GC);                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        (PTR)->drawable = (DRAWABLE);                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    } while(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define XDHD_RESET(PTR)                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    do {                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        (PTR)->npoints = 0;                                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    } while(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define XDHD_ADD_POINT(PTR, X, Y)                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    do {                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        XPoint* _pnts = (PTR)->pPoints;                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        jint _npnts = (PTR)->npoints;                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        if (_npnts >= (PTR)->maxpoints) {                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            jint newMax = (PTR)->maxpoints*2;                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            if ((PTR)->pPoints == (PTR)->dfPoints) {                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                (PTR)->pPoints = (XPoint*)malloc(newMax*sizeof(XPoint));    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                memcpy((PTR)->pPoints, _pnts, _npnts*sizeof(XPoint));       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            } else {                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                (PTR)->pPoints = (XPoint*)realloc(                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                    _pnts, newMax*sizeof(XPoint));                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            }                                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            _pnts = (PTR)->pPoints;                                         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            (PTR)->maxpoints = newMax;                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        _pnts += _npnts;                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        _pnts->x = X;                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        _pnts->y = Y;                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        (PTR)->npoints = _npnts + 1;                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    } while(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define XDHD_FREE_POINTS(PTR)                                               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    do {                                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if ((PTR)->pPoints != (PTR)->dfPoints) {                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            free((PTR)->pPoints);                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }                                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    } while(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
awt_drawArc(JNIEnv * env, jint drawable, GC xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            int startAngle, int endAngle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            int filled)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    int s, e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    if (w < 0 || h < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    if (endAngle >= 360 || endAngle <= -360) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        s = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        e = 360 * 64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        s = (startAngle % 360) * 64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        e = endAngle * 64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    if (filled == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        XDrawArc(awt_display, drawable, xgc, x, y, w, h, s, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        XFillArc(awt_display, drawable, xgc, x, y, w, h, s, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * Copy vertices from xcoordsArray and ycoordsArray to a buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * of XPoint structures, translating by transx and transy and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * collapsing empty segments out of the list as we go.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * The number of points to be converted should be guaranteed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * to be more than 2 by the caller and is stored at *pNpoints.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * The resulting number of uncollapsed unique translated vertices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * will be stored back into the location *pNpoints.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * The points pointer is guaranteed to be pointing to an area of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * memory large enough for POLYTEMPSIZE points and a larger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * area of memory is allocated (and returned) if that is not enough.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
static XPoint *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
transformPoints(JNIEnv * env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                jintArray xcoordsArray, jintArray ycoordsArray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                jint transx, jint transy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                XPoint * points, int *pNpoints, int close)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    int npoints = *pNpoints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    jint *xcoords, *ycoords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    xcoords = (jint *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        (*env)->GetPrimitiveArrayCritical(env, xcoordsArray, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    if (xcoords == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    ycoords = (jint *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        (*env)->GetPrimitiveArrayCritical(env, ycoordsArray, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    if (ycoords == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        (*env)->ReleasePrimitiveArrayCritical(env, xcoordsArray, xcoords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                                              JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    if (close) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        close = (xcoords[npoints - 1] != xcoords[0] ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                 ycoords[npoints - 1] != ycoords[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (close) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            npoints++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    if (npoints > POLYTEMPSIZE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        points = (XPoint *) malloc(sizeof(XPoint) * npoints);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    if (points != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        int in, out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        int oldx = CLAMP_TO_SHORT(xcoords[0] + transx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        int oldy = CLAMP_TO_SHORT(ycoords[0] + transy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        points[0].x = oldx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        points[0].y = oldy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (close) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            npoints--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        for (in = 1, out = 1; in < npoints; in++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            int newx = CLAMP_TO_SHORT(xcoords[in] + transx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            int newy = CLAMP_TO_SHORT(ycoords[in] + transy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            if (newx != oldx || newy != oldy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                points[out].x = newx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                points[out].y = newy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                out++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                oldx = newx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                oldy = newy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (out == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            points[1].x = oldx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            points[1].y = oldy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            out = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        } else if (close) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            points[out++] = points[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        *pNpoints = out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    (*env)->ReleasePrimitiveArrayCritical(env, xcoordsArray, xcoords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                                          JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    (*env)->ReleasePrimitiveArrayCritical(env, ycoordsArray, ycoords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                          JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    return points;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
}
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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * Method:    XDrawLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * Signature: (IJIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     jint x1, jint y1, jint x2, jint y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
              CLAMP_TO_SHORT(x1), CLAMP_TO_SHORT(y1),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
              CLAMP_TO_SHORT(x2), CLAMP_TO_SHORT(y2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 * Method:    XDrawRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * Signature: (IJIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    if (xsdo == NULL || w < 0 || h < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    if (w < 2 || h < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        /* REMIND: This optimization assumes thin lines. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
         * This optimization not only simplifies the processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
         * of a particular degenerate case, but it protects against
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
         * the anomalies of various X11 implementations that draw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
         * nothing for degenerate Polygons and Rectangles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                       CLAMP_TO_SHORT(x),  CLAMP_TO_SHORT(y),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                       CLAMP_TO_USHORT(w+1), CLAMP_TO_USHORT(h+1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        XDrawRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                       CLAMP_TO_SHORT(x),  CLAMP_TO_SHORT(y),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                       CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
 * Method:    XDrawRoundRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
 * Signature: (IJIIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawRoundRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     jint x, jint y, jint w, jint h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     jint arcW, jint arcH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    long ty1, ty2, tx1, tx2, cx, cy, cxw, cyh,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
         halfW, halfH, leftW, rightW, topH, bottomH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    if (xsdo == NULL || w < 0 || h < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    arcW = ABS(arcW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    arcH = ABS(arcH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    if (arcW > w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        arcW = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    if (arcH > h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        arcH = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    if (arcW == 0 || arcH == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        Java_sun_java2d_x11_X11Renderer_XDrawRect(env, xr, pXSData, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                                  x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    halfW = (arcW / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    halfH = (arcH / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /* clamp to short bounding box of round rectangle */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    cx = CLAMP_TO_SHORT(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    cy = CLAMP_TO_SHORT(y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    cxw = CLAMP_TO_SHORT(x + w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    cyh = CLAMP_TO_SHORT(y + h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /* clamp to short coordinates of lines */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    tx1 = CLAMP_TO_SHORT(x + halfW + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    tx2 = CLAMP_TO_SHORT(x + w - halfW - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    ty1 = CLAMP_TO_SHORT(y + halfH + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    ty2 = CLAMP_TO_SHORT(y + h - halfH - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * recalculate heightes and widthes of round parts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * to minimize distortions in visible area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    leftW = (tx1 - cx) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    rightW = (cxw - tx2) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    topH = (ty1 - cy) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    bottomH = (cyh - ty2) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                cx, cy, leftW, topH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                90, 90, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                cxw - rightW, cy, rightW, topH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                0, 90, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                cx, cyh - bottomH, leftW, bottomH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                180, 90, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                cxw - rightW, cyh - bottomH, rightW, bottomH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                270, 90, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    if (tx1 <= tx2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                  tx1, cy, tx2, cy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        if (h > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                      tx1, cyh, tx2, cyh);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    if (ty1 <= ty2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                  cx, ty1, cx, ty2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        if (w > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                      cxw, ty1, cxw, ty2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
 * Method:    XDrawOval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
 * Signature: (IJIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawOval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    if (w < 2 || h < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
         * Fix for 4205762 - 1x1 ovals do not draw on Ultra1, Creator3d
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
         * (related to 4411814 on Windows platform)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
         * Really small ovals degenerate to simple rectangles as they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
         * have no curvature or enclosed area.  Use XFillRectangle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         * for speed and to deal better with degenerate sizes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        if (w >= 0 && h >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                           x, y, w+1, h+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                    x, y, w, h, 0, 360, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
 * Method:    XDrawArc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
 * Signature: (IJIIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawArc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     jint x, jint y, jint w, jint h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     jint angleStart, jint angleExtent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                x, y, w, h, angleStart, angleExtent, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    X11SD_DirectRenderNotify(env, xsdo);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
 * Method:    XDrawPoly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
 * Signature: (IJII[I[IIZ)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XDrawPoly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     jint transx, jint transy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     jintArray xcoordsArray, jintArray ycoordsArray, jint npoints,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     jboolean isclosed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    XPoint pTmp[POLYTEMPSIZE], *points;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    if (JNU_IsNull(env, xcoordsArray) || JNU_IsNull(env, ycoordsArray)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        JNU_ThrowNullPointerException(env, "coordinate array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    if ((*env)->GetArrayLength(env, ycoordsArray) < npoints ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        (*env)->GetArrayLength(env, xcoordsArray) < npoints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    if (npoints < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                             pTmp, (int *)&npoints, isclosed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    if (points == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        JNU_ThrowOutOfMemoryError(env, "translated coordinate array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        if (npoints == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
             * Some X11 implementations fail to draw anything for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
             * simple 2 point polygons where the vertices are the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
             * same point even though this violates the X11
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
             * specification.  For simplicity we will dispatch all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
             * 2 point polygons through XDrawLine even if they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
             * non-degenerate as this may invoke less processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
             * down the line than a Poly primitive anyway.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            XDrawLine(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                      points[0].x, points[0].y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                      points[1].x, points[1].y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            XDrawLines(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                       points, npoints, CoordModeOrigin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        if (points != pTmp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            free(points);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
static void storeLine(DrawHandler* hnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                      jint x0, jint y0, jint x1, jint y1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    XDrawHandlerData* dhnd = (XDrawHandlerData*)(hnd->pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    XDHD_ADD_POINT(dhnd, x0, y0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    XDHD_ADD_POINT(dhnd, x1, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
static void storePoint(DrawHandler* hnd, jint x0, jint y0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    XDrawHandlerData* dhnd = (XDrawHandlerData*)(hnd->pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    XDHD_ADD_POINT(dhnd, x0, y0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
static void drawSubPath(ProcessHandler* hnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    XDrawHandlerData* dhnd = (XDrawHandlerData*)(hnd->dhnd->pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    XPoint *points = dhnd->pPoints;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    switch (dhnd->npoints) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        /* No-op */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        /* Draw the single pixel */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        XFillRectangle(awt_display, dhnd->drawable, dhnd->gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                       points[0].x, points[0].y, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    case 2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
         * The XDrawLines method for some X11 implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
         * fails to draw anything for simple 2 point polygons
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
         * where the vertices are the same point even though
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
         * this violates the X11 specification.  For simplicity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
         * we will dispatch all 2 point polygons through XDrawLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
         * even if they are non-degenerate as this may invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
         * less processing down the line than a poly primitive anyway.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        XDrawLine(awt_display, dhnd->drawable, dhnd->gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                  points[0].x, points[0].y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                  points[1].x, points[1].y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        /* Draw the entire polyline */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        XDrawLines(awt_display, dhnd->drawable, dhnd->gc, points,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                   dhnd->npoints, CoordModeOrigin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    XDHD_RESET(dhnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
static void drawScanline(DrawHandler* hnd, jint x0, jint x1, jint y0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    XDrawHandlerData* dhnd = (XDrawHandlerData*)(hnd->pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    XDrawLine(awt_display, dhnd->drawable, dhnd->gc, x0, y0, x1, y0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
 * Method:    XDoPath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
 * Signature: (Lsun/java2d/SunGraphics2D;JJIILjava/awt/geom/Path2D/Float;Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
Java_sun_java2d_x11_X11Renderer_XDoPath
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    (JNIEnv *env, jobject self, jobject sg2d, jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     jint transX, jint transY, jobject p2df, jboolean isFill)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    jarray typesArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    jobject pointArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    jarray coordsArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    jint numTypes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    jint fillRule;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    jint maxCoords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    jbyte *types;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    jfloat *coords;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    XDrawHandlerData dHData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    DrawHandler drawHandler = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        NULL, NULL, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        MIN_SHORT, MIN_SHORT, MAX_SHORT, MAX_SHORT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        0, 0, 0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        NULL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    PHStroke stroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    if (isFill) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        fillRule = (*env)->GetIntField(env, p2df, path2DWindingRuleID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    typesArray = (jarray)(*env)->GetObjectField(env, p2df, path2DTypesID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    coordsArray = (jarray)(*env)->GetObjectField(env, p2df,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                                                 path2DFloatCoordsID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    if (coordsArray == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        JNU_ThrowNullPointerException(env, "coordinates array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    numTypes = (*env)->GetIntField(env, p2df, path2DNumTypesID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    if ((*env)->GetArrayLength(env, typesArray) < numTypes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        JNU_ThrowArrayIndexOutOfBoundsException(env, "types array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    XDHD_INIT(&dHData, (GC)xgc, xsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    drawHandler.pData = &dHData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    stroke = (((*env)->GetIntField(env, sg2d, sg2dStrokeHintID) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
               sunHints_INTVAL_STROKE_PURE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
              ? PH_STROKE_PURE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
              : PH_STROKE_DEFAULT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    maxCoords = (*env)->GetArrayLength(env, coordsArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    coords = (jfloat*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        (*env)->GetPrimitiveArrayCritical(env, coordsArray, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    if (coords != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        types = (jbyte*)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            (*env)->GetPrimitiveArrayCritical(env, typesArray, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        if (types != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            jboolean ok;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            if (isFill) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                drawHandler.pDrawScanline = &drawScanline;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                ok = doFillPath(&drawHandler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                                transX, transY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                                coords, maxCoords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                types, numTypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                                stroke, fillRule);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                drawHandler.pDrawLine = &storeLine;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                drawHandler.pDrawPixel = &storePoint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                ok = doDrawPath(&drawHandler, &drawSubPath,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                                transX, transY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                                coords, maxCoords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
                                types, numTypes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                                stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            if (!ok) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                JNU_ThrowArrayIndexOutOfBoundsException(env, "coords array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            (*env)->ReleasePrimitiveArrayCritical(env, typesArray, types,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                                                  JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        (*env)->ReleasePrimitiveArrayCritical(env, coordsArray, coords,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                                              JNI_ABORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    XDHD_FREE_POINTS(&dHData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
 * Method:    XFillRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
 * Signature: (IJIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                   CLAMP_TO_SHORT(x),  CLAMP_TO_SHORT(y),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                   CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
 * Method:    XFillRoundRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
 * Signature: (IJIIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillRoundRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     jint x, jint y, jint w, jint h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     jint arcW, jint arcH)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    long ty1, ty2, tx1, tx2, cx, cy, cxw, cyh,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
         halfW, halfH, leftW, rightW, topH, bottomH;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    if (xsdo == NULL || w <= 0 || h <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    arcW = ABS(arcW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    arcH = ABS(arcH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    if (arcW > w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        arcW = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    if (arcH > h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        arcH = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    if (arcW == 0 || arcH == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        Java_sun_java2d_x11_X11Renderer_XFillRect(env, xr, pXSData, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                                                  x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    halfW = (arcW / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    halfH = (arcH / 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    /* clamp to short bounding box of round rectangle */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    cx = CLAMP_TO_SHORT(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    cy = CLAMP_TO_SHORT(y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    cxw = CLAMP_TO_SHORT(x + w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    cyh = CLAMP_TO_SHORT(y + h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    /* clamp to short coordinates of lines */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    tx1 = CLAMP_TO_SHORT(x + halfW + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    tx2 = CLAMP_TO_SHORT(x + w - halfW - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    ty1 = CLAMP_TO_SHORT(y + halfH + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    ty2 = CLAMP_TO_SHORT(y + h - halfH - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * recalculate heightes and widthes of round parts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * to minimize distortions in visible area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    leftW = (tx1 - cx) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    rightW = (cxw - tx2) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    topH = (ty1 - cy) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    bottomH = (cyh - ty2) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                cx, cy, leftW, topH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                90, 90, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                cxw - rightW, cy, rightW, topH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                0, 90, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                cx, cyh - bottomH, leftW, bottomH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                180, 90, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                cxw - rightW, cyh - bottomH, rightW, bottomH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                270, 90, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    if (tx1 < tx2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        if (cy < ty1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                           tx1, cy, tx2 - tx1, ty1 - cy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        if (ty2 < cyh) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                           tx1, ty2, tx2 - tx1, cyh - ty2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    if (ty1 < ty2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                       cx, ty1, cxw - cx, ty2 - ty1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
 * Method:    XFillOval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
 * Signature: (IJIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillOval
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    if (w < 3 || h < 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
         * Fix for 4205762 - 1x1 ovals do not draw on Ultra1, Creator3d
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
         * (related to 4411814 on Windows platform)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
         * Most X11 servers drivers have poor rendering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
         * for thin ellipses and the rendering is most strikingly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
         * different from our theoretical arcs.  Ideally we should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
         * trap all ovals less than some fairly large size and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
         * try to draw aesthetically pleasing ellipses, but that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
         * would require considerably more work to get the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
         * drawArc variants to match pixel for pixel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
         * Thin ovals of girth 1 pixel are simple rectangles.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
         * Thin ovals of girth 2 pixels are simple rectangles with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         * potentially smaller lengths.  Determine the correct length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         * by calculating .5*.5 + scaledlen*scaledlen == 1.0 which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
         * means that scaledlen is the sqrt(0.75).  Scaledlen is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         * relative to the true length (w or h) and needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
         * adjusted by half a pixel in different ways for odd or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
         * even lengths.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
#define SQRT_3_4 0.86602540378443864676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        if (w > 2 && h > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            int adjw = (int) ((SQRT_3_4 * w - ((w&1)-1)) * 0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            adjw = adjw * 2 + (w&1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            x += (w-adjw)/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            w = adjw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        } else if (h > 2 && w > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            int adjh = (int) ((SQRT_3_4 * h - ((h&1)-1)) * 0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            adjh = adjh * 2 + (h&1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            y += (h-adjh)/2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            h = adjh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
#undef SQRT_3_4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        if (w > 0 && h > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            XFillRectangle(awt_display, xsdo->drawable, (GC) xgc, x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                    x, y, w, h, 0, 360, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
 * Method:    XFillArc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
 * Signature: (IJIIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillArc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     jint x, jint y, jint w, jint h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     jint angleStart, jint angleExtent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    awt_drawArc(env, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                x, y, w, h, angleStart, angleExtent, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
 * Method:    XFillPoly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
 * Signature: (IJII[I[II)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillPoly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     jint transx, jint transy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     jintArray xcoordsArray, jintArray ycoordsArray, jint npoints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    XPoint pTmp[POLYTEMPSIZE], *points;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    if (JNU_IsNull(env, xcoordsArray) || JNU_IsNull(env, ycoordsArray)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        JNU_ThrowNullPointerException(env, "coordinate array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    if ((*env)->GetArrayLength(env, ycoordsArray) < npoints ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        (*env)->GetArrayLength(env, xcoordsArray) < npoints)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        JNU_ThrowArrayIndexOutOfBoundsException(env, "coordinate array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    if (npoints < 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    points = transformPoints(env, xcoordsArray, ycoordsArray, transx, transy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                             pTmp, (int *)&npoints, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    if (points == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        JNU_ThrowOutOfMemoryError(env, "translated coordinate array");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        if (npoints > 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            XFillPolygon(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                         points, npoints, Complex, CoordModeOrigin);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        if (points != pTmp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            free(points);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
 * Method:    XFillSpans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
 * Signature: (IJLsun/java2d/pipe/SpanIterator;JII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
JNIEXPORT void JNICALL Java_sun_java2d_x11_X11Renderer_XFillSpans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     jlong pXSData, jlong xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     jobject si, jlong pIterator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     jint transx, jint transy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    SpanIteratorFuncs *pFuncs = (SpanIteratorFuncs *) jlong_to_ptr(pIterator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    void *srData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    jint x, y, w, h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    jint spanbox[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
    X11SDOps *xsdo = (X11SDOps *) pXSData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    if (JNU_IsNull(env, si)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        JNU_ThrowNullPointerException(env, "span iterator");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    if (pFuncs == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        JNU_ThrowNullPointerException(env, "native iterator not supplied");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    srData = (*pFuncs->open)(env, si);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    while ((*pFuncs->nextSpan)(srData, spanbox)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        x = spanbox[0] + transx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        y = spanbox[1] + transy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        w = spanbox[2] - spanbox[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        h = spanbox[3] - spanbox[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        XFillRectangle(awt_display, xsdo->drawable, (GC) xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                       CLAMP_TO_SHORT(x),  CLAMP_TO_SHORT(y),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                       CLAMP_TO_USHORT(w), CLAMP_TO_USHORT(h));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    (*pFuncs->close)(env, srData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
 * Class:     sun_java2d_x11_X11Renderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
 * Method:    devCopyArea
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
 * Signature: (Lsun/java2d/SurfaceData;IIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
Java_sun_java2d_x11_X11Renderer_devCopyArea
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
    (JNIEnv *env, jobject xr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     jlong xsd, jlong gc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     jint srcx, jint srcy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     jint dstx, jint dsty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    X11SDOps *xsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
    GC xgc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    xsdo = (X11SDOps *)jlong_to_ptr(xsd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    if (xsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    xgc = (GC)gc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    if (xgc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    XCopyArea(awt_display, xsdo->drawable, xsdo->drawable, xgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
              srcx, srcy, width, height, dstx, dsty);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    X11SD_DirectRenderNotify(env, xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
}