jdk/src/share/native/sun/java2d/pipe/BufferedMaskBlit.c
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7752 bac6e958f08e
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7752
diff changeset
     2
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 887
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <jlong.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <jni_util.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "sun_java2d_pipe_BufferedMaskBlit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "sun_java2d_pipe_BufferedOpCodes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "Trace.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "IntArgb.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "IntRgb.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "IntBgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define MAX_MASK_LENGTH (32 * 32)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
extern unsigned char mul8table[256][256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * This implementation of MaskBlit first combines the source system memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * tile with the corresponding alpha mask and stores the resulting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * IntArgbPre pixels directly into the RenderBuffer.  Those pixels are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * then eventually pulled off the RenderBuffer and copied to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * surface in OGL/D3DMaskBlit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Note that currently there are only inner loops defined for IntArgb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * IntArgbPre, IntRgb, and IntBgr, as those are the most commonly used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * formats for this operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    (JNIEnv *env, jobject mb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     jlong buf, jint bpos,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     jobject srcData, jlong pSrcOps, jint srcType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     jbyteArray maskArray, jint masklen, jint maskoff, jint maskscan,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     jint srcx, jint srcy, jint dstx, jint dsty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    SurfaceDataOps *srcOps = (SurfaceDataOps *)jlong_to_ptr(pSrcOps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    SurfaceDataRasInfo srcInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    unsigned char *bbuf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    jint *pBuf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    J2dTraceLn1(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                "BufferedMaskBlit_enqueueTile: bpos=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                bpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    if (srcOps == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            "BufferedMaskBlit_enqueueTile: srcOps is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return bpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    bbuf = (unsigned char *)jlong_to_ptr(buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    if (bbuf == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            "BufferedMaskBlit_enqueueTile: cannot get direct buffer address");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return bpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    pBuf = (jint *)(bbuf + bpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    if (JNU_IsNull(env, maskArray)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            "BufferedMaskBlit_enqueueTile: mask array is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return bpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    if (masklen > MAX_MASK_LENGTH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        // REMIND: this approach is seriously flawed if the mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        //         length is ever greater than MAX_MASK_LENGTH (won't fit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        //         into the cached mask tile); so far this hasn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        //         been a problem though...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            "BufferedMaskBlit_enqueueTile: mask array too large");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return bpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    srcInfo.bounds.x1 = srcx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    srcInfo.bounds.y1 = srcy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    srcInfo.bounds.x2 = srcx + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    srcInfo.bounds.y2 = srcy + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    if (srcOps->Lock(env, srcOps, &srcInfo, SD_LOCK_READ) != SD_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        J2dRlsTraceLn(J2D_TRACE_WARNING,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                      "BufferedMaskBlit_enqueueTile: could not acquire lock");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return bpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    if (srcInfo.bounds.x2 > srcInfo.bounds.x1 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        srcInfo.bounds.y2 > srcInfo.bounds.y1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        srcOps->GetRasInfo(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (srcInfo.rasBase) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            jint h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            jint srcScanStride = srcInfo.scanStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            jint srcPixelStride = srcInfo.pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            jint *pSrc = (jint *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                PtrCoord(srcInfo.rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                         srcInfo.bounds.x1, srcInfo.pixelStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                         srcInfo.bounds.y1, srcInfo.scanStride);
7752
bac6e958f08e 7002627: JNI Critical Arrays should be released with the original (unmodified) pointer
bae
parents: 5506
diff changeset
   122
            unsigned char *pMask, *pMaskAlloc;
bac6e958f08e 7002627: JNI Critical Arrays should be released with the original (unmodified) pointer
bae
parents: 5506
diff changeset
   123
            pMask = pMaskAlloc =
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   124
                (*env)->GetPrimitiveArrayCritical(env, maskArray, 0);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   125
            if (pMask == NULL) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   126
                J2dRlsTraceLn(J2D_TRACE_ERROR,
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   127
                    "BufferedMaskBlit_enqueueTile: cannot lock mask array");
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   128
                SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   129
                SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   130
                return bpos;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   131
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            width = srcInfo.bounds.x2 - srcInfo.bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            height = srcInfo.bounds.y2 - srcInfo.bounds.y1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            maskoff += ((srcInfo.bounds.y1 - srcy) * maskscan +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        (srcInfo.bounds.x1 - srcx));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            maskscan -= width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            pMask += maskoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            srcScanStride -= width * srcPixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            h = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            J2dTraceLn4(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                        "  sx=%d sy=%d w=%d h=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                        srcInfo.bounds.x1, srcInfo.bounds.y1, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            J2dTraceLn2(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                        "  maskoff=%d maskscan=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                        maskoff, maskscan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            J2dTraceLn2(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                        "  pixstride=%d scanstride=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                        srcPixelStride, srcScanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            // enqueue parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            pBuf[0] = sun_java2d_pipe_BufferedOpCodes_MASK_BLIT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            pBuf[1] = dstx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            pBuf[2] = dsty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            pBuf[3] = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            pBuf[4] = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            pBuf += 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            bpos += 5 * sizeof(jint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            // apply alpha values from mask to the source tile, and store
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            // resulting IntArgbPre pixels into RenderBuffer (there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            // separate inner loops for the most common source formats)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            switch (srcType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            case sun_java2d_pipe_BufferedMaskBlit_ST_INT_ARGB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    jint w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    do {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   169
                        jint pathA = *pMask++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                        if (!pathA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                            pBuf[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                        } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   173
                            jint pixel = pSrc[0];
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   174
                            if (pathA == 0xff && (pixel >> 24) + 1 == 0) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   175
                                pBuf[0] = pixel;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   176
                            } else {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   177
                                jint r, g, b, a;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   178
                                ExtractIntDcmComponents1234(pixel, a, r, g, b);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   179
                                a = MUL8(pathA, a);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   180
                                r = MUL8(a, r);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   181
                                g = MUL8(a, g);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   182
                                b = MUL8(a, b);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   183
                                pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   184
                            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                        pSrc = PtrAddBytes(pSrc, srcPixelStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                        pBuf++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    } while (--w > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    pSrc = PtrAddBytes(pSrc, srcScanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    pMask = PtrAddBytes(pMask, maskscan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                } while (--h > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            case sun_java2d_pipe_BufferedMaskBlit_ST_INT_ARGB_PRE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    jint w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    do {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   198
                        jint pathA = *pMask++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                        if (!pathA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                            pBuf[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                        } else if (pathA == 0xff) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                            pBuf[0] = pSrc[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                        } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   204
                            jint r, g, b, a;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   205
                            a = MUL8(pathA, (pSrc[0] >> 24) & 0xff);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   206
                            r = MUL8(pathA, (pSrc[0] >> 16) & 0xff);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   207
                            g = MUL8(pathA, (pSrc[0] >>  8) & 0xff);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   208
                            b = MUL8(pathA, (pSrc[0] >>  0) & 0xff);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                            pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                        pSrc = PtrAddBytes(pSrc, srcPixelStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        pBuf++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    } while (--w > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    pSrc = PtrAddBytes(pSrc, srcScanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                    pMask = PtrAddBytes(pMask, maskscan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                } while (--h > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            case sun_java2d_pipe_BufferedMaskBlit_ST_INT_RGB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    jint w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    do {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   223
                        jint pathA = *pMask++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                        if (!pathA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                            pBuf[0] = 0;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   226
                        } else if (pathA == 0xff) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   227
                            pBuf[0] = pSrc[0] | 0xff000000;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                        } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   229
                            jint r, g, b, a;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   230
                            LoadIntRgbTo3ByteRgb(pSrc, c, 0, r, g, b);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                            a = pathA;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   232
                            r = MUL8(a, r);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   233
                            g = MUL8(a, g);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   234
                            b = MUL8(a, b);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                            pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                        pSrc = PtrAddBytes(pSrc, srcPixelStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                        pBuf++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    } while (--w > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    pSrc = PtrAddBytes(pSrc, srcScanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                    pMask = PtrAddBytes(pMask, maskscan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                } while (--h > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            case sun_java2d_pipe_BufferedMaskBlit_ST_INT_BGR:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                    jint w = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                    do {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   249
                        jint pathA = *pMask++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                        if (!pathA) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                            pBuf[0] = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                        } else {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   253
                            jint r, g, b, a;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   254
                            LoadIntBgrTo3ByteRgb(pSrc, c, 0, r, g, b);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                            a = pathA;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   256
                            r = MUL8(a, r);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   257
                            g = MUL8(a, g);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   258
                            b = MUL8(a, b);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                            pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                        pSrc = PtrAddBytes(pSrc, srcPixelStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                        pBuf++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    } while (--w > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    pSrc = PtrAddBytes(pSrc, srcScanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    pMask = PtrAddBytes(pMask, maskscan);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                } while (--h > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                // should not get here, just no-op...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            // increment current byte position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            bpos += width * height * sizeof(jint);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   276
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   277
            (*env)->ReleasePrimitiveArrayCritical(env, maskArray,
7752
bac6e958f08e 7002627: JNI Critical Arrays should be released with the original (unmodified) pointer
bae
parents: 5506
diff changeset
   278
                                                  pMaskAlloc, JNI_ABORT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    // return the current byte position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    return bpos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
}