0N/A/*
2362N/A * Copyright (c) 2001, 2004, 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#include <string.h>
0N/A#include <stdio.h>
0N/A#include "AnyByte.h"
0N/A#include "Index8Gray.h"
0N/A#include "AlphaMacros.h"
0N/A
0N/A#include "IntArgb.h"
0N/A#include "IntArgbPre.h"
0N/A#include "IntRgb.h"
0N/A#include "ThreeByteBgr.h"
0N/A#include "ByteGray.h"
0N/A#include "ByteIndexed.h"
0N/A#include "Index12Gray.h"
0N/A
0N/A/*
0N/A * This file declares, registers, and defines the various graphics
0N/A * primitive loops to manipulate surfaces of type "Index8Gray".
0N/A *
0N/A * See also LoopMacros.h
0N/A */
0N/A
0N/ARegisterFunc RegisterIndex8Gray;
0N/A
0N/ADECLARE_CONVERT_BLIT(IntArgb, Index8Gray);
0N/ADECLARE_CONVERT_BLIT(ThreeByteBgr, Index8Gray);
0N/ADECLARE_CONVERT_BLIT(ByteGray, Index8Gray);
0N/ADECLARE_CONVERT_BLIT(Index12Gray, Index8Gray);
0N/ADECLARE_CONVERT_BLIT(ByteIndexed, Index8Gray);
0N/ADECLARE_CONVERT_BLIT(Index8Gray, Index8Gray);
0N/A
0N/ADECLARE_SCALE_BLIT(Index8Gray, Index8Gray);
0N/ADECLARE_SCALE_BLIT(IntArgb, Index8Gray);
0N/ADECLARE_SCALE_BLIT(ThreeByteBgr, Index8Gray);
0N/ADECLARE_SCALE_BLIT(UshortGray, Index8Gray);
0N/ADECLARE_SCALE_BLIT(ByteIndexed, Index8Gray);
0N/ADECLARE_SCALE_BLIT(ByteGray, Index8Gray);
0N/ADECLARE_SCALE_BLIT(Index12Gray, Index8Gray);
0N/A
0N/ADECLARE_XPAR_CONVERT_BLIT(ByteIndexedBm, Index8Gray);
0N/ADECLARE_XPAR_BLITBG(ByteIndexedBm, Index8Gray);
0N/A
0N/ADECLARE_XOR_BLIT(IntArgb, Index8Gray);
0N/ADECLARE_ALPHA_MASKFILL(Index8Gray);
0N/ADECLARE_ALPHA_MASKBLIT(IntArgb, Index8Gray);
0N/ADECLARE_ALPHA_MASKBLIT(IntArgbPre, Index8Gray);
0N/ADECLARE_ALPHA_MASKBLIT(IntRgb, Index8Gray);
0N/ADECLARE_SRCOVER_MASKFILL(Index8Gray);
0N/ADECLARE_SRCOVER_MASKBLIT(IntArgb, Index8Gray);
0N/ADECLARE_SRCOVER_MASKBLIT(IntArgbPre, Index8Gray);
0N/ADECLARE_SOLID_DRAWGLYPHLISTAA(Index8Gray);
0N/A
0N/ADECLARE_TRANSFORMHELPER_FUNCS(Index8Gray);
0N/A
0N/ANativePrimitive Index8GrayPrimitives[] = {
0N/A REGISTER_CONVERT_BLIT(IntArgb, Index8Gray),
0N/A REGISTER_CONVERT_BLIT_EQUIV(IntRgb, Index8Gray,
0N/A NAME_CONVERT_BLIT(IntArgb, Index8Gray)),
0N/A REGISTER_CONVERT_BLIT(ThreeByteBgr, Index8Gray),
0N/A REGISTER_CONVERT_BLIT(ByteGray, Index8Gray),
0N/A REGISTER_CONVERT_BLIT(Index12Gray, Index8Gray),
0N/A REGISTER_CONVERT_BLIT_FLAGS(Index8Gray, Index8Gray,
0N/A SD_LOCK_LUT,
0N/A SD_LOCK_LUT | SD_LOCK_INVGRAY),
0N/A REGISTER_CONVERT_BLIT(ByteIndexed, Index8Gray),
0N/A
0N/A REGISTER_SCALE_BLIT(IntArgb, Index8Gray),
0N/A REGISTER_SCALE_BLIT_EQUIV(IntRgb, Index8Gray,
0N/A NAME_SCALE_BLIT(IntArgb, Index8Gray)),
0N/A REGISTER_SCALE_BLIT(ThreeByteBgr, Index8Gray),
0N/A REGISTER_SCALE_BLIT(UshortGray, Index8Gray),
0N/A REGISTER_SCALE_BLIT(ByteIndexed, Index8Gray),
0N/A REGISTER_SCALE_BLIT(ByteGray, Index8Gray),
0N/A REGISTER_SCALE_BLIT(Index12Gray, Index8Gray),
0N/A REGISTER_SCALE_BLIT_FLAGS(Index8Gray, Index8Gray, 0,
0N/A SD_LOCK_LUT | SD_LOCK_INVGRAY),
0N/A
0N/A REGISTER_XPAR_CONVERT_BLIT(ByteIndexedBm, Index8Gray),
0N/A REGISTER_XPAR_BLITBG(ByteIndexedBm, Index8Gray),
0N/A
0N/A REGISTER_XOR_BLIT(IntArgb, Index8Gray),
0N/A REGISTER_ALPHA_MASKFILL(Index8Gray),
0N/A REGISTER_ALPHA_MASKBLIT(IntArgb, Index8Gray),
0N/A REGISTER_ALPHA_MASKBLIT(IntArgbPre, Index8Gray),
0N/A REGISTER_ALPHA_MASKBLIT(IntRgb, Index8Gray),
0N/A REGISTER_SRCOVER_MASKFILL(Index8Gray),
0N/A REGISTER_SRCOVER_MASKBLIT(IntArgb, Index8Gray),
0N/A REGISTER_SRCOVER_MASKBLIT(IntArgbPre, Index8Gray),
0N/A REGISTER_SOLID_DRAWGLYPHLISTAA(Index8Gray),
0N/A
0N/A REGISTER_TRANSFORMHELPER_FUNCS(Index8Gray),
0N/A};
0N/A
0N/Aextern jboolean checkSameLut(jint *SrcReadLut, jint *DstReadLut,
0N/A SurfaceDataRasInfo *pSrcInfo,
0N/A SurfaceDataRasInfo *pDstInfo);
0N/A
0N/Ajboolean RegisterIndex8Gray(JNIEnv *env)
0N/A{
0N/A return RegisterPrimitives(env, Index8GrayPrimitives,
0N/A ArraySize(Index8GrayPrimitives));
0N/A}
0N/A
0N/Ajint PixelForIndex8Gray(SurfaceDataRasInfo *pRasInfo, jint rgb)
0N/A{
0N/A jint r, g, b, gray;
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b);
0N/A gray = ComposeByteGrayFrom3ByteRgb(r, g, b);
0N/A return pRasInfo->invGrayTable[gray];
0N/A}
0N/A
0N/ADEFINE_CONVERT_BLIT(IntArgb, Index8Gray, 3ByteRgb)
0N/A
0N/ADEFINE_CONVERT_BLIT(ThreeByteBgr, Index8Gray, 3ByteRgb)
0N/A
0N/ADEFINE_CONVERT_BLIT(ByteGray, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_CONVERT_BLIT(Index12Gray, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_CONVERT_BLIT_LUT8(ByteIndexed, Index8Gray, PreProcessLut)
0N/A
0N/Avoid NAME_CONVERT_BLIT(Index8Gray, Index8Gray)
0N/A (void *srcBase, void *dstBase,
0N/A juint width, juint height,
0N/A SurfaceDataRasInfo *pSrcInfo,
0N/A SurfaceDataRasInfo *pDstInfo,
0N/A NativePrimitive *pPrim,
0N/A CompositeInfo *pCompInfo)
0N/A{
0N/A DeclareIndex8GrayLoadVars(SrcRead)
0N/A DeclareIndex8GrayLoadVars(DstRead)
0N/A jint srcScan = pSrcInfo->scanStride;
0N/A jint dstScan = pDstInfo->scanStride;
0N/A
0N/A InitIndex8GrayLoadVars(SrcRead, pSrcInfo);
0N/A InitIndex8GrayLoadVars(DstRead, pDstInfo);
0N/A
0N/A if (checkSameLut(SrcReadLut, DstReadLut, pSrcInfo, pDstInfo)) {
0N/A do {
0N/A memcpy(dstBase, srcBase, width);
0N/A srcBase = PtrAddBytes(srcBase, srcScan);
0N/A dstBase = PtrAddBytes(dstBase, dstScan);
0N/A } while (--height > 0);
0N/A } else {
0N/A DeclareIndex8GrayStoreVars(DstWrite);
0N/A InitIndex8GrayStoreVarsY(DstWrite, pDstInfo);
0N/A
0N/A BlitLoopWidthHeight(Index8Gray, pSrc, srcBase, pSrcInfo,
0N/A Index8Gray, pDst, dstBase, pDstInfo, DstWrite,
0N/A width, height,
0N/A ConvertVia1ByteGray
0N/A (pSrc, Index8Gray, SrcRead,
0N/A pDst, Index8Gray, DstWrite, 0, 0));
0N/A }
0N/A}
0N/A
0N/Avoid NAME_SCALE_BLIT(Index8Gray, Index8Gray)
0N/A (void *srcBase, void *dstBase,
0N/A juint width, juint height,
0N/A jint sxloc, jint syloc,
0N/A jint sxinc, jint syinc, jint shift,
0N/A SurfaceDataRasInfo *pSrcInfo,
0N/A SurfaceDataRasInfo *pDstInfo,
0N/A NativePrimitive *pPrim,
0N/A CompositeInfo *pCompInfo)
0N/A{
0N/A DeclareIndex8GrayLoadVars(SrcRead)
0N/A DeclareIndex8GrayLoadVars(DstRead)
0N/A jint srcScan = pSrcInfo->scanStride;
0N/A jint dstScan = pDstInfo->scanStride;
0N/A DeclareIndex8GrayStoreVars(DstWrite)
0N/A
0N/A InitIndex8GrayLoadVars(SrcRead, pSrcInfo);
0N/A InitIndex8GrayLoadVars(DstRead, pDstInfo);
0N/A
0N/A if (checkSameLut(SrcReadLut, DstReadLut, pSrcInfo, pDstInfo)) {
0N/A BlitLoopScaleWidthHeight(Index8Gray, pSrc, srcBase, pSrcInfo,
0N/A Index8Gray, pDst, dstBase, pDstInfo, DstWrite,
0N/A x, width, height,
0N/A sxloc, syloc, sxinc, syinc, shift,
0N/A pDst[0] = pSrc[x]);
0N/A } else {
0N/A DeclareIndex8GrayStoreVars(DstWrite);
0N/A InitIndex8GrayStoreVarsY(DstWrite, pDstInfo);
0N/A BlitLoopScaleWidthHeight(Index8Gray, pSrc, srcBase, pSrcInfo,
0N/A Index8Gray, pDst, dstBase, pDstInfo, DstWrite,
0N/A x, width, height,
0N/A sxloc, syloc, sxinc, syinc, shift,
0N/A ConvertVia1ByteGray(pSrc, Index8Gray, SrcRead,
0N/A pDst, Index8Gray, DstWrite,
0N/A x, 0));
0N/A }
0N/A}
0N/A
0N/ADEFINE_SCALE_BLIT(IntArgb, Index8Gray, 3ByteRgb)
0N/A
0N/ADEFINE_SCALE_BLIT(ThreeByteBgr, Index8Gray, 3ByteRgb)
0N/A
0N/ADEFINE_SCALE_BLIT(UshortGray, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_SCALE_BLIT_LUT8(ByteIndexed, Index8Gray, PreProcessLut)
0N/A
0N/ADEFINE_SCALE_BLIT(ByteGray, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_SCALE_BLIT(Index12Gray, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_XPAR_CONVERT_BLIT_LUT8(ByteIndexedBm, Index8Gray, PreProcessLut)
0N/A
0N/ADEFINE_XPAR_BLITBG_LUT8(ByteIndexedBm, Index8Gray, PreProcessLut)
0N/A
0N/ADEFINE_XOR_BLIT(IntArgb, Index8Gray, AnyByte)
0N/A
0N/ADEFINE_ALPHA_MASKFILL(Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_ALPHA_MASKBLIT(IntArgb, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_ALPHA_MASKBLIT(IntArgbPre, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_ALPHA_MASKBLIT(IntRgb, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_SRCOVER_MASKFILL(Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_SRCOVER_MASKBLIT(IntArgb, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_SRCOVER_MASKBLIT(IntArgbPre, Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_SOLID_DRAWGLYPHLISTAA(Index8Gray, 1ByteGray)
0N/A
0N/ADEFINE_TRANSFORMHELPERS(Index8Gray)