0N/A/*
2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef ByteIndexed_h_Included
0N/A#define ByteIndexed_h_Included
0N/A
0N/A#include "IntDcm.h"
0N/A
0N/A/*
0N/A * This file contains macro and type definitions used by the macros in
0N/A * LoopMacros.h to manipulate a surface of type "ByteIndexed".
0N/A */
0N/A
0N/Atypedef jubyte ByteIndexedPixelType;
0N/Atypedef jubyte ByteIndexedDataType;
0N/A
0N/A#define ByteIndexedPixelStride 1
0N/A#define ByteIndexedBitsPerPixel 8
0N/A
0N/A#define DeclareByteIndexedLoadVars(PREFIX) \
0N/A jint *PREFIX ## Lut;
0N/A
0N/A#define DeclareByteIndexedStoreVars(PREFIX) \
0N/A int PREFIX ## XDither, PREFIX ## YDither; \
0N/A char *PREFIX ## rerr, *PREFIX ## gerr, *PREFIX ## berr; \
0N/A unsigned char *PREFIX ## InvLut;
0N/A
0N/A#define SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, LOC) \
0N/A do { \
0N/A PREFIX ## YDither = ((LOC & 7) << 3); \
0N/A } while (0)
0N/A
0N/A#define SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, LOC) \
0N/A do { \
0N/A PREFIX ## rerr = (pRasInfo)->redErrTable + PREFIX ## YDither; \
0N/A PREFIX ## gerr = (pRasInfo)->grnErrTable + PREFIX ## YDither; \
0N/A PREFIX ## berr = (pRasInfo)->bluErrTable + PREFIX ## YDither; \
0N/A PREFIX ## XDither = (LOC & 7); \
0N/A } while (0)
0N/A
0N/A#define InitByteIndexedLoadVars(PREFIX, pRasInfo) \
0N/A PREFIX ## Lut = (pRasInfo)->lutBase
0N/A
0N/A/* REMIND Could collapse Init..Store..X and Init..Store..Y into one Init
0N/A * and factor out the Set.. macros.
0N/A */
0N/A#define InitByteIndexedStoreVarsY(PREFIX, pRasInfo) \
0N/A do { \
0N/A SetByteIndexedStoreVarsYPos(PREFIX, pRasInfo, (pRasInfo)->bounds.y1); \
0N/A PREFIX ## InvLut = (pRasInfo)->invColorTable; \
0N/A } while (0)
0N/A
0N/A#define InitByteIndexedStoreVarsX(PREFIX, pRasInfo) \
0N/A SetByteIndexedStoreVarsXPos(PREFIX, pRasInfo, (pRasInfo)->bounds.x1);
0N/A
0N/A
0N/A#define NextByteIndexedStoreVarsX(PREFIX) \
0N/A PREFIX ## XDither = (PREFIX ## XDither + 1) & 7
0N/A
0N/A#define NextByteIndexedStoreVarsY(PREFIX) \
0N/A PREFIX ## YDither = (PREFIX ## YDither + (1 << 3)) & (7 << 3)
0N/A
0N/Atypedef jubyte ByteIndexedBmPixelType;
0N/Atypedef jubyte ByteIndexedBmDataType;
0N/A
0N/A#define ByteIndexedBmPixelStride 1
0N/A#define ByteIndexedBmBitsPerPixel 8
0N/A
0N/A#define DeclareByteIndexedBmLoadVars DeclareByteIndexedLoadVars
0N/A#define DeclareByteIndexedBmStoreVars DeclareByteIndexedStoreVars
0N/A#define InitByteIndexedBmLoadVars InitByteIndexedLoadVars
0N/A#define InitByteIndexedBmStoreVarsY InitByteIndexedStoreVarsY
0N/A#define InitByteIndexedBmStoreVarsX InitByteIndexedStoreVarsX
0N/A#define NextByteIndexedBmStoreVarsX NextByteIndexedStoreVarsX
0N/A#define NextByteIndexedBmStoreVarsY NextByteIndexedStoreVarsY
0N/A
0N/A#define LoadByteIndexedBmTo1IntArgb LoadByteIndexedTo1IntArgb
0N/A
0N/A#define CopyByteIndexedBmToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
0N/A do { \
0N/A jint argb = PREFIX ## Lut[pRow[x]]; \
0N/A (pRGB)[i] = argb & (argb >> 24); \
0N/A } while (0)
0N/A
0N/A
0N/A#define ByteIndexedXparLutEntry -1
0N/A#define ByteIndexedIsXparLutEntry(pix) (pix < 0)
0N/A#define StoreByteIndexedNonXparFromArgb StoreByteIndexedFrom1IntArgb
0N/A
0N/A#define StoreByteIndexedPixel(pRas, x, pixel) \
0N/A ((pRas)[x] = (jubyte) (pixel))
0N/A
0N/A#define DeclareByteIndexedPixelData(PREFIX)
0N/A#define ExtractByteIndexedPixelData(PIXEL, PREFIX)
0N/A
0N/A#define StoreByteIndexedPixelData(pPix, x, pixel, PREFIX) \
0N/A (pPix)[x] = (jubyte) (pixel)
0N/A
0N/A#define ByteIndexedPixelFromArgb(pixel, rgb, pRasInfo) \
0N/A do { \
0N/A jint r, g, b; \
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b); \
0N/A (pixel) = SurfaceData_InvColorMap((pRasInfo)->invColorTable, \
0N/A r, g, b); \
0N/A } while (0)
0N/A
0N/A#define LoadByteIndexedTo1IntRgb(pRas, PREFIX, x, rgb) \
0N/A (rgb) = PREFIX ## Lut[pRas[x]]
0N/A
0N/A#define LoadByteIndexedTo1IntArgb(pRas, PREFIX, x, argb) \
0N/A (argb) = PREFIX ## Lut[pRas[x]]
0N/A
0N/A#define LoadByteIndexedTo3ByteRgb(pRas, PREFIX, x, r, g, b) \
0N/A do { \
0N/A jint rgb = PREFIX ## Lut[pRas[x]]; \
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b); \
0N/A } while (0)
0N/A
0N/A#define LoadByteIndexedTo4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
0N/A do { \
0N/A jint argb = PREFIX ## Lut[pRas[x]]; \
0N/A ExtractIntDcmComponents1234(argb, a, r, g, b); \
0N/A } while (0)
0N/A
0N/A#define ByteClamp1Component(X) \
0N/A do { if (((X) >> 8) != 0) {X = (~(X >> 31)) & 255; } } while (0)
0N/A
0N/A#define ByteClamp3Components(R, G, B) \
0N/A do { \
0N/A if (((R|G|B) >> 8) != 0) { \
0N/A ByteClamp1Component(R); \
0N/A ByteClamp1Component(G); \
0N/A ByteClamp1Component(B); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, rgb) \
0N/A do { \
0N/A int r, g, b; \
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b); \
0N/A StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b); \
0N/A } while (0)
0N/A
0N/A#define StoreByteIndexedFrom1IntArgb(pRas, PREFIX, x, argb) \
0N/A StoreByteIndexedFrom1IntRgb(pRas, PREFIX, x, argb)
0N/A
0N/A#define StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b) \
0N/A do { \
0N/A r += PREFIX ## rerr[PREFIX ## XDither]; \
0N/A g += PREFIX ## gerr[PREFIX ## XDither]; \
0N/A b += PREFIX ## berr[PREFIX ## XDither]; \
0N/A ByteClamp3Components(r, g, b); \
0N/A (pRas)[x] = SurfaceData_InvColorMap(PREFIX ## InvLut, r, g, b); \
0N/A } while (0)
0N/A
0N/A#define StoreByteIndexedFrom4ByteArgb(pRas, PREFIX, x, a, r, g, b) \
0N/A StoreByteIndexedFrom3ByteRgb(pRas, PREFIX, x, r, g, b)
0N/A
0N/A#define CopyByteIndexedToIntArgbPre(pRGB, i, PREFIX, pRow, x) \
0N/A do { \
0N/A jint argb = PREFIX ## Lut[pRow[x]]; \
0N/A jint a = URShift(argb, 24); \
0N/A if (a == 0) { \
0N/A argb = 0; \
0N/A } else if (a < 0xff) { \
0N/A jint r = (argb >> 16) & 0xff; \
0N/A jint g = (argb >> 8) & 0xff; \
0N/A jint b = (argb ) & 0xff; \
0N/A r = MUL8(a, r); \
0N/A g = MUL8(a, g); \
0N/A b = MUL8(a, b); \
0N/A argb = ComposeIntDcmComponents1234(a, r, g, b); \
0N/A } \
0N/A (pRGB)[i] = argb; \
0N/A } while (0)
0N/A
0N/A
0N/A#define DeclareByteIndexedAlphaLoadData(PREFIX) \
0N/A jint *PREFIX ## Lut; \
0N/A jint PREFIX ## rgb;
0N/A
0N/A#define InitByteIndexedAlphaLoadData(PREFIX, pRasInfo) \
0N/A PREFIX ## Lut = (pRasInfo)->lutBase
0N/A
0N/A#define LoadAlphaFromByteIndexedFor4ByteArgb(pRas, PREFIX, COMP_PREFIX) \
0N/A do { \
0N/A PREFIX ## rgb = PREFIX ## Lut[(pRas)[0]]; \
0N/A COMP_PREFIX ## A = ((juint) PREFIX ## rgb) >> 24; \
0N/A } while (0)
0N/A
0N/A#define Postload4ByteArgbFromByteIndexed(pRas, PREFIX, COMP_PREFIX) \
0N/A do { \
0N/A COMP_PREFIX ## R = (PREFIX ## rgb >> 16) & 0xff; \
0N/A COMP_PREFIX ## G = (PREFIX ## rgb >> 8) & 0xff; \
0N/A COMP_PREFIX ## B = (PREFIX ## rgb >> 0) & 0xff; \
0N/A } while (0)
0N/A
0N/A
0N/A#define ByteIndexedIsPremultiplied 0
0N/A
0N/A#define StoreByteIndexedFrom4ByteArgbComps(pRas, PREFIX, x, COMP_PREFIX) \
0N/A StoreByteIndexedFrom4ByteArgb(pRas, PREFIX, x, \
0N/A COMP_PREFIX ## A, COMP_PREFIX ## R, \
0N/A COMP_PREFIX ## G, COMP_PREFIX ## B)
0N/A
0N/A#endif /* ByteIndexed_h_Included */