jdk/src/java.desktop/share/native/libawt/java2d/loops/Blit.c
author prr
Fri, 19 Sep 2014 09:41:05 -0700
changeset 26751 70bac69b37c9
parent 25859 jdk/src/java.desktop/share/native/libawt/sun/java2d/loops/Blit.c@3317bb8137f4
permissions -rw-r--r--
8056216: Remove "sun" directory layer from libawt and common Reviewed-by: erikj, ihse, coffeys
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20421
diff changeset
     2
 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "GraphicsPrimitiveMgr.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "Region.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "sun_java2d_loops_Blit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Class:     sun_java2d_loops_Blit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * Method:    Blit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;IIIIII)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
Java_sun_java2d_loops_Blit_Blit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    (JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     jobject srcData, jobject dstData, jobject comp, jobject clip,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
     jint srcx, jint srcy, jint dstx, jint dsty, jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    SurfaceDataOps *srcOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    SurfaceDataOps *dstOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    SurfaceDataRasInfo srcInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    SurfaceDataRasInfo dstInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    NativePrimitive *pPrim;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    CompositeInfo compInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    RegionData clipInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    jint dstFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    pPrim = GetNativePrim(env, self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    if (pPrim == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    if (pPrim->pCompType->getCompInfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        (*pPrim->pCompType->getCompInfo)(env, &compInfo, comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    if (Region_GetInfo(env, clip, &clipInfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    srcOps = SurfaceData_GetOps(env, srcData);
20421
8fab9959a1bc 8025280: [parfait] warnings from b107 for jdk.src.share.native.sun.java2d.loops: JNI exception pending, JNI critical region violation
jchen
parents: 5506
diff changeset
    63
    if (srcOps == 0) {
8fab9959a1bc 8025280: [parfait] warnings from b107 for jdk.src.share.native.sun.java2d.loops: JNI exception pending, JNI critical region violation
jchen
parents: 5506
diff changeset
    64
        return;
8fab9959a1bc 8025280: [parfait] warnings from b107 for jdk.src.share.native.sun.java2d.loops: JNI exception pending, JNI critical region violation
jchen
parents: 5506
diff changeset
    65
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    dstOps = SurfaceData_GetOps(env, dstData);
20421
8fab9959a1bc 8025280: [parfait] warnings from b107 for jdk.src.share.native.sun.java2d.loops: JNI exception pending, JNI critical region violation
jchen
parents: 5506
diff changeset
    67
    if (dstOps == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    srcInfo.bounds.x1 = srcx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    srcInfo.bounds.y1 = srcy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    srcInfo.bounds.x2 = srcx + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    srcInfo.bounds.y2 = srcy + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    dstInfo.bounds.x1 = dstx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    dstInfo.bounds.y1 = dsty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    dstInfo.bounds.x2 = dstx + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    dstInfo.bounds.y2 = dsty + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    srcx -= dstx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    srcy -= dsty;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    if (srcOps->Lock(env, srcOps, &srcInfo, pPrim->srcflags) != SD_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    dstFlags = pPrim->dstflags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    if (!Region_IsRectangular(&clipInfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        dstFlags |= SD_LOCK_PARTIAL_WRITE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    if (dstOps->Lock(env, dstOps, &dstInfo, dstFlags) != SD_SUCCESS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    SurfaceData_IntersectBlitBounds(&dstInfo.bounds, &srcInfo.bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                                    srcx, srcy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    if (!Region_IsEmpty(&clipInfo)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        srcOps->GetRasInfo(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        dstOps->GetRasInfo(env, dstOps, &dstInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        if (srcInfo.rasBase && dstInfo.rasBase) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            SurfaceDataBounds span;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            jint savesx = srcInfo.bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            jint savedx = dstInfo.bounds.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            Region_StartIteration(env, &clipInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            while (Region_NextIteration(&clipInfo, &span)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                void *pSrc = PtrCoord(srcInfo.rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                      srcx + span.x1, srcInfo.pixelStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                      srcy + span.y1, srcInfo.scanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                void *pDst = PtrCoord(dstInfo.rasBase,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                      span.x1, dstInfo.pixelStride,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                                      span.y1, dstInfo.scanStride);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                 * Fix for 4804375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                 * REMIND: There should probably be a better
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                 * way to give the span coordinates to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                 * inner loop.  This is only really needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                 * for the 1, 2, and 4 bit loops.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                srcInfo.bounds.x1 = srcx + span.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                dstInfo.bounds.x1 = span.x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                (*pPrim->funcs.blit)(pSrc, pDst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                                     span.x2 - span.x1, span.y2 - span.y1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                     &srcInfo, &dstInfo, pPrim, &compInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            Region_EndIteration(env, &clipInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            srcInfo.bounds.x1 = savesx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            dstInfo.bounds.x1 = savedx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        SurfaceData_InvokeRelease(env, dstOps, &dstInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
}