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 "windows.h"
  27 
  28 #ifdef __cplusplus
  29 extern "C" {
  30 #include "colordata.h"
  31 }
  32 #else
  33 #include "colordata.h"
  34 #endif
  35 #include "jni.h"
  36 
  37 #ifdef __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 
  42 typedef unsigned char MaskBits;
  43 
  44 extern uns_ordered_dither_array img_oda_alpha;
  45 
  46 #define BufComplete(cvdata, dstX1, dstY1, dstX2, dstY2)         \
  47     (((AwtImage *)cvdata)->BufDone(dstX1, dstY1, dstX2, dstY2))
  48 
  49 #define SendRow(cvdata, dstY, dstX1, dstX2)
  50 
  51 #define ImgInitMask(cvdata, x1, y1, x2, y2)                     \
  52     (((AwtImage *) cvdata)->GetMaskBuf(TRUE, x1, y1, x2, y2))
  53 
  54 #define ScanBytes(cvdata)       (((AwtImage *) cvdata)->GetBufScan())
  55 
  56 #define MaskScan(cvdata)                                        \
  57     MaskOffset((((AwtImage *) cvdata)->GetWidth() + 31) & (~31))
  58 
  59 #define MaskOffset(x)           ((x) >> 3)
  60 
  61 #define MaskInit(x)             (0x80 >> ((x) & 7))
  62 
  63 #define SetOpaqueBit(mask, bit)         ((mask) &= ~(bit))
  64 #define SetTransparentBit(mask, bit)    ((mask) |= (bit))
  65 
  66 #define ColorCubeFSMap(r, g, b)         AwtImage::CubeMap(r, g, b)
  67 
  68 #define ColorCubeOrdMapSgn(r, g, b)     AwtImage::CubeMap(r, g, b);
  69 
  70 #define GetPixelRGB(pixel, red, green, blue)                    \
  71     do {                                                        \
  72         RGBQUAD *cp = AwtImage::PixelColor(pixel);              \
  73         red = cp->rgbRed;                                       \
  74         green = cp->rgbGreen;                                   \
  75         blue = cp->rgbBlue;                                     \
  76     } while (0)
  77 
  78 #ifdef DEBUG
  79 #undef img_check
  80 #define img_check(condition)                                    \
  81     do {                                                        \
  82         if (!(condition)) {                                     \
  83             SignalError(0, JAVAPKG "InternalError",             \
  84                         "assertion failed:  " #condition);      \
  85             return SCALEFAILURE;                                \
  86         }                                                       \
  87     } while (0)
  88 #else /* DEBUG */
  89 #define img_check(condition)    do {} while (0)
  90 #endif /* DEBUG */
  91 
  92 void color_init();
  93 extern const char *cubemapArray;
  94 #define CUBEMAP(r,g,b) \
  95     ((dstLockInfo.inv_cmap)[(((r)>>3)<<10) | (((g)>>3)<<5) | ((b)>>3)])
  96 
  97 extern void freeICMColorData(ColorData *pData);
  98 
  99 JNIEXPORT void JNICALL
 100 initInverseGrayLut(int* prgb, int rgbsize, ColorData* cData);
 101 
 102 extern unsigned char* initCubemap(int* cmap, int cmap_len, int cube_dim);
 103 extern void initDitherTables(ColorData* cData);
 104 
 105 #define SET_CUBEMAPARRAY \
 106     if (lockInfo->lockedLut) { \
 107         lockInfo->inv_cmap = (const char *)cubemapArray; \
 108     } else { \
 109         lockInfo->inv_cmap = (const char*)lockInfo->colorData->img_clr_tbl; \
 110     }
 111 
 112 
 113 #ifdef __cplusplus
 114 }; /* end of extern "C" */
 115 #endif