/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifndef AlphaMath_h_Included
#define AlphaMath_h_Included
extern void initAlphaTables();
/*
* Multiply and Divide macros for single byte (8-bit) quantities representing
* the values 0.0 to 1.0 as 0x00 to 0xff.
* MUL8 multiplies its operands together
* DIV8 divides the first operand by the second, clipping to 0xff
* (Note that since the divisor for DIV8 is likely to be
* the alpha quantity which is likely to be the same for
* multiple adjacent invocations, the table is designed
* with the first index being the divisor to hopefully
* improve memory cache hits...)
*/
/*
* Multiply and Divide macros for operations involving a single short (16-bit)
* quantity and a single byte (8-bit) quantity. Typically, promoting the
* 8-bit value to 16 bits would lead to overflow when the operation occurs.
* These macros have been modified somewhat so that overflow will not occur.
* MUL8_16 multiplies an 8-bit value by a 16-bit value (the order of operands
* is unimportant since multiplication is a commutative operation)
* DIV16_8 divides the first (16-bit) operand by the second (8-bit) value
*/
/*
* Multiply and Divide macros for single short (16-bit) quantities
* representing the values 0.0 to 1.0 as 0x0000 to 0xffff.
* MUL16 multiplies its operands using the standard multiplication operator
* and normalizes the result to the appropriate range
* DIV16 divides the first operand by the second and normalizes the result
* to a 16-bit value
*/
/*
* Macro for the sum of two normalized (16-bit) products. Refer to the
* following equation and note that the right side reduces the number of
* divide operations in the left side and increases the precision of the
* result:
* a*f1 + b*f2 a*f1 + b*f2
* ---- ---- = ----------- (where n in this case will be 65535)
* n n n
*/
/*
* The following macros help to generalize the MaskBlit and MaskFill loops
* found in AlphaMacros.h. The appropriate macros will be used based on the
* strategy of the given loop. The strategy types take the form:
* <number of components per pixel><component data type><colorspace>
* For example, these are the current strategy types:
* 3ByteRgb (currently only used as a glyph list blending strategy where
* the alpha value itself is neither blended nor stored)
* 4ByteArgb (eg. IntArgb, ThreeByteBgr, Ushort555Rgb, ByteIndexed, etc.)
* 4ShortArgb (not used currently; could be used when surface types using
* 16 bits per component are implemented)
* 1ByteGray (eg. ByteGray)
* 1ShortGray (eg. UshortGray)
* Note that the macros which operate on alpha values have the word "Alpha"
* components of a given strategy will have the word "Components" or "Comps"
* in their name.
*/
/*
* MaxValFor ## STRATEGY
*/
/*
* AlphaType ## STRATEGY
*/
/*
* ComponentType ## STRATEGY
*/
/*
* DeclareAlphaVarFor ## STRATEGY(VAR)
*
* jint a;
*/
/*
* DeclareAndInitAlphaVarFor ## STRATEGY(VAR, initval)
*
* jint a = initval;
*/
/*
* DeclareAndClearAlphaVarFor ## STRATEGY(VAR)
*
* jint a = 0;
*/
/*
* DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(VAR)
*
* jint a = 0xff;
*/
/*
* DeclareAndInvertAlphaVarFor ## STRATEGY(VAR, invalpha)
*
* jint a = 0xff - resA;
*/
/*
* DeclareCompVarsFor ## STRATEGY(PREFIX)
*
* jint c;
*/
ComponentType1ByteGray PREFIX ## G;
/*
* DeclareAndInitExtraAlphaFor ## STRATEGY(VAR)
*
* jint extraA = (int)(pCompInfo->details.extraAlpha * 255.0 + 0.5);
*/
/*
* PromoteByteAlphaFor ## STRATEGY(a)
*/
#define PromoteByteAlphaFor4ByteArgb(a)
#define PromoteByteAlphaFor1ByteGray(a)
#define PromoteByteAlphaFor1ShortGray(a) \
(a) = (((a) << 8) + (a))
/*
* DeclareAndInitPathAlphaFor ## STRATEGY(VAR)
*
* jint pathA = *pMask++;
*/
/*
* MultiplyAlphaFor ## STRATEGY(a, b)
*
* a * b
*/
#define MultiplyAlphaFor4ByteArgb(a, b) \
MUL8(a, b)
#define MultiplyAlphaFor1ByteGray(a, b) \
MUL8(a, b)
#define MultiplyAlphaFor1ShortGray(a, b) \
MUL16(a, b)
/*
* MultiplyAndStore ## STRATEGY ## Comps(PROD_PREFIX, M1, M2_PREFIX)
*
* c = m1 * m2;
*/
do { \
} while (0)
/*
* DivideAndStore ## STRATEGY ## Comps(QUOT_PREFIX, D1_PREFIX, D2)
*
* c = d1 / d2;
*/
do { \
} while (0)
/*
* MultiplyAddAndStore ## STRATEGY ## Comps(RES_PREFIX, M1, \
* M2_PREFIX, A_PREFIX)
*
* c = (m1 * m2) + a;
*/
PRECISION) \
do { \
A_PREFIX ## R; \
A_PREFIX ## G; \
A_PREFIX ## B; \
} while (0)
PRECISION) \
A_PREFIX) \
A_PREFIX) \
A_PREFIX) \
/*
* MultMultAddAndStore ## STRATEGY ## Comps(RES_PREFIX, M1, M2_PREFIX, \
* M3, M4_PREFIX)
*
* c = (m1 * m2) + (m3 * m4);
*/
do { \
} while (0)
do { \
} while (0)
/*
* Store ## STRATEGY ## CompsUsingOp(L_PREFIX, OP, R_PREFIX)
*
* l op r; // where op can be something like = or +=
*/
do { \
} while (0)
/*
* Set ## STRATEGY ## CompsToZero(PREFIX)
*
* c = 0;
*/
PREFIX ## G = 0
PREFIX ## G = 0
#endif /* AlphaMath_h_Included */