src/java.desktop/share/native/libawt/java2d/loops/AnyByteBinary.h
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 26751 jdk/src/java.desktop/share/native/libawt/java2d/loops/AnyByteBinary.h@70bac69b37c9
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 15970
diff changeset
     2
 * Copyright (c) 2000, 2013, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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 AnyByteBinary_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define AnyByteBinary_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "AlphaMacros.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "LoopMacros.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "LineUtils.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * This file contains macros that are similar to those found in LoopMacros.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and AlphaMacros.h, yet have been specialized to manipulate any one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * surfaces in the "ByteBinary" family.  It also contains generalized versions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * of some macros that are used by the more specific ByteBinary surfaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/* REMIND: the ByteBinary store macros should probably do ordered dithering */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define DeclareByteBinaryLoadVars(PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    jint *PREFIX ## Lut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define DeclareByteBinaryStoreVars(PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    unsigned char *PREFIX ## InvLut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define SetByteBinaryStoreVarsYPos(PREFIX, pRasInfo, LOC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define SetByteBinaryStoreVarsXPos(PREFIX, pRasInfo, LOC)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define InitByteBinaryLoadVars(PREFIX, pRasInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    PREFIX ## Lut = (pRasInfo)->lutBase
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define InitByteBinaryStoreVarsY(PREFIX, pRasInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    PREFIX ## InvLut = (pRasInfo)->invColorTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define InitByteBinaryStoreVarsX(PREFIX, pRasInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#define NextByteBinaryStoreVarsX(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define NextByteBinaryStoreVarsY(PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define DeclareByteBinaryInitialLoadVars(TYPE, INFO, pRas, PREFIX, x) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    int PREFIX ## adjx = (x) + (INFO)->pixelBitOffset / TYPE ## BitsPerPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    int PREFIX ## index = (PREFIX ## adjx) / TYPE ## PixelsPerByte; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    int PREFIX ## bits = TYPE ## MaxBitOffset - \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                             (((PREFIX ## adjx) % TYPE ## PixelsPerByte) * \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                              TYPE ## BitsPerPixel); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    int PREFIX ## bbpix = (pRas)[PREFIX ## index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define InitialLoadByteBinary(TYPE, pRas, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        if (PREFIX ## bits < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            (pRas)[PREFIX ## index] = (jubyte) PREFIX ## bbpix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            PREFIX ## bbpix = (pRas)[++(PREFIX ## index)]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            PREFIX ## bits = TYPE ## MaxBitOffset; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define ShiftBitsByteBinary(TYPE, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    PREFIX ## bits -= TYPE ## BitsPerPixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define FinalStoreByteBinary(TYPE, pRas, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    (pRas)[PREFIX ## index] = (jubyte) PREFIX ## bbpix
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#define CurrentPixelByteBinary(TYPE, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    ((PREFIX ## bbpix >> PREFIX ## bits) & TYPE ## PixelMask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define StoreByteBinaryPixel(TYPE, pRas, x, pixel)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#define StoreByteBinaryPixelData(TYPE, pPix, x, pixel, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        PREFIX ## bbpix &= ~(TYPE ## PixelMask << PREFIX ## bits); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        PREFIX ## bbpix |= (pixel << PREFIX ## bits); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define ByteBinaryPixelFromArgb(TYPE, pixel, rgb, pRasInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        jint r, g, b; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        ExtractIntDcmComponentsX123(rgb, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        (pixel) = SurfaceData_InvColorMap((pRasInfo)->invColorTable, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                                          r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define XorByteBinaryPixelData(TYPE, pDst, x, PREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                               srcpixel, xorpixel, mask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    PREFIX ## bbpix ^= ((((srcpixel) ^ (xorpixel)) & TYPE ## PixelMask) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                           << PREFIX ## bits)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define LoadByteBinaryTo1IntRgb(TYPE, pRas, PREFIX, x, rgb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    (rgb) = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#define LoadByteBinaryTo1IntArgb(TYPE, pRas, PREFIX, x, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    (argb) = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#define LoadByteBinaryTo3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        jint rgb = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        ExtractIntDcmComponentsX123(rgb, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define LoadByteBinaryTo4ByteArgb(TYPE, pRas, PREFIX, x, a, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        jint argb = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        ExtractIntDcmComponents1234(argb, a, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#define StoreByteBinaryFrom1IntRgb(TYPE, pRas, PREFIX, x, rgb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        int r, g, b; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        ExtractIntDcmComponentsX123(rgb, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        StoreByteBinaryFrom3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
#define StoreByteBinaryFrom1IntArgb(TYPE, pRas, PREFIX, x, argb) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    StoreByteBinaryFrom1IntRgb(TYPE, pRas, PREFIX, x, argb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#define StoreByteBinaryFrom3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    StoreByteBinaryPixelData(TYPE, pRas, x, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                             SurfaceData_InvColorMap(PREFIX ## InvLut, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                                                     r, g, b), \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                             PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
#define StoreByteBinaryFrom4ByteArgb(TYPE, pRas, PREFIX, x, a, r, g, b) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    StoreByteBinaryFrom3ByteRgb(TYPE, pRas, PREFIX, x, r, g, b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
#define DeclareByteBinaryAlphaLoadData(TYPE, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    jint *PREFIX ## Lut; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    jint PREFIX ## rgb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#define InitByteBinaryAlphaLoadData(TYPE, PREFIX, pRasInfo) \
15970
068f2b5c2145 8005796: [parfait] Possible uninitialised variable at jdk/src/share/native/sun/java2d/loops/ByteBinary1Bit.c
jgodinez
parents: 5506
diff changeset
   156
    do { \
068f2b5c2145 8005796: [parfait] Possible uninitialised variable at jdk/src/share/native/sun/java2d/loops/ByteBinary1Bit.c
jgodinez
parents: 5506
diff changeset
   157
        PREFIX ## Lut = (pRasInfo)->lutBase; \
068f2b5c2145 8005796: [parfait] Possible uninitialised variable at jdk/src/share/native/sun/java2d/loops/ByteBinary1Bit.c
jgodinez
parents: 5506
diff changeset
   158
        PREFIX ## rgb = 0; \
068f2b5c2145 8005796: [parfait] Possible uninitialised variable at jdk/src/share/native/sun/java2d/loops/ByteBinary1Bit.c
jgodinez
parents: 5506
diff changeset
   159
    } while (0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
#define LoadAlphaFromByteBinaryFor4ByteArgb(TYPE, pRas, PREFIX, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        PREFIX ## rgb = PREFIX ## Lut[CurrentPixelByteBinary(TYPE, PREFIX)]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        COMP_PREFIX ## A = ((juint) PREFIX ## rgb) >> 24; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
#define Postload4ByteArgbFromByteBinary(TYPE, pRas, PREFIX, COMP_PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        COMP_PREFIX ## R = (PREFIX ## rgb >> 16) & 0xff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        COMP_PREFIX ## G = (PREFIX ## rgb >>  8) & 0xff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        COMP_PREFIX ## B = (PREFIX ## rgb >>  0) & 0xff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
#define ByteBinaryIsPremultiplied       0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
#define StoreByteBinaryFrom4ByteArgbComps(TYPE, pRas, PREFIX, x, COMP_PREFIX)\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    StoreByteBinaryFrom4ByteArgb(TYPE, pRas, PREFIX, x, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                 COMP_PREFIX ## A, COMP_PREFIX ## R, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                                 COMP_PREFIX ## G, COMP_PREFIX ## B)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
#define BBBlitLoopWidthHeight(SRCTYPE, SRCPTR, SRCBASE, SRCINFO, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                              DSTTYPE, DSTPTR, DSTBASE, DSTINFO, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                              WIDTH, HEIGHT, BODY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        SRCTYPE ## DataType *SRCPTR = (SRCTYPE ## DataType *) (SRCBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        DSTTYPE ## DataType *DSTPTR = (DSTTYPE ## DataType *) (DSTBASE); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        jint srcScan = (SRCINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        jint dstScan = (DSTINFO)->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        jint srcx1 = (SRCINFO)->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        jint dstx1 = (DSTINFO)->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        Init ## DSTTYPE ## StoreVarsY(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        srcScan -= (WIDTH) * SRCTYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        dstScan -= (WIDTH) * DSTTYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            Declare ## SRCTYPE ## InitialLoadVars(SRCINFO, SRCPTR, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                                                  srcx1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            Declare ## DSTTYPE ## InitialLoadVars(DSTINFO, DSTPTR, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                                  dstx1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            juint w = WIDTH; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                InitialLoad ## SRCTYPE(SRCPTR, SRCPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                InitialLoad ## DSTTYPE(DSTPTR, DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                BODY; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                ShiftBits ## SRCTYPE(SRCPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                ShiftBits ## DSTTYPE(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                SRCPTR = PtrAddBytes(SRCPTR, SRCTYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                DSTPTR = PtrAddBytes(DSTPTR, DSTTYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                Next ## DSTTYPE ## StoreVarsX(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            FinalStore ## DSTTYPE(DSTPTR, DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            SRCPTR = PtrAddBytes(SRCPTR, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            DSTPTR = PtrAddBytes(DSTPTR, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            Next ## DSTTYPE ## StoreVarsY(DSTPREFIX); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        } while (--HEIGHT > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
#define BBXorVia1IntArgb(SRCPTR, SRCTYPE, SRCPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                         DSTPTR, DSTTYPE, DSTPREFIX, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                         XVAR, XORPIXEL, MASK, DSTINFOPTR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        jint srcpixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        Load ## SRCTYPE ## To1IntArgb(SRCPTR, SRCPREFIX, XVAR, srcpixel); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (IsArgbTransparent(srcpixel)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            break; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        DSTTYPE ## PixelFromArgb(srcpixel, srcpixel, DSTINFOPTR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        Xor ## DSTTYPE ## PixelData(DSTPTR, XVAR, DSTPREFIX, srcpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                                    XORPIXEL, MASK); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
#define DEFINE_BYTE_BINARY_CONVERT_BLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
void NAME_CONVERT_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                                 juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                 SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                 SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                                 NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                                 CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    BBBlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                          DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                          width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                          ConvertVia ## STRATEGY(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                                 pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                                 0, 0)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
#define DEFINE_BYTE_BINARY_XOR_BLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
void NAME_XOR_BLIT(SRC, DST)(void *srcBase, void *dstBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                             juint width, juint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                             SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                             SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                             NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                             CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    Declare ## SRC ## LoadVars(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    BBBlitLoopWidthHeight(SRC, pSrc, srcBase, pSrcInfo, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                          DST, pDst, dstBase, pDstInfo, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                          width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                          BBXorVia1IntArgb(pSrc, SRC, SrcRead, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                                           pDst, DST, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                           0, xorpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                           alphamask, pDstInfo)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
#define DEFINE_BYTE_BINARY_SOLID_FILLRECT(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
void NAME_SOLID_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                              jint lox, jint loy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                              jint hix, jint hiy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                              jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                              NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                              CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    juint height = hiy - loy; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    juint width = hix - lox; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, lox) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            InitialLoad ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            ShiftBits ## DST(DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
#define DEFINE_BYTE_BINARY_SOLID_FILLSPANS(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
void NAME_SOLID_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                               SpanIteratorFuncs *pSpanFuncs, void *siData, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                               jint pixel, NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                               CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    void *pBase = pRasInfo->rasBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    jint bbox[4]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        jint x = bbox[0]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        jint y = bbox[1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        juint w = bbox[2] - x; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        juint h = bbox[3] - y; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        DST ## DataType *pPix = PtrCoord(pBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                                         x, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                                         y, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            jint relx = w; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                InitialLoad ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                ShiftBits ## DST(DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            } while (--relx > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        } while (--h > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
#define DEFINE_BYTE_BINARY_SOLID_DRAWLINE(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
void NAME_SOLID_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                              jint x1, jint y1, jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                              jint steps, jint error, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                              jint bumpmajormask, jint errmajor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                              jint bumpminormask, jint errminor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                              NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                              CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                                     x1, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                                     y1, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    DeclareBumps(bumpmajor, bumpminor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    scan *= DST ## PixelsPerByte; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, 1, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    if (errmajor == 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            x1 += bumpmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            Store ## DST ## PixelData(pPix, 0, pixel, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (error < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                x1 += bumpmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                error += errmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                x1 += bumpminor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                error -= errminor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
#define DEFINE_BYTE_BINARY_XOR_FILLRECT(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
void NAME_XOR_FILLRECT(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                            jint lox, jint loy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                            jint hix, jint hiy, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                            jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                            NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                            CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    juint height = hiy - loy; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    juint width = hix - lox; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    pPix = PtrCoord(pRasInfo->rasBase, lox, DST ## PixelStride, loy, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, lox) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            InitialLoad ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            Xor ## DST ## PixelData(pPix, 0, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                                    pixel, xorpixel, alphamask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            ShiftBits ## DST(DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
#define DEFINE_BYTE_BINARY_XOR_FILLSPANS(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
void NAME_XOR_FILLSPANS(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                             SpanIteratorFuncs *pSpanFuncs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                             void *siData, jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                             NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                             CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    void *pBase = pRasInfo->rasBase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    jint bbox[4]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    while ((*pSpanFuncs->nextSpan)(siData, bbox)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        jint x = bbox[0]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        jint y = bbox[1]; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        juint w = bbox[2] - x; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        juint h = bbox[3] - y; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        DST ## DataType *pPix = PtrCoord(pBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                         x, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                         y, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            jint relx = w; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                InitialLoad ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                Xor ## DST ## PixelData(pPix, 0, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                        pixel, xorpixel, alphamask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                ShiftBits ## DST(DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            } while (--relx > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        } while (--h > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
#define DEFINE_BYTE_BINARY_XOR_DRAWLINE(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
void NAME_XOR_DRAWLINE(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                            jint x1, jint y1, jint pixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                            jint steps, jint error, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                            jint bumpmajormask, jint errmajor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                            jint bumpminormask, jint errminor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                            NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                            CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    DST ## DataType *pPix = PtrCoord(pRasInfo->rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                                     x1, DST ## PixelStride, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                                     y1, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    DeclareBumps(bumpmajor, bumpminor) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    scan *= DST ## PixelsPerByte; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    InitBumps(bumpmajor, bumpminor, bumpmajormask, bumpminormask, 1, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    if (errmajor == 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            Xor ## DST ## PixelData(pPix, 0, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                                    pixel, xorpixel, alphamask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            x1 += bumpmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, x1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            Xor ## DST ## PixelData(pPix, 0, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                                    pixel, xorpixel, alphamask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            if (error < 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                x1 += bumpmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                error += errmajor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                x1 += bumpminor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                error -= errminor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        } while (--steps > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
#define DEFINE_BYTE_BINARY_SOLID_DRAWGLYPHLIST(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
void NAME_SOLID_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                                   ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                                   jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                                   jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                                   jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                                   jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                                   NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                                   CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    jint glyphCounter; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, left) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            jint x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                InitialLoad ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                if (pixels[x]) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                    Store ## DST ## PixelData(pPix, 0, fgpixel, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                ShiftBits ## DST(DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
 * REMIND: we shouldn't be attempting to do antialiased text for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
 *         ByteBinary surfaces in the first place
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
#define DEFINE_BYTE_BINARY_SOLID_DRAWGLYPHLISTAA(DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
void NAME_SOLID_DRAWGLYPHLISTAA(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                                     ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                                     jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                                     jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                     jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                                     jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                                     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                                     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    jint glyphCounter; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    Declare ## DST ## LoadVars(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    Declare ## DST ## StoreVars(pix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    Init ## DST ## LoadVars(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    Init ## DST ## StoreVarsY(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    Init ## DST ## StoreVarsX(pix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(argbcolor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        Set ## DST ## StoreVarsYPos(pix, pRasInfo, top); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, pix, left) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            int x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            Set ## DST ## StoreVarsXPos(pix, pRasInfo, left); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                InitialLoad ## DST(pPix, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                GlyphListAABlend ## STRATEGY(DST, pixels, x, pPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                                             fgpixel, pix, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                ShiftBits ## DST(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                Next ## DST ## StoreVarsX(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            FinalStore ## DST(pPix, pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            Next ## DST ## StoreVarsY(pix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
#define DEFINE_BYTE_BINARY_XOR_DRAWGLYPHLIST(DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
void NAME_XOR_DRAWGLYPHLIST(DST)(SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                                 ImageRef *glyphs, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                                 jint totalGlyphs, jint fgpixel, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                                 jint argbcolor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                 jint clipLeft, jint clipTop, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                                 jint clipRight, jint clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                                 NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                                 CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    jint glyphCounter; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    jint scan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    jint xorpixel = pCompInfo->details.xorPixel; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    juint alphamask = pCompInfo->alphaMask; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    DST ## DataType *pPix; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        DeclareDrawGlyphListClipVars(pixels, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                                     left, top, right, bottom) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        ClipDrawGlyphList(DST, pixels, 1, rowBytes, width, height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                          left, top, right, bottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                          clipLeft, clipTop, clipRight, clipBottom, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                          glyphs, glyphCounter, continue) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        pPix = PtrCoord(pRasInfo->rasBase,left,DST ## PixelStride,top,scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            Declare ## DST ## InitialLoadVars(pRasInfo, pPix, DstPix, left) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            jint x = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                InitialLoad ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                if (pixels[x]) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                    Xor ## DST ## PixelData(pPix, 0, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                                            fgpixel, xorpixel, alphamask); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                ShiftBits ## DST(DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            } while (++x < width); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            FinalStore ## DST(pPix, DstPix); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            pPix = PtrAddBytes(pPix, scan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            pixels += rowBytes; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
#define DEFINE_BYTE_BINARY_ALPHA_MASKBLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
void NAME_ALPHA_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    (void *dstBase, void *srcBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    DeclareAndClearAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    DeclareAndInitExtraAlphaFor ## STRATEGY(extraA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    jint srcScan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    jint dstScan = pDstInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    jboolean loadsrc, loaddst; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    jint srcx1 = pSrcInfo->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    jint dstx1 = pDstInfo->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    SRC ## DataType *pSrc = (SRC ## DataType *) (srcBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    DST ## DataType *pDst = (DST ## DataType *) (dstBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    Declare ## SRC ## AlphaLoadData(SrcRead) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    Declare ## DST ## AlphaLoadData(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    DeclareAlphaOperands(SrcOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    DeclareAlphaOperands(DstOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].srcOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                                        SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].dstOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                                        DstOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    loadsrc = !FuncIsZero(SrcOp) || FuncNeedsAlpha(DstOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    loaddst = pMask || !FuncIsZero(DstOp) || FuncNeedsAlpha(SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    Init ## SRC ## AlphaLoadData(SrcRead, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    Init ## DST ## AlphaLoadData(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    srcScan -= width * SRC ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    dstScan -= width * DST ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    Init ## DST ## StoreVarsY(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        Declare ## SRC ## InitialLoadVars(pSrcInfo, pSrc, SrcRead, srcx1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        Declare ## DST ## InitialLoadVars(pDstInfo, pDst, DstWrite, dstx1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            DeclareAlphaVarFor ## STRATEGY(dstF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            InitialLoad ## SRC(pSrc, SrcRead); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            InitialLoad ## DST(pDst, DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                pathA = *pMask++; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                if (!pathA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                    ShiftBits ## SRC(SrcRead); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                    ShiftBits ## DST(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                    pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                    pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                    Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            if (loadsrc) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc,SrcRead,src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                srcA = MultiplyAlphaFor ## STRATEGY(extraA, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            if (loaddst) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                LoadAlphaFrom ## DST ## For ## STRATEGY(pDst,DstWrite,dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            srcF = ApplyAlphaOperands(SrcOp, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            dstF = ApplyAlphaOperands(DstOp, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            if (pathA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                dstF = MaxValFor ## STRATEGY - pathA + \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                           MultiplyAlphaFor ## STRATEGY(pathA, dstF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            if (srcF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                resA = MultiplyAlphaFor ## STRATEGY(srcF, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                if (!(SRC ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    srcF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                    srcF = MultiplyAlphaFor ## STRATEGY(srcF, extraA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                if (srcF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
                    /* assert(loadsrc); */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
                    Postload ## STRATEGY ## From ## SRC(pSrc, SrcRead, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                    if (srcF != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                        MultiplyAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                                                              srcF, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
                    Set ## STRATEGY ## CompsToZero(res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                if (dstF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                    ShiftBits ## SRC(SrcRead); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                    ShiftBits ## DST(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                    pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                    pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                resA = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                Set ## STRATEGY ## CompsToZero(res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                if (!(DST ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                    dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                    DeclareCompVarsFor ## STRATEGY(tmp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                    /* assert(loaddst); */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                    Postload ## STRATEGY ## From ## DST(pDst,DstWrite,tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                    if (dstF != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                        MultiplyAndStore ## STRATEGY ## Comps(tmp, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                                                              dstF, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                    Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            if (!(DST ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            Store ## DST ## From ## STRATEGY ## Comps(pDst, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                                                      0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            ShiftBits ## SRC(SrcRead); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            ShiftBits ## DST(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        FinalStore ## DST(pDst, DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        pSrc = PtrAddBytes(pSrc, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        pDst = PtrAddBytes(pDst, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        Next ## DST ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
#define DEFINE_BYTE_BINARY_ALPHA_MASKFILL(TYPE, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
void NAME_ALPHA_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    (void *rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     jint fgColor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    DeclareAlphaVarFor ## STRATEGY(dstF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    DeclareAlphaVarFor ## STRATEGY(dstFbase) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    jint rasScan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    jboolean loaddst; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    jint x1 = pRasInfo->bounds.x1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    TYPE ## DataType *pRas = (TYPE ## DataType *) (rasBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    Declare ## TYPE ## AlphaLoadData(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    Declare ## TYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    DeclareAlphaOperands(SrcOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    DeclareAlphaOperands(DstOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    if (srcA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        MultiplyAndStore ## STRATEGY ## Comps(src, srcA, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].srcOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                                        SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].dstOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                                        DstOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    loaddst = pMask || !FuncIsZero(DstOp) || FuncNeedsAlpha(SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    dstFbase = dstF = ApplyAlphaOperands(DstOp, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    Init ## TYPE ## AlphaLoadData(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    Init ## TYPE ## StoreVarsY(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        Declare ## TYPE ## InitialLoadVars(pRasInfo, pRas, DstWrite, x1) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
            InitialLoad ## TYPE(pRas, DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                pathA = *pMask++; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                if (!pathA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                    ShiftBits ## TYPE(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                    Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                dstF = dstFbase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            if (loaddst) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                LoadAlphaFrom ## TYPE ## For ## STRATEGY(pRas,DstWrite,dst);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
            srcF = ApplyAlphaOperands(SrcOp, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            if (pathA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                dstF = MaxValFor ## STRATEGY - pathA + \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                           MultiplyAlphaFor ## STRATEGY(pathA, dstF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            if (srcF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                if (srcF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                    resA = srcA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                    Store ## STRATEGY ## CompsUsingOp(res, =, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    resA = MultiplyAlphaFor ## STRATEGY(srcF, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                    MultiplyAndStore ## STRATEGY ## Comps(res, srcF, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                if (dstF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                    ShiftBits ## TYPE(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                    Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                resA = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                Set ## STRATEGY ## CompsToZero(res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                if (!(TYPE ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                    dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                    DeclareCompVarsFor ## STRATEGY(tmp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                    /* assert(loaddst); */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                    Postload ## STRATEGY ## From ## TYPE(pRas,DstWrite,tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                    if (dstF != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                        MultiplyAndStore ## STRATEGY ## Comps(tmp, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                                                              dstF, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                    Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            if (!(TYPE ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
            { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            Store ## TYPE ## From ## STRATEGY ## Comps(pRas, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                                                       0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            ShiftBits ## TYPE(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        FinalStore ## TYPE(pRas, DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        pRas = PtrAddBytes(pRas, rasScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        Next ## TYPE ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
 * The macros defined above use the following macro definitions supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
 * for the various ByteBinary-specific surface types to manipulate pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
 * In the macro names in the following definitions, the string <stype>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
 * is used as a place holder for the SurfaceType name (eg. ByteBinary2Bit).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
 * The macros above access these type specific macros using the ANSI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
 * CPP token concatenation operator "##".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
 * Declare<stype>InitialLoadVars     Declare and initialize the variables used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
 *                                   for managing byte/bit offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
 * InitialLoad<stype>                Store the current byte, fetch the next
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
 *                                   byte, and reset the bit offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
 * ShiftBits<stype>                  Advance to the next pixel by adjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
 *                                   the bit offset (1, 2, or 4 bits)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
 * FinalStore<stype>                 Store the current byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
 * CurrentPixel<stype>               Represents the current pixel by shifting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
 *                                   the value with the current bit offset and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
 *                                   then masking the value to either 1, 2, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
 *                                   4 bits
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
#endif /* AnyByteBinary_h_Included */