jdk/src/solaris/native/sun/java2d/loops/vis_SrcMaskFill.c
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7745 ebd6382e93fd
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7745
diff changeset
     2
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#if !defined(JAVA2D_NO_MLIB) || defined(MLIB_ADD_SUFF)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <vis_AlphaMacros.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/* ##############################################################
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * IntArgbSrcMaskFill()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * FourByteAbgrSrcMaskFill()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define MASK_FILL(rr, pathA, dstA, dstARGB)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
{                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    mlib_d64 t0, t1;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    dstA = MUL8_INT(dstA, 0xff - pathA);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    t0 = MUL8_VIS(cnstARGB0, pathA);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    t1 = MUL8_VIS(dstARGB, dstA);                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    rr = vis_fpadd16(t0, t1);                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    dstA = dstA + mul8_cnstA[pathA];                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    DIV_ALPHA(rr, dstA);                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
static void IntArgbSrcMaskFill_line(mlib_f32 *dst_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                                    mlib_u8  *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                                    mlib_s32 width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                                    mlib_d64 fgARGB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                                    mlib_f32 cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                                    mlib_u8  *mul8_cnstA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                    mlib_u8  *mul8_tbl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    mlib_s32 i, i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    mlib_s32 pathA0, pathA1, dstA0, dstA1, msk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    mlib_d64 res0, res1, dstARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    mlib_f32 dstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    i = i0 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    if ((mlib_s32)dst_ptr & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        pathA0 = pMask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        if (pathA0 == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            dst_ptr[i] = vis_read_hi(fgARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        } else if (pathA0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            dstA0 = *(mlib_u8*)(dst_ptr + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            dstARGB0 = dst_ptr[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            MASK_FILL(res0, pathA0, dstA0, dstARGB0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            dst_ptr[i] = vis_fpack16(res0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            *(mlib_u8*)(dst_ptr + i) = dstA0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        i0 = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    for (i = i0; i <= width - 2; i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        pathA0 = pMask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        pathA1 = pMask[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        dstA0 = *(mlib_u8*)(dst_ptr + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        dstA1 = *(mlib_u8*)(dst_ptr + i + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        dstARGB = *(mlib_d64*)(dst_ptr + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        MASK_FILL(res0, pathA0, dstA0, vis_read_hi(dstARGB));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        MASK_FILL(res1, pathA1, dstA1, vis_read_lo(dstARGB));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        res0 = vis_fpack16_pair(res0, res1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        msk = (((-pathA0) & (1 << 11)) | ((-pathA1) & (1 << 10))) >> 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        vis_pst_32(res0, dst_ptr + i, msk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        *(mlib_u8*)(dst_ptr + i    ) = dstA0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        *(mlib_u8*)(dst_ptr + i + 1) = dstA1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        msk = (((254 - pathA0) & (1 << 11)) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
               ((254 - pathA1) & (1 << 10))) >> 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        vis_pst_32(fgARGB, dst_ptr + i, msk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    if (i < width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        pathA0 = pMask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        if (pathA0 == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            dst_ptr[i] = vis_read_hi(fgARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        } else if (pathA0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            dstA0 = *(mlib_u8*)(dst_ptr + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            dstARGB0 = dst_ptr[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            MASK_FILL(res0, pathA0, dstA0, dstARGB0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            dst_ptr[i] = vis_fpack16(res0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            *(mlib_u8*)(dst_ptr + i) = dstA0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
void ADD_SUFF(IntArgbSrcMaskFill)(void *rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                  jubyte *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                                  jint maskOff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                  jint maskScan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                  jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                  jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                                  jint fgColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                  SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                  NativePrimitive *pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                  CompositeInfo *pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    mlib_s32 cnstA, cnstR, cnstG, cnstB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    mlib_s32 rasScan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    mlib_f32 cnstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    mlib_d64 fgARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    mlib_u8  *mul8_cnstA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    cnstA = (fgColor >> 24) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    cnstR = (fgColor >> 16) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    cnstG = (fgColor >>  8) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    cnstB = (fgColor      ) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    if (cnstA == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        fgColor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    if (pMask == NULL) {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   153
        void *pBase = pRasInfo->rasBase;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   154
        pRasInfo->rasBase = rasBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        ADD_SUFF(AnyIntSetRect)(pRasInfo,
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   156
                                0, 0, width, height,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                fgColor, pPrim, pCompInfo);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   158
        pRasInfo->rasBase = pBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    mul8_cnstA = mul8table[cnstA];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    if (cnstA != 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        cnstR = mul8_cnstA[cnstR];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        cnstG = mul8_cnstA[cnstG];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        cnstB = mul8_cnstA[cnstB];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    cnstARGB0 = F32_FROM_U8x4(cnstA, cnstR, cnstG, cnstB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    fgARGB = vis_to_double_dup(fgColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    pMask += maskOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    if (rasScan == 4*width && maskScan == width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    vis_write_gsr(7 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        IntArgbSrcMaskFill_line(rasBase, pMask, width, fgARGB, cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                                mul8_cnstA, (void*)mul8table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        PTR_ADD(rasBase, rasScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        PTR_ADD(pMask, maskScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
void ADD_SUFF(FourByteAbgrSrcMaskFill)(void *rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                       jubyte *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                       jint maskOff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                       jint maskScan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                       jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                       jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                       jint fgColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                                       SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                       NativePrimitive *pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                                       CompositeInfo *pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    mlib_d64 buff[BUFF_SIZE/2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    void     *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    mlib_s32 cnstA, cnstR, cnstG, cnstB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    mlib_s32 rasScan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    mlib_f32 cnstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    mlib_d64 fgARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    mlib_u8  *mul8_cnstA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    cnstA = (mlib_u32)fgColor >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    cnstR = (fgColor >> 16) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    cnstG = (fgColor >>  8) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    cnstB = (fgColor      ) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    if (pMask == NULL) {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   219
        void *pBase = pRasInfo->rasBase;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   220
        pRasInfo->rasBase = rasBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (cnstA == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            fgColor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            fgColor = (fgColor << 8) | cnstA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        ADD_SUFF(Any4ByteSetRect)(pRasInfo,
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   227
                                  0, 0, width, height,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                  fgColor, pPrim, pCompInfo);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   229
        pRasInfo->rasBase = pBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    mul8_cnstA = mul8table[cnstA];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    if (cnstA == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        fgColor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        cnstR = cnstG = cnstB = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        fgColor = (cnstA << 24) | (cnstB << 16) | (cnstG << 8) | cnstR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        if (cnstA != 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            cnstR = mul8_cnstA[cnstR];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            cnstG = mul8_cnstA[cnstG];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            cnstB = mul8_cnstA[cnstB];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    cnstARGB0 = F32_FROM_U8x4(cnstA, cnstB, cnstG, cnstR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    fgARGB = vis_to_double_dup(fgColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    pMask += maskOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    if (((mlib_s32)rasBase | rasScan) & 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        if (rasScan == 4*width && maskScan == width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    vis_write_gsr(7 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        if (!((mlib_s32)rasBase & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            IntArgbSrcMaskFill_line(rasBase, pMask, width, fgARGB, cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                    mul8_cnstA, (void*)mul8table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            mlib_ImageCopy_na(rasBase, pbuff, width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            IntArgbSrcMaskFill_line(pbuff, pMask, width, fgARGB, cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                                    mul8_cnstA, (void*)mul8table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            mlib_ImageCopy_na(pbuff, rasBase, width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        PTR_ADD(rasBase, rasScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        PTR_ADD(pMask, maskScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
/* ##############################################################
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
 * IntRgbSrcMaskFill()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
 * IntBgrSrcMaskFill()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
#undef  MASK_FILL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
#define MASK_FILL(rr, pathA, dstA, dstARGB)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
{                                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    mlib_d64 t0, t1;                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    dstA = 0xff - pathA;                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    t0 = MUL8_VIS(cnstARGB0, pathA);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    t1 = MUL8_VIS(dstARGB, dstA);                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    rr = vis_fpadd16(t0, t1);                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    dstA = dstA + mul8_cnstA[pathA];                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    DIV_ALPHA_RGB(rr, dstA);                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
static void IntRgbSrcMaskFill_line(mlib_f32 *dst_ptr,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                                   mlib_u8  *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                                   mlib_s32 width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                                   mlib_d64 fgARGB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                                   mlib_f32 cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                                   mlib_u8  *mul8_cnstA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                                   mlib_u8  *mul8_tbl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    mlib_s32 i, i0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    mlib_s32 pathA0, pathA1, dstA0, dstA1, msk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    mlib_d64 res0, res1, dstARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    mlib_f32 dstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    i = i0 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    if ((mlib_s32)dst_ptr & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        pathA0 = pMask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        if (pathA0 == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            dst_ptr[i] = vis_read_hi(fgARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        } else if (pathA0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            dstARGB0 = dst_ptr[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            MASK_FILL(res0, pathA0, dstA0, dstARGB0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            dst_ptr[i] = vis_fpack16(res0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        i0 = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    for (i = i0; i <= width - 2; i += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        pathA0 = pMask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        pathA1 = pMask[i + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        dstARGB = *(mlib_d64*)(dst_ptr + i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        MASK_FILL(res0, pathA0, dstA0, vis_read_hi(dstARGB));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        MASK_FILL(res1, pathA1, dstA1, vis_read_lo(dstARGB));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        res0 = vis_fpack16_pair(res0, res1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        msk = (((-pathA0) & (1 << 11)) | ((-pathA1) & (1 << 10))) >> 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        vis_pst_32(res0, dst_ptr + i, msk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        msk = (((254 - pathA0) & (1 << 11)) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
               ((254 - pathA1) & (1 << 10))) >> 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        vis_pst_32(fgARGB, dst_ptr + i, msk);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    if (i < width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        pathA0 = pMask[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        if (pathA0 == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
            dst_ptr[i] = vis_read_hi(fgARGB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        } else if (pathA0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            dstARGB0 = dst_ptr[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            MASK_FILL(res0, pathA0, dstA0, dstARGB0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            dst_ptr[i] = vis_fpack16(res0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
void ADD_SUFF(IntRgbSrcMaskFill)(void *rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                                 jubyte *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                                 jint maskOff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                 jint maskScan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                 jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                 jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                                 jint fgColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                                 SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                                 NativePrimitive *pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                                 CompositeInfo *pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    mlib_s32 cnstA, cnstR, cnstG, cnstB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    mlib_s32 rasScan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    mlib_f32 cnstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    mlib_d64 fgARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    mlib_u8  *mul8_cnstA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    cnstA = (fgColor >> 24) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    cnstR = (fgColor >> 16) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    cnstG = (fgColor >>  8) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    cnstB = (fgColor      ) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    if (cnstA == 0) fgColor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    if (pMask == NULL) {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   397
        void *pBase = pRasInfo->rasBase;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   398
        pRasInfo->rasBase = rasBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        ADD_SUFF(AnyIntSetRect)(pRasInfo,
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   400
                                0, 0, width, height,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                                fgColor, pPrim, pCompInfo);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   402
        pRasInfo->rasBase = pBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    mul8_cnstA = mul8table[cnstA];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    if (cnstA != 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        cnstR = mul8_cnstA[cnstR];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        cnstG = mul8_cnstA[cnstG];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        cnstB = mul8_cnstA[cnstB];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    cnstARGB0 = F32_FROM_U8x4(cnstA, cnstR, cnstG, cnstB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    fgARGB = vis_to_double_dup(fgColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    pMask += maskOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    if (rasScan == 4*width && maskScan == width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    vis_write_gsr(7 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        IntRgbSrcMaskFill_line(rasBase, pMask, width, fgARGB, cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                               mul8_cnstA, (void*)mul8table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        PTR_ADD(rasBase, rasScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        PTR_ADD(pMask, maskScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
void ADD_SUFF(IntBgrSrcMaskFill)(void *rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                 jubyte *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                 jint maskOff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                                 jint maskScan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                 jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                                 jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                                 jint fgColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                                 SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                                 NativePrimitive *pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                 CompositeInfo *pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    mlib_s32 cnstA, cnstR, cnstG, cnstB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    mlib_s32 rasScan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    mlib_f32 cnstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    mlib_d64 fgARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    mlib_u8  *mul8_cnstA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    cnstA = (fgColor >> 24) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    cnstR = (fgColor >> 16) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    cnstG = (fgColor >>  8) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    cnstB = (fgColor      ) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    if (cnstA == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        fgColor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        fgColor = (cnstB << 16) | (cnstG << 8) | (cnstR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    if (pMask == NULL) {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   467
        void *pBase = pRasInfo->rasBase;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   468
        pRasInfo->rasBase = rasBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        ADD_SUFF(AnyIntSetRect)(pRasInfo,
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   470
                                0, 0, width, height,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                                fgColor, pPrim, pCompInfo);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   472
        pRasInfo->rasBase = pBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    mul8_cnstA = mul8table[cnstA];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    if (cnstA != 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        cnstR = mul8_cnstA[cnstR];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        cnstG = mul8_cnstA[cnstG];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        cnstB = mul8_cnstA[cnstB];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    cnstARGB0 = F32_FROM_U8x4(cnstA, cnstB, cnstG, cnstR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    fgARGB = vis_to_double_dup(fgColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    pMask += maskOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    if (rasScan == 4*width && maskScan == width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    vis_write_gsr(7 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        IntRgbSrcMaskFill_line(rasBase, pMask, width, fgARGB, cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                               mul8_cnstA, (void*)mul8table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        PTR_ADD(rasBase, rasScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        PTR_ADD(pMask, maskScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
void ADD_SUFF(ThreeByteBgrSrcMaskFill)(void *rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                                       jubyte *pMask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                                       jint maskOff,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                                       jint maskScan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                                       jint width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                                       jint height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                                       jint fgColor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                                       SurfaceDataRasInfo *pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                                       NativePrimitive *pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                                       CompositeInfo *pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    mlib_d64 buff[BUFF_SIZE/2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    void     *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    mlib_s32 cnstA, cnstR, cnstG, cnstB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    mlib_s32 rasScan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    mlib_f32 cnstARGB0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    mlib_d64 fgARGB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    mlib_u8  *mul8_cnstA;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    mlib_s32 j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    cnstA = (fgColor >> 24) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    cnstR = (fgColor >> 16) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    cnstG = (fgColor >>  8) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    cnstB = (fgColor      ) & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    if (cnstA == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        fgColor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    if (pMask == NULL) {
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   537
        void *pBase = pRasInfo->rasBase;
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   538
        pRasInfo->rasBase = rasBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        ADD_SUFF(Any3ByteSetRect)(pRasInfo,
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   540
                                  0, 0, width, height,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                                  fgColor, pPrim, pCompInfo);
7745
ebd6382e93fd 6766342: Improve performance of Ductus rasterizer
flar
parents: 5506
diff changeset
   542
        pRasInfo->rasBase = pBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    mul8_cnstA = mul8table[cnstA];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    if (cnstA != 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        cnstR = mul8_cnstA[cnstR];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        cnstG = mul8_cnstA[cnstG];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        cnstB = mul8_cnstA[cnstB];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    cnstARGB0 = F32_FROM_U8x4(cnstA, cnstR, cnstG, cnstB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    fgARGB = vis_to_double_dup(fgColor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    pMask += maskOff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    vis_write_gsr(7 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        ADD_SUFF(ThreeByteBgrToIntArgbConvert)(rasBase, pbuff, width, 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                                               pRasInfo, pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                                               pPrim, pCompInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        IntRgbSrcMaskFill_line(pbuff, pMask, width, fgARGB, cnstARGB0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                               mul8_cnstA, (void*)mul8table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        IntArgbToThreeByteBgrConvert(pbuff, rasBase, width, 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                                     pRasInfo, pRasInfo, pPrim, pCompInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        PTR_ADD(rasBase, rasScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        PTR_ADD(pMask, maskScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
#endif