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."); } }
static void draw( EGL_OBJECT_PTR scbar ) { #if EGL_CONFIG_OBJECT_HAVE_SELF_SURFACE==1 { SURFACE* oldtarget; int old_x = scbar->rect.x; int old_y = scbar->rect.y; scbar->selfsurface = CREATE_SURFACE( scbar->rect.w, scbar->rect.h, EGL_SCREEN_BPP ); if( scbar->selfsurface == NULL ) { r_make_scbar( scbar ); return; } scbar->rect.x = scbar->rect.y = 0; oldtarget = EGL_SET_TARGET_SURFACE( scbar->selfsurface ); r_make_scbar( scbar ); EGL_SET_TARGET_SURFACE( oldtarget ); scbar->rect.x = old_x; scbar->rect.y = old_y; DRAW_SURFACE( scbar->selfsurface, scbar->rect.x, scbar->rect.y ); RELEASE_SURFACE( scbar->selfsurface ); } #else { r_make_scbar( scbar ); } #endif }
static int bmfont_close ( BMFont *pFont ) { int i; if ( pFont == 0 ) return 0; if ( pFont->chars ) { free ( pFont->chars ); } if ( pFont->surfs ) { for ( i = 0; i < pFont->pagecnt; i++ ) { SURFACE *psurf = pFont->surfs[i]; RELEASE_SURFACE( psurf ); //malloc by loadtga } free ( pFont->surfs ); } free ( pFont ); return 1; }
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(); }
static void egl_delete_scrollbar( EGL_HANDLE hObj ) { EGL_OBJECT_PTR pObj; if( hObj == NULL ) return ; pObj = ( EGL_OBJECT_PTR )hObj; delete_selfdata( pObj->selfdata ); #if EGL_CONFIG_OBJECT_HAVE_SELF_SURFACE==1 if( pObj->selfsurface ) RELEASE_SURFACE( pObj->selfsurface ); #endif prv_egl_delete_object( pObj ); }
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."); } }
static void drawchar_vright ( int x, int y, SCharDescr *ch ) { SURFACE *psurf ; SURFACE *temp; int i, k; int bpp ; if ( ch->page >= cur_pFont->pagecnt ) return; psurf = cur_pFont->surfs[ch->page]; temp = CREATE_SURFACE( ch->srcH, ch->srcW, psurf->bpp ); temp->pixtype = psurf->pixtype; if ( psurf->pal ) { temp->pal->colorkey = psurf->pal->colorkey; temp->pal->nColors = psurf->pal->nColors; memcpy ( temp->pal->colors, psurf->pal->colors, psurf->pal->nColors * 4 ); } bpp = psurf->bpp / 8; //byte per pixel if ( bpp == 4 ) { U8 *src = ( U8 * ) ( ( U32 ) psurf->pixels + ch->srcX * bpp + ch->srcY * psurf->pitch ); for ( i = 0; i < ch->srcW; i++ ) { U32 *dest = ( U32 * ) ( ( U32 ) temp->pixels + ( temp->pitch * i ) ); for ( k = 0; k < temp->w; k++ ) { U32 data = * ( U32 * ) ( src + ( ( temp->w - 1 - k ) * psurf->pitch ) ); *dest = data; dest++; } src += bpp; } } else if ( bpp == 1 ) { U8 *src = ( U8 * ) ( ( U32 ) psurf->pixels + ch->srcX * bpp + ch->srcY * psurf->pitch ); for ( i = 0; i < ch->srcW; i++ ) { U8 *dest = ( U8 * ) ( ( U32 ) temp->pixels + ( temp->pitch * i ) ); for ( k = 0; k < temp->w; k++ ) { U8 data = * ( src + ( ( temp->w - 1 - k ) * psurf->pitch ) ); *dest = data; dest++; } src ++; } } if ( cur_pFont->bAutoKerning == FALSE ) y += ( cur_pFont->fontsize - ch->xAdv + ch->xOff ) / 2; DRAW_SURFACE_SCALE_RECT ( temp, x + cur_pFont->fontHeight - ch->yOff - ch->srcH , y + ch->xOff, temp->w, temp->h, 0, 0, temp->w, temp->h ); RELEASE_SURFACE( temp ); }
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(); }