1 | /* |
2 | * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. |
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | * |
5 | * This code is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License version 2 only, as |
7 | * published by the Free Software Foundation. Oracle designates this |
8 | * particular file as subject to the "Classpath" exception as provided |
9 | * by Oracle in the LICENSE file that accompanied this code. |
10 | * |
11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14 | * version 2 for more details (a copy is included in the LICENSE file that |
15 | * accompanied this code). |
16 | * |
17 | * You should have received a copy of the GNU General Public License version |
18 | * 2 along with this work; if not, write to the Free Software Foundation, |
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
20 | * |
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 | * or visit www.oracle.com if you need additional information or have any |
23 | * questions. |
24 | */ |
25 | |
26 | #include "jni.h" |
27 | #include "color.h" |
28 | |
29 | #if !defined(HEADLESS) && !defined(MACOSX) |
30 | typedef struct { |
31 | ImgConvertData cvdata; /* The data needed by ImgConvertFcn's */ |
32 | struct Hsun_awt_image_ImageRepresentation *hJavaObject; /* backptr */ |
33 | XID pixmap; /* The X11 pixmap containing the image */ |
34 | XID mask; /* The X11 pixmap with the transparency mask */ |
35 | int bgcolor; /* The current bg color installed in pixmap */ |
36 | |
37 | int depth; /* The depth of the destination image */ |
38 | int dstW; /* The width of the destination pixmap */ |
39 | int dstH; /* The height of the destination pixmap */ |
40 | |
41 | XImage *xim; /* The Ximage structure for the temp buffer */ |
42 | XImage *maskim; /* The Ximage structure for the mask */ |
43 | |
44 | int hints; /* The delivery hints from the producer */ |
45 | |
46 | Region curpixels; /* The region of randomly converted pixels */ |
47 | struct { |
48 | int num; /* The last fully delivered scanline */ |
49 | char *seen; /* The lines which have been delivered */ |
50 | } curlines; /* For hints=COMPLETESCANLINES */ |
51 | } IRData; |
52 | |
53 | typedef unsigned int MaskBits; |
54 | |
55 | extern int image_Done(IRData *ird, int x1, int y1, int x2, int y2); |
56 | |
57 | extern void *image_InitMask(IRData *ird, int x1, int y1, int x2, int y2); |
58 | |
59 | #define BufComplete(cvdata, dstX1, dstY1, dstX2, dstY2) \ |
60 | image_Done((IRData *) cvdata, dstX1, dstY1, dstX2, dstY2) |
61 | |
62 | #define SendRow(ird, dstY, dstX1, dstX2) |
63 | |
64 | #define ImgInitMask(cvdata, x1, y1, x2, y2) \ |
65 | image_InitMask((IRData *)cvdata, x1, y1, x2, y2) |
66 | |
67 | #define ScanBytes(cvdata) (((IRData *)cvdata)->xim->bytes_per_line) |
68 | |
69 | #define MaskScan(cvdata) \ |
70 | ((((IRData *)cvdata)->maskim->bytes_per_line) >> 2) |
71 | |
72 | #endif /* !HEADLESS && !MACOSX */ |
73 | |
74 | #define MaskOffset(x) ((x) >> 5) |
75 | |
76 | #define MaskInit(x) (1U << (31 - ((x) & 31))) |
77 | |
78 | #define SetOpaqueBit(mask, bit) ((mask) |= (bit)) |
79 | #define SetTransparentBit(mask, bit) ((mask) &= ~(bit)) |
80 | |
81 | #define UCHAR_ARG(uc) ((unsigned char)(uc)) |
82 | #define ColorCubeFSMap(r, g, b) \ |
83 | cData->img_clr_tbl [ ((UCHAR_ARG(r)>>3)<<10) | \ |
84 | ((UCHAR_ARG(g)>>3)<<5) | (UCHAR_ARG(b)>>3)] |
85 | |
86 | #define ColorCubeOrdMapSgn(r, g, b) \ |
87 | ((dstLockInfo.inv_cmap)[ ((UCHAR_ARG(r)>>3)<<10) | \ |
88 | ((UCHAR_ARG(g)>>3)<<5) | (UCHAR_ARG(b)>>3)]) |
89 | |
90 | #define GetPixelRGB(pixel, red, green, blue) \ |
91 | do { \ |
92 | ColorEntry *cp = &awt_Colors[pixel]; \ |
93 | red = cp->r; \ |
94 | green = cp->g; \ |
95 | blue = cp->b; \ |
96 | } while (0) |
97 | |
98 | #define CUBEMAP(r,g,b) ColorCubeOrdMapSgn(r, g, b) |
99 | #define cubemapArray 1 |
100 | |
101 | extern uns_ordered_dither_array img_oda_alpha; |
102 | |
103 | extern void freeICMColorData(ColorData *pData); |
104 | |
105 | JNIEXPORT void JNICALL |
106 | initInverseGrayLut(int* prgb, int rgbsize, ColorData* cData); |
107 | |
108 | extern unsigned char* initCubemap(int* cmap, int cmap_len, int cube_dim); |
109 | extern void initDitherTables(ColorData* cData); |
110 | |
111 | #define SET_CUBEMAPARRAY \ |
112 | lockInfo->inv_cmap = (const char*)lockInfo->colorData->img_clr_tbl |
113 | |