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