src/java.desktop/unix/native/common/awt/img_util_md.h
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) 1996, 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
56106
40e61db323c2 First stab at removing mapfiles.
ihse
parents: 47216
diff changeset
    26
#include "jni.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "color.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
24566
a43e10e7f3a6 8003900: X11 dependencies should be removed from Mac OS X build.
ddehaven
parents: 5506
diff changeset
    29
#if !defined(HEADLESS) && !defined(MACOSX)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
    ImgConvertData cvdata;      /* The data needed by ImgConvertFcn's */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
    struct Hsun_awt_image_ImageRepresentation *hJavaObject;     /* backptr */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    XID pixmap;                 /* The X11 pixmap containing the image */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    XID mask;                   /* The X11 pixmap with the transparency mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    int bgcolor;                /* The current bg color installed in pixmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    int depth;                  /* The depth of the destination image */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    int dstW;                   /* The width of the destination pixmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    int dstH;                   /* The height of the destination pixmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    XImage *xim;                /* The Ximage structure for the temp buffer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    XImage *maskim;             /* The Ximage structure for the mask */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    int hints;                  /* The delivery hints from the producer */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    Region curpixels;           /* The region of randomly converted pixels */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        int num;                /* The last fully delivered scanline */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        char *seen;             /* The lines which have been delivered */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    } curlines;                 /* For hints=COMPLETESCANLINES */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
} IRData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
typedef unsigned int MaskBits;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
extern int image_Done(IRData *ird, int x1, int y1, int x2, int y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
extern void *image_InitMask(IRData *ird, int x1, int y1, int x2, int y2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define BufComplete(cvdata, dstX1, dstY1, dstX2, dstY2)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    image_Done((IRData *) cvdata, dstX1, dstY1, dstX2, dstY2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#define SendRow(ird, dstY, dstX1, dstX2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define ImgInitMask(cvdata, x1, y1, x2, y2)                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    image_InitMask((IRData *)cvdata, x1, y1, x2, y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define ScanBytes(cvdata)       (((IRData *)cvdata)->xim->bytes_per_line)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
#define MaskScan(cvdata)                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        ((((IRData *)cvdata)->maskim->bytes_per_line) >> 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
24566
a43e10e7f3a6 8003900: X11 dependencies should be removed from Mac OS X build.
ddehaven
parents: 5506
diff changeset
    72
#endif /* !HEADLESS && !MACOSX */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define MaskOffset(x)           ((x) >> 5)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#define MaskInit(x)             (1U << (31 - ((x) & 31)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#define SetOpaqueBit(mask, bit)         ((mask) |= (bit))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define SetTransparentBit(mask, bit)    ((mask) &= ~(bit))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define UCHAR_ARG(uc)    ((unsigned char)(uc))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define ColorCubeFSMap(r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    cData->img_clr_tbl [    ((UCHAR_ARG(r)>>3)<<10) |                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                    ((UCHAR_ARG(g)>>3)<<5) | (UCHAR_ARG(b)>>3)]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define ColorCubeOrdMapSgn(r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    ((dstLockInfo.inv_cmap)[    ((UCHAR_ARG(r)>>3)<<10) |                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                    ((UCHAR_ARG(g)>>3)<<5) | (UCHAR_ARG(b)>>3)])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define GetPixelRGB(pixel, red, green, blue)                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    do {                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        ColorEntry *cp = &awt_Colors[pixel];                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        red = cp->r;                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        green = cp->g;                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        blue = cp->b;                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define CUBEMAP(r,g,b) ColorCubeOrdMapSgn(r, g, b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define cubemapArray 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
extern uns_ordered_dither_array img_oda_alpha;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
extern void freeICMColorData(ColorData *pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
56106
40e61db323c2 First stab at removing mapfiles.
ihse
parents: 47216
diff changeset
   105
JNIEXPORT void initInverseGrayLut(int* prgb, int rgbsize, ColorData* cData);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
extern unsigned char* initCubemap(int* cmap, int cmap_len, int cube_dim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
extern void initDitherTables(ColorData* cData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#define SET_CUBEMAPARRAY \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    lockInfo->inv_cmap = (const char*)lockInfo->colorData->img_clr_tbl