jdk/src/solaris/native/sun/java2d/loops/vis_FourByteAbgr.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 Gray2Argb(x)   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    0xff000000 | (x << 16) | (x << 8) | x
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#if VIS >= 0x200
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define BMASK_FOR_ARGB         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    vis_write_bmask(0x03214765, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define RGB2ABGR_DB(x)         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    x = vis_for(x, amask);     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    ARGB2ABGR_DB(x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
#define INSERT_U8_34R                                          \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    sdl = vis_fpmerge(vis_read_hi(sFF), vis_read_hi(sdh));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    sdm = vis_fpmerge(vis_read_lo(sFF), vis_read_lo(sdh));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    dd0 = vis_fpmerge(vis_read_hi(sdl), vis_read_hi(sdj));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    dd1 = vis_fpmerge(vis_read_lo(sdl), vis_read_lo(sdj));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    dd2 = vis_fpmerge(vis_read_hi(sdm), vis_read_hi(sdk));     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    dd3 = vis_fpmerge(vis_read_lo(sdm), vis_read_lo(sdk))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
void IntArgbToIntAbgrConvert_line(mlib_s32 *srcBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                  mlib_s32 *dstBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                  mlib_s32 width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    mlib_s32 *dst_end = dstBase + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    mlib_d64 dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    mlib_f32 ff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    if ((mlib_s32)srcBase & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        ff = *(mlib_f32*)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        ARGB2ABGR_FL(ff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        *(mlib_f32*)dstBase = ff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        srcBase++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        dstBase++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    if ((mlib_s32)dstBase & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        for (; dstBase <= (dst_end - 2); dstBase += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            dd = *(mlib_d64*)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            ((mlib_f32*)dstBase)[0] = vis_read_hi(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            ((mlib_f32*)dstBase)[1] = vis_read_lo(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            srcBase += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        for (; dstBase <= (dst_end - 2); dstBase += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            dd = *(mlib_d64*)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            *(mlib_d64*)dstBase = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            srcBase += 2;
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
    if (dstBase < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        ff = *(mlib_f32*)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        ARGB2ABGR_FL(ff)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        *(mlib_f32*)dstBase = ff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
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
void ADD_SUFF(FourByteAbgrToIntArgbConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    mlib_u32 *argb = (mlib_u32 *)dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    mlib_u8  *pabgr = (mlib_u8 *)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    mlib_s32 dstScan = (pDstInfo)->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    mlib_s32 srcScan = (pSrcInfo)->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    mlib_s32 i, j, count, left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    mlib_d64 w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            mlib_u8  *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            mlib_s32 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                *dst++ = (src[0] << 24) | (src[3] << 16) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                         (src[2] << 8) | (src[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                src += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    if (dstScan == 4*width && srcScan == dstScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    count = width >> 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    left = width & 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    if ((((mlib_addr)pabgr & 3) == 0) && ((srcScan & 3) == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        mlib_u32 *abgr = (mlib_u32 *)pabgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        dstScan >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        srcScan >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        for (i = 0; i < height; i++, argb += dstScan, abgr += srcScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            if ((((mlib_addr) argb | (mlib_addr) abgr) & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                mlib_d64 *d_abgr = (mlib_d64 *) abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                mlib_d64 *d_argb = (mlib_d64 *) argb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                    w_abgr = d_abgr[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                    d_argb[j] = w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    w_abgr = d_abgr[count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    ((mlib_f32 *) argb)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                mlib_f32 v_abgr0, v_abgr1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    v_abgr0 = ((mlib_f32 *) abgr)[2 * j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    v_abgr1 = ((mlib_f32 *) abgr)[2 * j + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    w_abgr = vis_freg_pair(v_abgr0, v_abgr1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    ((mlib_f32 *) argb)[2 * j] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    ((mlib_f32 *) argb)[2 * j + 1] = vis_read_lo(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    v_abgr0 = ((mlib_f32 *) abgr)[2 * count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    w_abgr = vis_freg_pair(v_abgr0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    ((mlib_f32 *) argb)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    } else {      /* abgr is not aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        mlib_u8 *abgr = pabgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        mlib_d64 *d_abgr, db0, db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        dstScan >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        for (i = 0; i < height; i++, argb += dstScan, abgr += srcScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            d_abgr = vis_alignaddr(abgr, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            db0 = *d_abgr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            if (((mlib_addr) argb & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                mlib_d64 *d_argb = (mlib_d64 *) argb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                    db1 = d_abgr[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    d_argb[j] = w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    db1 = d_abgr[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                    ((mlib_f32 *) argb)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                mlib_d64 w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                db1 = *d_abgr++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    ((mlib_f32 *) argb)[2 * j] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    ((mlib_f32 *) argb)[2 * j + 1] = vis_read_lo(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                    db1 = d_abgr[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                    w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                    ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                    ((mlib_f32 *) argb)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
void ADD_SUFF(IntArgbToFourByteAbgrConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    mlib_u32 *argb = (mlib_u32 *)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    mlib_u8 *abgr = (mlib_u8 *)dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    mlib_s32 dstScan = (pDstInfo)->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    mlib_s32 srcScan = (pSrcInfo)->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    mlib_s32 i, j, count, left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    mlib_d64 w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                mlib_u32 x = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    if (dstScan == 4*width && srcScan == dstScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    count = width >> 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    left = width & 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    srcScan >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    for (i = 0; i < height; i++, argb += srcScan, abgr += dstScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        if ((((mlib_addr) abgr | (mlib_addr) argb) & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            mlib_d64 *d_argb = (mlib_d64 *) argb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            mlib_d64 *d_abgr = (mlib_d64 *) abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                w_abgr = d_argb[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                d_abgr[j] = w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                w_abgr = d_argb[count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                ((mlib_f32 *) abgr)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        } else if (((mlib_addr) abgr & 3) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            mlib_f32 v_argb0, v_argb1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                v_argb0 = ((mlib_f32 *) argb)[2 * j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                v_argb1 = ((mlib_f32 *) argb)[2 * j + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                w_abgr = vis_freg_pair(v_argb0, v_argb1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                ((mlib_f32 *) abgr)[2 * j] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                ((mlib_f32 *) abgr)[2 * j + 1] = vis_read_lo(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                v_argb0 = ((mlib_f32 *) argb)[2 * count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                w_abgr = vis_freg_pair(v_argb0, vis_fzeros());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                ARGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                ((mlib_f32 *) abgr)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        } else {      /* abgr is not aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            mlib_u8 *pend = abgr + (width << 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            mlib_d64 *d_abgr, db0, db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            mlib_s32 emask, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            mlib_f32 *f_argb = (mlib_f32 *) argb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            off = (mlib_addr)abgr & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            vis_alignaddr((void *)(8 - off), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            d_abgr = (mlib_d64 *) (abgr - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            db1 = vis_freg_pair(*f_argb++, *f_argb++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            ARGB2ABGR_DB(db1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            w_abgr = vis_faligndata(db1, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            emask = vis_edge8(abgr, pend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            vis_pst_8(w_abgr, d_abgr++, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            db1 = vis_freg_pair(f_argb[0], f_argb[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            for (; (mlib_addr)d_abgr < (mlib_addr)(pend - 6); ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                ARGB2ABGR_DB(db1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                *d_abgr++ = w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                f_argb += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                db1 = vis_freg_pair(f_argb[0], f_argb[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            if ((mlib_addr)d_abgr <= (mlib_addr)pend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                ARGB2ABGR_DB(db1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                emask = vis_edge8(d_abgr, pend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                vis_pst_8(w_abgr, d_abgr, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
void ADD_SUFF(IntRgbToFourByteAbgrConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    mlib_u32 *argb = (mlib_u32 *)srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    mlib_u8  *abgr = (mlib_u8 *)dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    mlib_s32 dstScan = (pDstInfo)->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    mlib_s32 srcScan = (pSrcInfo)->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    mlib_s32 i, j, count, left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    mlib_d64 w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    mlib_d64 amask = vis_to_double_dup(0xFF000000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                mlib_u32 x = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                dst[0] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    if (dstScan == 4*width && srcScan == dstScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    count = width >> 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    left = width & 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    srcScan >>= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    for (i = 0; i < height; i++, argb += srcScan, abgr += dstScan) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        if ((((mlib_addr) abgr | (mlib_addr) argb) & 7) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            mlib_d64 *d_argb = (mlib_d64 *) argb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            mlib_d64 *d_abgr = (mlib_d64 *) abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                w_abgr = d_argb[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                RGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                d_abgr[j] = w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                w_abgr = d_argb[count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                RGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                ((mlib_f32 *) abgr)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        } else if (((mlib_addr) abgr & 3) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            mlib_f32 v_argb0, v_argb1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            for (j = 0; j < count; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                v_argb0 = ((mlib_f32 *) argb)[2 * j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                v_argb1 = ((mlib_f32 *) argb)[2 * j + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                w_abgr = vis_freg_pair(v_argb0, v_argb1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                RGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                ((mlib_f32 *) abgr)[2 * j] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                ((mlib_f32 *) abgr)[2 * j + 1] = vis_read_lo(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            if (left) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                v_argb0 = ((mlib_f32 *) argb)[2 * count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                w_abgr = vis_freg_pair(v_argb0, vis_fzeros());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                RGB2ABGR_DB(w_abgr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                ((mlib_f32 *) abgr)[2 * count] = vis_read_hi(w_abgr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        } else {      /* abgr is not aligned */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            mlib_u8 *pend = abgr + (width << 2) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            mlib_d64 *d_abgr, db0, db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            mlib_s32 emask, off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            mlib_f32 *f_argb = (mlib_f32 *) argb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            off = (mlib_addr)abgr & 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            vis_alignaddr((void *)(8 - off), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            d_abgr = (mlib_d64 *) (abgr - off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            db1 = vis_freg_pair(*f_argb++, *f_argb++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            RGB2ABGR_DB(db1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            w_abgr = vis_faligndata(db1, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            emask = vis_edge8(abgr, pend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            vis_pst_8(w_abgr, d_abgr++, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            db1 = vis_freg_pair(f_argb[0], f_argb[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            for (; (mlib_addr)d_abgr < (mlib_addr)(pend - 6); ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                RGB2ABGR_DB(db1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                *d_abgr++ = w_abgr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                db0 = db1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                f_argb += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                db1 = vis_freg_pair(f_argb[0], f_argb[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            if ((mlib_addr)d_abgr <= (mlib_addr)pend) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                RGB2ABGR_DB(db1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                w_abgr = vis_faligndata(db0, db1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                emask = vis_edge8(d_abgr, pend);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                vis_pst_8(w_abgr, d_abgr, emask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
void ADD_SUFF(ThreeByteBgrToFourByteAbgrConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    mlib_d64 sd0, sd1, sd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    mlib_d64 dd0, dd1, dd2, dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    mlib_d64 sda, sdb, sdc, sdd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    mlib_d64 sde, sdf, sdg, sdh;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    mlib_d64 sdi, sdj, sdk, sdl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    mlib_d64 sdm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    mlib_d64 sFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    mlib_s32 r, g, b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                dst[0] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                dst[1] = src[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                dst[2] = src[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                dst[3] = src[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                src += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    if (dstScan == 4*width && srcScan == 3*width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    sFF = vis_fone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        mlib_u8 *pSrc = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        mlib_u8 *pDst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (!(((mlib_s32)pSrc | (mlib_s32)pDst) & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            for (i = 0; i <= ((mlib_s32)width - 8); i += 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                sd0 = ((mlib_d64*)pSrc)[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                sd1 = ((mlib_d64*)pSrc)[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                sd2 = ((mlib_d64*)pSrc)[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                pSrc += 3*8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                INSERT_U8_34R;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                ((mlib_d64*)pDst)[0] = dd0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                ((mlib_d64*)pDst)[1] = dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                ((mlib_d64*)pDst)[2] = dd2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                ((mlib_d64*)pDst)[3] = dd3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                pDst += 4*8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            for (; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                b = pSrc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                g = pSrc[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                r = pSrc[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                ((mlib_u16*)pDst)[0] = 0xff00 | b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                ((mlib_u16*)pDst)[1] = (g << 8) | r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                pSrc += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                pDst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        } else if (!((mlib_s32)pDst & 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                b = pSrc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                g = pSrc[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                r = pSrc[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                ((mlib_u16*)pDst)[0] = 0xff00 | b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                ((mlib_u16*)pDst)[1] = (g << 8) | r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                pSrc += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                pDst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            *pDst++ = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            for (i = 0; i < (mlib_s32)width - 1; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                b = pSrc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                g = pSrc[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                r = pSrc[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                ((mlib_u16*)pDst)[0] = (b << 8) | g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                ((mlib_u16*)pDst)[1] = (r << 8) | 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                pSrc += 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                pDst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            if (width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                pDst[0] = pSrc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                pDst[1] = pSrc[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                pDst[2] = pSrc[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
#if 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
#define LOAD_BGR(dd) {                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    mlib_u8  *sp = pSrc - 1 + 3*(tmpsxloc >> shift);   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    mlib_d64 *ap = (void*)((mlib_addr)sp &~ 7);        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    vis_alignaddr(sp, 0);                              \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    dd = vis_faligndata(ap[0], ap[1]);                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    tmpsxloc += sxinc;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
#define LOAD_BGR(dd) {                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    mlib_u8 *sp = pSrc + 3*(tmpsxloc >> shift);        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    dd = vis_faligndata(vis_ld_u8(sp + 2), dd);        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    dd = vis_faligndata(vis_ld_u8(sp + 1), dd);        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    dd = vis_faligndata(vis_ld_u8(sp    ), dd);        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    dd = vis_faligndata(amask, dd);                    \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    tmpsxloc += sxinc;                                 \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
void ADD_SUFF(ThreeByteBgrToFourByteAbgrScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    mlib_d64 d0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    mlib_d64 amask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    mlib_s32 r, g, b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    if (width < 16 /*|| (((mlib_s32)dstBase | dstScan) & 3)*/) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            mlib_u8  *pSrc = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            mlib_u8  *pDst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            PTR_ADD(pSrc, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                mlib_u8 *pp = pSrc + 3*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                pDst[0] = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                pDst[1] = pp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                pDst[2] = pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                pDst[3] = pp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                pDst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    vis_alignaddr(NULL, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    amask = vis_to_double_dup(0xFF000000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        mlib_u8 *pSrc = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        mlib_u8 *pDst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        PTR_ADD(pSrc, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        if (!((mlib_s32)pDst & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                LOAD_BGR(d0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                ((mlib_f32*)pDst)[0] = vis_fors(vis_read_hi(d0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                                                vis_read_hi(amask));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                pDst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        } else if (!((mlib_s32)pDst & 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                mlib_u8 *pp = pSrc + 3*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                b = pp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                g = pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                r = pp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                ((mlib_u16*)pDst)[2*i    ] = 0xff00 | b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
                ((mlib_u16*)pDst)[2*i + 1] = (g << 8) | r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            *pDst++ = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
            for (i = 0; i < (mlib_s32)width - 1; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
                mlib_u8 *pp = pSrc + 3*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                b = pp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                g = pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                r = pp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                ((mlib_u16*)pDst)[2*i    ] = (b << 8) | g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                ((mlib_u16*)pDst)[2*i + 1] = (r << 8) | 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            if (width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                mlib_u8 *pp = pSrc + 3*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                pDst[4*i  ] = pp[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                pDst[4*i+1] = pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                pDst[4*i+2] = pp[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
void ADD_SUFF(ByteGrayToFourByteAbgrConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    mlib_d64 d0, d1, d2, d3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    mlib_f32 ff, aa = vis_fones();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    mlib_s32 i, j, x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    if (!(((mlib_s32)dstBase | dstScan) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        ADD_SUFF(ByteGrayToIntArgbConvert)(BLIT_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                x = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                dst[0] = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                dst[2] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                dst[3] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    if (srcScan == width && dstScan == 4*width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        while (((mlib_s32)src & 3) && dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            x = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            dst[0] = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            dst[2] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            dst[3] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        if (!((mlib_s32)dst & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
            for (; dst <= (dst_end - 4*4); dst += 4*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                ff = *(mlib_f32*)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                d0 = vis_fpmerge(aa, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                d1 = vis_fpmerge(ff, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                d2 = vis_fpmerge(vis_read_hi(d0), vis_read_hi(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                d3 = vis_fpmerge(vis_read_lo(d0), vis_read_lo(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                ((mlib_f32*)dst)[0] = vis_read_hi(d2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                ((mlib_f32*)dst)[1] = vis_read_lo(d2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                ((mlib_f32*)dst)[2] = vis_read_hi(d3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                ((mlib_f32*)dst)[3] = vis_read_lo(d3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                src += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            dp = vis_alignaddr(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            d3 = vis_faligndata(dp[0], dp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            vis_alignaddrl(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            for (; dst <= (dst_end - 4*4); dst += 4*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                ff = *(mlib_f32*)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                d0 = vis_fpmerge(aa, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                d1 = vis_fpmerge(ff, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                d2 = vis_fpmerge(vis_read_hi(d0), vis_read_hi(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                *dp++ = vis_faligndata(d3, d2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                d3 = vis_fpmerge(vis_read_lo(d0), vis_read_lo(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                *dp++ = vis_faligndata(d2, d3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                src += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            vis_pst_8(vis_faligndata(d3, d3), dp, vis_edge8(dp, dst - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            x = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            dst[0] = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            dst[2] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            dst[3] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
void ADD_SUFF(IntArgbToFourByteAbgrXorBlit)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    mlib_u32 xorpixel = pCompInfo->details.xorPixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    mlib_u32 alphamask = pCompInfo->alphaMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    mlib_d64 dd, d_xorpixel, d_alphamask, d_zero;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    mlib_s32 i, j, x, neg_mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        xorpixel = (xorpixel << 24) | (xorpixel >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        alphamask = (alphamask << 24) | (alphamask >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
            mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                x = src[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                neg_mask = x >> 31;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                x = (x ^ xorpixel) & (neg_mask &~ alphamask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                dst[0] ^= x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
                dst[1] ^= x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                dst[2] ^= x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                dst[3] ^= x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    if (srcScan == 4*width && dstScan == 4*width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
    d_zero = vis_fzero();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    d_xorpixel = vis_freg_pair(vis_ldfa_ASI_PL(&xorpixel),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                               vis_ldfa_ASI_PL(&xorpixel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    d_alphamask = vis_freg_pair(vis_ldfa_ASI_PL(&alphamask),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                                vis_ldfa_ASI_PL(&alphamask));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    dd = vis_freg_pair(vis_read_hi(d_xorpixel), vis_read_hi(d_alphamask));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
    xorpixel = ((mlib_s32*)&dd)[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
    alphamask = ((mlib_s32*)&dd)[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        mlib_u8  *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            for (; dst <= (dst_end - 8); dst += 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                dd = vis_freg_pair(((mlib_f32*)src)[0], ((mlib_f32*)src)[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                neg_mask = vis_fcmplt32(dd, d_zero);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
                dd = vis_fxor(dd, d_xorpixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                dd = vis_fandnot(d_alphamask, dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                dd = vis_fxor(dd, *(mlib_d64*)dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                vis_pst_32(dd, dst, neg_mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            x = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            neg_mask = x >> 31;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            x = (x ^ xorpixel) & (neg_mask &~ alphamask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
            dst[0] ^= x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            dst[1] ^= x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            dst[2] ^= x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            dst[3] ^= x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
void ADD_SUFF(ByteGrayToFourByteAbgrScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    mlib_d64 d0, d1, d2, d3, dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    mlib_f32 ff, aa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    mlib_s32 i, j, x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
/*  if (!(((mlib_s32)dstBase | dstScan) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    ADD_SUFF(ByteGrayToIntArgbScaleConvert)(SCALE_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                dst[4*i    ] = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                dst[4*i + 2] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                dst[4*i + 3] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    aa = vis_fones();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        if (!((mlib_s32)dst & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            vis_alignaddr(NULL, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            for (; dst <= (dst_end - 4*4); dst += 4*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                LOAD_NEXT_U8(dd, src + ((tmpsxloc + 3*sxinc) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                LOAD_NEXT_U8(dd, src + ((tmpsxloc + 2*sxinc) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                LOAD_NEXT_U8(dd, src + ((tmpsxloc +   sxinc) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                LOAD_NEXT_U8(dd, src + ((tmpsxloc          ) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                tmpsxloc += 4*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                ff = vis_read_hi(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                d0 = vis_fpmerge(aa, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
                d1 = vis_fpmerge(ff, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
                d2 = vis_fpmerge(vis_read_hi(d0), vis_read_hi(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
                d3 = vis_fpmerge(vis_read_lo(d0), vis_read_lo(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
                ((mlib_f32*)dst)[0] = vis_read_hi(d2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
                ((mlib_f32*)dst)[1] = vis_read_lo(d2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                ((mlib_f32*)dst)[2] = vis_read_hi(d3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                ((mlib_f32*)dst)[3] = vis_read_lo(d3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
            mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
            dp = vis_alignaddr(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
            d3 = vis_faligndata(dp[0], dp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
            vis_alignaddrl(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            for (; dst <= (dst_end - 4*4); dst += 4*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                mlib_d64 s0, s1, s2, s3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                s0 = vis_ld_u8(src + ((tmpsxloc          ) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                s1 = vis_ld_u8(src + ((tmpsxloc +   sxinc) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                s2 = vis_ld_u8(src + ((tmpsxloc + 2*sxinc) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                s3 = vis_ld_u8(src + ((tmpsxloc + 3*sxinc) >> shift));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                tmpsxloc += 4*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                s0 = vis_fpmerge(vis_read_lo(s0), vis_read_lo(s2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                s1 = vis_fpmerge(vis_read_lo(s1), vis_read_lo(s3));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                dd = vis_fpmerge(vis_read_lo(s0), vis_read_lo(s1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                ff = vis_read_lo(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                d0 = vis_fpmerge(aa, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                d1 = vis_fpmerge(ff, ff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                d2 = vis_fpmerge(vis_read_hi(d0), vis_read_hi(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                *dp++ = vis_faligndata(d3, d2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                d3 = vis_fpmerge(vis_read_lo(d0), vis_read_lo(d1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                *dp++ = vis_faligndata(d2, d3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            vis_pst_8(vis_faligndata(d3, d3), dp, vis_edge8(dp, dst - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            dst[0] = 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            dst[2] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            dst[3] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
void ADD_SUFF(ByteIndexedToFourByteAbgrConvert)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    jint *pixLut = pSrcInfo->lutBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    mlib_d64 dd, d_old;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    mlib_s32 i, j, x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
/*  if (!(((mlib_s32)dstBase | dstScan) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    ADD_SUFF(ByteIndexedToIntAbgrConvert)(BLIT_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    if (width < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
                x = pixLut[src[i]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                dst[4*i    ] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
    if (srcScan == width && dstScan == 4*width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                dd = vis_freg_pair(((mlib_f32*)pixLut)[src[0]],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                                   ((mlib_f32*)pixLut)[src[1]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            dp = vis_alignaddr(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            dd = vis_faligndata(dp[0], dp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            vis_alignaddrl(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                d_old = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                dd = vis_freg_pair(((mlib_f32*)pixLut)[src[0]],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                                   ((mlib_f32*)pixLut)[src[1]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                *dp++ = vis_faligndata(d_old, dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            vis_pst_8(vis_faligndata(dd, dd), dp, vis_edge8(dp, dst - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            x = pixLut[*src++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
            dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
            dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
void ADD_SUFF(ByteIndexedBmToFourByteAbgrXparOver)(BLIT_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    jint *pixLut = pSrcInfo->lutBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    mlib_d64 dd, dzero;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    mlib_s32 i, j, x, mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
/*  if (!(((mlib_s32)dstBase | dstScan) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    ADD_SUFF(ByteIndexedToIntAbgrConvert)(BLIT_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    if (width < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                x = pixLut[src[i]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                if (x < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                    dst[4*i    ] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                    dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                    dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                    dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    if (srcScan == width && dstScan == 4*width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    dzero = vis_fzero();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                dd = vis_freg_pair(((mlib_f32*)pixLut)[src[0]],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                                   ((mlib_f32*)pixLut)[src[1]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                mask = vis_fcmplt32(dd, dzero);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                vis_pst_32(dd, dst, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
            x = pixLut[*src++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
            if (x < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
                dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
void ADD_SUFF(ByteIndexedBmToFourByteAbgrXparBgCopy)(BCOPY_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    jint *pixLut = pSrcInfo->lutBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
    mlib_d64 dd, dzero, d_bgpixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    mlib_s32 i, j, x, mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
    mlib_s32 bgpix0 = bgpixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
    mlib_s32 bgpix1 = bgpixel >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
    mlib_s32 bgpix2 = bgpixel >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
    mlib_s32 bgpix3 = bgpixel >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    if (width < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                x = pixLut[src[i]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                if (x < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                    dst[4*i    ] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                    dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                    dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
                    dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                    dst[4*i    ] = bgpix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                    dst[4*i + 1] = bgpix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                    dst[4*i + 2] = bgpix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                    dst[4*i + 3] = bgpix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
            PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    if (srcScan == width && dstScan == 4*width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        width *= height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        height = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
    dzero = vis_fzero();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
    d_bgpixel = vis_freg_pair(vis_ldfa_ASI_PL(&bgpixel),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
                              vis_ldfa_ASI_PL(&bgpixel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
                dd = vis_freg_pair(((mlib_f32*)pixLut)[src[0]],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
                                   ((mlib_f32*)pixLut)[src[1]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
                mask = vis_fcmplt32(dd, dzero);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
                *(mlib_d64*)dst = d_bgpixel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                vis_pst_32(dd, dst, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
            x = pixLut[*src++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            if (x < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
                dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
                dst[0] = bgpix0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
                dst[1] = bgpix1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                dst[2] = bgpix2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                dst[3] = bgpix3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        PTR_ADD(srcBase, srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
void ADD_SUFF(ByteIndexedToFourByteAbgrScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
    jint *pixLut = pSrcInfo->lutBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
    mlib_d64 dd, d_old;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
    mlib_s32 i, j, x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
    if (!(((mlib_s32)dstBase | dstScan) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        ADD_SUFF(ByteIndexedToIntAbgrScaleConvert)(SCALE_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    if (width < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
                x = pixLut[src[tmpsxloc >> shift]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
                dst[4*i    ] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
                dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
                dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
                dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
                dd = LOAD_2F32(pixLut, src[tmpsxloc >> shift],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
                                       src[(tmpsxloc + sxinc) >> shift]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
            mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
            dp = vis_alignaddr(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
            dd = vis_faligndata(dp[0], dp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
            vis_alignaddrl(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
                d_old = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
                dd = LOAD_2F32(pixLut, src[tmpsxloc >> shift],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
                                       src[(tmpsxloc + sxinc) >> shift]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
                *dp++ = vis_faligndata(d_old, dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
            vis_pst_8(vis_faligndata(dd, dd), dp, vis_edge8(dp, dst - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
            x = pixLut[src[tmpsxloc >> shift]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
            dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
            dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
            dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
void ADD_SUFF(ByteIndexedBmToFourByteAbgrScaleXparOver)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
    jint *pixLut = pSrcInfo->lutBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
    mlib_d64 dd, dzero;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
    mlib_s32 i, j, x, mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
    if (!(((mlib_s32)dstBase | dstScan) & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
        ADD_SUFF(ByteIndexedToIntAbgrScaleConvert)(SCALE_CALL_PARAMS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
    if (width < 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
            mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
                x = pixLut[src[tmpsxloc >> shift]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
                if (x < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
                    dst[4*i    ] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                    dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                    dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
                    dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
    dzero = vis_fzero();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
        mlib_u8 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        mlib_u8 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
        mlib_u8 *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                dd = LOAD_2F32(pixLut, src[tmpsxloc >> shift],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                                       src[(tmpsxloc + sxinc) >> shift]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                mask = vis_fcmplt32(dd, dzero);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
                vis_pst_32(dd, dst, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
            x = pixLut[src[tmpsxloc >> shift]];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
            if (x < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
                dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
void ADD_SUFF(IntArgbBmToFourByteAbgrScaleXparOver)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
    mlib_d64 dd, amask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
    mlib_s32 i, j, x, mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
            mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
            mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
                x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
                if (x >> 24) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
                    dst[4*i    ] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
                    dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
                    dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
                    dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
    amask = vis_to_double_dup(0xFF000000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
        mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
        mlib_u8  *dst_end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
        dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
        if (!((mlib_s32)dst & 7)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
                mlib_s32 *pp0 = src + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
                mlib_s32 *pp1 = src + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
                dd = vis_freg_pair(*(mlib_f32*)pp0, *(mlib_f32*)pp1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
                dd = vis_for(dd, amask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
                mask = (((-*(mlib_u8*)pp0) >> 31) & 2) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
                       (((-*(mlib_u8*)pp1) >> 31) & 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                vis_pst_32(dd, dst, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
        while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
            x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
            if (x >> 24) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
                dst[0] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
#ifdef MLIB_ADD_SUFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
#pragma weak IntArgbBmToFourByteAbgrPreScaleXparOver_F =       \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
             IntArgbBmToFourByteAbgrScaleXparOver_F
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
#pragma weak IntArgbBmToFourByteAbgrPreScaleXparOver =         \
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
             IntArgbBmToFourByteAbgrScaleXparOver
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
void ADD_SUFF(FourByteAbgrToIntArgbScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
            mlib_u8  *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            mlib_s32 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
                mlib_u8 *pp = src + 4*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
                *dst++ = (pp[0] << 24) | (pp[3] << 16) | (pp[2] << 8) | pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
        mlib_u8  *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
        mlib_s32 *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
        mlib_s32 *dst_end = dst + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
        mlib_s32 off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
        mlib_d64 dd, dd0, dd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
        mlib_f32 *pp0, *pp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
        if ((mlib_s32)dst & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
            mlib_u8 *pp = src + 4*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
            *dst++ = (pp[0] << 24) | (pp[3] << 16) | (pp[2] << 8) | pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
        off = (mlib_s32)src & 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        if (!off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
            for (; dst <= (dst_end - 2); dst += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
                pp0 = (mlib_f32*)src + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
                pp1 = (mlib_f32*)src + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
                dd = vis_freg_pair(pp0[0], pp1[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
            vis_alignaddr(NULL, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
            for (; dst <= (dst_end - 2); dst += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
                pp0 = (mlib_f32*)(src - off) + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
                pp1 = (mlib_f32*)(src - off) + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
                dd0 = vis_freg_pair(pp0[0], pp0[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
                dd1 = vis_freg_pair(pp1[0], pp1[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
                dd0 = vis_faligndata(dd0, dd0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
                dd1 = vis_faligndata(dd1, dd1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
                ARGB2ABGR_FL2(dd, vis_read_hi(dd0), vis_read_hi(dd1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
        if (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
            mlib_u8 *pp = src + 4*(tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
            *dst++ = (pp[0] << 24) | (pp[3] << 16) | (pp[2] << 8) | pp[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
void ADD_SUFF(IntArgbToFourByteAbgrScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
    mlib_s32 x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
            mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
            mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
                x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
                dst[4*i    ] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
                dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
                dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
                dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
        mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
        mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
        mlib_u8  *dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
        mlib_d64 dd, d_old;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
        mlib_f32 *pp0, *pp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
        if (!((mlib_s32)dst & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
            if ((mlib_s32)dst & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
                x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
                dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
                pp0 = (mlib_f32*)src + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
                pp1 = (mlib_f32*)src + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
                dd = vis_freg_pair(pp0[0], pp1[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
            mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
            dp = vis_alignaddr(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
            dd = vis_faligndata(dp[0], dp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
            vis_alignaddrl(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
                d_old = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
                pp0 = (mlib_f32*)src + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
                pp1 = (mlib_f32*)src + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
                dd = vis_freg_pair(pp0[0], pp1[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
                ARGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
                *dp++ = vis_faligndata(d_old, dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
            vis_pst_8(vis_faligndata(dd, dd), dp, vis_edge8(dp, dst - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
        if (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
            x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
            dst[0] = x >> 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
            dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
            dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
void ADD_SUFF(IntRgbToFourByteAbgrScaleConvert)(SCALE_PARAMS)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
    mlib_s32 dstScan = pDstInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
    mlib_s32 srcScan = pSrcInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
    mlib_s32 x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
    mlib_d64 amask = vis_to_double_dup(0xFF000000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
    if (width < 16) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
            mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
            mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
            mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
            PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
            for (i = 0; i < width; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
                x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
                dst[4*i    ] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
                dst[4*i + 1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
                dst[4*i + 2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
                dst[4*i + 3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
            PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
            syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
    BMASK_FOR_ARGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
    for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
        mlib_s32 *src = srcBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
        mlib_u8  *dst = dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
        mlib_u8  *dst_end = dst + 4*width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
        mlib_s32 tmpsxloc = sxloc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
        mlib_d64 dd, d_old;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
        mlib_f32 *pp0, *pp1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
        PTR_ADD(src, (syloc >> shift) * srcScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
        if (!((mlib_s32)dst & 3)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
            if ((mlib_s32)dst & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
                x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
                tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
                dst[0] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
                dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1801
                dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1802
                dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
                dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
                pp0 = (mlib_f32*)src + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
                pp1 = (mlib_f32*)src + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1809
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
                dd = vis_freg_pair(pp0[0], pp1[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
                RGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
                *(mlib_d64*)dst = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
            mlib_d64 *dp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1816
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
            dp = vis_alignaddr(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
            dd = vis_faligndata(dp[0], dp[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
            vis_alignaddrl(dst, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
            for (; dst <= (dst_end - 2*4); dst += 2*4) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
                d_old = dd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1824
                pp0 = (mlib_f32*)src + (tmpsxloc >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
                pp1 = (mlib_f32*)src + ((tmpsxloc + sxinc) >> shift);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
                tmpsxloc += 2*sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
                dd = vis_freg_pair(pp0[0], pp1[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
                RGB2ABGR_DB(dd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
                *dp++ = vis_faligndata(d_old, dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1831
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
            vis_pst_8(vis_faligndata(dd, dd), dp, vis_edge8(dp, dst - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
        if (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
            x = src[tmpsxloc >> shift];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1837
            tmpsxloc += sxinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1838
            dst[0] = 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1839
            dst[1] = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
            dst[2] = x >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
            dst[3] = x >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
            dst += 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
        PTR_ADD(dstBase, dstScan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1846
        syloc += syinc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1852
void ADD_SUFF(FourByteAbgrDrawGlyphListAA)(SurfaceDataRasInfo * pRasInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
                                           ImageRef *glyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
                                           jint totalGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
                                           jint fgpixel, jint argbcolor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
                                           jint clipLeft, jint clipTop,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1857
                                           jint clipRight, jint clipBottom,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1858
                                           NativePrimitive * pPrim,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
                                           CompositeInfo * pCompInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1860
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1861
    mlib_d64 buff[BUFF_SIZE/2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1862
    void     *pbuff = buff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
    mlib_s32 glyphCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
    mlib_s32 scan = pRasInfo->scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
    mlib_u8  *dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
    mlib_s32 i, j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
    mlib_d64 dmix0, dmix1, dd, d0, d1, e0, e1, fgpixel_d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1868
    mlib_d64 done, done16, d_half;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1869
    mlib_s32 pix, mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1870
    mlib_f32 fgpixel_f, srcG_f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1871
    mlib_s32 max_width = BUFF_SIZE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1872
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1873
    done = vis_to_double_dup(0x7fff7fff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1874
    done16 = vis_to_double_dup(0x7fff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1875
    d_half = vis_to_double_dup((1 << (16 + 6)) | (1 << 6));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1876
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1877
    fgpixel_f = vis_ldfa_ASI_PL(&fgpixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1878
    fgpixel_d = vis_freg_pair(fgpixel_f, fgpixel_f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1879
    srcG_f = vis_to_float(argbcolor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1880
    ARGB2ABGR_FL(srcG_f)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1881
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1882
    vis_write_gsr(0 << 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1883
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1884
    for (glyphCounter = 0; glyphCounter < totalGlyphs; glyphCounter++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1885
        const jubyte *pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1886
        unsigned int rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
        int left, top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
        int width, height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
        int right, bottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
        pixels = (const jubyte *) glyphs[glyphCounter].pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
        if (!pixels) continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
        left = glyphs[glyphCounter].x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
        top = glyphs[glyphCounter].y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
        width = glyphs[glyphCounter].width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
        height = glyphs[glyphCounter].height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
        rowBytes = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
        right = left + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
        bottom = top + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
        if (left < clipLeft) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
            pixels += clipLeft - left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
            left = clipLeft;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
        if (top < clipTop) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
            pixels += (clipTop - top) * rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
            top = clipTop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
        if (right > clipRight) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
            right = clipRight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
        if (bottom > clipBottom) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
            bottom = clipBottom;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
        if (right <= left || bottom <= top) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
        width = right - left;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
        height = bottom - top;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
        dstBase = pRasInfo->rasBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
        PTR_ADD(dstBase, top*scan + 4*left);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
        if (((mlib_s32)dstBase | scan) & 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
            if (width > max_width) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
                if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
                    mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
                pbuff = mlib_malloc(width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
                if (pbuff == NULL) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
                max_width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
        for (j = 0; j < height; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
            mlib_u8  *src = (void*)pixels;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
            mlib_s32 *dst, *dst_end;
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1939
            mlib_u8 *dst_start;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
            if ((mlib_s32)dstBase & 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
                COPY_NA(dstBase, pbuff, width*sizeof(mlib_s32));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
                dst = pbuff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
                dst = (void*)dstBase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
            }
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1947
            dst_start = (void*)dst;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
            dst_end = dst + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1950
            /* Need to reset the GSR from the values set by the
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1951
             * convert call near the end of this loop.
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1952
             */
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1953
            vis_write_gsr(7 << 0);
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1954
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
            if ((mlib_s32)dst & 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1956
                pix = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
                dd = vis_fpadd16(MUL8_VIS(srcG_f, pix), d_half);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
                dd = vis_fpadd16(MUL8_VIS(*(mlib_f32*)dst, 255 - pix), dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
                *(mlib_f32*)dst = vis_fpack16(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1960
                if (pix == 255) *(mlib_f32*)dst = vis_read_hi(fgpixel_d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
                dst++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1963
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1964
#pragma pipeloop(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1965
            for (; dst <= (dst_end - 2); dst += 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1966
                dmix0 = vis_freg_pair(((mlib_f32 *)vis_mul8s_tbl)[src[0]],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1967
                                      ((mlib_f32 *)vis_mul8s_tbl)[src[1]]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1968
                mask = vis_fcmplt32(dmix0, done16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1969
                dmix1 = vis_fpsub16(done, dmix0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1970
                src += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1971
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1972
                dd = *(mlib_d64*)dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1973
                d0 = vis_fmul8x16al(srcG_f, vis_read_hi(dmix0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
                d1 = vis_fmul8x16al(srcG_f, vis_read_lo(dmix0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1975
                e0 = vis_fmul8x16al(vis_read_hi(dd), vis_read_hi(dmix1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
                e1 = vis_fmul8x16al(vis_read_lo(dd), vis_read_lo(dmix1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                d0 = vis_fpadd16(vis_fpadd16(d0, d_half), e0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
                d1 = vis_fpadd16(vis_fpadd16(d1, d_half), e1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1979
                dd = vis_fpack16_pair(d0, d1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
                *(mlib_d64*)dst = fgpixel_d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1982
                vis_pst_32(dd, dst, mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1985
            while (dst < dst_end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1986
                pix = *src++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1987
                dd = vis_fpadd16(MUL8_VIS(srcG_f, pix), d_half);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1988
                dd = vis_fpadd16(MUL8_VIS(*(mlib_f32*)dst, 255 - pix), dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1989
                *(mlib_f32*)dst = vis_fpack16(dd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
                if (pix == 255) *(mlib_f32*)dst = vis_read_hi(fgpixel_d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
                dst++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1994
            ADD_SUFF(IntArgbPreToIntArgbConvert)(dst_start, dst_start,
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1995
                                                 width, 1,
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1996
                                                 pRasInfo, pRasInfo,
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1997
                                                 pPrim, pCompInfo);
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  1998
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
            if ((mlib_s32)dstBase & 3) {
549
4273b1234967 6679308: Poor text rendering on translucent image.
prr
parents: 2
diff changeset
  2000
                COPY_NA(dst_start, dstBase, width*sizeof(mlib_s32));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2001
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
            PTR_ADD(dstBase, scan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
            pixels += rowBytes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2008
    if (pbuff != buff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
        mlib_free(pbuff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2011
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2015
#endif /* JAVA2D_NO_MLIB */