Path: blob/master/src/java.desktop/share/native/libawt/java2d/loops/ByteGray.h
41159 views
/*1* Copyright (c) 2000, 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 ByteGray_h_Included26#define ByteGray_h_Included2728#include "IntDcm.h"2930/*31* This file contains macro and type definitions used by the macros in32* LoopMacros.h to manipulate a surface of type "ByteGray".33*/3435typedef jubyte ByteGrayPixelType;36typedef jubyte ByteGrayDataType;3738#define ByteGrayIsOpaque 13940#define ByteGrayPixelStride 141#define ByteGrayBitsPerPixel 84243#define DeclareByteGrayLoadVars(PREFIX)44#define DeclareByteGrayStoreVars(PREFIX)45#define SetByteGrayStoreVarsYPos(PREFIX, pRasInfo, y)46#define SetByteGrayStoreVarsXPos(PREFIX, pRasInfo, x)47#define InitByteGrayLoadVars(PREFIX, pRasInfo)48#define InitByteGrayStoreVarsY(PREFIX, pRasInfo)49#define InitByteGrayStoreVarsX(PREFIX, pRasInfo)50#define NextByteGrayStoreVarsX(PREFIX)51#define NextByteGrayStoreVarsY(PREFIX)52#define DeclareByteGrayPixelData(PREFIX)53#define ExtractByteGrayPixelData(PIXEL, PREFIX)5455#define ByteGrayXparLutEntry -156#define ByteGrayIsXparLutEntry(pix) (pix < 0)57#define StoreByteGrayNonXparFromArgb StoreByteGrayFrom1IntArgb585960#define ComposeByteGrayFrom3ByteRgb(r, g, b) \61(ByteGrayDataType)(((77*(r)) + (150*(g)) + (29*(b)) + 128) / 256)626364#define StoreByteGrayPixel(pRas, x, pixel) \65((pRas)[x] = (jubyte) (pixel))6667#define StoreByteGrayPixelData(pPix, x, pixel, PREFIX) \68StoreByteGrayPixel(pPix, x, pixel)6970#define ByteGrayPixelFromArgb(pixel, rgb, pRasInfo) \71do { \72jint r, g, b; \73ExtractIntDcmComponentsX123(rgb, r, g, b); \74(pixel) = ComposeByteGrayFrom3ByteRgb(r, g, b); \75} while (0)767778#define LoadByteGrayTo1IntRgb(pRas, PREFIX, x, rgb) \79do { \80int gray = (pRas)[x]; \81(rgb) = (((gray << 8) | gray) << 8) | gray; \82} while (0)8384#define LoadByteGrayTo1IntArgb(pRas, PREFIX, x, argb) \85do { \86int gray = (pRas)[x]; \87(argb) = (((((0xff << 8) | gray) << 8) | gray) << 8) | gray; \88} while (0)8990#define LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b) \91((r) = (g) = (b) = (pRas)[x])9293#define LoadByteGrayTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \94do { \95LoadByteGrayTo3ByteRgb(pRas, PREFIX, x, r, g, b); \96(a) = 0xff; \97} while (0)9899#define LoadByteGrayTo1ByteGray(pRas, PREFIX, x, gray) \100(gray) = (pRas)[x]101102#define StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, rgb) \103do { \104int r, g, b; \105ExtractIntDcmComponentsX123(rgb, r, g, b); \106StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \107} while (0)108109#define StoreByteGrayFrom1IntArgb(pRas, PREFIX, x, argb) \110StoreByteGrayFrom1IntRgb(pRas, PREFIX, x, argb)111112#define StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \113(pRas)[x] = ComposeByteGrayFrom3ByteRgb(r, g, b)114115#define StoreByteGrayFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \116StoreByteGrayFrom3ByteRgb(pRas, PREFIX, x, r, g, b)117118#define StoreByteGrayFrom1ByteGray(pRas, PREFIX, x, gray) \119StoreByteGrayPixel(pRas, x, gray)120121#define CopyByteGrayToIntArgbPre(pRGB, i, PREFIX, pRow, x) \122LoadByteGrayTo1IntArgb(pRow, PREFIX, x, pRGB[i])123124125#define DeclareByteGrayAlphaLoadData(PREFIX)126#define InitByteGrayAlphaLoadData(PREFIX, pRasInfo)127128#define LoadAlphaFromByteGrayFor1ByteGray(pRas, PREFIX, COMP_PREFIX) \129COMP_PREFIX ## A = 0xff130131#define Postload1ByteGrayFromByteGray(pRas, PREFIX, COMP_PREFIX) \132COMP_PREFIX ## G = pRas[0]133134135#define ByteGrayIsPremultiplied 0136137#define DeclareByteGrayBlendFillVars(PREFIX) \138jubyte PREFIX;139140#define ClearByteGrayBlendFillVars(PREFIX, argb) \141PREFIX = 0142143#define InitByteGrayBlendFillVarsNonPre(PREFIX, argb, COMP_PREFIX) \144PREFIX = (jubyte) COMP_PREFIX ## G145146#define InitByteGrayBlendFillVarsPre(PREFIX, argb, COMP_PREFIX)147148#define StoreByteGrayBlendFill(pRas, PREFIX, x, argb, COMP_PREFIX) \149(pRas)[x] = PREFIX150151#define StoreByteGrayFrom1ByteGrayComps(pRas, PREFIX, x, COMP_PREFIX) \152StoreByteGrayPixel(pRas, x, COMP_PREFIX ## G)153154#endif /* ByteGray_h_Included */155156157