0N/A/*
2362N/A * Copyright (c) 1996, 1997, 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/*
0N/A * This file contains macro definitions for the Alpha category of the
0N/A * macros used by the generic scaleloop function.
0N/A *
0N/A * This implementation of the Alpha macros will perform an ordered
0N/A * dither of the 8-bit alpha values collected from the input pixel
0N/A * data to construct a 1-bit deep image mask used to control the
0N/A * pixel coverage of the color pixels in the output. This is a
0N/A * minimal quality implementation of Alpha that has the advantage
0N/A * that it is easy to support on a wide variety of platforms and
0N/A * graphics systems.
0N/A *
0N/A * This file can be used to provide the default implementation of the
0N/A * Alpha macros, handling all transparency cases.
0N/A */
0N/A
0N/A/*
0N/A * The macro IfAlpha is used by the varous pixel conversion macros
0N/A * to conditionally compile code that is only needed if alpha values
0N/A * are going to be used.
0N/A */
0N/A#define IfAlpha(statements) statements
0N/A
0N/A#ifdef DEBUG
0N/A#define DeclareAlphaDebugVars \
0N/A MaskBits *endMask;
0N/A#define SetupEndMask(mask, dstH, cvdata) \
0N/A do {endMask = mask + dstH * MaskScan(cvdata);} while (0)
0N/A#else /* DEBUG */
0N/A#define DeclareAlphaDebugVars
0N/A#define SetupEndMask(mask, dstH, cvdata) \
0N/A do {} while (0)
0N/A#endif /* DEBUG */
0N/A
0N/A#define DeclareAlphaVars \
0N/A DeclareAlphaDebugVars \
0N/A MaskBits *mask; \
0N/A MaskBits maskbits, maskcurbit, maskadjust; \
0N/A int laststore; \
0N/A extern uns_ordered_dither_array img_oda_alpha;
0N/A
0N/A#define InitAlpha(cvdata, dstY, dstX1, dstX2) \
0N/A do { \
0N/A laststore = 1; \
0N/A mask = (MaskBits *) cvdata->maskbuf; \
0N/A maskadjust = - (MaskOffset(dstX2) - MaskOffset(dstX1)); \
0N/A if (mask) { \
0N/A SetupEndMask(mask, dstTotalHeight, cvdata); \
0N/A mask += ((dstY * MaskScan(cvdata)) \
0N/A + MaskOffset(dstX1)); \
0N/A maskadjust += MaskScan(cvdata); \
0N/A maskcurbit = 1; \
0N/A } else { \
0N/A maskcurbit = 0; \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define StartAlphaRow(cvdata, dstX, dstY) \
0N/A do { \
0N/A if (maskcurbit) { \
0N/A maskbits = *mask; \
0N/A maskcurbit = MaskInit(dstX); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define IncrementMaskBit(dstX) \
0N/A do { \
0N/A if (((maskcurbit) >>= 1) == 0) { \
0N/A *mask++ = maskbits; \
0N/A if (dstX < DSTX2 - 1) { \
0N/A img_check(mask < endMask); \
0N/A maskbits = *mask; \
0N/A } else { \
0N/A laststore = 0; \
0N/A } \
0N/A maskcurbit = MaskInit(0); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define SetTransparentPixel(cvdata, dstX, dstY) \
0N/A do { \
0N/A if (!maskcurbit) { \
0N/A mask = (MaskBits *) ImgInitMask(cvdata, \
0N/A DSTX1, DSTY1, \
0N/A DSTX2, DSTY2); \
0N/A if (!mask) { \
0N/A SignalError(0, JAVAPKG "OutOfMemoryError", 0); \
0N/A return SCALEFAILURE; \
0N/A } \
0N/A SetupEndMask(mask, dstTotalHeight, cvdata); \
0N/A mask += ((dstY * MaskScan(cvdata)) \
0N/A + MaskOffset(dstX)); \
0N/A maskadjust += MaskScan(cvdata); \
0N/A maskbits = *mask; \
0N/A maskcurbit = MaskInit(dstX); \
0N/A } \
0N/A SetTransparentBit(maskbits, maskcurbit); \
0N/A IncrementMaskBit(dstX); \
0N/A } while (0)
0N/A
0N/A#define SetOpaquePixel(cvdata, dstX, dstY) \
0N/A do { \
0N/A if (maskcurbit) { \
0N/A SetOpaqueBit(maskbits, maskcurbit); \
0N/A IncrementMaskBit(dstX); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define ApplyAlpha(cvdata, dstX, dstY, alpha) \
0N/A do { \
0N/A if (alpha + img_oda_alpha[dstX & 7][dstY & 7] < 255) { \
0N/A SetTransparentPixel(cvdata, dstX, dstY); \
0N/A } else { \
0N/A SetOpaquePixel(cvdata, dstX, dstY); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define EndMaskLine() \
0N/A do { \
0N/A if (maskcurbit) { \
0N/A if (laststore) { \
0N/A img_check(mask < endMask); \
0N/A *mask = maskbits; \
0N/A } \
0N/A mask += maskadjust; \
0N/A } \
0N/A } while (0)