0N/A/*
2362N/A * Copyright (c) 2000, 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
0N/A#include "AnyByte.h"
0N/A#include "ByteIndexed.h"
0N/A#include "AlphaMacros.h"
0N/A
0N/A#include "IntArgb.h"
0N/A#include "IntArgbBm.h"
0N/A#include "IntArgbPre.h"
0N/A#include "IntRgb.h"
0N/A#include "ThreeByteBgr.h"
0N/A#include "ByteGray.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 "ByteIndexed".
0N/A *
0N/A * See also LoopMacros.h
0N/A */
0N/A
0N/ARegisterFunc RegisterByteIndexed;
0N/A
0N/ADECLARE_CONVERT_BLIT(IntArgb, ByteIndexed);
0N/ADECLARE_CONVERT_BLIT(ThreeByteBgr, ByteIndexed);
0N/ADECLARE_CONVERT_BLIT(ByteGray, ByteIndexed);
0N/ADECLARE_CONVERT_BLIT(ByteIndexed, ByteIndexed);
0N/ADECLARE_CONVERT_BLIT(Index12Gray, ByteIndexed);
0N/ADECLARE_SCALE_BLIT(IntArgb, ByteIndexed);
0N/ADECLARE_SCALE_BLIT(ThreeByteBgr, ByteIndexed);
0N/ADECLARE_SCALE_BLIT(ByteGray, ByteIndexed);
0N/ADECLARE_SCALE_BLIT(Index12Gray, ByteIndexed);
0N/ADECLARE_SCALE_BLIT(ByteIndexed, ByteIndexed);
0N/ADECLARE_XPAR_CONVERT_BLIT(ByteIndexedBm, ByteIndexed);
0N/ADECLARE_XPAR_SCALE_BLIT(ByteIndexedBm, ByteIndexed);
0N/ADECLARE_XPAR_SCALE_BLIT(IntArgbBm, ByteIndexed);
0N/ADECLARE_XPAR_BLITBG(ByteIndexedBm, ByteIndexed);
0N/ADECLARE_XPAR_CONVERT_BLIT(IntArgbBm, ByteIndexed);
0N/ADECLARE_XPAR_BLITBG(IntArgbBm, ByteIndexed);
0N/A
0N/ADECLARE_XOR_BLIT(IntArgb, ByteIndexed);
0N/ADECLARE_ALPHA_MASKFILL(ByteIndexed);
0N/ADECLARE_ALPHA_MASKBLIT(IntArgb, ByteIndexed);
0N/ADECLARE_ALPHA_MASKBLIT(IntArgbPre, ByteIndexed);
0N/ADECLARE_ALPHA_MASKBLIT(IntRgb, ByteIndexed);
0N/ADECLARE_SOLID_DRAWGLYPHLISTAA(ByteIndexed);
0N/A
0N/ADECLARE_TRANSFORMHELPER_FUNCS(ByteIndexed);
0N/ADECLARE_TRANSFORMHELPER_FUNCS(ByteIndexedBm);
0N/A
0N/ANativePrimitive ByteIndexedPrimitives[] = {
0N/A REGISTER_CONVERT_BLIT(IntArgb, ByteIndexed),
0N/A REGISTER_CONVERT_BLIT_EQUIV(IntRgb, ByteIndexed,
0N/A NAME_CONVERT_BLIT(IntArgb, ByteIndexed)),
0N/A REGISTER_CONVERT_BLIT_EQUIV(IntArgbBm, ByteIndexed,
0N/A NAME_CONVERT_BLIT(IntArgb, ByteIndexed)),
0N/A REGISTER_CONVERT_BLIT(ThreeByteBgr, ByteIndexed),
0N/A REGISTER_CONVERT_BLIT(ByteGray, ByteIndexed),
0N/A REGISTER_CONVERT_BLIT(Index12Gray, ByteIndexed),
0N/A REGISTER_CONVERT_BLIT_FLAGS(ByteIndexed, ByteIndexed, 0, SD_LOCK_LUT),
0N/A REGISTER_SCALE_BLIT(IntArgb, ByteIndexed),
0N/A REGISTER_SCALE_BLIT_EQUIV(IntRgb, ByteIndexed,
0N/A NAME_SCALE_BLIT(IntArgb, ByteIndexed)),
0N/A REGISTER_SCALE_BLIT_EQUIV(IntArgbBm, ByteIndexed,
0N/A NAME_SCALE_BLIT(IntArgb, ByteIndexed)),
0N/A REGISTER_SCALE_BLIT(ThreeByteBgr, ByteIndexed),
0N/A REGISTER_SCALE_BLIT(ByteGray, ByteIndexed),
0N/A REGISTER_SCALE_BLIT(Index12Gray, ByteIndexed),
0N/A REGISTER_SCALE_BLIT_FLAGS(ByteIndexed, ByteIndexed, 0, SD_LOCK_LUT),
0N/A REGISTER_XPAR_CONVERT_BLIT(ByteIndexedBm, ByteIndexed),
0N/A REGISTER_XPAR_SCALE_BLIT(ByteIndexedBm, ByteIndexed),
0N/A REGISTER_XPAR_SCALE_BLIT(IntArgbBm, ByteIndexed),
0N/A REGISTER_XPAR_BLITBG(ByteIndexedBm, ByteIndexed),
0N/A REGISTER_XPAR_CONVERT_BLIT(IntArgbBm, ByteIndexed),
0N/A REGISTER_XPAR_BLITBG(IntArgbBm, ByteIndexed),
0N/A
0N/A REGISTER_XOR_BLIT(IntArgb, ByteIndexed),
0N/A REGISTER_ALPHA_MASKFILL(ByteIndexed),
0N/A REGISTER_ALPHA_MASKBLIT(IntArgb, ByteIndexed),
0N/A REGISTER_ALPHA_MASKBLIT(IntArgbPre, ByteIndexed),
0N/A REGISTER_ALPHA_MASKBLIT(IntRgb, ByteIndexed),
0N/A REGISTER_SOLID_DRAWGLYPHLISTAA(ByteIndexed),
0N/A
0N/A REGISTER_TRANSFORMHELPER_FUNCS(ByteIndexed),
0N/A REGISTER_TRANSFORMHELPER_FUNCS(ByteIndexedBm),
0N/A};
0N/A
0N/Ajboolean RegisterByteIndexed(JNIEnv *env)
0N/A{
0N/A return RegisterPrimitives(env, ByteIndexedPrimitives,
0N/A ArraySize(ByteIndexedPrimitives));
0N/A}
0N/A
0N/Ajint PixelForByteIndexed(SurfaceDataRasInfo *pRasInfo, jint rgb)
0N/A{
0N/A jint r, g, b;
0N/A ExtractIntDcmComponentsX123(rgb, r, g, b);
0N/A return SurfaceData_InvColorMap(pRasInfo->invColorTable, r, g, b);
0N/A}
0N/A
0N/Ajboolean checkSameLut(jint *SrcReadLut, jint *DstReadLut,
0N/A SurfaceDataRasInfo *pSrcInfo,
0N/A SurfaceDataRasInfo *pDstInfo)
0N/A{
0N/A if (SrcReadLut != DstReadLut) {
0N/A juint lutSize = pSrcInfo->lutSize;
0N/A if (lutSize > pDstInfo->lutSize) {
0N/A return JNI_FALSE;
0N/A } else {
0N/A juint i;
0N/A for (i = 0; i < lutSize; i++) {
0N/A if (SrcReadLut[i] != DstReadLut[i]) {
0N/A return JNI_FALSE;
0N/A }
0N/A }
0N/A }
0N/A }
0N/A return JNI_TRUE;
0N/A}
0N/A
0N/ADEFINE_CONVERT_BLIT(IntArgb, ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_CONVERT_BLIT(ThreeByteBgr, ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_CONVERT_BLIT(ByteGray, ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_CONVERT_BLIT(Index12Gray, ByteIndexed, 3ByteRgb)
0N/A
0N/Avoid NAME_CONVERT_BLIT(ByteIndexed, ByteIndexed)
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 DeclareByteIndexedLoadVars(SrcRead)
0N/A DeclareByteIndexedLoadVars(DstRead)
0N/A jint srcScan = pSrcInfo->scanStride;
0N/A jint dstScan = pDstInfo->scanStride;
0N/A
0N/A InitByteIndexedLoadVars(SrcRead, pSrcInfo);
0N/A InitByteIndexedLoadVars(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 DeclareByteIndexedStoreVars(DstWrite);
0N/A
0N/A BlitLoopWidthHeight(ByteIndexed, pSrc, srcBase, pSrcInfo,
0N/A ByteIndexed, pDst, dstBase, pDstInfo, DstWrite,
0N/A width, height,
0N/A ConvertVia3ByteRgb
0N/A (pSrc, ByteIndexed, SrcRead,
0N/A pDst, ByteIndexed, DstWrite, 0, 0));
0N/A }
0N/A}
0N/A
0N/ADEFINE_SCALE_BLIT(IntArgb, ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_SCALE_BLIT(ThreeByteBgr, ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_SCALE_BLIT(ByteGray, ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_SCALE_BLIT(Index12Gray, ByteIndexed, 3ByteRgb)
0N/A
0N/Avoid NAME_SCALE_BLIT(ByteIndexed, ByteIndexed)
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 DeclareByteIndexedLoadVars(SrcRead)
0N/A DeclareByteIndexedLoadVars(DstRead)
0N/A jint srcScan = pSrcInfo->scanStride;
0N/A jint dstScan = pDstInfo->scanStride;
0N/A DeclareByteIndexedStoreVars(DstWrite)
0N/A
0N/A InitByteIndexedLoadVars(SrcRead, pSrcInfo);
0N/A InitByteIndexedLoadVars(DstRead, pDstInfo);
0N/A
0N/A if (checkSameLut(SrcReadLut, DstReadLut, pSrcInfo, pDstInfo)) {
0N/A BlitLoopScaleWidthHeight(ByteIndexed, pSrc, srcBase, pSrcInfo,
0N/A ByteIndexed, 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 BlitLoopScaleWidthHeight(ByteIndexed, pSrc, srcBase, pSrcInfo,
0N/A ByteIndexed, pDst, dstBase, pDstInfo, DstWrite,
0N/A x, width, height,
0N/A sxloc, syloc, sxinc, syinc, shift,
0N/A ConvertVia3ByteRgb(pSrc, ByteIndexed, SrcRead,
0N/A pDst, ByteIndexed, DstWrite,
0N/A x, 0));
0N/A }
0N/A}
0N/A
0N/ADEFINE_XPAR_CONVERT_BLIT_LUT8(ByteIndexedBm, ByteIndexed, ConvertOnTheFly)
0N/A
0N/ADEFINE_XPAR_SCALE_BLIT_LUT8(ByteIndexedBm, ByteIndexed, ConvertOnTheFly)
0N/A
0N/ADEFINE_XPAR_SCALE_BLIT(IntArgbBm, ByteIndexed, 1IntRgb)
0N/A
0N/ADEFINE_XPAR_BLITBG_LUT8(ByteIndexedBm, ByteIndexed, ConvertOnTheFly)
0N/A
0N/ADEFINE_XPAR_CONVERT_BLIT(IntArgbBm, ByteIndexed, 1IntRgb)
0N/A
0N/ADEFINE_XPAR_BLITBG(IntArgbBm, ByteIndexed, 1IntRgb)
0N/A
0N/ADEFINE_XOR_BLIT(IntArgb, ByteIndexed, AnyByte)
0N/A
0N/ADEFINE_ALPHA_MASKFILL(ByteIndexed, 4ByteArgb)
0N/A
0N/ADEFINE_ALPHA_MASKBLIT(IntArgb, ByteIndexed, 4ByteArgb)
0N/A
0N/ADEFINE_ALPHA_MASKBLIT(IntArgbPre, ByteIndexed, 4ByteArgb)
0N/A
0N/ADEFINE_ALPHA_MASKBLIT(IntRgb, ByteIndexed, 4ByteArgb)
0N/A
0N/ADEFINE_SOLID_DRAWGLYPHLISTAA(ByteIndexed, 3ByteRgb)
0N/A
0N/ADEFINE_TRANSFORMHELPERS(ByteIndexed)
0N/A
0N/ADEFINE_TRANSFORMHELPERS(ByteIndexedBm)