Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/ImageData.h
41159 views
/*1* Copyright (c) 1997, 2000, 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/*26* @author Charlton Innovations, Inc.27*/2829#ifndef _Included_ImageData30#define _Included_ImageData3132#ifdef __cplusplus33extern "C" {34#endif3536#include "colordata.h"373839typedef struct ImageDataID {40jfieldID dataID;41jfieldID lutDataID;42jfieldID typeID;43jfieldID lutDataLengthID;44jfieldID pixelStrideID;45jfieldID scanlineStrideID;46jfieldID numChannelsID;47jfieldID bytePerChannelID;48jfieldID pixelsPerDataUnitID;4950jfieldID xViewAreaID;51jfieldID yViewAreaID;52jfieldID dxViewAreaID;53jfieldID dyViewAreaID;54jfieldID xDeviceAreaID;55jfieldID yDeviceAreaID;56jfieldID dxDeviceAreaID;57jfieldID dyDeviceAreaID;58jfieldID xOutputAreaID;59jfieldID yOutputAreaID;60jfieldID dxOutputAreaID;61jfieldID dyOutputAreaID;6263jfieldID intDataID;64jfieldID shortDataID;65jfieldID byteDataID;6667jfieldID lutArrayID;6869jfieldID originXID;70jfieldID originYID;7172jfieldID theResRatioID;73jfieldID theScaleFactorXID;74jfieldID theScaleFactorYID;7576jfieldID lockMethodID;77jfieldID lockFunctionID;78jfieldID platformInfoID;79jfieldID deviceInfoID;80jfieldID colorModelID;8182jfieldID grayInverseLutDataID;83} ImageDataID;8485extern ImageDataID gImageData;8687int minImageWidths(JNIEnv *env, int width1, jobject img1, jobject img2);88int minImageRows(JNIEnv *env, int rows1, jobject img1, jobject img2);8990typedef int (*deferredLockFunc) (JNIEnv *env, jobject idData);919293typedef struct ImageDataIntLockInfo {94unsigned int *lockedBuffer; /* filled if buffer previously locked */95deferredLockFunc lockFunction; /* ptr to lock function (optional) */96unsigned int xOutput,yOutput; /* top-left of clipped output area */97unsigned int scanStride;98unsigned int bytePerChannel;99unsigned int pixelStride;100unsigned int pixelsPerData;101102jintArray arrayToLock; /* filled if buffer not previously locked */103unsigned int *arrayLockedBuffer; /* state needed for unlock of array */104int arrayLockedOffset; /* offset from start of array to copy image */105} ImageDataIntLockInfo;106107typedef struct ImageDataShortLockInfo {108unsigned short *lockedBuffer; /* filled if buffer previously locked */109deferredLockFunc lockFunction; /* ptr to lock function (optional) */110unsigned int xOutput,yOutput; /* top-left of clipped output area */111unsigned int scanStride;112unsigned int bytePerChannel;113unsigned int pixelStride;114unsigned int pixelsPerData;115116jshortArray arrayToLock; /* filled if buffer not previously locked */117unsigned short *arrayLockedBuffer; /* state needed for unlock of array */118int arrayLockedOffset; /* offset from start of array to copy image */119} ImageDataShortLockInfo;120121typedef struct ImageDataByteLockInfo {122unsigned char *lockedBuffer; /* filled if buffer previously locked */123deferredLockFunc lockFunction; /* ptr to lock function (optional) */124unsigned int xOutput,yOutput; /* top-left of clipped output area */125unsigned int scanStride;126unsigned int bytePerChannel;127unsigned int pixelStride;128unsigned int pixelsPerData;129130jbyteArray arrayToLock; /* filled if buffer not previously locked */131unsigned char *arrayLockedBuffer; /* state needed for unlock of array */132int arrayLockedOffset; /* offset from start of array to copy image */133} ImageDataByteLockInfo;134135typedef struct ImageDataShortIndexedLockInfo {136unsigned short *lockedBuffer; /* filled if buffer previously locked */137deferredLockFunc lockFunction; /* ptr to lock function (optional) */138unsigned int xOutput,yOutput; /* top-left of clipped output area */139unsigned int scanStride;140unsigned int bytePerChannel;141unsigned int pixelStride;142unsigned int pixelsPerData;143144jshortArray arrayToLock; /* filled if buffer not previously locked */145unsigned short *arrayLockedBuffer; /* state needed for unlock of array */146int arrayLockedOffset; /* offset from start of array to copy image */147148unsigned int *lockedLut;149jintArray arrayToLockLut;150unsigned int *arrayLockedLut;151unsigned int arrayLutSize;152} ImageDataShortIndexedLockInfo;153154typedef struct ImageDataByteIndexedLockInfo {155unsigned char *lockedBuffer; /* filled if buffer previously locked */156deferredLockFunc lockFunction; /* ptr to lock function (optional) */157unsigned int xOutput,yOutput; /* top-left of clipped output area */158unsigned int scanStride;159unsigned int bytePerChannel;160unsigned int pixelStride;161unsigned int pixelsPerData;162163jbyteArray arrayToLock; /* filled if buffer not previously locked */164unsigned char *arrayLockedBuffer; /* state needed for unlock of array */165int arrayLockedOffset; /* offset from start of array to copy image */166167unsigned int *lockedLut;168jintArray arrayToLockLut;169unsigned int *arrayLockedLut;170unsigned int arrayLutSize;171unsigned int minLut[256]; /* provide min size LUT - speed inner loops */172ColorData *colorData;173unsigned int lockedForWrite;174const char* inv_cmap; /* The inverse cmap to use */175} ImageDataByteIndexedLockInfo;176177typedef struct ImageDataIndex8GrayLockInfo {178unsigned char *lockedBuffer; /* filled if buffer previously locked */179deferredLockFunc lockFunction; /* ptr to lock function (optional) */180unsigned int xOutput,yOutput; /* top-left of clipped output area */181unsigned int scanStride;182unsigned int bytePerChannel;183unsigned int pixelStride;184185jbyteArray arrayToLock; /* filled if buffer not previously locked */186unsigned char *arrayLockedBuffer; /* state needed for unlock of array */187int arrayLockedOffset; /* offset from start of array to copy image */188189unsigned int *lockedLut;190jintArray arrayToLockLut;191unsigned int *arrayLockedLut;192unsigned int arrayLutSize;193unsigned int minLut[256];194ColorData *colorData;195unsigned int lockedForWrite;196const char* inv_cmap; /* The inverse cmap to use */197198unsigned int *lockedInverseGrayLut;199200} ImageDataIndex8GrayLockInfo;201202typedef struct ImageDataIndex12GrayLockInfo {203unsigned short *lockedBuffer; /* filled if buffer previously locked */204deferredLockFunc lockFunction; /* ptr to lock function (optional) */205unsigned int xOutput,yOutput; /* top-left of clipped output area */206unsigned int scanStride;207unsigned int bytePerChannel;208unsigned int pixelStride;209210jshortArray arrayToLock; /* filled if buffer not previously locked */211unsigned short *arrayLockedBuffer; /* state needed for unlock of array */212int arrayLockedOffset; /* offset from start of array to copy image */213214unsigned int *lockedLut;215jintArray arrayToLockLut;216unsigned int *arrayLockedLut;217unsigned int arrayLutSize;218unsigned int *minLut; /* Not used right now, and therefore just having a219pointer instead of an array */220ColorData *colorData;221unsigned int lockedForWrite;222const char* inv_cmap; /* The inverse cmap to use */223224unsigned int *lockedInverseGrayLut;225226} ImageDataIndex12GrayLockInfo;227228typedef struct ImageDataBitLockInfo {229unsigned char *lockedBuffer; /* filled if buffer previously locked */230deferredLockFunc lockFunction; /* ptr to lock function (optional) */231unsigned int xOutput,yOutput; /* top-left of clipped output area */232unsigned int scanStride;233unsigned int bytePerChannel;234unsigned int pixelStride;235unsigned int pixelsPerData;236237jbyteArray arrayToLock; /* filled if buffer not previously locked */238unsigned char *arrayLockedBuffer; /* state needed for unlock of array */239int arrayLockedOffset; /* offset from start of array to copy image */240} ImageDataBitLockInfo;241242int offsetOfAlphaData(JNIEnv *env, jobject img, int scanStride);243#define offsetOfSrcData(env, img, srcStride, srcBump, offsetVar) \244do { \245int x1, y1; \246int x2, y2; \247x1 = (*env)->GetIntField(env, img, gImageData.xDeviceAreaID); \248y1 = (*env)->GetIntField(env, img, gImageData.yDeviceAreaID); \249x2 = (*env)->GetIntField(env, img, gImageData.xOutputAreaID); \250y2 = (*env)->GetIntField(env, img, gImageData.yOutputAreaID); \251offsetVar = srcBump * (x2 - x1) + srcStride * (y2 - y1); \252} while (0);253254long getPlatformInfoFromImageData(JNIEnv *env, jobject img);255256JNIEXPORT void JNICALL257getViewOriginFromImageData(JNIEnv *env, jobject img, int *x, int *y);258259JNIEXPORT void JNICALL260getDeviceOriginFromImageData(JNIEnv *env, jobject img, int *x, int *y);261262JNIEXPORT void JNICALL263getOutputOriginFromImageData(JNIEnv *env, jobject img, int *x, int *y);264265JNIEXPORT void JNICALL266getTypeFromImageData(JNIEnv *env, jobject img, int *type);267268JNIEXPORT void JNICALL269getOriginFromImageData(JNIEnv *env, jobject img, int *x, int *y);270271JNIEXPORT double JNICALL272getResRatioFromImageData(JNIEnv *env, jobject img);273274JNIEXPORT void JNICALL275getScaleFactorFromImageData(JNIEnv *env, jobject img, double *sx, double *sy);276277JNIEXPORT int JNICALL278getDeviceInfoFromImageData(JNIEnv *env, jobject img);279280/*281* Integer component raster handlers282*/283284JNIEXPORT void JNICALL getIntImageLockInfo(285JNIEnv *env, jobject img,286ImageDataIntLockInfo *lockInfo);287JNIEXPORT unsigned int * JNICALL lockIntImageData(288JNIEnv *env, ImageDataIntLockInfo *lockInfo);289JNIEXPORT void JNICALL unlockIntImageData(290JNIEnv *env, ImageDataIntLockInfo *lockInfo);291292/*293* Short component raster handlers294*/295296JNIEXPORT void JNICALL getShortImageLockInfo(297JNIEnv *env, jobject img,298ImageDataShortLockInfo *lockInfo);299JNIEXPORT unsigned short * JNICALL lockShortImageData(300JNIEnv *env, ImageDataShortLockInfo *lockInfo);301JNIEXPORT void JNICALL unlockShortImageData(302JNIEnv *env, ImageDataShortLockInfo *lockInfo);303304/*305* Byte component raster handlers306*/307308JNIEXPORT void JNICALL getByteImageLockInfo(309JNIEnv *env, jobject img,310ImageDataByteLockInfo *lockInfo);311JNIEXPORT unsigned char * JNICALL lockByteImageData(312JNIEnv *env, ImageDataByteLockInfo *lockInfo);313JNIEXPORT void JNICALL unlockByteImageData(314JNIEnv *env, ImageDataByteLockInfo *lockInfo);315316/*317* Short Indexed component raster handlers318*/319320JNIEXPORT void JNICALL getShortIndexedImageLockInfo(321JNIEnv *env, jobject img,322ImageDataShortIndexedLockInfo *lockInfo);323JNIEXPORT unsigned short * JNICALL lockShortIndexedImageData(324JNIEnv *env, ImageDataShortIndexedLockInfo *lockInfo);325JNIEXPORT void JNICALL unlockShortIndexedImageData(326JNIEnv *env, ImageDataShortIndexedLockInfo *lockInfo);327328/*329* Byte Indexed component raster handlers330*/331332JNIEXPORT void JNICALL getByteIndexedImageLockInfo(333JNIEnv *env, jobject img,334ImageDataByteIndexedLockInfo *lockInfo);335JNIEXPORT unsigned char * JNICALL lockByteIndexedImageData(336JNIEnv *env, ImageDataByteIndexedLockInfo *lockInfo);337JNIEXPORT void JNICALL unlockByteIndexedImageData(338JNIEnv *env, ImageDataByteIndexedLockInfo *lockInfo);339/*340* Index 8 Gray component raster handlers341*/342343JNIEXPORT void JNICALL getIndex8GrayImageLockInfo(344JNIEnv *env, jobject img,345ImageDataIndex8GrayLockInfo *lockInfo);346JNIEXPORT unsigned char * JNICALL lockIndex8GrayImageData(347JNIEnv *env, ImageDataIndex8GrayLockInfo *lockInfo);348JNIEXPORT void JNICALL unlockIndex8GrayImageData(349JNIEnv *env, ImageDataIndex8GrayLockInfo *lockInfo);350/*351* Index 12 Gray component raster handlers352*/353354JNIEXPORT void JNICALL getIndex12GrayImageLockInfo(355JNIEnv *env, jobject img,356ImageDataIndex12GrayLockInfo *lockInfo);357JNIEXPORT unsigned short * JNICALL lockIndex12GrayImageData(358JNIEnv *env, ImageDataIndex12GrayLockInfo *lockInfo);359JNIEXPORT void JNICALL unlockIndex12GrayImageData(360JNIEnv *env, ImageDataIndex12GrayLockInfo *lockInfo);361362/*363* Bit component raster handlers364*/365366JNIEXPORT void JNICALL getBitImageLockInfo(367JNIEnv *env, jobject img, ImageDataBitLockInfo *lockInfo);368JNIEXPORT unsigned char *JNICALL lockBitImageData(369JNIEnv *env, ImageDataBitLockInfo *lockInfo);370JNIEXPORT void JNICALL unlockBitImageData(371JNIEnv *env, ImageDataBitLockInfo *lockInfo);372373#ifdef __cplusplus374};375#endif376377#endif378379380