3261N/A * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * This file contains macros to aid in defining native graphics 0N/A * primitive functions. 0N/A * A number of useful building block macros are defined, but the 0N/A * vast majority of primitives are defined completely by a single 0N/A * macro expansion which uses macro names in the argument list to 0N/A * choose not only from a small number of strategies but also to 0N/A * choose macro packages specific to the source and destination 0N/A * pixel formats - greatly simplifying all aspects of creating 0N/A * See the following macros which define entire functions with 0N/A * just one or two surface names and sometimes a strategy name: 0N/A * DEFINE_ISOCOPY_BLIT(ANYTYPE) 0N/A * DEFINE_ISOXOR_BLIT(ANYTYPE) 0N/A * DEFINE_CONVERT_BLIT(SRC, DST, CONV_METHOD) 0N/A * DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY) 0N/A * DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY) 0N/A * DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY) 0N/A * DEFINE_SOLID_FILLRECT(DST) 0N/A * DEFINE_SOLID_FILLSPANS(DST) 0N/A * DEFINE_SOLID_DRAWLINE(DST) 0N/A * Many of these loop macros take the name of a SurfaceType as 0N/A * an argument and use the ANSI CPP token concatenation operator 0N/A * "##" to reference macro and type definitions that are specific 0N/A * to that type of surface. 0N/A * A description of the various surface specific macro utilities 0N/A * that are used by these loop macros appears at the end of the 0N/A * file. The definitions of these surface-specific macros will 0N/A * usually appear in a header file named after the SurfaceType 0N/A * This loop is the standard "while (--height > 0)" loop used by 0N/A * some of the blits below. 0N/A * used by most of the basic blits below. 0N/A }
while (--w > 0); \
0N/A * used by most of the scaled blits below. It calculates the proper 0N/A }
while (--w > 0); \
0N/A * This loop is a standard horizontal loop iterating with a "relative" 0N/A * X coordinate (0 <= X < WIDTH) used primarily by the LUT conversion 0N/A * preprocessing loops below. 0N/A * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via an intermediate "jint rgb" format. 0N/A * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via an intermediate "jint argb" format. 0N/A * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via an intermediate set of 3 component variables "jint r, g, b". 0N/A * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via an intermediate set of 4 component variables "jint a, r, g, b". 0N/A * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via an intermediate "jint gray" format. 0N/A * This is a "conversion strategy" for use with the DEFINE_XPAR_CONVERT_BLIT 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via the specified intermediate format while testing for transparent pixels. 0N/A * This is a "conversion strategy" for use with the DEFINE_XPAR_BLITBG 0N/A * macros. It converts from the source pixel format to the destination 0N/A * via the specified intermediate format while substituting the specified 0N/A * bgcolor for transparent pixels. 0N/A * This macro determines whether or not the given pixel is considered 0N/A * "transparent" for XOR purposes. The ARGB pixel is considered 0N/A * "transparent" if the alpha value is < 0.5. 0N/A * This is a "conversion strategy" for use with the DEFINE_XOR_BLIT macro. It 0N/A * converts the source pixel to an intermediate ARGB value and then converts 0N/A * the ARGB value to the pixel representation for the destination surface. It 0N/A * then XORs the srcpixel, xorpixel, and destination pixel together and stores 0N/A * the result in the destination surface. 0N/A * "LUT_STRATEGY" macro sets. 0N/A * There are 2 major strategies for dealing with luts and 3 0N/A * implementations of those strategies. 0N/A * The 2 strategies are "PreProcessLut" and "ConvertOnTheFly". 0N/A * For the "PreProcessLut" strategy, the raw ARGB lut supplied 0N/A * by the SD_LOCK_LUT flag is converted at the beginning into a 0N/A * form that is more suited for storing into the destination 0N/A * pixel format. The inner loop consists of a series of table 0N/A * lookups with very little conversion from that intermediate 0N/A * For the "ConvertOnTheFly" strategy, the raw ARGB values are 0N/A * converted on a pixel by pixel basis in the inner loop itself. 0N/A * This strategy is most useful for formats which tend to use 0N/A * the ARGB color format as their pixel format also. 0N/A * Each of these strategies has 3 implementations which are needed 0N/A * for the special cases: 0N/A * - straight conversion (invoked from DEFINE_CONVERT_BLIT_LUT) 0N/A * - straight conversion with transparency handling (invoked from 0N/A * DEFINE_XPAR_CONVERT_BLIT_LUT) 0N/A * - straight conversion with a bgcolor for the transparent pixels 0N/A * (invoked from DEFINE_XPAR_BLITBG_LUT) 0N/A * Start of PreProcessLut strategy macros, CONVERT_BLIT implementation. 0N/A * Start of ConvertOnTheFly strategy macros, CONVERT_BLIT implementation. 0N/A * Start of PreProcessLut strategy macros, XPAR_CONVERT_BLIT implementation. 0N/A * Start of ConvertOnTheFly strategy macros, CONVERT_BLIT implementation. 0N/A * Start of PreProcessLut strategy macros, BLITBG implementation. 0N/A * Start of ConvertOnTheFly strategy macros, BLITBG implementation. 0N/A * These macros provide consistent naming conventions for the 0N/A * various types of native primitive inner loop functions. 0N/A * The names are mechanically constructed from the SurfaceType names. 0N/A * These macros conveniently name and declare the indicated native 0N/A * primitive loop function for forward referencing. 0N/A * These macros construct the necessary NativePrimitive structure 0N/A * for the indicated native primitive loop function which will be 0N/A * declared somewhere prior and defined elsewhere (usually after). 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for copying pixels of a common type from one buffer to another. 0N/A * This macro defines an entire function to implement a ScaleBlit inner loop 0N/A * for scaling pixels of a common type from one buffer to another. 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for XORing pixels of a common type from one buffer into another. 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for converting pixels from a buffer of one type into a buffer of 0N/A * another type. No blending is done of the pixels. 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for converting pixels from a buffer of byte pixels with a lookup 0N/A * table into a buffer of another type. No blending is done of the pixels. 0N/A * This macro defines an entire function to implement a ScaleBlit inner 0N/A * loop for scaling and converting pixels from a buffer of one type into 0N/A * a buffer of another type. No blending is done of the pixels. 0N/A * This macro defines an entire function to implement a ScaleBlit inner 0N/A * loop for scaling and converting pixels from a buffer of byte pixels 0N/A * with a lookup table into a buffer of another type. No blending is 0N/A * done of the pixels. 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for drawing opaque pixels from a buffer of one type onto a buffer of 0N/A * another type, ignoring the transparent pixels in the source buffer. 0N/A * No blending is done of the pixels - the converted pixel value is 0N/A * either copied or the destination is left untouched. 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for converting pixels from a buffer of byte pixels with a lookup 0N/A * table containing transparent pixels into a buffer of another type. 0N/A * No blending is done of the pixels - the converted pixel value is 0N/A * either copied or the destination is left untouched. 0N/A * This macro defines an entire function to implement a ScaleBlit inner 0N/A * loop for scaling and converting pixels from a buffer of byte pixels 0N/A * with a lookup table containing transparent pixels into a buffer of 0N/A * No blending is done of the pixels - the converted pixel value is 0N/A * either copied or the destination is left untouched. 0N/A * This macro defines an entire function to implement a ScaleBlit inner 0N/A * loop for scaling and converting pixels from a buffer of one type 0N/A * containing transparent pixels into a buffer of another type. 0N/A * No blending is done of the pixels - the converted pixel value is 0N/A * either copied or the destination is left untouched. 0N/A * This macro defines an entire function to implement a BlitBg inner loop 0N/A * for converting pixels from a buffer of one type containing transparent 0N/A * pixels into a buffer of another type with a specified bgcolor for the 0N/A * transparent pixels. 0N/A * No blending is done of the pixels other than to substitute the 0N/A * bgcolor for any transparent pixels. 0N/A * This macro defines an entire function to implement a BlitBg inner loop 0N/A * for converting pixels from a buffer of byte pixels with a lookup 0N/A * table containing transparent pixels into a buffer of another type 0N/A * with a specified bgcolor for the transparent pixels. 0N/A * No blending is done of the pixels other than to substitute the 0N/A * bgcolor for any transparent pixels. 0N/A * This macro defines an entire function to implement a Blit inner loop 0N/A * for converting pixels from a buffer of one type into a buffer of 0N/A * another type. Each source pixel is XORed with the current XOR color value. 0N/A * That result is then XORed with the destination pixel and the final 0N/A * result is stored in the destination surface. 0N/A * This macro defines an entire function to implement a FillRect inner loop 0N/A * for setting a rectangular region of pixels to a specific pixel value. 0N/A * No blending of the fill color is done with the pixels. 0N/A * This macro defines an entire function to implement a FillSpans inner loop 0N/A * for iterating through a list of spans and setting those regions of pixels 0N/A * to a specific pixel value. No blending of the fill color is done with 0N/A }
while (--h > 0); \
3172N/A * This macro defines an entire function to implement a FillParallelogram 3172N/A * inner loop for tracing 2 diagonal edges (left and right) and setting 3172N/A * those regions of pixels between them to a specific pixel value. 3172N/A * No blending of the fill color is done with the pixels. 0N/A * This macro declares the bumpmajor and bumpminor variables used for the 0N/A * DrawLine functions. 0N/A * This macro extracts "instructions" from the bumpmajor and bumpminor masks 0N/A * that determine the initial bumpmajor and bumpminor values. The bumpmajor 0N/A * and bumpminor masks are laid out in the following format: 0N/A * bumpmajormask: bumpminormask: 0N/A * bit0: bumpmajor = pixelStride bit0: bumpminor = pixelStride 0N/A * bit1: bumpmajor = -pixelStride bit1: bumpminor = -pixelStride 0N/A * bit2: bumpmajor = scanStride bit2: bumpminor = scanStride 0N/A * bit3: bumpmajor = -scanStride bit3: bumpminor = -scanStride 0N/A * This macro defines an entire function to implement a DrawLine inner loop 0N/A * for iterating along a horizontal or vertical line and setting the pixels 0N/A * on that line to a specific pixel value. No blending of the fill color 0N/A * is done with the pixels. 0N/A * This macro defines an entire function to implement a FillRect inner loop 0N/A * for setting a rectangular region of pixels to a specific pixel value. 0N/A * Each destination pixel is XORed with the current XOR mode color as well as 0N/A * the current fill color. 0N/A * This macro defines an entire function to implement a FillSpans inner loop 0N/A * for iterating through a list of spans and setting those regions of pixels 0N/A * to a specific pixel value. Each destination pixel is XORed with the 0N/A * current XOR mode color as well as the current fill color. 0N/A }
while (--h > 0); \
0N/A * This macro defines an entire function to implement a DrawLine inner loop 0N/A * for iterating along a horizontal or vertical line and setting the pixels 0N/A * on that line to a specific pixel value. Each destination pixel is XORed 0N/A * with the current XOR mode color as well as the current draw color. 0N/A * This macro is used to declare the variables needed by the glyph clipping 0N/A * This macro represents the glyph clipping code used in the various 0N/A * DRAWGLYPHLIST macros. This macro is typically used within a loop. Note 0N/A * that the body of this macro is NOT wrapped in a do..while block due to 0N/A * the use of continue statements within the block (those continue statements 0N/A * are intended skip the outer loop, not the do..while loop). To combat this 0N/A * problem, pass in the code (typically a continue statement) that should be 0N/A * executed when a null glyph is encountered. 0N/A /* if any clipping required, modify parameters now */ \
0N/A /* Multiply needed for LCD text as PIXELS is really BYTES */ \
0N/A/* There is no alpha channel in the glyph data with which to interpolate 0N/A * between the src and dst alphas, but a reasonable approximation is to 0N/A * sum the coverage alphas of the colour channels and divide by 3. 0N/A * We can approximate division by 3 using mult and shift. See 0N/A /* subpixel positioning adjustment */ \
0N/A * The macros defined above use the following macro definitions supplied 0N/A * for the various surface types to manipulate pixels and pixel data. 0N/A * The surface-specific macros are typically supplied by header files 0N/A * In the macro names in the following definitions, the string <stype> 0N/A * is used as a place holder for the SurfaceType name (i.e. IntArgb). 0N/A * The macros above access these type specific macros using the ANSI 0N/A * CPP token concatenation operator "##". 0N/A * <stype>DataType A typedef for the type of the pointer 0N/A * that is used to access the raster data 0N/A * for the given surface type. 0N/A * <stype>PixelStride Pixel stride for the surface type. 0N/A * Declare<stype>LoadVars Declare the variables needed to control 0N/A * loading color information from an stype 0N/A * raster (i.e. lookup tables). 0N/A * Init<stype>LoadVars Init the lookup table variables. 0N/A * Declare<stype>StoreVars Declare the storage variables needed to 0N/A * control storing pixel data based on the 0N/A * pixel coordinate (i.e. dithering variables). 0N/A * Init<stype>StoreVarsY Init the dither variables for starting Y. 0N/A * Next<stype>StoreVarsY Increment the dither variables for next Y. 0N/A * Init<stype>StoreVarsX Init the dither variables for starting X. 0N/A * Next<stype>StoreVarsX Increment the dither variables for next X. 0N/A * Load<stype>To1IntRgb Load a pixel and form an INT_RGB integer. 0N/A * Store<stype>From1IntRgb Store a pixel from an INT_RGB integer. 0N/A * Load<stype>To1IntArgb Load a pixel and form an INT_ARGB integer. 0N/A * Store<stype>From1IntArgb Store a pixel from an INT_ARGB integer. 0N/A * Load<stype>To3ByteRgb Load a pixel into R, G, and B components. 0N/A * Store<stype>From3ByteRgb Store a pixel from R, G, and B components. 0N/A * Load<stype>To4ByteArgb Load a pixel into A, R, G, and B components. 0N/A * Store<stype>From4ByteArgb Store a pixel from A, R, G, and B components. 0N/A * Load<stype>To1ByteGray Load a pixel and form a BYTE_GRAY byte. 0N/A * Store<stype>From1ByteGray Store a pixel from a BYTE_GRAY byte. 0N/A * <stype>PixelType Typedef for a "single quantity pixel" (SQP) 0N/A * that can hold the data for one stype pixel. 0N/A * <stype>XparLutEntry An SQP that can be used to represent a 0N/A * transparent pixel for stype. 0N/A * Store<stype>NonXparFromArgb Store an SQP from an INT_ARGB integer in 0N/A * such a way that it would not be confused 0N/A * with the XparLutEntry value for stype. 0N/A * <stype>IsXparLutEntry Test an SQP for the XparLutEntry value. 0N/A * Store<stype>Pixel Store the pixel data from an SQP. 0N/A * <stype>PixelFromArgb Converts an INT_ARGB value into the specific 0N/A * pixel representation for the surface type. 0N/A * Declare<stype>PixelData Declare the pixel data variables (PDV) needed 0N/A * to hold the elements of pixel data ready to 0N/A * store into an stype raster (may be empty for 0N/A * stypes whose SQP format is their data format). 0N/A * Extract<stype>PixelData Extract an SQP value into the PDVs. 0N/A * Store<stype>PixelData Store the PDVs into an stype raster. 0N/A * XorCopy<stype>PixelData Xor the PDVs into an stype raster. 0N/A#
endif /* LoopMacros_h_Included */