J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun in the LICENSE file that accompanied this code. |
| 10 | * |
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | * version 2 for more details (a copy is included in the LICENSE file that |
| 15 | * accompanied this code). |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License version |
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | #include "GraphicsPrimitiveMgr.h" |
| 27 | |
| 28 | #include "sun_java2d_loops_MaskFill.h" |
| 29 | |
| 30 | /* |
| 31 | * Class: sun_java2d_loops_MaskFill |
| 32 | * Method: MaskFill |
| 33 | * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Ljava/awt/Composite;IIII[BII)V |
| 34 | */ |
| 35 | JNIEXPORT void JNICALL |
| 36 | Java_sun_java2d_loops_MaskFill_MaskFill |
| 37 | (JNIEnv *env, jobject self, |
| 38 | jobject sg2d, jobject sData, jobject comp, |
| 39 | jint x, jint y, jint w, jint h, |
| 40 | jbyteArray maskArray, jint maskoff, jint maskscan) |
| 41 | { |
| 42 | SurfaceDataOps *sdOps; |
| 43 | SurfaceDataRasInfo rasInfo; |
| 44 | NativePrimitive *pPrim; |
| 45 | CompositeInfo compInfo; |
| 46 | |
| 47 | pPrim = GetNativePrim(env, self); |
| 48 | if (pPrim == NULL) { |
| 49 | return; |
| 50 | } |
| 51 | if (pPrim->pCompType->getCompInfo != NULL) { |
| 52 | (*pPrim->pCompType->getCompInfo)(env, &compInfo, comp); |
| 53 | } |
| 54 | |
| 55 | sdOps = SurfaceData_GetOps(env, sData); |
| 56 | if (sdOps == 0) { |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | rasInfo.bounds.x1 = x; |
| 61 | rasInfo.bounds.y1 = y; |
| 62 | rasInfo.bounds.x2 = x + w; |
| 63 | rasInfo.bounds.y2 = y + h; |
| 64 | if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) { |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | if (rasInfo.bounds.x2 > rasInfo.bounds.x1 && |
| 69 | rasInfo.bounds.y2 > rasInfo.bounds.y1) |
| 70 | { |
| 71 | jint color = GrPrim_Sg2dGetEaRGB(env, sg2d); |
| 72 | sdOps->GetRasInfo(env, sdOps, &rasInfo); |
| 73 | if (rasInfo.rasBase) { |
| 74 | jint width = rasInfo.bounds.x2 - rasInfo.bounds.x1; |
| 75 | jint height = rasInfo.bounds.y2 - rasInfo.bounds.y1; |
| 76 | void *pDst = PtrCoord(rasInfo.rasBase, |
| 77 | rasInfo.bounds.x1, rasInfo.pixelStride, |
| 78 | rasInfo.bounds.y1, rasInfo.scanStride); |
| 79 | unsigned char *pMask = |
| 80 | (maskArray |
| 81 | ? (*env)->GetPrimitiveArrayCritical(env, maskArray, 0) |
| 82 | : 0); |
| 83 | maskoff += ((rasInfo.bounds.y1 - y) * maskscan + |
| 84 | (rasInfo.bounds.x1 - x)); |
| 85 | (*pPrim->funcs.maskfill)(pDst, |
| 86 | pMask, maskoff, maskscan, |
| 87 | width, height, |
| 88 | color, &rasInfo, |
| 89 | pPrim, &compInfo); |
| 90 | if (pMask) { |
| 91 | (*env)->ReleasePrimitiveArrayCritical(env, maskArray, |
| 92 | pMask, JNI_ABORT); |
| 93 | } |
| 94 | } |
| 95 | SurfaceData_InvokeRelease(env, sdOps, &rasInfo); |
| 96 | } |
| 97 | SurfaceData_InvokeUnlock(env, sdOps, &rasInfo); |
| 98 | } |