src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h
author alitvinov
Fri, 31 May 2019 18:16:57 +0100
changeset 58626 a9ed3d93cca3
parent 47216 71c04702a3d5
permissions -rw-r--r--
8218877: Help transform transformers Reviewed-by: serb, prr, mschoene, bpb, ssahoo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
     2
 * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef LoopMacros_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define LoopMacros_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "j2d_md.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "LineUtils.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * This file contains macros to aid in defining native graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * primitive functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * A number of useful building block macros are defined, but the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * vast majority of primitives are defined completely by a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * macro expansion which uses macro names in the argument list to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * choose not only from a small number of strategies but also to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * choose macro packages specific to the source and destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * pixel formats - greatly simplifying all aspects of creating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * a new loop.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * See the following macros which define entire functions with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * just one or two surface names and sometimes a strategy name:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *     DEFINE_ISOCOPY_BLIT(ANYTYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *     DEFINE_ISOXOR_BLIT(ANYTYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *     DEFINE_CONVERT_BLIT(SRC, DST, CONV_METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *     DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *     DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *     DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *     DEFINE_SOLID_FILLRECT(DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *     DEFINE_SOLID_FILLSPANS(DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *     DEFINE_SOLID_DRAWLINE(DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * Many of these loop macros take the name of a SurfaceType as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * an argument and use the ANSI CPP token concatenation operator
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * "##" to reference macro and type definitions that are specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * to that type of surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * A description of the various surface specific macro utilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * that are used by these loop macros appears at the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * file.  The definitions of these surface-specific macros will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * usually appear in a header file named after the SurfaceType
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * name (i.e. IntArgb.h, ByteGray.h, etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * This loop is the standard "while (--height > 0)" loop used by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * some of the blits below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define BlitLoopHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                       DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                       HEIGHT, BODY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        SRCTYPE ## DataType *SRCPTR = (SRCTYPE ## DataType *) (SRCBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        jint srcScan = (SRCINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        jint dstScan = (DSTINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            BODY; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            SRCPTR = PtrAddBytes(SRCPTR, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        } while (--HEIGHT > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * This loop is the standard nested "while (--width/height > 0)" loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * used by most of the basic blits below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#define BlitLoopWidthHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                            DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                            WIDTH, HEIGHT, BODY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        SRCTYPE ## DataType *SRCPTR = (SRCTYPE ## DataType *) (SRCBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        jint srcScan = (SRCINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        jint dstScan = (DSTINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        srcScan -= (WIDTH) * SRCTYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        dstScan -= (WIDTH) * DSTTYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            juint w = WIDTH; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                BODY; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                SRCPTR = PtrAddBytes(SRCPTR, SRCTYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                DSTPTR = PtrAddBytes(DSTPTR, DSTTYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            SRCPTR = PtrAddBytes(SRCPTR, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        } while (--HEIGHT > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * This loop is the standard nested "while (--width/height > 0)" loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * used by most of the scaled blits below.  It calculates the proper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * X source variable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define BlitLoopScaleWidthHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                 DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                                 XVAR, WIDTH, HEIGHT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                 SXLOC, SYLOC, SXINC, SYINC, SHIFT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                 BODY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        SRCTYPE ## DataType *SRCPTR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        jint srcScan = (SRCINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        jint dstScan = (DSTINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        dstScan -= (WIDTH) * DSTTYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            juint w = WIDTH; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            jint tmpsxloc = SXLOC; \
58626
a9ed3d93cca3 8218877: Help transform transformers
alitvinov
parents: 47216
diff changeset
   140
            SRCPTR = PtrPixelsRow(SRCBASE, (SYLOC >> SHIFT), srcScan); \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                jint XVAR = (tmpsxloc >> SHIFT); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                BODY; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                DSTPTR = PtrAddBytes(DSTPTR, DSTTYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                tmpsxloc += SXINC; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            SYLOC += SYINC; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        } while (--HEIGHT > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * This loop is a standard horizontal loop iterating with a "relative"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * X coordinate (0 <= X < WIDTH) used primarily by the LUT conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * preprocessing loops below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
#define BlitLoopXRel(DSTTYPE, DSTINFO, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                     XVAR, WIDTH, BODY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        juint XVAR = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            BODY; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        } while (++XVAR < WIDTH); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * via an intermediate "jint rgb" format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#define ConvertVia1IntRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                          DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                          SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        int rgb; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        Load ## SRCTYPE ## To1IntRgb(SRCPTR, SRCPREFIX, SXVAR, rgb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        Store ## DSTTYPE ## From1IntRgb(DSTPTR, DSTPREFIX, DXVAR, rgb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * via an intermediate "jint argb" format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
#define ConvertVia1IntArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                           DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                           SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        int argb; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        Load ## SRCTYPE ## To1IntArgb(SRCPTR, SRCPREFIX, SXVAR, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        Store ## DSTTYPE ## From1IntArgb(DSTPTR, DSTPREFIX, DXVAR, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * via an intermediate set of 3 component variables "jint r, g, b".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
#define ConvertVia3ByteRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                           DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                           SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        jint r, g, b; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        Load ## SRCTYPE ## To3ByteRgb(SRCPTR, SRCPREFIX, SXVAR, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        Store ## DSTTYPE ## From3ByteRgb(DSTPTR, DSTPREFIX, DXVAR, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * via an intermediate set of 4 component variables "jint a, r, g, b".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
#define ConvertVia4ByteArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                            DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                            SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        jint a, r, g, b; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        Load ## SRCTYPE ## To4ByteArgb(SRCPTR, SRCPREFIX, SXVAR, a, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        Store ## DSTTYPE ## From4ByteArgb(DSTPTR, DSTPREFIX, DXVAR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                          a, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 * This is a "conversion strategy" for use with the DEFINE_CONVERT_BLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 * via an intermediate "jint gray" format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
#define ConvertVia1ByteGray(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                            DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                            SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        jint gray; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        Load ## SRCTYPE ## To1ByteGray(SRCPTR, SRCPREFIX, SXVAR, gray); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        Store ## DSTTYPE ## From1ByteGray(DSTPTR, DSTPREFIX, DXVAR, gray); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 * This is a "conversion strategy" for use with the DEFINE_XPAR_CONVERT_BLIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 * via the specified intermediate format while testing for transparent pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
#define ConvertXparVia1IntRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                              DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                              SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        Declare ## SRCTYPE ## Data(XparLoad); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        Load ## SRCTYPE ## Data(SRCPTR, SRCPREFIX, SXVAR, XparLoad); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if (! (Is ## SRCTYPE ## DataTransparent(XparLoad))) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            int rgb; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            Convert ## SRCTYPE ## DataTo1IntRgb(XparLoad, rgb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            Store ## DSTTYPE ## From1IntRgb(DSTPTR, DSTPREFIX, DXVAR, rgb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * This is a "conversion strategy" for use with the DEFINE_XPAR_BLITBG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 * macros.  It converts from the source pixel format to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * via the specified intermediate format while substituting the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
 * bgcolor for transparent pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
#define BgCopyXparVia1IntRgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                             DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                             SXVAR, DXVAR, BGPIXEL, BGPREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        Declare ## SRCTYPE ## Data(XparLoad); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        Load ## SRCTYPE ## Data(SRCPTR, SRCPREFIX, SXVAR, XparLoad); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        if (Is ## SRCTYPE ## DataTransparent(XparLoad)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            Store ## DSTTYPE ## PixelData(DSTPTR, DXVAR, BGPIXEL, BGPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            int rgb; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            Convert ## SRCTYPE ## DataTo1IntRgb(XparLoad, rgb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            Store ## DSTTYPE ## From1IntRgb(DSTPTR, DSTPREFIX, DXVAR, rgb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
 * This macro determines whether or not the given pixel is considered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
 * "transparent" for XOR purposes.  The ARGB pixel is considered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
 * "transparent" if the alpha value is < 0.5.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
#define IsArgbTransparent(pixel) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    (((jint) pixel) >= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
 * This is a "conversion strategy" for use with the DEFINE_XOR_BLIT macro.  It
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
 * converts the source pixel to an intermediate ARGB value and then converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
 * the ARGB value to the pixel representation for the destination surface.  It
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
 * then XORs the srcpixel, xorpixel, and destination pixel together and stores
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
 * the result in the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
#define XorVia1IntArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                       DSTPTR, DSTTYPE, DSTANYTYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                       XVAR, XORPIXEL, XORPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                       MASK, MASKPREFIX, DSTINFOPTR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        jint srcpixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        Declare ## DSTANYTYPE ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        Load ## SRCTYPE ## To1IntArgb(SRCPTR, SRCPREFIX, XVAR, srcpixel); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        if (IsArgbTransparent(srcpixel)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            break; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        DSTTYPE ## PixelFromArgb(srcpixel, srcpixel, DSTINFOPTR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        Extract ## DSTANYTYPE ## PixelData(srcpixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        Xor ## DSTANYTYPE ## PixelData(srcpixel, pix, DSTPTR, XVAR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                                       XORPIXEL, XORPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                                       MASK, MASKPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
 * "LUT_STRATEGY" macro sets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
 * There are 2 major strategies for dealing with luts and 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
 * implementations of those strategies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
 * The 2 strategies are "PreProcessLut" and "ConvertOnTheFly".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
 * For the "PreProcessLut" strategy, the raw ARGB lut supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
 * by the SD_LOCK_LUT flag is converted at the beginning into a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
 * form that is more suited for storing into the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
 * pixel format.  The inner loop consists of a series of table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
 * lookups with very little conversion from that intermediate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
 * pixel format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
 * For the "ConvertOnTheFly" strategy, the raw ARGB values are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
 * converted on a pixel by pixel basis in the inner loop itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
 * This strategy is most useful for formats which tend to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
 * the ARGB color format as their pixel format also.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
 * Each of these strategies has 3 implementations which are needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
 * for the special cases:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
 * - straight conversion (invoked from DEFINE_CONVERT_BLIT_LUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
 * - straight conversion with transparency handling (invoked from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
 *   DEFINE_XPAR_CONVERT_BLIT_LUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
 * - straight conversion with a bgcolor for the transparent pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
 *   (invoked from DEFINE_XPAR_BLITBG_LUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
/***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
 * Start of PreProcessLut strategy macros, CONVERT_BLIT implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
#define LutSize(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    (1 << TYPE ## BitsPerPixel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
#define DeclarePreProcessLutLut(SRC, DST, PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    DST ## PixelType PIXLUT[LutSize(SRC)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
#define SetupPreProcessLutLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        jint *srcLut = (SRCINFO)->lutBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        juint lutSize = (SRCINFO)->lutSize; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        Declare ## DST ## StoreVars(PreLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        Init ## DST ## StoreVarsY(PreLut, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        if (lutSize >= LutSize(SRC)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            lutSize = LutSize(SRC); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            DST ## PixelType *pPIXLUT = &PIXLUT[lutSize]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                Store ## DST ## From1IntArgb(pPIXLUT, PreLut, 0, 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            } while (++pPIXLUT < &PIXLUT[LutSize(SRC)]); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        BlitLoopXRel(DST, DSTINFO, PreLut, x, lutSize, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                     do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                         jint argb = srcLut[x]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                         Store ## DST ## From1IntArgb(PIXLUT, PreLut, x, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                     } while (0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
#define BodyPreProcessLutLut(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                             DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                             SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    DSTPTR[DXVAR] = PIXLUT[SRCPTR[SXVAR]]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
 * End of PreProcessLut/CONVERT_BLIT macros.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
 ***/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
/***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
 * Start of ConvertOnTheFly strategy macros, CONVERT_BLIT implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
#define DeclareConvertOnTheFlyLut(SRC, DST, PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    Declare ## SRC ## LoadVars(PIXLUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
#define SetupConvertOnTheFlyLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    Init ## SRC ## LoadVars(PIXLUT, SRCINFO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
#define BodyConvertOnTheFlyLut(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                               DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                               SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    ConvertVia1IntArgb(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                       DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                       SXVAR, DXVAR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
 * End of ConvertOnTheFly/CONVERT_BLIT macros.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
 ***/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
/***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
 * Start of PreProcessLut strategy macros, XPAR_CONVERT_BLIT implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
#define DeclarePreProcessLutXparLut(SRC, DST, PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    jint PIXLUT[LutSize(SRC)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
#define SetupPreProcessLutXparLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        jint *srcLut = (SRCINFO)->lutBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        juint lutSize = (SRCINFO)->lutSize; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        Declare ## DST ## StoreVars(PreLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        Init ## DST ## StoreVarsY(PreLut, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        if (lutSize >= LutSize(SRC)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            lutSize = LutSize(SRC); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            jint *pPIXLUT = &PIXLUT[lutSize]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                pPIXLUT[0] = DST ## XparLutEntry; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            } while (++pPIXLUT < &PIXLUT[LutSize(SRC)]); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        BlitLoopXRel(DST, DSTINFO, PreLut, x, lutSize, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                     do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                         jint argb = srcLut[x]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                         if (argb < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                             Store ## DST ## NonXparFromArgb \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                 (PIXLUT, PreLut, x, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                         } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                             PIXLUT[x] = DST ## XparLutEntry; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                         } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                     } while (0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
#define BodyPreProcessLutXparLut(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                 DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                 SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        jint pix = PIXLUT[SRCPTR[SXVAR]]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        if (! DSTTYPE ## IsXparLutEntry(pix)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            DSTPTR[DXVAR] = (DSTTYPE ## PixelType) pix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
 * End of PreProcessLut/XPAR_CONVERT_BLIT macros.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
 ***/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
/***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
 * Start of ConvertOnTheFly strategy macros, CONVERT_BLIT implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
#define DeclareConvertOnTheFlyXparLut(SRC, DST, PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    Declare ## SRC ## LoadVars(PIXLUT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
#define SetupConvertOnTheFlyXparLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    Init ## SRC ## LoadVars(PIXLUT, SRCINFO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
#define BodyConvertOnTheFlyXparLut(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                                   DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                                   SXVAR, DXVAR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        jint argb; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        Load ## SRCTYPE ## To1IntArgb(SRCPTR, PIXLUT, SXVAR, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        if (argb < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            Store ## DSTTYPE ## From1IntArgb(DSTPTR, DSTPREFIX, DXVAR, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
 * End of ConvertOnTheFly/CONVERT_BLIT macros.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
 ***/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
/***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
 * Start of PreProcessLut strategy macros, BLITBG implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
#define DeclarePreProcessLutBgLut(SRC, DST, PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    jint PIXLUT[LutSize(SRC)];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
#define SetupPreProcessLutBgLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO, BGPIXEL) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        jint *srcLut = (SRCINFO)->lutBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        juint lutSize = (SRCINFO)->lutSize; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        Declare ## DST ## StoreVars(PreLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        Init ## DST ## StoreVarsY(PreLut, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        if (lutSize >= LutSize(SRC)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            lutSize = LutSize(SRC); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            jint *pPIXLUT = &PIXLUT[lutSize]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                pPIXLUT[0] = BGPIXEL; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            } while (++pPIXLUT < &PIXLUT[LutSize(SRC)]); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        BlitLoopXRel(DST, DSTINFO, PreLut, x, lutSize, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                     do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                         jint argb = srcLut[x]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                         if (argb < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                             Store ## DST ## From1IntArgb(PIXLUT, PreLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                                                          x, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                         } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                             PIXLUT[x] = BGPIXEL; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                         } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                     } while (0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
#define BodyPreProcessLutBgLut(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                               DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                               SXVAR, DXVAR, BGPIXEL) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        jint pix = PIXLUT[SRCPTR[SXVAR]]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        Store ## DSTTYPE ## Pixel(DSTPTR, DXVAR, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
 * End of PreProcessLut/BLITBG implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
 ***/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
/***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
 * Start of ConvertOnTheFly strategy macros, BLITBG implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
#define DeclareConvertOnTheFlyBgLut(SRC, DST, PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    Declare ## SRC ## LoadVars(PIXLUT) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    Declare ## DST ## PixelData(bgpix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
#define SetupConvertOnTheFlyBgLut(SRC, DST, PIXLUT, SRCINFO, DSTINFO, BGPIXEL) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        Init ## SRC ## LoadVars(PIXLUT, SRCINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        Extract ## DST ## PixelData(BGPIXEL, bgpix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
#define BodyConvertOnTheFlyBgLut(SRCPTR, SRCTYPE, PIXLUT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                 DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                 SXVAR, DXVAR, BGPIXEL) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        jint argb; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        Load ## SRCTYPE ## To1IntArgb(SRCPTR, PIXLUT, SXVAR, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        if (argb < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            Store ## DSTTYPE ## From1IntArgb(DSTPTR, DSTPREFIX, DXVAR, argb); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            Store ## DSTTYPE ## PixelData(DSTPTR, DXVAR, BGPIXEL, bgpix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
 * End of ConvertOnTheFly/BLITBG macros.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
 ***/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
 * These macros provide consistent naming conventions for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
 * various types of native primitive inner loop functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
 * The names are mechanically constructed from the SurfaceType names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
#define NAME_CONVERT_BLIT(SRC, DST)      SRC ## To ## DST ## Convert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
#define NAME_SCALE_BLIT(SRC, DST)        SRC ## To ## DST ## ScaleConvert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
#define NAME_XPAR_CONVERT_BLIT(SRC, DST) SRC ## To ## DST ## XparOver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
#define NAME_XPAR_SCALE_BLIT(SRC, DST)   SRC ## To ## DST ## ScaleXparOver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
#define NAME_XPAR_BLITBG(SRC, DST)       SRC ## To ## DST ## XparBgCopy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
#define NAME_XOR_BLIT(SRC, DST)          SRC ## To ## DST ## XorBlit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
#define NAME_ISOCOPY_BLIT(ANYTYPE)       ANYTYPE ## IsomorphicCopy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
#define NAME_ISOSCALE_BLIT(ANYTYPE)      ANYTYPE ## IsomorphicScaleCopy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
#define NAME_ISOXOR_BLIT(ANYTYPE)        ANYTYPE ## IsomorphicXorCopy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
#define NAME_SOLID_FILLRECT(TYPE)        TYPE ## SetRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
#define NAME_SOLID_FILLSPANS(TYPE)       TYPE ## SetSpans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
#define NAME_SOLID_DRAWLINE(TYPE)        TYPE ## SetLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
#define NAME_XOR_FILLRECT(TYPE)          TYPE ## XorRect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
#define NAME_XOR_FILLSPANS(TYPE)         TYPE ## XorSpans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
#define NAME_XOR_DRAWLINE(TYPE)          TYPE ## XorLine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
#define NAME_SRC_MASKFILL(TYPE)          TYPE ## SrcMaskFill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
#define NAME_SRCOVER_MASKFILL(TYPE)      TYPE ## SrcOverMaskFill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
#define NAME_ALPHA_MASKFILL(TYPE)        TYPE ## AlphaMaskFill
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
#define NAME_SRCOVER_MASKBLIT(SRC, DST)  SRC ## To ## DST ## SrcOverMaskBlit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
#define NAME_ALPHA_MASKBLIT(SRC, DST)    SRC ## To ## DST ## AlphaMaskBlit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
#define NAME_SOLID_DRAWGLYPHLIST(TYPE)   TYPE ## DrawGlyphList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
#define NAME_SOLID_DRAWGLYPHLISTAA(TYPE) TYPE ## DrawGlyphListAA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
#define NAME_SOLID_DRAWGLYPHLISTLCD(TYPE) TYPE ## DrawGlyphListLCD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
#define NAME_XOR_DRAWGLYPHLIST(TYPE)     TYPE ## DrawGlyphListXor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
#define NAME_TRANSFORMHELPER(TYPE, MODE) TYPE ## MODE ## TransformHelper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
#define NAME_TRANSFORMHELPER_NN(TYPE)    NAME_TRANSFORMHELPER(TYPE, NrstNbr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
#define NAME_TRANSFORMHELPER_BL(TYPE)    NAME_TRANSFORMHELPER(TYPE, Bilinear)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
#define NAME_TRANSFORMHELPER_BC(TYPE)    NAME_TRANSFORMHELPER(TYPE, Bicubic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
#define NAME_TRANSFORMHELPER_FUNCS(TYPE) TYPE ## TransformHelperFuncs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   610
#define NAME_SOLID_FILLPGRAM(TYPE)       TYPE ## SetParallelogram
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   611
#define NAME_SOLID_PGRAM_FUNCS(TYPE)     TYPE ## SetParallelogramFuncs
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   612
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   613
#define NAME_XOR_FILLPGRAM(TYPE)         TYPE ## XorParallelogram
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   614
#define NAME_XOR_PGRAM_FUNCS(TYPE)       TYPE ## XorParallelogramFuncs
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   615
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
 * These macros conveniently name and declare the indicated native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
 * primitive loop function for forward referencing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
#define DECLARE_CONVERT_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    BlitFunc NAME_CONVERT_BLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
#define DECLARE_SCALE_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    ScaleBlitFunc NAME_SCALE_BLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
#define DECLARE_XPAR_CONVERT_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    BlitFunc NAME_XPAR_CONVERT_BLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
#define DECLARE_XPAR_SCALE_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    ScaleBlitFunc NAME_XPAR_SCALE_BLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
#define DECLARE_XPAR_BLITBG(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    BlitBgFunc NAME_XPAR_BLITBG(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
#define DECLARE_XOR_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    BlitFunc NAME_XOR_BLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
#define DECLARE_ISOCOPY_BLIT(ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    BlitFunc NAME_ISOCOPY_BLIT(ANYTYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
#define DECLARE_ISOSCALE_BLIT(ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    ScaleBlitFunc NAME_ISOSCALE_BLIT(ANYTYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
#define DECLARE_ISOXOR_BLIT(ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    BlitFunc NAME_ISOXOR_BLIT(ANYTYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
#define DECLARE_SOLID_FILLRECT(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    FillRectFunc NAME_SOLID_FILLRECT(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
#define DECLARE_SOLID_FILLSPANS(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    FillSpansFunc NAME_SOLID_FILLSPANS(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
#define DECLARE_SOLID_DRAWLINE(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    DrawLineFunc NAME_SOLID_DRAWLINE(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
#define DECLARE_XOR_FILLRECT(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    FillRectFunc NAME_XOR_FILLRECT(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
#define DECLARE_XOR_FILLSPANS(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    FillSpansFunc NAME_XOR_FILLSPANS(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
#define DECLARE_XOR_DRAWLINE(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    DrawLineFunc NAME_XOR_DRAWLINE(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
#define DECLARE_ALPHA_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    MaskFillFunc NAME_ALPHA_MASKFILL(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
#define DECLARE_SRC_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    MaskFillFunc NAME_SRC_MASKFILL(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
#define DECLARE_SRCOVER_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    MaskFillFunc NAME_SRCOVER_MASKFILL(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
#define DECLARE_SRCOVER_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    MaskBlitFunc NAME_SRCOVER_MASKBLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
#define DECLARE_ALPHA_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    MaskBlitFunc NAME_ALPHA_MASKBLIT(SRC, DST)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
#define DECLARE_SOLID_DRAWGLYPHLIST(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    DrawGlyphListFunc NAME_SOLID_DRAWGLYPHLIST(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
#define DECLARE_SOLID_DRAWGLYPHLISTAA(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    DrawGlyphListAAFunc NAME_SOLID_DRAWGLYPHLISTAA(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
#define DECLARE_SOLID_DRAWGLYPHLISTLCD(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    DrawGlyphListLCDFunc NAME_SOLID_DRAWGLYPHLISTLCD(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
#define DECLARE_XOR_DRAWGLYPHLIST(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    DrawGlyphListFunc NAME_XOR_DRAWGLYPHLIST(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
#define DECLARE_TRANSFORMHELPER_FUNCS(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    TransformHelperFunc NAME_TRANSFORMHELPER_NN(TYPE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    TransformHelperFunc NAME_TRANSFORMHELPER_BL(TYPE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    TransformHelperFunc NAME_TRANSFORMHELPER_BC(TYPE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    TransformHelperFuncs NAME_TRANSFORMHELPER_FUNCS(TYPE)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   698
#define DECLARE_SOLID_PARALLELOGRAM(TYPE) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   699
    FillParallelogramFunc NAME_SOLID_FILLPGRAM(TYPE); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   700
    DECLARE_SOLID_DRAWLINE(TYPE); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   701
    DrawParallelogramFuncs NAME_SOLID_PGRAM_FUNCS(TYPE)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   702
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   703
#define DECLARE_XOR_PARALLELOGRAM(TYPE) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   704
    FillParallelogramFunc NAME_XOR_FILLPGRAM(TYPE); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   705
    DECLARE_XOR_DRAWLINE(TYPE); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   706
    DrawParallelogramFuncs NAME_XOR_PGRAM_FUNCS(TYPE)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   707
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
 * These macros construct the necessary NativePrimitive structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
 * for the indicated native primitive loop function which will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
 * declared somewhere prior and defined elsewhere (usually after).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
#define REGISTER_CONVERT_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    REGISTER_BLIT(SRC, SrcNoEa, DST, NAME_CONVERT_BLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
#define REGISTER_CONVERT_BLIT_FLAGS(SRC, DST, SFLAGS, DFLAGS) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
    REGISTER_BLIT_FLAGS(SRC, SrcNoEa, DST, NAME_CONVERT_BLIT(SRC, DST), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                        SFLAGS, DFLAGS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
#define REGISTER_CONVERT_BLIT_EQUIV(SRC, DST, FUNC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    REGISTER_BLIT(SRC, SrcNoEa, DST, FUNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
#define REGISTER_SCALE_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    REGISTER_SCALEBLIT(SRC, SrcNoEa, DST, NAME_SCALE_BLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
#define REGISTER_SCALE_BLIT_FLAGS(SRC, DST, SFLAGS, DFLAGS) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    REGISTER_SCALEBLIT_FLAGS(SRC, SrcNoEa, DST, NAME_SCALE_BLIT(SRC, DST), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                             SFLAGS, DFLAGS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
#define REGISTER_SCALE_BLIT_EQUIV(SRC, DST, FUNC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    REGISTER_SCALEBLIT(SRC, SrcNoEa, DST, FUNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
#define REGISTER_XPAR_CONVERT_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    REGISTER_BLIT(SRC, SrcOverBmNoEa, DST, NAME_XPAR_CONVERT_BLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
#define REGISTER_XPAR_CONVERT_BLIT_EQUIV(SRC, DST, FUNC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    REGISTER_BLIT(SRC, SrcOverBmNoEa, DST, FUNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
#define REGISTER_XPAR_SCALE_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    REGISTER_SCALEBLIT(SRC, SrcOverBmNoEa, DST, NAME_XPAR_SCALE_BLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
#define REGISTER_XPAR_SCALE_BLIT_EQUIV(SRC, DST, FUNC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    REGISTER_SCALEBLIT(SRC, SrcOverBmNoEa, DST, FUNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
#define REGISTER_XPAR_BLITBG(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    REGISTER_BLITBG(SRC, SrcNoEa, DST, NAME_XPAR_BLITBG(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
#define REGISTER_XPAR_BLITBG_EQUIV(SRC, DST, FUNC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    REGISTER_BLITBG(SRC, SrcNoEa, DST, FUNC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
#define REGISTER_XOR_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    REGISTER_BLIT(SRC, Xor, DST, NAME_XOR_BLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
#define REGISTER_ISOCOPY_BLIT(THISTYPE, ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    REGISTER_BLIT(THISTYPE, SrcNoEa, THISTYPE, NAME_ISOCOPY_BLIT(ANYTYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
#define REGISTER_ISOSCALE_BLIT(THISTYPE, ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    REGISTER_SCALEBLIT(THISTYPE, SrcNoEa, THISTYPE, NAME_ISOSCALE_BLIT(ANYTYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
#define REGISTER_ISOXOR_BLIT(THISTYPE, ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    REGISTER_BLIT(THISTYPE, Xor, THISTYPE, NAME_ISOXOR_BLIT(ANYTYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
#define REGISTER_SOLID_FILLRECT(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    REGISTER_FILLRECT(AnyColor, SrcNoEa, TYPE, NAME_SOLID_FILLRECT(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
#define REGISTER_SOLID_FILLSPANS(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    REGISTER_FILLSPANS(AnyColor, SrcNoEa, TYPE, NAME_SOLID_FILLSPANS(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
#define REGISTER_SOLID_LINE_PRIMITIVES(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    REGISTER_LINE_PRIMITIVES(AnyColor, SrcNoEa, TYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                             NAME_SOLID_DRAWLINE(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
#define REGISTER_XOR_FILLRECT(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    REGISTER_FILLRECT(AnyColor, Xor, TYPE, NAME_XOR_FILLRECT(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
#define REGISTER_XOR_FILLSPANS(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    REGISTER_FILLSPANS(AnyColor, Xor, TYPE, NAME_XOR_FILLSPANS(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
#define REGISTER_XOR_LINE_PRIMITIVES(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    REGISTER_LINE_PRIMITIVES(AnyColor, Xor, TYPE, NAME_XOR_DRAWLINE(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
#define REGISTER_ALPHA_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    REGISTER_MASKFILL(AnyColor, AnyAlpha, TYPE, NAME_ALPHA_MASKFILL(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
#define REGISTER_SRC_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    REGISTER_MASKFILL(AnyColor, Src, TYPE, NAME_SRC_MASKFILL(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
#define REGISTER_SRCOVER_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    REGISTER_MASKFILL(AnyColor, SrcOver, TYPE, NAME_SRCOVER_MASKFILL(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
#define REGISTER_SRCOVER_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    REGISTER_MASKBLIT(SRC, SrcOver, DST, NAME_SRCOVER_MASKBLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
#define REGISTER_ALPHA_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    REGISTER_MASKBLIT(SRC, AnyAlpha, DST, NAME_ALPHA_MASKBLIT(SRC, DST))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
#define REGISTER_SOLID_DRAWGLYPHLIST(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    REGISTER_DRAWGLYPHLIST(AnyColor, SrcNoEa, TYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                           NAME_SOLID_DRAWGLYPHLIST(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
#define REGISTER_SOLID_DRAWGLYPHLISTAA(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    REGISTER_DRAWGLYPHLISTAA(AnyColor, SrcNoEa, TYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                             NAME_SOLID_DRAWGLYPHLISTAA(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
#define REGISTER_SOLID_DRAWGLYPHLISTLCD(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    REGISTER_DRAWGLYPHLISTLCD(AnyColor, SrcNoEa, TYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                             NAME_SOLID_DRAWGLYPHLISTLCD(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
#define REGISTER_XOR_DRAWGLYPHLIST(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    REGISTER_DRAWGLYPHLIST(AnyColor, Xor, TYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                           NAME_XOR_DRAWGLYPHLIST(TYPE)), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    REGISTER_DRAWGLYPHLISTAA(AnyColor, Xor, TYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                             NAME_XOR_DRAWGLYPHLIST(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
#define REGISTER_TRANSFORMHELPER_FUNCS(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    REGISTER_PRIMITIVE(TransformHelper, TYPE, SrcNoEa, IntArgbPre, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                       (AnyFunc *) &NAME_TRANSFORMHELPER_FUNCS(TYPE))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   819
#define REGISTER_SOLID_PARALLELOGRAM(TYPE) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   820
    REGISTER_PRIMITIVE(FillParallelogram, AnyColor, SrcNoEa, TYPE, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   821
                       NAME_SOLID_FILLPGRAM(TYPE)), \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   822
    REGISTER_PRIMITIVE(DrawParallelogram, AnyColor, SrcNoEa, TYPE, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   823
                       (AnyFunc *) &NAME_SOLID_PGRAM_FUNCS(TYPE))
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   824
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   825
#define REGISTER_XOR_PARALLELOGRAM(TYPE) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   826
    REGISTER_PRIMITIVE(FillParallelogram, AnyColor, Xor, TYPE, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   827
                       NAME_XOR_FILLPGRAM(TYPE)), \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   828
    REGISTER_PRIMITIVE(DrawParallelogram, AnyColor, Xor, TYPE, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   829
                       (AnyFunc *) &NAME_XOR_PGRAM_FUNCS(TYPE))
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
   830
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
 * for copying pixels of a common type from one buffer to another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
#define DEFINE_ISOCOPY_BLIT(ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
void NAME_ISOCOPY_BLIT(ANYTYPE)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                                juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                                SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                                SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                                NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                                CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    Declare ## ANYTYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    BlitLoopHeight(ANYTYPE, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                   ANYTYPE, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                   height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                   memcpy(pDst, pSrc, width * ANYTYPE ## PixelStride)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
 * This macro defines an entire function to implement a ScaleBlit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
 * for scaling pixels of a common type from one buffer to another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
#define DEFINE_ISOSCALE_BLIT(ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
void NAME_ISOSCALE_BLIT(ANYTYPE)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                                 juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                                 jint sxloc, jint syloc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                                 jint sxinc, jint syinc, jint shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                                 SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                                 SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                                 NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                                 CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    Declare ## ANYTYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    BlitLoopScaleWidthHeight(ANYTYPE, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                             ANYTYPE, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                             x, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                             sxloc, syloc, sxinc, syinc, shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                             Copy ## ANYTYPE ## PixelData(pSrc, x, pDst, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
 * for XORing pixels of a common type from one buffer into another.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
#define DEFINE_ISOXOR_BLIT(ANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
void NAME_ISOXOR_BLIT(ANYTYPE)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                               juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                               SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                               SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                               NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                               CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    Declare ## ANYTYPE ## PixelData(xor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    Declare ## ANYTYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    Extract ## ANYTYPE ## PixelData(xorpixel, xor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    BlitLoopWidthHeight(ANYTYPE, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                        ANYTYPE, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                        XorCopy ## ANYTYPE ## PixelData(pSrc, pDst, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                                                        xorpixel, xor)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
 * for converting pixels from a buffer of one type into a buffer of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
 * another type.  No blending is done of the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
#define DEFINE_CONVERT_BLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
void NAME_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                                 juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                                 SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                                 SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                                 NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                                 CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                        ConvertVia ## STRATEGY(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                                               pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                                               0, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
 * for converting pixels from a buffer of byte pixels with a lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
 * table into a buffer of another type.  No blending is done of the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
#define DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
void NAME_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                                 juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                                 SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                                 SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                                 NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                                 CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    Declare ## LUT_STRATEGY ## Lut(SRC, DST, pixLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    Setup ## LUT_STRATEGY ## Lut(SRC, DST, pixLut,\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                                 pSrcInfo, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                        Body ## LUT_STRATEGY ## Lut(pSrc, SRC, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                                                    pixLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                                                    pDst, DST, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                                                    DstWrite, 0, 0));\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
#define DEFINE_CONVERT_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    DEFINE_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
 * This macro defines an entire function to implement a ScaleBlit inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
 * loop for scaling and converting pixels from a buffer of one type into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
 * a buffer of another type.  No blending is done of the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
#define DEFINE_SCALE_BLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
void NAME_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                               juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                               jint sxloc, jint syloc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                               jint sxinc, jint syinc, jint shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                               SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                               SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                               NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                               CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                             DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                             x, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                             sxloc, syloc, sxinc, syinc, shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                             ConvertVia ## STRATEGY(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                                                    pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                                                    x, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
 * This macro defines an entire function to implement a ScaleBlit inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
 * loop for scaling and converting pixels from a buffer of byte pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
 * with a lookup table into a buffer of another type.  No blending is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
 * done of the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
#define DEFINE_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
void NAME_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                               juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                               jint sxloc, jint syloc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                               jint sxinc, jint syinc, jint shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                               SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                               SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                               NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                               CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    Declare ## LUT_STRATEGY ## Lut(SRC, DST, pixLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    Setup ## LUT_STRATEGY ## Lut(SRC, DST, pixLut, pSrcInfo, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                             DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                             x, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                             sxloc, syloc, sxinc, syinc, shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                             Body ## LUT_STRATEGY ## Lut(pSrc, SRC, pixLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                                                         pDst, DST, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                                                         DstWrite, x, 0));\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
#define DEFINE_SCALE_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    DEFINE_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
 * for drawing opaque pixels from a buffer of one type onto a buffer of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
 * another type, ignoring the transparent pixels in the source buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
 * No blending is done of the pixels - the converted pixel value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
 * either copied or the destination is left untouched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
#define DEFINE_XPAR_CONVERT_BLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
void NAME_XPAR_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                                      juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                                      SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                                      SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                                      NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                                      CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                        ConvertXparVia ## STRATEGY(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                                                   pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                                                   0, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
 * for converting pixels from a buffer of byte pixels with a lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
 * table containing transparent pixels into a buffer of another type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
 * No blending is done of the pixels - the converted pixel value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
 * either copied or the destination is left untouched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
#define DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
void NAME_XPAR_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                                      juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
                                      SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
                                      SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
                                      NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
                                      CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
    Declare ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    Setup ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut, pSrcInfo, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                        Body ## LUT_STRATEGY ## XparLut(pSrc, SRC, pixLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                                                        pDst, DST, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                                                        DstWrite, 0, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
#define DEFINE_XPAR_CONVERT_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    DEFINE_XPAR_CONVERT_BLIT_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
 * This macro defines an entire function to implement a ScaleBlit inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
 * loop for scaling and converting pixels from a buffer of byte pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
 * with a lookup table containing transparent pixels into a buffer of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
 * another type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
 * No blending is done of the pixels - the converted pixel value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
 * either copied or the destination is left untouched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
#define DEFINE_XPAR_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
void NAME_XPAR_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                                    juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                                    jint sxloc, jint syloc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                                    jint sxinc, jint syinc, jint shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                                    SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                                    SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                                    NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                                    CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    Declare ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    Setup ## LUT_STRATEGY ## XparLut(SRC, DST, pixLut, pSrcInfo, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                             DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                             x, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                             sxloc, syloc, sxinc, syinc, shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                             Body ## LUT_STRATEGY ## XparLut(pSrc, SRC, pixLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                                                             pDst, DST, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                                                             DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                                                             x, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
#define DEFINE_XPAR_SCALE_BLIT_LUT8(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    DEFINE_XPAR_SCALE_BLIT_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
 * This macro defines an entire function to implement a ScaleBlit inner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
 * loop for scaling and converting pixels from a buffer of one type
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
 * containing transparent pixels into a buffer of another type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
 * No blending is done of the pixels - the converted pixel value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
 * either copied or the destination is left untouched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
#define DEFINE_XPAR_SCALE_BLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
void NAME_XPAR_SCALE_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                               juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                               jint sxloc, jint syloc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
                               jint sxinc, jint syinc, jint shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
                               SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
                               SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
                               NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                               CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
    BlitLoopScaleWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                             DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                             x, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                             sxloc, syloc, sxinc, syinc, shift, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                             ConvertXparVia ## STRATEGY(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                                                        pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                                                        x, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
 * This macro defines an entire function to implement a BlitBg inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
 * for converting pixels from a buffer of one type containing transparent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
 * pixels into a buffer of another type with a specified bgcolor for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
 * transparent pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
 * No blending is done of the pixels other than to substitute the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
 * bgcolor for any transparent pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
#define DEFINE_XPAR_BLITBG(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
void NAME_XPAR_BLITBG(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
                                juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                                jint bgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                                SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                                SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                                NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                                CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
    Declare ## DST ## PixelData(bgdata) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    Extract ## DST ## PixelData(bgpixel, bgdata); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                        BgCopyXparVia ## STRATEGY(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                                                  pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                                                  0, 0, bgpixel, bgdata)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
 * This macro defines an entire function to implement a BlitBg inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
 * for converting pixels from a buffer of byte pixels with a lookup
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
 * table containing transparent pixels into a buffer of another type
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
 * with a specified bgcolor for the transparent pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
 * No blending is done of the pixels other than to substitute the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
 * bgcolor for any transparent pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
#define DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
void NAME_XPAR_BLITBG(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
                                juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                                jint bgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
                                SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
                                SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
                                NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
                                CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
    Declare ## LUT_STRATEGY ## BgLut(SRC, DST, pixLut) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
    Setup ## LUT_STRATEGY ## BgLut(SRC, DST, pixLut, pSrcInfo, pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                                   bgpixel); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
                        Body ## LUT_STRATEGY ## BgLut(pSrc, SRC, pixLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
                                                      pDst, DST, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                                                      DstWrite, 0, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
                                                      bgpixel)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
#define DEFINE_XPAR_BLITBG_LUT8(SRC, DST, LUT_STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
    DEFINE_XPAR_BLITBG_LUT(SRC, DST, LUT_STRATEGY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
 * This macro defines an entire function to implement a Blit inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
 * for converting pixels from a buffer of one type into a buffer of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
 * another type.  Each source pixel is XORed with the current XOR color value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
 * That result is then XORed with the destination pixel and the final
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
 * result is stored in the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
#define DEFINE_XOR_BLIT(SRC, DST, DSTANYTYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
void NAME_XOR_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                             juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                             SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                             SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                             NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                             CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    Declare ## DSTANYTYPE ## PixelData(xor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
    Declare ## DSTANYTYPE ## PixelData(mask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
    Extract ## DSTANYTYPE ## PixelData(xorpixel, xor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    Extract ## DSTANYTYPE ## PixelData(alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
    BlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                        DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                        width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                        XorVia1IntArgb(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                                       pDst, DST, DSTANYTYPE, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                                       0, xorpixel, xor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                                       alphamask, mask, pDstInfo)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
 * This macro defines an entire function to implement a FillRect inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
 * for setting a rectangular region of pixels to a specific pixel value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
 * No blending of the fill color is done with the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
#define DEFINE_SOLID_FILLRECT(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
void NAME_SOLID_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
                              jint lox, jint loy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
                              jint hix, jint hiy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                              jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
                              NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                              CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
    juint height = hiy - loy; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    juint width = hix - lox; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
    Extract ## DST ## PixelData(pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        juint x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            Store ## DST ## PixelData(pPix, x, pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
 * This macro defines an entire function to implement a FillSpans inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
 * for iterating through a list of spans and setting those regions of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
 * to a specific pixel value.  No blending of the fill color is done with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
 * the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
#define DEFINE_SOLID_FILLSPANS(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
void NAME_SOLID_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
                               SpanIteratorFuncs *pSpanFuncs, void *siData, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                               jint pixel, NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                               CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
    void *pBase = pRasInfo->rasBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
    jint bbox[4]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
    Extract ## DST ## PixelData(pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
    while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        jint x = bbox[0]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        jint y = bbox[1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
        juint w = bbox[2] - x; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        juint h = bbox[3] - y; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
        DST ## DataType *pPix = PtrCoord(pBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                                         x, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                                         y, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
            juint relx; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            for (relx = 0; relx < w; relx++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                Store ## DST ## PixelData(pPix, relx, pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        } while (--h > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
/*
7487
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1296
 * This macro defines an entire function to implement a FillParallelogram
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1297
 * inner loop for tracing 2 diagonal edges (left and right) and setting
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1298
 * those regions of pixels between them to a specific pixel value.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1299
 * No blending of the fill color is done with the pixels.
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1300
 */
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1301
#define DEFINE_SOLID_FILLPGRAM(DST) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1302
void NAME_SOLID_FILLPGRAM(DST)(SurfaceDataRasInfo *pRasInfo, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1303
                               jint lox, jint loy, jint hix, jint hiy, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1304
                               jlong leftx, jlong dleftx, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1305
                               jlong rightx, jlong drightx, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1306
                               jint pixel, struct _NativePrimitive *pPrim, \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1307
                               CompositeInfo *pCompInfo) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1308
{ \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1309
    Declare ## DST ## PixelData(pix) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1310
    jint scan = pRasInfo->scanStride; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1311
    DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, 0, 0, loy, scan); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1312
 \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1313
    Extract ## DST ## PixelData(pixel, pix); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1314
    while (loy < hiy) { \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1315
        jint lx = WholeOfLong(leftx); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1316
        jint rx = WholeOfLong(rightx); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1317
        if (lx < lox) lx = lox; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1318
        if (rx > hix) rx = hix; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1319
        while (lx < rx) { \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1320
            Store ## DST ## PixelData(pPix, lx, pixel, pix); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1321
            lx++; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1322
        } \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1323
        pPix = PtrAddBytes(pPix, scan); \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1324
        leftx += dleftx; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1325
        rightx += drightx; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1326
        loy++; \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1327
    } \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1328
}
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1329
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1330
#define DEFINE_SOLID_DRAWPARALLELOGRAM_FUNCS(DST) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1331
    DrawParallelogramFuncs NAME_SOLID_PGRAM_FUNCS(DST) = { \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1332
        NAME_SOLID_FILLPGRAM(DST), \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1333
        NAME_SOLID_DRAWLINE(DST), \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1334
    };
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1335
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1336
#define DEFINE_SOLID_PARALLELOGRAM(DST) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1337
    DEFINE_SOLID_FILLPGRAM(DST) \
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1338
    DEFINE_SOLID_DRAWPARALLELOGRAM_FUNCS(DST)
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1339
9b031d062ede 6775317: Improve performance of non-AA transformed rectangles and single wide lines in software pipelines
flar
parents: 5506
diff changeset
  1340
/*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
 * This macro declares the bumpmajor and bumpminor variables used for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
 * DrawLine functions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
#define DeclareBumps(BUMPMAJOR, BUMPMINOR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
    jint BUMPMAJOR, BUMPMINOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
 * This macro extracts "instructions" from the bumpmajor and bumpminor masks
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
 * that determine the initial bumpmajor and bumpminor values.  The bumpmajor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
 * and bumpminor masks are laid out in the following format:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
 * bumpmajormask:                      bumpminormask:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
 * bit0: bumpmajor = pixelStride       bit0: bumpminor = pixelStride
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
 * bit1: bumpmajor = -pixelStride      bit1: bumpminor = -pixelStride
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
 * bit2: bumpmajor = scanStride        bit2: bumpminor = scanStride
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
 * bit3: bumpmajor = -scanStride       bit3: bumpminor = -scanStride
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
#define InitBumps(BUMPMAJOR, BUMPMINOR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
                  BUMPMAJORMASK, BUMPMINORMASK, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
                  PIXELSTRIDE, SCANSTRIDE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
    BUMPMAJOR = (BUMPMAJORMASK & BUMP_POS_PIXEL) ? PIXELSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
                    (BUMPMAJORMASK & BUMP_NEG_PIXEL) ? -PIXELSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
                        (BUMPMAJORMASK & BUMP_POS_SCAN) ? SCANSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
                                                          -SCANSTRIDE; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    BUMPMINOR = (BUMPMINORMASK & BUMP_POS_PIXEL) ? PIXELSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
                    (BUMPMINORMASK & BUMP_NEG_PIXEL) ? -PIXELSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
                        (BUMPMINORMASK & BUMP_POS_SCAN) ? SCANSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
                            (BUMPMINORMASK & BUMP_NEG_SCAN) ? -SCANSTRIDE : \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
                                                              0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
    BUMPMINOR += BUMPMAJOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
 * This macro defines an entire function to implement a DrawLine inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
 * for iterating along a horizontal or vertical line and setting the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
 * on that line to a specific pixel value.  No blending of the fill color
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
 * is done with the pixels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
#define DEFINE_SOLID_DRAWLINE(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
void NAME_SOLID_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
                              jint x1, jint y1, jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
                              jint steps, jint error, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
                              jint bumpmajormask, jint errmajor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
                              jint bumpminormask, jint errminor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
                              NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
                              CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
    DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
                                     x1, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
                                     y1, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
    DeclareBumps(bumpmajor, bumpminor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
    InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
              DST ## PixelStride, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
    Extract ## DST ## PixelData(pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    if (errmajor == 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
            Store ## DST ## PixelData(pPix, 0, pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            pPix = PtrAddBytes(pPix, bumpmajor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
            Store ## DST ## PixelData(pPix, 0, pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
            if (error < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                pPix = PtrAddBytes(pPix, bumpmajor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
                error += errmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
                pPix = PtrAddBytes(pPix, bumpminor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
                error -= errminor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
 * This macro defines an entire function to implement a FillRect inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
 * for setting a rectangular region of pixels to a specific pixel value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
 * Each destination pixel is XORed with the current XOR mode color as well as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
 * the current fill color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
#define DEFINE_XOR_FILLRECT(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
void NAME_XOR_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
                            jint lox, jint loy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
                            jint hix, jint hiy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                            jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
                            NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
                            CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
    Declare ## DST ## PixelData(xor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
    Declare ## DST ## PixelData(mask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    juint height = hiy - loy; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
    juint width = hix - lox; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
    pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
    Extract ## DST ## PixelData(xorpixel, xor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
    Extract ## DST ## PixelData(pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
    Extract ## DST ## PixelData(alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
        juint x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
            Xor ## DST ## PixelData(pixel, pix, pPix, x, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                                    xorpixel, xor, alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
        } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
        pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
 * This macro defines an entire function to implement a FillSpans inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
 * for iterating through a list of spans and setting those regions of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
 * to a specific pixel value.  Each destination pixel is XORed with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
 * current XOR mode color as well as the current fill color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
#define DEFINE_XOR_FILLSPANS(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
void NAME_XOR_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
                             SpanIteratorFuncs *pSpanFuncs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
                             void *siData, jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                             NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
                             CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
    void *pBase = pRasInfo->rasBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
    Declare ## DST ## PixelData(xor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
    Declare ## DST ## PixelData(mask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
    jint bbox[4]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
    Extract ## DST ## PixelData(xorpixel, xor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
    Extract ## DST ## PixelData(pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
    Extract ## DST ## PixelData(alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
    while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
        jint x = bbox[0]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
        jint y = bbox[1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        juint w = bbox[2] - x; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
        juint h = bbox[3] - y; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
        DST ## DataType *pPix = PtrCoord(pBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
                                         x, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
                                         y, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
            juint relx; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
            for (relx = 0; relx < w; relx++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
                Xor ## DST ## PixelData(pixel, pix, pPix, relx, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
                                        xorpixel, xor, alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
        } while (--h > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
 * This macro defines an entire function to implement a DrawLine inner loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
 * for iterating along a horizontal or vertical line and setting the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
 * on that line to a specific pixel value.  Each destination pixel is XORed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
 * with the current XOR mode color as well as the current draw color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
#define DEFINE_XOR_DRAWLINE(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
void NAME_XOR_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
                            jint x1, jint y1, jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
                            jint steps, jint error, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
                            jint bumpmajormask, jint errmajor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
                            jint bumpminormask, jint errminor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
                            NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
                            CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
    Declare ## DST ## PixelData(xor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
    Declare ## DST ## PixelData(mask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
    DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
                                     x1, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
                                     y1, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
    DeclareBumps(bumpmajor, bumpminor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
    InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
              DST ## PixelStride, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
    Extract ## DST ## PixelData(xorpixel, xor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
    Extract ## DST ## PixelData(pixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
    Extract ## DST ## PixelData(alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
    if (errmajor == 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
            Xor ## DST ## PixelData(pixel, pix, pPix, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                                    xorpixel, xor, alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
            pPix = PtrAddBytes(pPix, bumpmajor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
            Xor ## DST ## PixelData(pixel, pix, pPix, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
                                    xorpixel, xor, alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
            if (error < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
                pPix = PtrAddBytes(pPix, bumpmajor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
                error += errmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
                pPix = PtrAddBytes(pPix, bumpminor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
                error -= errminor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
 * This macro is used to declare the variables needed by the glyph clipping
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
 * macro.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
#define DeclareDrawGlyphListClipVars(PIXELS, ROWBYTES, WIDTH, HEIGHT, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
                                     LEFT, TOP, RIGHT, BOTTOM) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
    const jubyte * PIXELS; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
    int ROWBYTES; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
    int LEFT, TOP; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
    int WIDTH, HEIGHT; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
    int RIGHT, BOTTOM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
 * This macro represents the glyph clipping code used in the various
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
 * DRAWGLYPHLIST macros.  This macro is typically used within a loop.  Note
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
 * that the body of this macro is NOT wrapped in a do..while block due to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
 * the use of continue statements within the block (those continue statements
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
 * are intended skip the outer loop, not the do..while loop).  To combat this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
 * problem, pass in the code (typically a continue statement) that should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
 * executed when a null glyph is encountered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
#define ClipDrawGlyphList(DST, PIXELS, BYTESPERPIXEL, ROWBYTES, WIDTH, HEIGHT,\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
                          LEFT, TOP, RIGHT, BOTTOM, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
                          CLIPLEFT, CLIPTOP, CLIPRIGHT, CLIPBOTTOM, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
                          GLYPHS, GLYPHCOUNTER, NULLGLYPHCODE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
    PIXELS = (const jubyte *)GLYPHS[GLYPHCOUNTER].pixels; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
    if (!PIXELS) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
        NULLGLYPHCODE; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
    ROWBYTES = GLYPHS[GLYPHCOUNTER].rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
    LEFT     = GLYPHS[GLYPHCOUNTER].x; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
    TOP      = GLYPHS[GLYPHCOUNTER].y; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
    WIDTH    = GLYPHS[GLYPHCOUNTER].width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
    HEIGHT   = GLYPHS[GLYPHCOUNTER].height; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
    /* if any clipping required, modify parameters now */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
    RIGHT  = LEFT + WIDTH; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
    BOTTOM = TOP + HEIGHT; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
    if (LEFT < CLIPLEFT) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    /* Multiply needed for LCD text as PIXELS is really BYTES */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
        PIXELS += (CLIPLEFT - LEFT) * BYTESPERPIXEL ; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
        LEFT = CLIPLEFT; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    if (TOP < CLIPTOP) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
        PIXELS += (CLIPTOP - TOP) * ROWBYTES; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
        TOP = CLIPTOP; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
    if (RIGHT > CLIPRIGHT) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
        RIGHT = CLIPRIGHT; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
    if (BOTTOM > CLIPBOTTOM) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
        BOTTOM = CLIPBOTTOM; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
    if (RIGHT <= LEFT || BOTTOM <= TOP) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
        NULLGLYPHCODE; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
    WIDTH = RIGHT - LEFT; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
    HEIGHT = BOTTOM - TOP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
#define DEFINE_SOLID_DRAWGLYPHLIST(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
void NAME_SOLID_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
                                   ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
                                   jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
                                   jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
                                   jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
                                   jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
                                   NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
                                   CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
    jint glyphCounter; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
    Extract ## DST ## PixelData(fgpixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
        ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
            int x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
                if (pixels[x]) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
                    Store ## DST ## PixelData(pPix, x, fgpixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
            } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
#define GlyphListAABlend3ByteRgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
                                 FG_PIXEL, PREFIX, SRC_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
   do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
        DeclareCompVarsFor3ByteRgb(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
        jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
        if (mixValSrc) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
            if (mixValSrc < 255) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
                jint mixValDst = 255 - mixValSrc; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
                Load ## DST ## To3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
                                          dstR, dstG, dstB); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
                MultMultAddAndStore3ByteRgbComps(dst, mixValDst, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
                                                 mixValSrc, SRC_PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
                Store ## DST ## From3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
                                             dstR, dstG, dstB); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
                Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
                                          FG_PIXEL, PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
    } while (0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1671
/*
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1672
 * Antialiased glyph drawing results in artifacts around the character edges
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1673
 * when text is drawn ontop of translucent background color. The standard
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1674
 * blending equation for two colors:
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1675
 * destColor = srcColor * glyphAlpha + destColor * (1 - glyphAlpha)
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1676
 * works only when srcColor and destColor are opaque. For translucent srcColor
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1677
 * and destColor, the respective alpha components in each color will influence
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1678
 * the visibility of the color and the visibility of the color below it. Hence
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1679
 * the equation for blending is given as:
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1680
 * resA = srcAlpha + dstAlpha * (1 - srcAlpha)
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1681
 * resCol = (srcColor * srcAlpha + destColor * destAlpha * (1- srcAlpha))/resA
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1682
 * In addition, srcAlpha is multiplied with the glyphAlpha- that indicates the
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1683
 * grayscale mask value of the glyph being drawn. The combined result provides
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1684
 * smooth antialiased text on the buffer without any artifacts. Since the
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1685
 * logic is executed for every pixel in a glyph, the implementation is further
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1686
 * optimized to reduce computation and improve execution time.
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1687
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
#define GlyphListAABlend4ByteArgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
                                  FG_PIXEL, PREFIX, SRC_PREFIX) \
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1690
    do { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1691
        DeclareAlphaVarFor4ByteArgb(resA) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1692
        DeclareCompVarsFor4ByteArgb(res) \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
        jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
        if (mixValSrc) { \
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1695
            if (mixValSrc != 0xff) { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1696
                PromoteByteAlphaFor4ByteArgb(mixValSrc); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1697
                resA = MultiplyAlphaFor4ByteArgb(mixValSrc, SRC_PREFIX ## A); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1698
            } else { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1699
                resA = SRC_PREFIX ## A; \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1700
            } \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1701
            if (resA != MaxValFor4ByteArgb) { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1702
                DeclareAndInvertAlphaVarFor4ByteArgb(dstF, resA) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1703
                DeclareAndClearAlphaVarFor4ByteArgb(dstA) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1704
                DeclareCompVarsFor4ByteArgb(dst) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1705
                DeclareCompVarsFor4ByteArgb(tmp) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1706
                MultiplyAndStore4ByteArgbComps(res, resA, SRC_PREFIX); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1707
                if (!(DST ## IsPremultiplied)) { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1708
                    Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1709
                                               dstA, dstR, dstG, dstB); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1710
                    Store4ByteArgbCompsUsingOp(tmp, =, dst); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1711
                } else { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1712
                    Declare ## DST ## AlphaLoadData(DstPix) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1713
                    jint pixelOffset = PIXEL_INDEX * (DST ## PixelStride); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1714
                    DST ## DataType *pixelAddress = PtrAddBytes(DST_PTR, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1715
                                                                pixelOffset); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1716
                    LoadAlphaFrom ## DST ## For4ByteArgb(pixelAddress, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1717
                                                         DstPix, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1718
                                                         dst); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1719
                    Postload4ByteArgbFrom ## DST(pixelAddress, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1720
                                                 DstPix, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1721
                                                 tmp); \
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1722
                } \
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1723
                if (dstA) { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1724
                    DeclareAlphaVarFor4ByteArgb(blendF) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1725
                    dstA = MultiplyAlphaFor4ByteArgb(dstF, dstA); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1726
                    resA += dstA; \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1727
                    blendF = SrcOver ## DST ## BlendFactor(dstF, dstA); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1728
                    if (blendF != MaxValFor4ByteArgb) { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1729
                        MultiplyAndStore4ByteArgbComps(tmp, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1730
                                                       blendF, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1731
                                                       tmp); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1732
                    } \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1733
                    Store4ByteArgbCompsUsingOp(res, +=, tmp); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1734
                } \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
                Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
                                          FG_PIXEL, PREFIX); \
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1738
                break; \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
            } \
37800
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1740
            if (!(DST ## IsOpaque) && \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1741
                !(DST ## IsPremultiplied) && resA && \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1742
                resA < MaxValFor4ByteArgb) \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1743
            { \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1744
                DivideAndStore4ByteArgbComps(res, res, resA); \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1745
            } \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1746
            Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
518e44c93fbb 8015070: Antialiased text on translucent backgrounds gets bright artifacts
ntv
parents: 26751
diff changeset
  1747
                                               PIXEL_INDEX, res); \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
    } while (0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
#define GlyphListAABlend1ByteGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
                                  FG_PIXEL, PREFIX, SRC_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
   do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
        DeclareCompVarsFor1ByteGray(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
        jint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
        if (mixValSrc) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
            if (mixValSrc < 255) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
                jint mixValDst = 255 - mixValSrc; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
                Load ## DST ## To1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
                                           dstG); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
                MultMultAddAndStore1ByteGrayComps(dst, mixValDst, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
                                                  mixValSrc, SRC_PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
                Store ## DST ## From1ByteGray(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
                                              dstG); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
                Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
                                          FG_PIXEL, PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
    } while (0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
#define GlyphListAABlend1ShortGray(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
                                   FG_PIXEL, PREFIX, SRC_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
   do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
        DeclareCompVarsFor1ShortGray(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
        juint mixValSrc = GLYPH_PIXELS[PIXEL_INDEX]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
        if (mixValSrc) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
            if (mixValSrc < 255) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
                juint mixValDst; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
                PromoteByteAlphaFor1ShortGray(mixValSrc); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
                mixValDst = 0xffff - mixValSrc; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
                Load ## DST ## To1ShortGray(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
                                            dstG); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
                MultMultAddAndStore1ShortGrayComps(dst, mixValDst, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
                                                   mixValSrc, SRC_PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
                Store ## DST ## From1ShortGray(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
                                               dstG); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
                Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
                                          FG_PIXEL, PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
    } while (0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
#define DEFINE_SOLID_DRAWGLYPHLISTAA(DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
void NAME_SOLID_DRAWGLYPHLISTAA(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
                                     ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
                                     jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
                                     jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
                                     jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
                                     jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
                                     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
                                     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
    jint glyphCounter; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
    Declare ## DST ## PixelData(solidpix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
    Declare ## DST ## LoadVars(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
    Declare ## DST ## StoreVars(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
    Init ## DST ## LoadVars(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
    Init ## DST ## StoreVarsY(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
    Init ## DST ## StoreVarsX(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(argbcolor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
    Extract ## DST ## PixelData(fgpixel, solidpix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
        ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
        Set ## DST ## StoreVarsYPos(pix, pRasInfo, top); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
            int x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
            Set ## DST ## StoreVarsXPos(pix, pRasInfo, left); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
                GlyphListAABlend ## STRATEGY(DST, pixels, x, pPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
                                             fgpixel, solidpix, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
                Next ## DST ## StoreVarsX(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
            } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
            Next ## DST ## StoreVarsY(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
#define GlyphListLCDBlend3ByteRgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
                                  FG_PIXEL, PREFIX, SRC_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
   do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
        DeclareCompVarsFor3ByteRgb(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
        jint mixValSrcG = GLYPH_PIXELS[PIXEL_INDEX*3+1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
        jint mixValSrcR, mixValSrcB; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
        if (rgbOrder) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
            mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
            mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
            mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
            mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
        if ((mixValSrcR | mixValSrcG | mixValSrcB) != 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
            if ((mixValSrcR & mixValSrcG & mixValSrcB) < 255) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
                jint mixValDstR = 255 - mixValSrcR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
                jint mixValDstG = 255 - mixValSrcG; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
                jint mixValDstB = 255 - mixValSrcB; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
                Load ## DST ## To3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
                                          dstR, dstG, dstB); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
                dstR = invGammaLut[dstR]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
                dstG = invGammaLut[dstG]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
                dstB = invGammaLut[dstB]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
                MultMultAddAndStoreLCD3ByteRgbComps(dst, mixValDst, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
                                                    mixValSrc, SRC_PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
                dstR = gammaLut[dstR]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
                dstG = gammaLut[dstG]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
                dstB = gammaLut[dstB]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
                Store ## DST ## From3ByteRgb(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
                                             dstR, dstG, dstB); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
                Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
                                          FG_PIXEL, PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
/* There is no alpha channel in the glyph data with which to interpolate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
 * between the src and dst alphas, but a reasonable approximation is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
 * sum the coverage alphas of the colour channels and divide by 3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
 * We can approximate division by 3 using mult and shift. See
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
 * sun/font/scalerMethods.c for a detailed explanation of why "21931"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
#define GlyphListLCDBlend4ByteArgb(DST, GLYPH_PIXELS, PIXEL_INDEX, DST_PTR, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
                                  FG_PIXEL, PREFIX, SRC_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
   do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
        DeclareAlphaVarFor4ByteArgb(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
        DeclareCompVarsFor4ByteArgb(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
        jint mixValSrcG = GLYPH_PIXELS[PIXEL_INDEX*3+1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
        jint mixValSrcR, mixValSrcB; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
        if (rgbOrder) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
            mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
            mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
            mixValSrcR = GLYPH_PIXELS[PIXEL_INDEX*3+2]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
            mixValSrcB = GLYPH_PIXELS[PIXEL_INDEX*3]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
        if ((mixValSrcR | mixValSrcG | mixValSrcB) != 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
            if ((mixValSrcR & mixValSrcG & mixValSrcB) < 255) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
                jint mixValDstR = 255 - mixValSrcR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
                jint mixValDstG = 255 - mixValSrcG; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
                jint mixValDstB = 255 - mixValSrcB; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
                jint mixValSrcA = ((mixValSrcR + mixValSrcG + mixValSrcB) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
                                    * 21931) >> 16;\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
                jint mixValDstA = 255 - mixValSrcA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
                Load ## DST ## To4ByteArgb(DST_PTR, pix, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
                                           dstA, dstR, dstG, dstB); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
                dstR = invGammaLut[dstR]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
                dstG = invGammaLut[dstG]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
                dstB = invGammaLut[dstB]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
                dstA = MUL8(dstA, mixValDstA) + \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
                       MUL8(SRC_PREFIX ## A, mixValSrcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
                MultMultAddAndStoreLCD4ByteArgbComps(dst, mixValDst, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
                                                  mixValSrc, SRC_PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
                dstR = gammaLut[dstR]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
                dstG = gammaLut[dstG]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
                dstB = gammaLut[dstB]; \
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1925
                if (!(DST ## IsOpaque) && \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1926
                    !(DST ## IsPremultiplied) && dstA && dstA < 255) { \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1927
                    DivideAndStore4ByteArgbComps(dst, dst, dstA); \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1928
                } \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1929
                Store ## DST ## From4ByteArgbComps(DST_PTR, pix, \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1930
                                                   PIXEL_INDEX, dst); \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
                Store ## DST ## PixelData(DST_PTR, PIXEL_INDEX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
                                          FG_PIXEL, PREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
    } while (0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
#define DEFINE_SOLID_DRAWGLYPHLISTLCD(DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
void NAME_SOLID_DRAWGLYPHLISTLCD(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
                                     ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
                                     jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
                                     jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
                                     jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
                                     jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
                                     jint rgbOrder, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
                                     unsigned char *gammaLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
                                     unsigned char * invGammaLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
                                     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
                                     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
    jint glyphCounter, bpp; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1954
    Declare ## DST ## PixelData(solidpix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
    Declare ## DST ## LoadVars(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
    Declare ## DST ## StoreVars(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
    Init ## DST ## LoadVars(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
    Init ## DST ## StoreVarsY(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
    Init ## DST ## StoreVarsX(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(argbcolor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
    Extract ## DST ## PixelData(fgpixel, solidpix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
    srcR = invGammaLut[srcR]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
    srcG = invGammaLut[srcG]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
    srcB = invGammaLut[srcB]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
        bpp = \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
        (glyphs[glyphCounter].rowBytes == glyphs[glyphCounter].width) ? 1 : 3;\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
        ClipDrawGlyphList(DST, pixels, bpp, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
        Set ## DST ## StoreVarsYPos(pix, pRasInfo, top); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
        if (bpp!=1) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
           /* subpixel positioning adjustment */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
            pixels += glyphs[glyphCounter].rowBytesOffset; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
            int x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
            Set ## DST ## StoreVarsXPos(pix, pRasInfo, left); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
            if (bpp==1) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
                do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
                    if (pixels[x]) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
                        Store ## DST ## PixelData(pPix, x, fgpixel, solidpix);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
                } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1995
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
                do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
                    GlyphListLCDBlend ## STRATEGY(DST, pixels, x, pPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
                                                   fgpixel, solidpix, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
                    Next ## DST ## StoreVarsX(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2000
                } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
            Next ## DST ## StoreVarsY(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
#define DEFINE_XOR_DRAWGLYPHLIST(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
void NAME_XOR_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
                                 ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
                                 jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
                                 jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
                                 jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
                                 jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
                                 NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
                                 CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
    jint glyphCounter; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
    Declare ## DST ## PixelData(xor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
    Declare ## DST ## PixelData(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2025
    Declare ## DST ## PixelData(mask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2026
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2027
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
    Extract ## DST ## PixelData(xorpixel, xor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
    Extract ## DST ## PixelData(fgpixel, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
    Extract ## DST ## PixelData(alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2031
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2032
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
        ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2035
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2040
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2041
            int x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
                if (pixels[x]) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
                    Xor ## DST ## PixelData(fgpixel, pix, pPix, x, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
                                            xorpixel, xor, alphamask, mask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
            } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2049
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2050
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2051
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2054
#define DEFINE_TRANSFORMHELPER_NN(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2055
void NAME_TRANSFORMHELPER_NN(SRC)(SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2056
                                  jint *pRGB, jint numpix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
                                  jlong xlong, jlong dxlong, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
                                  jlong ylong, jlong dylong) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
    SRC ## DataType *pBase = pSrcInfo->rasBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
    jint scan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
    jint *pEnd = pRGB + numpix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
    xlong += IntToLong(pSrcInfo->bounds.x1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
    ylong += IntToLong(pSrcInfo->bounds.y1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2069
    while (pRGB < pEnd) { \
58626
a9ed3d93cca3 8218877: Help transform transformers
alitvinov
parents: 47216
diff changeset
  2070
        SRC ## DataType *pRow = PtrPixelsRow(pBase, WholeOfLong(ylong), scan); \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
        Copy ## SRC ## ToIntArgbPre(pRGB, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
                                    SrcRead, pRow, WholeOfLong(xlong)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
        pRGB++; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
        xlong += dxlong; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
        ylong += dylong; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
#define DEFINE_TRANSFORMHELPER_BL(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
void NAME_TRANSFORMHELPER_BL(SRC)(SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
                                  jint *pRGB, jint numpix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
                                  jlong xlong, jlong dxlong, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
                                  jlong ylong, jlong dylong) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
    jint scan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
    jint cx, cy, cw, ch; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
    jint *pEnd = pRGB + numpix*4; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
    cx = pSrcInfo->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
    cw = pSrcInfo->bounds.x2-cx; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
    cy = pSrcInfo->bounds.y1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
    ch = pSrcInfo->bounds.y2-cy; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
    xlong -= LongOneHalf; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
    ylong -= LongOneHalf; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
    while (pRGB < pEnd) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
        jint xwhole = WholeOfLong(xlong); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
        jint ywhole = WholeOfLong(ylong); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
        jint xdelta, ydelta, isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
        SRC ## DataType *pRow; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
        xdelta = ((juint) (xwhole + 1 - cw)) >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
        isneg = xwhole >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
        xwhole -= isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
        xdelta += isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
        ydelta = ((ywhole + 1 - ch) >> 31); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
        isneg = ywhole >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
        ywhole -= isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
        ydelta -= isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
        ydelta &= scan; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
        xwhole += cx; \
58626
a9ed3d93cca3 8218877: Help transform transformers
alitvinov
parents: 47216
diff changeset
  2118
        pRow = PtrPixelsRow(pSrcInfo->rasBase, ywhole + cy, scan); \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
        Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
        Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole+xdelta); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
        pRow = PtrAddBytes(pRow, ydelta); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
        Copy ## SRC ## ToIntArgbPre(pRGB, 2, SrcRead, pRow, xwhole); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
        Copy ## SRC ## ToIntArgbPre(pRGB, 3, SrcRead, pRow, xwhole+xdelta); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
        pRGB += 4; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
        xlong += dxlong; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
        ylong += dylong; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
#define DEFINE_TRANSFORMHELPER_BC(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
void NAME_TRANSFORMHELPER_BC(SRC)(SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
                                  jint *pRGB, jint numpix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
                                  jlong xlong, jlong dxlong, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
                                  jlong ylong, jlong dylong) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
    jint scan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
    jint cx, cy, cw, ch; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
    jint *pEnd = pRGB + numpix*16; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
    cx = pSrcInfo->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
    cw = pSrcInfo->bounds.x2-cx; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
    cy = pSrcInfo->bounds.y1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
    ch = pSrcInfo->bounds.y2-cy; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
    xlong -= LongOneHalf; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
    ylong -= LongOneHalf; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
    while (pRGB < pEnd) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
        jint xwhole = WholeOfLong(xlong); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
        jint ywhole = WholeOfLong(ylong); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2155
        jint xdelta0, xdelta1, xdelta2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2156
        jint ydelta0, ydelta1, ydelta2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2157
        jint isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2158
        SRC ## DataType *pRow; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2159
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2160
        xdelta0 = (-xwhole) >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
        xdelta1 = ((juint) (xwhole + 1 - cw)) >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
        xdelta2 = ((juint) (xwhole + 2 - cw)) >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
        isneg = xwhole >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
        xwhole -= isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2165
        xdelta1 += isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2166
        xdelta2 += xdelta1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2167
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2168
        ydelta0 = ((-ywhole) >> 31) & (-scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2169
        ydelta1 = ((ywhole + 1 - ch) >> 31) & scan; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
        ydelta2 = ((ywhole + 2 - ch) >> 31) & scan; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
        isneg = ywhole >> 31; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
        ywhole -= isneg; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
        ydelta1 += (isneg & -scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
        xwhole += cx; \
58626
a9ed3d93cca3 8218877: Help transform transformers
alitvinov
parents: 47216
diff changeset
  2176
        pRow = PtrPixelsRow(pSrcInfo->rasBase, ywhole + cy, scan); \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
        pRow = PtrAddBytes(pRow, ydelta0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
        Copy ## SRC ## ToIntArgbPre(pRGB,  0, SrcRead, pRow, xwhole+xdelta0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
        Copy ## SRC ## ToIntArgbPre(pRGB,  1, SrcRead, pRow, xwhole        ); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
        Copy ## SRC ## ToIntArgbPre(pRGB,  2, SrcRead, pRow, xwhole+xdelta1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
        Copy ## SRC ## ToIntArgbPre(pRGB,  3, SrcRead, pRow, xwhole+xdelta2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
        pRow = PtrAddBytes(pRow, -ydelta0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
        Copy ## SRC ## ToIntArgbPre(pRGB,  4, SrcRead, pRow, xwhole+xdelta0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
        Copy ## SRC ## ToIntArgbPre(pRGB,  5, SrcRead, pRow, xwhole        ); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
        Copy ## SRC ## ToIntArgbPre(pRGB,  6, SrcRead, pRow, xwhole+xdelta1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
        Copy ## SRC ## ToIntArgbPre(pRGB,  7, SrcRead, pRow, xwhole+xdelta2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
        pRow = PtrAddBytes(pRow, ydelta1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
        Copy ## SRC ## ToIntArgbPre(pRGB,  8, SrcRead, pRow, xwhole+xdelta0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
        Copy ## SRC ## ToIntArgbPre(pRGB,  9, SrcRead, pRow, xwhole        ); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
        Copy ## SRC ## ToIntArgbPre(pRGB, 10, SrcRead, pRow, xwhole+xdelta1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
        Copy ## SRC ## ToIntArgbPre(pRGB, 11, SrcRead, pRow, xwhole+xdelta2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
        pRow = PtrAddBytes(pRow, ydelta2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
        Copy ## SRC ## ToIntArgbPre(pRGB, 12, SrcRead, pRow, xwhole+xdelta0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
        Copy ## SRC ## ToIntArgbPre(pRGB, 13, SrcRead, pRow, xwhole        ); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
        Copy ## SRC ## ToIntArgbPre(pRGB, 14, SrcRead, pRow, xwhole+xdelta1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
        Copy ## SRC ## ToIntArgbPre(pRGB, 15, SrcRead, pRow, xwhole+xdelta2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
        pRGB += 16; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
        xlong += dxlong; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
        ylong += dylong; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
#define DEFINE_TRANSFORMHELPER_FUNCS(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
    TransformHelperFuncs NAME_TRANSFORMHELPER_FUNCS(SRC) = { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
        NAME_TRANSFORMHELPER_NN(SRC), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
        NAME_TRANSFORMHELPER_BL(SRC), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
        NAME_TRANSFORMHELPER_BC(SRC), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2211
#define DEFINE_TRANSFORMHELPERS(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2212
    DEFINE_TRANSFORMHELPER_NN(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
    DEFINE_TRANSFORMHELPER_BL(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
    DEFINE_TRANSFORMHELPER_BC(SRC) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
    DEFINE_TRANSFORMHELPER_FUNCS(SRC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
 * The macros defined above use the following macro definitions supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
 * for the various surface types to manipulate pixels and pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
 * The surface-specific macros are typically supplied by header files
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
 * named after the SurfaceType name (i.e. IntArgb.h, ByteGray.h, etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
 * In the macro names in the following definitions, the string <stype>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
 * is used as a place holder for the SurfaceType name (i.e. IntArgb).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
 * The macros above access these type specific macros using the ANSI
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
 * CPP token concatenation operator "##".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
 * <stype>DataType               A typedef for the type of the pointer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
 *                               that is used to access the raster data
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
 *                               for the given surface type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
 * <stype>PixelStride            Pixel stride for the surface type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
 * Declare<stype>LoadVars        Declare the variables needed to control
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2234
 *                               loading color information from an stype
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
 *                               raster (i.e. lookup tables).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
 * Init<stype>LoadVars           Init the lookup table variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
 * Declare<stype>StoreVars       Declare the storage variables needed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
 *                               control storing pixel data based on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
 *                               pixel coordinate (i.e. dithering variables).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
 * Init<stype>StoreVarsY         Init the dither variables for starting Y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
 * Next<stype>StoreVarsY         Increment the dither variables for next Y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
 * Init<stype>StoreVarsX         Init the dither variables for starting X.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
 * Next<stype>StoreVarsX         Increment the dither variables for next X.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
 * Load<stype>To1IntRgb          Load a pixel and form an INT_RGB integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
 * Store<stype>From1IntRgb       Store a pixel from an INT_RGB integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
 * Load<stype>To1IntArgb         Load a pixel and form an INT_ARGB integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2248
 * Store<stype>From1IntArgb      Store a pixel from an INT_ARGB integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2249
 * Load<stype>To3ByteRgb         Load a pixel into R, G, and B components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2250
 * Store<stype>From3ByteRgb      Store a pixel from R, G, and B components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2251
 * Load<stype>To4ByteArgb        Load a pixel into A, R, G, and B components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2252
 * Store<stype>From4ByteArgb     Store a pixel from A, R, G, and B components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2253
 * Load<stype>To1ByteGray        Load a pixel and form a BYTE_GRAY byte.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2254
 * Store<stype>From1ByteGray     Store a pixel from a BYTE_GRAY byte.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2255
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
 * <stype>PixelType              Typedef for a "single quantity pixel" (SQP)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2257
 *                               that can hold the data for one stype pixel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2258
 * <stype>XparLutEntry           An SQP that can be used to represent a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2259
 *                               transparent pixel for stype.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2260
 * Store<stype>NonXparFromArgb   Store an SQP from an INT_ARGB integer in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2261
 *                               such a way that it would not be confused
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2262
 *                               with the XparLutEntry value for stype.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2263
 * <stype>IsXparLutEntry         Test an SQP for the XparLutEntry value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2264
 * Store<stype>Pixel             Store the pixel data from an SQP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2265
 * <stype>PixelFromArgb          Converts an INT_ARGB value into the specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2266
 *                               pixel representation for the surface type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2267
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2268
 * Declare<stype>PixelData       Declare the pixel data variables (PDV) needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2269
 *                               to hold the elements of pixel data ready to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2270
 *                               store into an stype raster (may be empty for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2271
 *                               stypes whose SQP format is their data format).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2272
 * Extract<stype>PixelData       Extract an SQP value into the PDVs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2273
 * Store<stype>PixelData         Store the PDVs into an stype raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2274
 * XorCopy<stype>PixelData       Xor the PDVs into an stype raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2275
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2276
#endif /* LoopMacros_h_Included */