jdk/src/solaris/native/sun/java2d/loops/vis_FourByteAbgrPre.c
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 549 4273b1234967
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 549
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
#define FUNC_CONVERT(TYPE, OPER)                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
void ADD_SUFF(TYPE##ToFourByteAbgrPre##OPER)(BLIT_PARAMS)                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
{                                                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    mlib_d64 buff[BUFF_SIZE/2];                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    void     *pbuff = buff;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    mlib_s32 dstScan = pDstInfo->scanStride;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    mlib_s32 srcScan = pSrcInfo->scanStride;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    mlib_s32 j;                                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    for (j = 0; j < height; j++) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        ADD_SUFF(TYPE##ToIntArgbPre##OPER)(srcBase, pbuff, width, 1,         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
                                           pSrcInfo, pDstInfo,               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
                                           pPrim, pCompInfo);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                                               pSrcInfo, pDstInfo,           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                                               pPrim, pCompInfo);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        PTR_ADD(dstBase, dstScan);                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        PTR_ADD(srcBase, srcScan);                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }                                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    if (pbuff != buff) {                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        mlib_free(pbuff);                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }                                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define FUNC_SCALE_1(TYPE, OPER)                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
void ADD_SUFF(TYPE##ToFourByteAbgrPre##OPER)(SCALE_PARAMS)                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
{                                                                            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    mlib_d64 buff[BUFF_SIZE/2];                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    void     *pbuff = buff;                                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    mlib_s32 dstScan = pDstInfo->scanStride;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    mlib_s32 j;                                                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    if (width > BUFF_SIZE) pbuff = mlib_malloc(width*sizeof(mlib_s32));      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    for (j = 0; j < height; j++) {                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        ADD_SUFF(TYPE##ToIntArgbPre##OPER)(srcBase, pbuff, width, 1,         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                                           sxloc, syloc,                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                                           sxinc, syinc, shift,              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                           pSrcInfo, pDstInfo,               \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                           pPrim, pCompInfo);                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        ADD_SUFF(IntArgbToFourByteAbgrConvert)(pbuff, dstBase, width, 1,     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                                               pSrcInfo, pDstInfo,           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                               pPrim, pCompInfo);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        PTR_ADD(dstBase, dstScan);                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        syloc += syinc;                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }                                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                                                                             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    if (pbuff != buff) {                                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        mlib_free(pbuff);                                                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    }                                                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
#define FUNC_INDEXED(TYPE, OPER, PARAMS, CALL_PARAMS)                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
void ADD_SUFF(TYPE##ToFourByteAbgrPre##OPER)(PARAMS)                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
{                                                                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    SurfaceDataRasInfo new_src[1];                                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    jint *pixLut = pSrcInfo->lutBase;                                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    mlib_s32 buff[256];                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    ADD_SUFF(IntArgbToIntArgbPreConvert)(pixLut, buff, 256, 1,         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                         pSrcInfo, pDstInfo,           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                                         pPrim, pCompInfo);            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    new_src->lutBase = buff;                                           \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    new_src->scanStride = pSrcInfo->scanStride;                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    pSrcInfo = new_src;                                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                                                       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    ADD_SUFF(TYPE##ToFourByteAbgr##OPER)(CALL_PARAMS);                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
void ADD_SUFF(FourByteAbgrPreToIntArgbConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    ADD_SUFF(FourByteAbgrToIntArgbConvert)(BLIT_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    pSrcInfo = pDstInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    srcBase = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    ADD_SUFF(IntArgbPreToIntArgbConvert)(BLIT_CALL_PARAMS);
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(FourByteAbgrPreToIntArgbScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    ADD_SUFF(FourByteAbgrToIntArgbScaleConvert)(SCALE_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    pSrcInfo = pDstInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    srcBase = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    ADD_SUFF(IntArgbPreToIntArgbConvert)(BLIT_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
FUNC_CONVERT(ByteGray, Convert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
FUNC_CONVERT(IntArgb,  Convert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
FUNC_CONVERT(IntRgb,   Convert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
FUNC_CONVERT(ThreeByteBgr, Convert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
FUNC_SCALE_1(ByteGray, ScaleConvert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
FUNC_SCALE_1(IntArgb,  ScaleConvert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
FUNC_SCALE_1(IntRgb,   ScaleConvert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
FUNC_SCALE_1(ThreeByteBgr, ScaleConvert)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
FUNC_INDEXED(ByteIndexed,   Convert,       BLIT_PARAMS,  BLIT_CALL_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
FUNC_INDEXED(ByteIndexedBm, XparOver,      BLIT_PARAMS,  BLIT_CALL_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
FUNC_INDEXED(ByteIndexedBm, XparBgCopy,    BCOPY_PARAMS, BCOPY_CALL_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
FUNC_INDEXED(ByteIndexedBm, ScaleXparOver, SCALE_PARAMS, SCALE_CALL_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
FUNC_INDEXED(ByteIndexed,   ScaleConvert,  SCALE_PARAMS, SCALE_CALL_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
void ADD_SUFF(FourByteAbgrPreDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                              ImageRef *glyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                                              jint totalGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                              jint fgpixel, jint argbcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                              jint clipLeft, jint clipTop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                              jint clipRight, jint clipBottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                                              NativePrimitive * pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                              CompositeInfo * pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    mlib_d64 buff[BUFF_SIZE/2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    void     *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    mlib_s32 glyphCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    mlib_s32 scan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    mlib_u8  *dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    mlib_s32 solidpix0, solidpix1, solidpix2, solidpix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    mlib_d64 dmix0, dmix1, dd, d0, d1, e0, e1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    mlib_d64 done, d_half;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    mlib_s32 pix;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    mlib_f32 srcG_f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    mlib_s32 max_width = BUFF_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    solidpix0 = fgpixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    solidpix1 = fgpixel >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    solidpix2 = fgpixel >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    solidpix3 = fgpixel >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    done = vis_to_double_dup(0x7fff7fff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    d_half = vis_to_double_dup((1 << (16 + 6)) | (1 << 6));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    srcG_f = vis_to_float(argbcolor);
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   184
    ARGB2ABGR_FL(srcG_f);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        const jubyte *pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        unsigned int rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        int left, top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        int width, height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        int right, bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        pixels = (const jubyte *) glyphs[glyphCounter].pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        if (!pixels) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        left = glyphs[glyphCounter].x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        top = glyphs[glyphCounter].y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        width = glyphs[glyphCounter].width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        height = glyphs[glyphCounter].height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        rowBytes = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        right = left + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        bottom = top + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        if (left < clipLeft) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            pixels += clipLeft - left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            left = clipLeft;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        if (top < clipTop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            pixels += (clipTop - top) * rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            top = clipTop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (right > clipRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            right = clipRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (bottom > clipBottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            bottom = clipBottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (right <= left || bottom <= top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        width = right - left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        height = bottom - top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        dstBase = pRasInfo->rasBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        PTR_ADD(dstBase, top*scan + 4*left);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        if (((mlib_s32)dstBase | scan) & 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            if (width > max_width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                pbuff = mlib_malloc(width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                if (pbuff == NULL) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                max_width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            mlib_u8  *src = (void*)pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            mlib_s32 *dst, *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            mlib_u8  *dst8;
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   242
            mlib_u8* dst_start = dstBase;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   244
            /*
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   245
             * Typically the inner loop here works on Argb input data, an
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   246
             * Argb color, and produces ArgbPre output data.  To use that
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   247
             * standard approach we would need a FourByteAbgrPre to IntArgb
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   248
             * converter for the front end and an IntArgbPre to FourByteAbgrPre
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   249
             * converter for the back end.  The converter exists for the
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   250
             * front end, but it is a workaround implementation that uses a 2
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   251
             * stage conversion and an intermediate buffer that is allocated
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   252
             * on every call.  The converter for the back end doesn't really
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   253
             * exist, but we could reuse the IntArgb to FourByteAbgr converter
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   254
             * to do the same work - at the cost of swapping the components as
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   255
             * we copy the data back.  All of this is more work than we really
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   256
             * need so we use an alternate procedure:
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   257
             * - Copy the data into an int-aligned temporary buffer (if needed)
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   258
             * - Convert the data from FourByteAbgrPre to IntAbgr by using the
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   259
             * IntArgbPre to IntArgb converter in the int-aligned buffer.
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   260
             * - Swap the color data to Abgr so that the inner loop goes from
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   261
             * IntAbgr data to IntAbgrPre data
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   262
             * - Simply copy the IntAbgrPre data back into place.
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   263
             */
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   264
            if (((mlib_s32)dstBase) & 3) {
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   265
                COPY_NA(dstBase, pbuff, width*sizeof(mlib_s32));
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   266
                dst_start = pbuff;
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   267
            }
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   268
            ADD_SUFF(IntArgbPreToIntArgbConvert)(dst_start, pbuff, width, 1,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                                      pRasInfo, pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                                                      pPrim, pCompInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            vis_write_gsr(0 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            dst = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            dst_end = dst + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            if ((mlib_s32)dst & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                pix = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                dd = vis_fpadd16(MUL8_VIS(srcG_f, pix), d_half);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                dd = vis_fpadd16(MUL8_VIS(*(mlib_f32*)dst, 255 - pix), dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                *(mlib_f32*)dst = vis_fpack16(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                dst++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            for (; dst <= (dst_end - 2); dst += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                dmix0 = vis_freg_pair(((mlib_f32 *)vis_mul8s_tbl)[src[0]],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                                      ((mlib_f32 *)vis_mul8s_tbl)[src[1]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                dmix1 = vis_fpsub16(done, dmix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                dd = *(mlib_d64*)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                d0 = vis_fmul8x16al(srcG_f, vis_read_hi(dmix0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                d1 = vis_fmul8x16al(srcG_f, vis_read_lo(dmix0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                e0 = vis_fmul8x16al(vis_read_hi(dd), vis_read_hi(dmix1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                e1 = vis_fmul8x16al(vis_read_lo(dd), vis_read_lo(dmix1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                d0 = vis_fpadd16(vis_fpadd16(d0, d_half), e0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                d1 = vis_fpadd16(vis_fpadd16(d1, d_half), e1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                dd = vis_fpack16_pair(d0, d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                pix = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                dd = vis_fpadd16(MUL8_VIS(srcG_f, pix), d_half);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                dd = vis_fpadd16(MUL8_VIS(*(mlib_f32*)dst, 255 - pix), dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                *(mlib_f32*)dst = vis_fpack16(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                dst++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
   312
            COPY_NA(pbuff, dstBase, width*sizeof(mlib_s32));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            src = (void*)pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            dst8 = (void*)dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                if (src[i] == 255) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    dst8[4*i    ] = solidpix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                    dst8[4*i + 1] = solidpix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                    dst8[4*i + 2] = solidpix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                    dst8[4*i + 3] = solidpix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            PTR_ADD(dstBase, scan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            pixels += rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
#endif /* JAVA2D_NO_MLIB */