Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/Index8Gray.h
41159 views
/*1* Copyright (c) 2001, 2008, 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#ifndef Index8Gray_h_Included26#define Index8Gray_h_Included2728#include "IntDcm.h"29#include "ByteGray.h"3031/*32* This file contains macro and type definitions used by the macros in33* LoopMacros.h to manipulate a surface of type "Index8Gray".34*/3536typedef jubyte Index8GrayPixelType;37typedef jubyte Index8GrayDataType;3839#define Index8GrayIsOpaque 14041#define Index8GrayPixelStride 142#define Index8GrayBitsPerPixel 84344#define DeclareIndex8GrayLoadVars(PREFIX) \45jint *PREFIX ## Lut;4647#define DeclareIndex8GrayStoreVars(PREFIX) \48jint *PREFIX ## InvGrayLut;4950#define SetIndex8GrayStoreVarsYPos(PREFIX, pRasInfo, LOC)51#define SetIndex8GrayStoreVarsXPos(PREFIX, pRasInfo, LOC)52#define InitIndex8GrayLoadVars(PREFIX, pRasInfo) \53PREFIX ## Lut = (pRasInfo)->lutBase5455#define InitIndex8GrayStoreVarsY(PREFIX, pRasInfo) \56PREFIX ## InvGrayLut = (pRasInfo)->invGrayTable;5758#define InitIndex8GrayStoreVarsX(PREFIX, pRasInfo)59#define NextIndex8GrayStoreVarsX(PREFIX)60#define NextIndex8GrayStoreVarsY(PREFIX)6162#define Index8GrayXparLutEntry -163#define Index8GrayIsXparLutEntry(pix) (pix < 0)64#define StoreIndex8GrayNonXparFromArgb StoreIndex8GrayFrom1IntArgb6566#define StoreIndex8GrayPixel(pRas, x, pixel) \67((pRas)[x] = (jubyte) (pixel))6869#define DeclareIndex8GrayPixelData(PREFIX)7071#define ExtractIndex8GrayPixelData(PIXEL, PREFIX)7273#define StoreIndex8GrayPixelData(pPix, x, pixel, PREFIX) \74((pPix)[x] = (jubyte)(pixel))7576#define Index8GrayPixelFromArgb(pixel, rgb, pRasInfo) \77do { \78jint r, g, b, gray; \79ExtractIntDcmComponentsX123(rgb, r, g, b); \80gray = ComposeByteGrayFrom3ByteRgb(r, g, b); \81(pixel) = (pRasInfo)->invGrayTable[gray]; \82} while (0)8384#define LoadIndex8GrayTo1IntRgb(pRas, PREFIX, x, rgb) \85(rgb) = PREFIX ## Lut[pRas[x]]8687#define LoadIndex8GrayTo1IntArgb(pRas, PREFIX, x, argb) \88(argb) = PREFIX ## Lut[pRas[x]]8990#define LoadIndex8GrayTo1ByteGray(pRas, PREFIX, x, gray) \91(gray) = (jubyte)PREFIX ## Lut[pRas[x]]9293#define LoadIndex8GrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \94r = g = b = (jubyte)PREFIX ## Lut[pRas[x]]9596#define LoadIndex8GrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \97do { \98a = 0xff; \99LoadIndex8GrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \100} while (0)101102#define StoreIndex8GrayFrom1IntRgb(pRas, PREFIX, x, rgb) \103do { \104int r, g, b; \105ExtractIntDcmComponentsX123(rgb, r, g, b); \106StoreIndex8GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \107} while (0)108109#define StoreIndex8GrayFrom1IntArgb(pRas, PREFIX, x, argb) \110StoreIndex8GrayFrom1IntRgb(pRas, PREFIX, x, argb)111112#define StoreIndex8GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \113do { \114int gray = ComposeByteGrayFrom3ByteRgb(r, g, b); \115(pRas)[x] = (jubyte) (PREFIX ## InvGrayLut[gray]); \116} while (0)117118#define StoreIndex8GrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \119StoreIndex8GrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)120121#define StoreIndex8GrayFrom1ByteGray(pRas, PREFIX, x, gray) \122(pRas)[x] = (jubyte) (PREFIX ## InvGrayLut[gray]);123124#define CopyIndex8GrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \125(pRGB)[i] = PREFIX ## Lut[pRow[x]]126127128#define DeclareIndex8GrayAlphaLoadData(PREFIX) \129jint *PREFIX ## Lut;130131#define InitIndex8GrayAlphaLoadData(PREFIX, pRasInfo) \132PREFIX ## Lut = (pRasInfo)->lutBase133134#define LoadAlphaFromIndex8GrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \135COMP_PREFIX ## A = 0xff136137#define Postload1ByteGrayFromIndex8Gray(pRas, PREFIX, COMP_PREFIX) \138COMP_PREFIX ## G = (jubyte)PREFIX ## Lut[(pRas)[0]]139140#define StoreIndex8GrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \141StoreIndex8GrayFrom1ByteGray(pRas, PREFIX, x, COMP_PREFIX ## G)142143#define Index8GrayIsPremultiplied 0144145#endif /* Index8Gray_h_Included */146147148