src/share/native/sun/java2d/pipe/BufferedMaskBlit.c

Print this page




 102     srcInfo.bounds.y2 = srcy + height;
 103 
 104     if (srcOps->Lock(env, srcOps, &srcInfo, SD_LOCK_READ) != SD_SUCCESS) {
 105         J2dRlsTraceLn(J2D_TRACE_WARNING,
 106                       "BufferedMaskBlit_enqueueTile: could not acquire lock");
 107         return bpos;
 108     }
 109 
 110     if (srcInfo.bounds.x2 > srcInfo.bounds.x1 &&
 111         srcInfo.bounds.y2 > srcInfo.bounds.y1)
 112     {
 113         srcOps->GetRasInfo(env, srcOps, &srcInfo);
 114         if (srcInfo.rasBase) {
 115             jint h;
 116             jint srcScanStride = srcInfo.scanStride;
 117             jint srcPixelStride = srcInfo.pixelStride;
 118             jint *pSrc = (jint *)
 119                 PtrCoord(srcInfo.rasBase,
 120                          srcInfo.bounds.x1, srcInfo.pixelStride,
 121                          srcInfo.bounds.y1, srcInfo.scanStride);
 122             unsigned char *pMask =

 123                 (*env)->GetPrimitiveArrayCritical(env, maskArray, 0);
 124             if (pMask == NULL) {
 125                 J2dRlsTraceLn(J2D_TRACE_ERROR,
 126                     "BufferedMaskBlit_enqueueTile: cannot lock mask array");
 127                 SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
 128                 SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
 129                 return bpos;
 130             }
 131 
 132             width = srcInfo.bounds.x2 - srcInfo.bounds.x1;
 133             height = srcInfo.bounds.y2 - srcInfo.bounds.y1;
 134             maskoff += ((srcInfo.bounds.y1 - srcy) * maskscan +
 135                         (srcInfo.bounds.x1 - srcx));
 136             maskscan -= width;
 137             pMask += maskoff;
 138             srcScanStride -= width * srcPixelStride;
 139             h = height;
 140 
 141             J2dTraceLn4(J2D_TRACE_VERBOSE,
 142                         "  sx=%d sy=%d w=%d h=%d",


 257                             b = MUL8(a, b);
 258                             pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
 259                         }
 260                         pSrc = PtrAddBytes(pSrc, srcPixelStride);
 261                         pBuf++;
 262                     } while (--w > 0);
 263                     pSrc = PtrAddBytes(pSrc, srcScanStride);
 264                     pMask = PtrAddBytes(pMask, maskscan);
 265                 } while (--h > 0);
 266                 break;
 267 
 268             default:
 269                 // should not get here, just no-op...
 270                 break;
 271             }
 272 
 273             // increment current byte position
 274             bpos += width * height * sizeof(jint);
 275 
 276             (*env)->ReleasePrimitiveArrayCritical(env, maskArray,
 277                                                   pMask, JNI_ABORT);
 278         }
 279         SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
 280     }
 281     SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
 282 
 283     // return the current byte position
 284     return bpos;
 285 }


 102     srcInfo.bounds.y2 = srcy + height;
 103 
 104     if (srcOps->Lock(env, srcOps, &srcInfo, SD_LOCK_READ) != SD_SUCCESS) {
 105         J2dRlsTraceLn(J2D_TRACE_WARNING,
 106                       "BufferedMaskBlit_enqueueTile: could not acquire lock");
 107         return bpos;
 108     }
 109 
 110     if (srcInfo.bounds.x2 > srcInfo.bounds.x1 &&
 111         srcInfo.bounds.y2 > srcInfo.bounds.y1)
 112     {
 113         srcOps->GetRasInfo(env, srcOps, &srcInfo);
 114         if (srcInfo.rasBase) {
 115             jint h;
 116             jint srcScanStride = srcInfo.scanStride;
 117             jint srcPixelStride = srcInfo.pixelStride;
 118             jint *pSrc = (jint *)
 119                 PtrCoord(srcInfo.rasBase,
 120                          srcInfo.bounds.x1, srcInfo.pixelStride,
 121                          srcInfo.bounds.y1, srcInfo.scanStride);
 122             unsigned char *pMask, *pMaskAlloc;
 123             pMask = pMaskAlloc =
 124                 (*env)->GetPrimitiveArrayCritical(env, maskArray, 0);
 125             if (pMask == NULL) {
 126                 J2dRlsTraceLn(J2D_TRACE_ERROR,
 127                     "BufferedMaskBlit_enqueueTile: cannot lock mask array");
 128                 SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
 129                 SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
 130                 return bpos;
 131             }
 132 
 133             width = srcInfo.bounds.x2 - srcInfo.bounds.x1;
 134             height = srcInfo.bounds.y2 - srcInfo.bounds.y1;
 135             maskoff += ((srcInfo.bounds.y1 - srcy) * maskscan +
 136                         (srcInfo.bounds.x1 - srcx));
 137             maskscan -= width;
 138             pMask += maskoff;
 139             srcScanStride -= width * srcPixelStride;
 140             h = height;
 141 
 142             J2dTraceLn4(J2D_TRACE_VERBOSE,
 143                         "  sx=%d sy=%d w=%d h=%d",


 258                             b = MUL8(a, b);
 259                             pBuf[0] = (a << 24) | (r << 16) | (g << 8) | b;
 260                         }
 261                         pSrc = PtrAddBytes(pSrc, srcPixelStride);
 262                         pBuf++;
 263                     } while (--w > 0);
 264                     pSrc = PtrAddBytes(pSrc, srcScanStride);
 265                     pMask = PtrAddBytes(pMask, maskscan);
 266                 } while (--h > 0);
 267                 break;
 268 
 269             default:
 270                 // should not get here, just no-op...
 271                 break;
 272             }
 273 
 274             // increment current byte position
 275             bpos += width * height * sizeof(jint);
 276 
 277             (*env)->ReleasePrimitiveArrayCritical(env, maskArray,
 278                                                   pMaskAlloc, JNI_ABORT);
 279         }
 280         SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
 281     }
 282     SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
 283 
 284     // return the current byte position
 285     return bpos;
 286 }