jdk/src/java.desktop/share/native/libawt/java2d/loops/AlphaMacros.h
author ntv
Fri, 06 May 2016 11:23:49 +0000
changeset 37800 518e44c93fbb
parent 26751 70bac69b37c9
permissions -rw-r--r--
8015070: Antialiased text on translucent backgrounds gets bright artifacts Reviewed-by: flar, prr, jdv Contributed-by: prahalad.kumar.narayanan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef AlphaMacros_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define AlphaMacros_h_Included
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "AlphaMath.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "IntArgb.h"                 /* for "Extract...FromArgb" macros */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#define DeclareAlphaOperands(PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    jint PREFIX ## And, PREFIX ## Xor, PREFIX ## Add;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define ExtractAlphaOperandsFor4ByteArgb(f, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        PREFIX ## And = (f).andval; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        PREFIX ## Xor = (f).xorval; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        PREFIX ## Add = (jint) (f).addval - PREFIX ## Xor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define ExtractAlphaOperandsFor1ByteGray(f, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    ExtractAlphaOperandsFor4ByteArgb(f, PREFIX)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define ExtractAlphaOperandsFor1ShortGray(f, PREFIX) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        PREFIX ## And = ((f).andval << 8) + (f).andval; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        PREFIX ## Xor = (f).xorval; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        PREFIX ## Add = (jint) (((f).addval << 8) + (f).addval) - \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                                                            PREFIX ## Xor; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    } while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define ApplyAlphaOperands(PREFIX, a) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    ((((a) & PREFIX ## And) ^ PREFIX ## Xor) + PREFIX ## Add)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#define FuncNeedsAlpha(PREFIX)  (PREFIX ## And != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define FuncIsZero(PREFIX)      ((PREFIX ## And | PREFIX ## Add) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    jubyte      addval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    jubyte      andval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    jshort      xorval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
} AlphaOperands;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    AlphaOperands       srcOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    AlphaOperands       dstOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
} AlphaFunc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
extern AlphaFunc AlphaRules[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define DEFINE_ALPHA_MASKBLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
void NAME_ALPHA_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    (void *dstBase, void *srcBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    DeclareAndClearAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    DeclareAndInitExtraAlphaFor ## STRATEGY(extraA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    jint srcScan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    jint dstScan = pDstInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    jboolean loadsrc, loaddst; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    SRC ## DataType *pSrc = (SRC ## DataType *) (srcBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    DST ## DataType *pDst = (DST ## DataType *) (dstBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    Declare ## SRC ## AlphaLoadData(SrcPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    Declare ## DST ## AlphaLoadData(DstPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    DeclareAlphaOperands(SrcOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    DeclareAlphaOperands(DstOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].srcOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                        SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].dstOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                        DstOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    loadsrc = !FuncIsZero(SrcOp) || FuncNeedsAlpha(DstOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    loaddst = pMask || !FuncIsZero(DstOp) || FuncNeedsAlpha(SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    Init ## SRC ## AlphaLoadData(SrcPix, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    Init ## DST ## AlphaLoadData(DstPix, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    srcScan -= width * SRC ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    dstScan -= width * DST ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    Init ## DST ## StoreVarsY(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            DeclareAlphaVarFor ## STRATEGY(dstF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                pathA = *pMask++; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                if (!pathA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            if (loadsrc) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc, SrcPix, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                srcA = MultiplyAlphaFor ## STRATEGY(extraA, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            if (loaddst) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                LoadAlphaFrom ## DST ## For ## STRATEGY(pDst, DstPix, dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            srcF = ApplyAlphaOperands(SrcOp, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            dstF = ApplyAlphaOperands(DstOp, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            if (pathA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                dstF = MaxValFor ## STRATEGY - pathA + \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                           MultiplyAlphaFor ## STRATEGY(pathA, dstF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            if (srcF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                resA = MultiplyAlphaFor ## STRATEGY(srcF, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                if (!(SRC ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                    srcF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    srcF = MultiplyAlphaFor ## STRATEGY(srcF, extraA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                if (srcF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    /* assert(loadsrc); */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    Postload ## STRATEGY ## From ## SRC(pSrc, SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                    if (srcF != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                        MultiplyAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                                              srcF, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    if (dstF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                        pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                        pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                        Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                        continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    Set ## STRATEGY ## CompsToZero(res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                if (dstF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                    pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                resA = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                Set ## STRATEGY ## CompsToZero(res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                if (!(DST ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    DeclareCompVarsFor ## STRATEGY(tmp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    /* assert(loaddst); */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    Postload ## STRATEGY ## From ## DST(pDst, DstPix, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    if (dstF != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                        MultiplyAndStore ## STRATEGY ## Comps(tmp, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                                                              dstF, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            if (!(DST ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            Store ## DST ## From ## STRATEGY ## Comps(pDst, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                                                      0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        pSrc = PtrAddBytes(pSrc, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        pDst = PtrAddBytes(pDst, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        Next ## DST ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
/* REMIND: This macro is as yet, untested */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#define DEFINE_SRC_MASKBLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
void NAME_SRC_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    (void *dstBase, void *srcBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    DeclareAndInitExtraAlphaFor ## STRATEGY(extraA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    jint srcScan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    jint dstScan = pDstInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    SRC ## DataType *pSrc = (SRC ## DataType *) (srcBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    DST ## DataType *pDst = (DST ## DataType *) (dstBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    Declare ## SRC ## AlphaLoadData(SrcPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    Declare ## DST ## AlphaLoadData(DstPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    Init ## SRC ## AlphaLoadData(SrcPix, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    Init ## DST ## AlphaLoadData(DstPix, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    srcScan -= width * SRC ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    dstScan -= width * DST ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    Init ## DST ## StoreVarsY(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                DeclareAlphaVarFor ## STRATEGY(dstF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                DeclareAndInitPathAlphaFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                if (pathA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                    LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                                            SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                    resA = MultiplyAlphaFor ## STRATEGY(extraA, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    if (SRC ## IsPremultiplied) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                        srcF = extraA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                        srcF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    Postload ## STRATEGY ## From ## SRC(pSrc, SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    if (pathA < 0xff) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                        DeclareAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                        DeclareCompVarsFor ## STRATEGY(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                        PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                        srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                        dstF = MaxValFor ## STRATEGY - pathA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                        LoadAlphaFrom ## DST ## For ## STRATEGY(pDst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                                                                DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                                                                dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                        dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                        if (!(DST ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                            dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                        Postload ## STRATEGY ## From ## DST(pDst, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                                                            dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                        resA = dstA + \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                                 MultiplyAlphaFor ## STRATEGY(pathA, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                        MultMultAddAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                                                                 dstF, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                                                                 srcF, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                    } else if (srcF < MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                        MultiplyAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                                                              srcF, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                    if (!(DST ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                        resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                        DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    Store ## DST ## From ## STRATEGY ## Comps(pDst, DstWrite,\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                                              0, res);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            pSrc = PtrAddBytes(pSrc, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            pDst = PtrAddBytes(pDst, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            Next ## DST ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    } else /* pMask == 0 */ { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc, SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                resA = MultiplyAlphaFor ## STRATEGY(extraA, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                if (SRC ## IsPremultiplied) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    srcF = extraA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                    srcF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                Postload ## STRATEGY ## From ## SRC(pSrc, SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                if (srcF < MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                    MultiplyAndStore ## STRATEGY ## Comps(res, srcF, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                if (!(DST ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                    resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                    DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                Store ## DST ## From ## STRATEGY ## Comps(pDst, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                                                          0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            pSrc = PtrAddBytes(pSrc, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            pDst = PtrAddBytes(pDst, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            Next ## DST ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
#define DEFINE_SRCOVER_MASKBLIT(SRC, DST, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
void NAME_SRCOVER_MASKBLIT(SRC, DST) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    (void *dstBase, void *srcBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     SurfaceDataRasInfo *pDstInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     SurfaceDataRasInfo *pSrcInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    DeclareAndInitExtraAlphaFor ## STRATEGY(extraA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    jint srcScan = pSrcInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    jint dstScan = pDstInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    SRC ## DataType *pSrc = (SRC ## DataType *) (srcBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    DST ## DataType *pDst = (DST ## DataType *) (dstBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    Declare ## SRC ## AlphaLoadData(SrcPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    Declare ## DST ## AlphaLoadData(DstPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    Declare ## DST ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    Init ## SRC ## AlphaLoadData(SrcPix, pSrcInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    Init ## DST ## AlphaLoadData(DstPix, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    srcScan -= width * SRC ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    dstScan -= width * DST ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    Init ## DST ## StoreVarsY(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                DeclareAndInitPathAlphaFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                if (pathA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                    DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                    DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                    PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                    pathA = MultiplyAlphaFor ## STRATEGY(pathA, extraA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                    LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                                                            SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    resA = MultiplyAlphaFor ## STRATEGY(pathA, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                    if (resA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                        if (SRC ## IsPremultiplied) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                            srcF = pathA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                            srcF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                        Postload ## STRATEGY ## From ## SRC(pSrc, SrcPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                                                            res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                        if (resA < MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                            DeclareAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                            DeclareCompVarsFor ## STRATEGY(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                            DeclareAndInvertAlphaVarFor ## STRATEGY(dstF, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                                                                    resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                            LoadAlphaFrom ## DST ## For ## STRATEGY(pDst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                                                                    DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                                                                    dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                            dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                            if (!(DST ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                                dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                            Postload ## STRATEGY ## From ## DST(pDst, DstPix,\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                                                                dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                            resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                            MultMultAddAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                                                  dstF, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                                                                  srcF, res);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                        } else if (srcF < MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                            MultiplyAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                                                                  srcF, res);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                        } \
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   419
                        if (!(DST ## IsOpaque) && \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   420
                            !(DST ## IsPremultiplied) && resA && \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                            resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                        { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                            DivideAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                                                                res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                        Store ## DST ## From ## STRATEGY ## Comps(pDst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                                                                  DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                                                                  0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            pSrc = PtrAddBytes(pSrc, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            pDst = PtrAddBytes(pDst, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            Next ## DST ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    } else /* pMask == 0 */ { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            Init ## DST ## StoreVarsX(DstWrite, pDstInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                LoadAlphaFrom ## SRC ## For ## STRATEGY(pSrc, SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                resA = MultiplyAlphaFor ## STRATEGY(extraA, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                if (resA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    if (SRC ## IsPremultiplied) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                        srcF = extraA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                        srcF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    Postload ## STRATEGY ## From ## SRC(pSrc, SrcPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                    if (resA < MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                        DeclareAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                        DeclareCompVarsFor ## STRATEGY(dst) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                        DeclareAndInvertAlphaVarFor ## STRATEGY(dstF, resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                        LoadAlphaFrom ## DST ## For ## STRATEGY(pDst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                                                                DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                                                                dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                        dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                        if (!(DST ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                            dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                        Postload ## STRATEGY ## From ## DST(pDst, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                                            dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                        resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                        MultMultAddAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                                                 dstF, dst, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                                                                 srcF, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                    } else if (srcF < MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                        MultiplyAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                                                              srcF, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    } \
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   479
                    if (!(DST ## IsOpaque) && \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   480
                        !(DST ## IsPremultiplied) && resA && \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                        resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                    { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                        DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                    Store ## DST ## From ## STRATEGY ## Comps(pDst, DstWrite,\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                                                              0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                pSrc = PtrAddBytes(pSrc, SRC ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                pDst = PtrAddBytes(pDst, DST ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                Next ## DST ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            pSrc = PtrAddBytes(pSrc, srcScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            pDst = PtrAddBytes(pDst, dstScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            Next ## DST ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
#define DEFINE_ALPHA_MASKFILL(TYPE, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
void NAME_ALPHA_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    (void *rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     jint fgColor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    DeclareAndSetOpaqueAlphaVarFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    DeclareAlphaVarFor ## STRATEGY(dstF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    DeclareAlphaVarFor ## STRATEGY(dstFbase) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    jint rasScan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    jboolean loaddst; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    TYPE ## DataType *pRas = (TYPE ## DataType *) (rasBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    Declare ## TYPE ## AlphaLoadData(DstPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    Declare ## TYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    DeclareAlphaOperands(SrcOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    DeclareAlphaOperands(DstOp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    if (srcA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        MultiplyAndStore ## STRATEGY ## Comps(src, srcA, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].srcOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                                        SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    ExtractAlphaOperandsFor ## STRATEGY(AlphaRules[pCompInfo->rule].dstOps, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                                        DstOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    loaddst = pMask || !FuncIsZero(DstOp) || FuncNeedsAlpha(SrcOp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    dstFbase = dstF = ApplyAlphaOperands(DstOp, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    Init ## TYPE ## AlphaLoadData(DstPix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    rasScan -= width * TYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    Init ## TYPE ## StoreVarsY(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            DeclareAlphaVarFor ## STRATEGY(srcF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                pathA = *pMask++; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                if (!pathA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                    pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                    Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                dstF = dstFbase; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            if (loaddst) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                LoadAlphaFrom ## TYPE ## For ## STRATEGY(pRas, DstPix, dst);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            srcF = ApplyAlphaOperands(SrcOp, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            if (pathA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                srcF = MultiplyAlphaFor ## STRATEGY(pathA, srcF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                dstF = MaxValFor ## STRATEGY - pathA + \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                           MultiplyAlphaFor ## STRATEGY(pathA, dstF); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            if (srcF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                if (srcF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                    resA = srcA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                    Store ## STRATEGY ## CompsUsingOp(res, =, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                    resA = MultiplyAlphaFor ## STRATEGY(srcF, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                    MultiplyAndStore ## STRATEGY ## Comps(res, srcF, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                if (dstF == MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                    pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                    Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                    continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                resA = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
                Set ## STRATEGY ## CompsToZero(res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                if (TYPE ## IsPremultiplied) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                    dstA = dstF; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                if (dstA) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    DeclareCompVarsFor ## STRATEGY(tmp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                    /* assert(loaddst); */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                    Postload ## STRATEGY ## From ## TYPE(pRas, DstPix, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                    if (dstA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                        MultiplyAndStore ## STRATEGY ## Comps(tmp, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                                                              dstA, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                    Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            if (!(TYPE ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            Store ## TYPE ## From ## STRATEGY ## Comps(pRas, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                                                       0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        pRas = PtrAddBytes(pRas, rasScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        Next ## TYPE ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
#define DEFINE_SRC_MASKFILL(TYPE, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
void NAME_SRC_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    (void *rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     jint fgColor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    jint rasScan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    TYPE ## DataType *pRas = (TYPE ## DataType *) (rasBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    Declare ## TYPE ## AlphaLoadData(DstPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    Declare ## TYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    Declare ## TYPE ## BlendFillVars(DstFill) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    if (srcA == 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        Set ## STRATEGY ## CompsToZero(src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        Clear ## TYPE ## BlendFillVars(DstFill, fgColor); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        if (!(TYPE ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            Init ## TYPE ## BlendFillVarsNonPre(DstFill, fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        if (srcA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            MultiplyAndStore ## STRATEGY ## Comps(src, srcA, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        if (TYPE ## IsPremultiplied) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            Init ## TYPE ## BlendFillVarsPre(DstFill, fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    Init ## TYPE ## AlphaLoadData(DstPix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    Init ## TYPE ## StoreVarsY(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    rasScan -= width * TYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                DeclareAlphaVarFor ## STRATEGY(dstF) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                DeclareAndInitPathAlphaFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                if (pathA > 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                    if (pathA == 0xff) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                        /* pathA ignored here, not promoted */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                        Store ## TYPE ## BlendFill(pRas, DstFill, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                                                   fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                        PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                        dstF = MaxValFor ## STRATEGY - pathA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                        LoadAlphaFrom ## TYPE ## For ## STRATEGY(pRas, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                                                                 DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                                                                 res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                        resA = MultiplyAlphaFor ## STRATEGY(dstF, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                        if (!(TYPE ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                            dstF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                        resA += MultiplyAlphaFor ## STRATEGY(pathA, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                        Postload ## STRATEGY ## From ## TYPE(pRas, DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                                                             res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                        MultMultAddAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                                                                 dstF, res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                                                                 pathA, src);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                        if (!(TYPE ## IsPremultiplied) && resA && \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                            resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                        { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
                            DivideAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
                                                                res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
                        Store ## TYPE ## From ## STRATEGY ## Comps(pRas, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                                                                   DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                                                                   0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            pRas = PtrAddBytes(pRas, rasScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            Next ## TYPE ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    } else /* pMask == 0 */ { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                Store ## TYPE ## BlendFill(pRas, DstFill, 0, fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            pRas = PtrAddBytes(pRas, rasScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            Next ## TYPE ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
#define DEFINE_SRCOVER_MASKFILL(TYPE, STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
void NAME_SRCOVER_MASKFILL(TYPE) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    (void *rasBase, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     jubyte *pMask, jint maskOff, jint maskScan, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     jint width, jint height, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     jint fgColor, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     SurfaceDataRasInfo *pRasInfo, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     NativePrimitive *pPrim, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     CompositeInfo *pCompInfo) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
{ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    DeclareAlphaVarFor ## STRATEGY(srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    DeclareCompVarsFor ## STRATEGY(src) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    jint rasScan = pRasInfo->scanStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    TYPE ## DataType *pRas = (TYPE ## DataType *) (rasBase); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    Declare ## TYPE ## AlphaLoadData(DstPix) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    Declare ## TYPE ## StoreVars(DstWrite) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    Extract ## STRATEGY ## CompsAndAlphaFromArgb(fgColor, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    if (srcA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        if (srcA == 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
            return; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        MultiplyAndStore ## STRATEGY ## Comps(src, srcA, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
    Init ## TYPE ## AlphaLoadData(DstPix, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    Init ## TYPE ## StoreVarsY(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    rasScan -= width * TYPE ## PixelStride; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    if (pMask) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        pMask += maskOff; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        maskScan -= width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                DeclareAndInitPathAlphaFor ## STRATEGY(pathA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                if (pathA > 0) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                    if (pathA != 0xff) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                        PromoteByteAlphaFor ## STRATEGY(pathA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                        resA = MultiplyAlphaFor ## STRATEGY(pathA, srcA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                        MultiplyAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                                                              pathA, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                    } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                        /* pathA ignored here, not promoted */ \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                        resA = srcA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                        Store ## STRATEGY ## CompsUsingOp(res, =, src); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
                    if (resA != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                        DeclareAndInvertAlphaVarFor ## STRATEGY(dstF, resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                        DeclareAndClearAlphaVarFor ## STRATEGY(dstA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                        LoadAlphaFrom ## TYPE ## For ## STRATEGY(pRas, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                                                                 DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                                                                 dst); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                        dstA = MultiplyAlphaFor ## STRATEGY(dstF, dstA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                        if (!(TYPE ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                            dstF = dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                        resA += dstA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                        if (dstF) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                            DeclareCompVarsFor ## STRATEGY(tmp) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                            Postload ## STRATEGY ## From ## TYPE(pRas, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                                                                 DstPix, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                                                                 tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                            if (dstF != MaxValFor ## STRATEGY) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                                MultiplyAndStore ## STRATEGY ## Comps(tmp, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                                                                      dstF, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                                                                      tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
                            Store ## STRATEGY ## CompsUsingOp(res, +=, tmp); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                    } \
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   802
                    if (!(TYPE ## IsOpaque) && \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   803
                        !(TYPE ## IsPremultiplied) && resA && \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                        resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                    { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                        DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                    Store ## TYPE ## From ## STRATEGY ## Comps(pRas, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                                                               DstWrite, 0, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                                                               res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            pRas = PtrAddBytes(pRas, rasScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            Next ## TYPE ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            pMask = PtrAddBytes(pMask, maskScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    } else /* pMask == 0 */ { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            jint w = width; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            Init ## TYPE ## StoreVarsX(DstWrite, pRasInfo); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                DeclareAlphaVarFor ## STRATEGY(resA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                DeclareCompVarsFor ## STRATEGY(res) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                DeclareAndInvertAlphaVarFor ## STRATEGY(dstF, srcA) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                LoadAlphaFrom ## TYPE ## For ## STRATEGY(pRas, DstPix, res);\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                resA = MultiplyAlphaFor ## STRATEGY(dstF, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                if (!(TYPE ## IsPremultiplied)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                    dstF = resA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                resA += srcA; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                Postload ## STRATEGY ## From ## TYPE(pRas, DstPix, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                MultiplyAddAndStore ## STRATEGY ## Comps(res, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                                                         dstF, res, src); \
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   837
                if (!(TYPE ## IsOpaque) && \
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   838
                    !(TYPE ## IsPremultiplied) && resA && \
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                    resA < MaxValFor ## STRATEGY) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                    DivideAndStore ## STRATEGY ## Comps(res, res, resA); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                Store ## TYPE ## From ## STRATEGY ## Comps(pRas, DstWrite, \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                                                           0, res); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                pRas = PtrAddBytes(pRas, TYPE ## PixelStride); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                Next ## TYPE ## StoreVarsX(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            } while (--w > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            pRas = PtrAddBytes(pRas, rasScan); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            Next ## TYPE ## StoreVarsY(DstWrite); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        } while (--height > 0); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
 * The macros defined above use the following macro definitions supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
 * for the various surface types to manipulate pixels and pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
 * The surface-specific macros are typically supplied by header files
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
 * named after the SurfaceType name (eg. IntArgb.h, ByteGray.h, etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
 * In the macro names in the following definitions, the string <stype>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
 * is used as a place holder for the SurfaceType name (eg. IntArgb).  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
 * string <strategy> is a place holder for the strategy name (eg. 4ByteArgb).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
 * The macros above access these type specific macros using the ANSI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
 * CPP token concatenation operator "##".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
 * Declare<stype>AlphaLoadData       Declare the variables used when an alpha
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
 *                                   value is pre-fetched to see whether or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
 *                                   not blending needs to occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
 * Init<stype>AlphaLoadData          Initialize the aforementioned variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
 * LoadAlphaFrom<stype>For<strategy> Load the alpha value for the given pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
 *                                   into a variable used later (the strategy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
 *                                   type determines the bit depth of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
 *                                   alpha value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
 * Postload<strategy>From<stype>     Load the pixel components from the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
 *                                   surface type into the form required by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
 *                                   the given strategy.  Typically there will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
 *                                   be a couple macros of this variety, one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
 *                                   for 4ByteArgb, one for 1ByteGray, one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
 *                                   for 1ShortGray, etc.  Its code is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
 *                                   executed when blending needs to occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
 * <stype>IsPremultiplied            Constant specifying whether the pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
 *                                   components have been premultiplied with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
 *                                   the alpha value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
 * Declare<stype>BlendFillVars       Declare the variables used when alpha
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
 *                                   blending need not occur (mask and source
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
 *                                   pixel are opaque)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
 * Clear<stype>BlendFillVars         Clear the variables used in a no-blend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
 *                                   situation (may modify argb argument)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
 * Init<stype>BlendFillVarsNonPre    Initialize the variables used for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
 *                                   no-blending situation (this macro is for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
 *                                   surfaces that do not have premultiplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
 *                                   components) (may modify argb argument)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
 * Init<stype>BlendFillVarsPre       Initialize the variables used for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
 *                                   no-blending situation (this macro is for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
 *                                   surfaces that have premultiplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
 *                                   components) (may modify argb argument)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
 * Store<stype>BlendFill             Simply store the pixel for the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
 *                                   surface (used when blending is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
 *                                   unnecessary)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
 * Store<stype>From<strategy>Comps   Store the pixel for the given surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
 *                                   type after converting it from a pixel of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
 *                                   the given strategy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
#endif /* AlphaMacros_h_Included */