src/java.desktop/share/native/libawt/java2d/SurfaceData.c
author ihse
Tue, 13 Feb 2018 10:37:33 +0100
branchihse-remove-mapfiles-branch
changeset 56106 40e61db323c2
parent 47216 71c04702a3d5
child 56721 01b558efd286
permissions -rw-r--r--
First stab at removing mapfiles.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
56106
40e61db323c2 First stab at removing mapfiles.
ihse
parents: 47216
diff changeset
     2
 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "Disposer.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 5506
diff changeset
    31
#include "stdlib.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "string.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
 * This include file contains information on how to use a SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * object from native code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
static jclass pInvalidPipeClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
static jclass pNullSurfaceDataClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
static jfieldID pDataID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
static jfieldID allGrayID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
jfieldID validID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
GeneralDisposeFunc SurfaceData_DisposeOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define InitClass(var, env, name) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    var = (*env)->FindClass(env, name); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    if (var == NULL) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        return; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define InitField(var, env, jcl, name, type) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    var = (*env)->GetFieldID(env, jcl, name, type); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    if (var == NULL) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        return; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define InitGlobalClassRef(var, env, name) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    jobject jtmp; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    InitClass(jtmp, env, name); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    var = (*env)->NewGlobalRef(env, jtmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    if (var == NULL) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        return; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Class:     sun_java2d_SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * Method:    initIDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
Java_sun_java2d_SurfaceData_initIDs(JNIEnv *env, jclass sd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    jclass pICMClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    InitGlobalClassRef(pInvalidPipeClass, env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                       "sun/java2d/InvalidPipeException");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    InitGlobalClassRef(pNullSurfaceDataClass, env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                       "sun/java2d/NullSurfaceData");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    InitField(pDataID, env, sd, "pData", "J");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    InitField(validID, env, sd, "valid", "Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    InitClass(pICMClass, env, "java/awt/image/IndexColorModel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    InitField(allGrayID, env, pICMClass, "allgrayopaque", "Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Class:     sun_java2d_SurfaceData
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * Method:    isOpaqueGray
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
Java_sun_java2d_SurfaceData_isOpaqueGray(JNIEnv *env, jclass sdClass,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                         jobject icm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    if (icm == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    return (*env)->GetBooleanField(env, icm, allGrayID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
static SurfaceDataOps *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
GetSDOps(JNIEnv *env, jobject sData, jboolean callSetup)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    SurfaceDataOps *ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    if (JNU_IsNull(env, sData)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        JNU_ThrowNullPointerException(env, "surfaceData");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    ops = (SurfaceDataOps *)JNU_GetLongFieldAsPtr(env, sData, pDataID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    if (ops == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (!(*env)->ExceptionOccurred(env) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            !(*env)->IsInstanceOf(env, sData, pNullSurfaceDataClass))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            if (!(*env)->GetBooleanField(env, sData, validID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                SurfaceData_ThrowInvalidPipeException(env, "invalid data");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                JNU_ThrowNullPointerException(env, "native ops missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    } else if (callSetup) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        SurfaceData_InvokeSetup(env, ops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    return ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
JNIEXPORT SurfaceDataOps * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
SurfaceData_GetOps(JNIEnv *env, jobject sData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    return GetSDOps(env, sData, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
JNIEXPORT SurfaceDataOps * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
SurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    return GetSDOps(env, sData, JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
SurfaceData_SetOps(JNIEnv *env, jobject sData, SurfaceDataOps *ops)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    if (JNU_GetLongFieldAsPtr(env, sData, pDataID) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        JNU_SetLongFieldFromPtr(env, sData, pDataID, ops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        /* Register the data for disposal */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        Disposer_AddRecord(env, sData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                           SurfaceData_DisposeOps,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                           ptr_to_jlong(ops));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        JNU_ThrowInternalError(env, "Attempting to set SurfaceData ops twice");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
SurfaceData_ThrowInvalidPipeException(JNIEnv *env, const char *msg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    (*env)->ThrowNew(env, pInvalidPipeClass, msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#define GETMIN(v1, v2)          (((v1) > (t=(v2))) && ((v1) = t))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
#define GETMAX(v1, v2)          (((v1) < (t=(v2))) && ((v1) = t))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
SurfaceData_IntersectBounds(SurfaceDataBounds *dst, SurfaceDataBounds *src)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    int t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    GETMAX(dst->x1, src->x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    GETMAX(dst->y1, src->y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    GETMIN(dst->x2, src->x2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    GETMIN(dst->y2, src->y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
SurfaceData_IntersectBoundsXYXY(SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                                jint x1, jint y1, jint x2, jint y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    int t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    GETMAX(bounds->x1, x1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    GETMAX(bounds->y1, y1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    GETMIN(bounds->x2, x2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    GETMIN(bounds->y2, y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
SurfaceData_IntersectBoundsXYWH(SurfaceDataBounds *bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                jint x, jint y, jint w, jint h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    w = (w <= 0) ? x : x+w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    if (w < x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        w = 0x7fffffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    if (bounds->x1 < x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        bounds->x1 = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    if (bounds->x2 > w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        bounds->x2 = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    h = (h <= 0) ? y : y+h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    if (h < y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        h = 0x7fffffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    if (bounds->y1 < y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        bounds->y1 = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    if (bounds->y2 > h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        bounds->y2 = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
SurfaceData_IntersectBlitBounds(SurfaceDataBounds *src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                SurfaceDataBounds *dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                jint dx, jint dy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    int t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    GETMAX(dst->x1, src->x1 + dx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    GETMAX(dst->y1, src->y1 + dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    GETMIN(dst->x2, src->x2 + dx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    GETMIN(dst->y2, src->y2 + dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    GETMAX(src->x1, dst->x1 - dx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    GETMAX(src->y1, dst->y1 - dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    GETMIN(src->x2, dst->x2 - dx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    GETMIN(src->y2, dst->y2 - dy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
56106
40e61db323c2 First stab at removing mapfiles.
ihse
parents: 47216
diff changeset
   234
JNIEXPORT SurfaceDataOps *
40e61db323c2 First stab at removing mapfiles.
ihse
parents: 47216
diff changeset
   235
SurfaceData_InitOps(JNIEnv *env, jobject sData, int opsSize)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    SurfaceDataOps *ops = malloc(opsSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    SurfaceData_SetOps(env, sData, ops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    if (ops != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        memset(ops, 0, opsSize);
20422
1a47790e7d9b 8025480: [parfait] "JNI exception pending" warnings from b107 for jdk.src.share.native.sun.java2d
jchen
parents: 12047
diff changeset
   241
        if (!(*env)->ExceptionCheck(env)) {
1a47790e7d9b 8025480: [parfait] "JNI exception pending" warnings from b107 for jdk.src.share.native.sun.java2d
jchen
parents: 12047
diff changeset
   242
            ops->sdObject = (*env)->NewWeakGlobalRef(env, sData);
1a47790e7d9b 8025480: [parfait] "JNI exception pending" warnings from b107 for jdk.src.share.native.sun.java2d
jchen
parents: 12047
diff changeset
   243
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    return ops;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
void SurfaceData_DisposeOps(JNIEnv *env, jlong ops)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    if (ops != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        SurfaceDataOps *sdops = (SurfaceDataOps*)jlong_to_ptr(ops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        /* Invoke the ops-specific disposal function */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        SurfaceData_InvokeDispose(env, sdops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        (*env)->DeleteWeakGlobalRef(env, sdops->sdObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        free(sdops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
}