JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_beginRenderingIIIII(JNIEnv* env, jobject objectHandle, jint minX, jint minY, jint width, jint height, jint windingRule) { Renderer* rdr; Surface* surface; jobject surfaceHandle; rdr = (Renderer*)JLongToPointer( (*env)->GetLongField(env, objectHandle, fieldIds[RENDERER_NATIVE_PTR])); SURFACE_FROM_RENDERER(surface, env, surfaceHandle, objectHandle); ACQUIRE_SURFACE(surface, env, surfaceHandle); INVALIDATE_RENDERER_SURFACE(rdr); renderer_beginRendering5(rdr, minX, minY, width, height, windingRule); RELEASE_SURFACE(surface, env, surfaceHandle); if (JNI_TRUE == readAndClearMemErrorFlag()) { JNI_ThrowNew(env, "java/lang/OutOfMemoryError", "Allocation of internal renderer buffer failed."); } }
KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_pisces_AbstractSurface_drawSurfaceImpl() { KNI_StartHandles(2); KNI_DeclareHandle(objectHandle); KNI_DeclareHandle(surfaceHandle); jint srcX = KNI_GetParameterAsInt(2); jint srcY = KNI_GetParameterAsInt(3); jint dstX = KNI_GetParameterAsInt(4); jint dstY = KNI_GetParameterAsInt(5); jint width = KNI_GetParameterAsInt(6); jint height = KNI_GetParameterAsInt(7); jfloat opacity = KNI_GetParameterAsFloat(8); Surface* dstSurface; Surface* srcSurface; KNI_GetThisPointer(objectHandle); dstSurface = (Surface*)JLongToPointer( KNI_GetLongField(objectHandle, fieldIds[SURFACE_NATIVE_PTR])); KNI_GetParameterAsObject(1, surfaceHandle); srcSurface = (Surface*)JLongToPointer( KNI_GetLongField(surfaceHandle, fieldIds[SURFACE_NATIVE_PTR])); CORRECT_DIMS(dstSurface, dstX, dstY, width, height, srcX, srcY); CORRECT_DIMS(srcSurface, srcX, srcY, width, height, dstX, dstY); if ((width > 0) && (height > 0) && (opacity > 0)) { ACQUIRE_SURFACE(dstSurface, objectHandle); ACQUIRE_SURFACE(srcSurface, surfaceHandle); surface_drawSurface(dstSurface, dstX, dstY, width, height, srcSurface, srcX, srcY, opacity); RELEASE_SURFACE(srcSurface, surfaceHandle); RELEASE_SURFACE(dstSurface, objectHandle); } KNI_EndHandles(); KNI_ReturnVoid(); }
KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_pisces_AbstractSurface_drawRGBImpl() { KNI_StartHandles(2); KNI_DeclareHandle(objectHandle); KNI_DeclareHandle(arrayHandle); jint offset = KNI_GetParameterAsInt(2); jint scanLength = KNI_GetParameterAsInt(3); jint x = KNI_GetParameterAsInt(4); jint y = KNI_GetParameterAsInt(5); jint width = KNI_GetParameterAsInt(6); jint height = KNI_GetParameterAsInt(7); jfloat opacity = KNI_GetParameterAsFloat(8); jint srcX = 0; jint srcY = 0; Surface* surface; KNI_GetParameterAsObject(1, arrayHandle); KNI_GetThisPointer(objectHandle); surface = (Surface*)JLongToPointer( KNI_GetLongField(objectHandle, fieldIds[SURFACE_NATIVE_PTR])); CORRECT_DIMS(surface, x, y, width, height, srcX, srcY); if ((width > 0) && (height > 0)) { jint* tempArray; offset += srcY * scanLength + srcX; SNI_BEGIN_RAW_POINTERS; tempArray = &JavaIntArray(arrayHandle)[offset]; ACQUIRE_SURFACE(surface, objectHandle); surface_drawRGB(surface, x, y, width, height, tempArray, scanLength, opacity); RELEASE_SURFACE(surface, objectHandle); SNI_END_RAW_POINTERS; } KNI_EndHandles(); KNI_ReturnVoid(); }
JNIEXPORT void JNICALL Java_com_sun_pisces_PiscesRenderer_drawLine(JNIEnv* env, jobject objectHandle, jint x0, jint y0, jint x1, jint y1) { Renderer* rdr; Surface* surface; jobject surfaceHandle; rdr = (Renderer*)JLongToPointer( (*env)->GetLongField(env, objectHandle, fieldIds[RENDERER_NATIVE_PTR])); SURFACE_FROM_RENDERER(surface, env, surfaceHandle, objectHandle); ACQUIRE_SURFACE(surface, env, surfaceHandle); INVALIDATE_RENDERER_SURFACE(rdr); renderer_drawLine(rdr, x0, y0, x1, y1); RELEASE_SURFACE(surface, env, surfaceHandle); if (JNI_TRUE == readAndClearMemErrorFlag()) { JNI_ThrowNew(env, "java/lang/OutOfMemoryError", "Allocation of internal renderer buffer failed."); } }
KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_pisces_AbstractSurface_getRGB() { KNI_StartHandles(2); KNI_DeclareHandle(objectHandle); KNI_DeclareHandle(arrayHandle); jint offset = KNI_GetParameterAsInt(2); jint scanLength = KNI_GetParameterAsInt(3); jint x = KNI_GetParameterAsInt(4); jint y = KNI_GetParameterAsInt(5); jint width = KNI_GetParameterAsInt(6); jint height = KNI_GetParameterAsInt(7); jint dstX = 0; jint dstY = 0; Surface* surface; KNI_GetParameterAsObject(1, arrayHandle); KNI_GetThisPointer(objectHandle); surface = (Surface*)JLongToPointer( KNI_GetLongField(objectHandle, fieldIds[SURFACE_NATIVE_PTR])); CORRECT_DIMS(surface, x, y, width, height, dstX, dstY); if ((width > 0) && (height > 0)) { jint size = ((height - 1) * scanLength + width) * sizeof(jint); jint* tempArray = (jint*)PISCESmalloc(size); if (NULL == tempArray) { KNI_ThrowNew("java/lang/OutOfMemoryError", "Allocation of temporary renderer memory buffer failed."); } else { jint* src; jint* dst; jint srcScanRest = surface->width - width; jint dstScanRest = scanLength - width; ACQUIRE_SURFACE(surface, objectHandle); src = (jint*)surface->data + y * surface->width + x; dst = tempArray; for (; height > 0; --height) { jint w2 = width; for (; w2 > 0; --w2) { *dst++ = *src++; } src += srcScanRest; dst += dstScanRest; } offset += dstY * scanLength + dstX; KNI_SetRawArrayRegion(arrayHandle, offset * sizeof(jint), size, (const jbyte*)tempArray); RELEASE_SURFACE(surface, objectHandle); PISCESfree(tempArray); } } KNI_EndHandles(); KNI_ReturnVoid(); }