Path: blob/master/src/java.desktop/unix/native/common/awt/img_util_md.h
41153 views
/*1* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include "jni.h"26#include "color.h"2728#if !defined(HEADLESS) && !defined(MACOSX)29typedef struct {30ImgConvertData cvdata; /* The data needed by ImgConvertFcn's */31struct Hsun_awt_image_ImageRepresentation *hJavaObject; /* backptr */32XID pixmap; /* The X11 pixmap containing the image */33XID mask; /* The X11 pixmap with the transparency mask */34int bgcolor; /* The current bg color installed in pixmap */3536int depth; /* The depth of the destination image */37int dstW; /* The width of the destination pixmap */38int dstH; /* The height of the destination pixmap */3940XImage *xim; /* The Ximage structure for the temp buffer */41XImage *maskim; /* The Ximage structure for the mask */4243int hints; /* The delivery hints from the producer */4445Region curpixels; /* The region of randomly converted pixels */46struct {47int num; /* The last fully delivered scanline */48char *seen; /* The lines which have been delivered */49} curlines; /* For hints=COMPLETESCANLINES */50} IRData;5152typedef unsigned int MaskBits;5354extern int image_Done(IRData *ird, int x1, int y1, int x2, int y2);5556extern void *image_InitMask(IRData *ird, int x1, int y1, int x2, int y2);5758#define BufComplete(cvdata, dstX1, dstY1, dstX2, dstY2) \59image_Done((IRData *) cvdata, dstX1, dstY1, dstX2, dstY2)6061#define SendRow(ird, dstY, dstX1, dstX2)6263#define ImgInitMask(cvdata, x1, y1, x2, y2) \64image_InitMask((IRData *)cvdata, x1, y1, x2, y2)6566#define ScanBytes(cvdata) (((IRData *)cvdata)->xim->bytes_per_line)6768#define MaskScan(cvdata) \69((((IRData *)cvdata)->maskim->bytes_per_line) >> 2)7071#endif /* !HEADLESS && !MACOSX */7273#define MaskOffset(x) ((x) >> 5)7475#define MaskInit(x) (1U << (31 - ((x) & 31)))7677#define SetOpaqueBit(mask, bit) ((mask) |= (bit))78#define SetTransparentBit(mask, bit) ((mask) &= ~(bit))7980#define UCHAR_ARG(uc) ((unsigned char)(uc))81#define ColorCubeFSMap(r, g, b) \82cData->img_clr_tbl [ ((UCHAR_ARG(r)>>3)<<10) | \83((UCHAR_ARG(g)>>3)<<5) | (UCHAR_ARG(b)>>3)]8485#define ColorCubeOrdMapSgn(r, g, b) \86((dstLockInfo.inv_cmap)[ ((UCHAR_ARG(r)>>3)<<10) | \87((UCHAR_ARG(g)>>3)<<5) | (UCHAR_ARG(b)>>3)])8889#define GetPixelRGB(pixel, red, green, blue) \90do { \91ColorEntry *cp = &awt_Colors[pixel]; \92red = cp->r; \93green = cp->g; \94blue = cp->b; \95} while (0)9697#define CUBEMAP(r,g,b) ColorCubeOrdMapSgn(r, g, b)98#define cubemapArray 199100extern uns_ordered_dither_array img_oda_alpha;101102extern void freeICMColorData(ColorData *pData);103104JNIEXPORT void JNICALL105initInverseGrayLut(int* prgb, int rgbsize, ColorData* cData);106107extern unsigned char* initCubemap(int* cmap, int cmap_len, int cube_dim);108extern void initDitherTables(ColorData* cData);109110#define SET_CUBEMAPARRAY \111lockInfo->inv_cmap = (const char*)lockInfo->colorData->img_clr_tbl112113114