/* private native int _eglCopyBuffers ( int display , int surface , Graphics target ) ; */ KNIEXPORT KNI_RETURNTYPE_INT Java_javax_microedition_khronos_egl_EGL10Impl__1eglCopyBuffers() { EGLDisplay display = (EGLDisplay) KNI_GetParameterAsInt(1); EGLSurface surface = (EGLSurface) KNI_GetParameterAsInt(2); jint width = KNI_GetParameterAsInt(4); jint height = KNI_GetParameterAsInt(5); jint flip = 0; JSR239_Pixmap *pixmap = (JSR239_Pixmap *) 0; EGLBoolean returnValue = EGL_FALSE; KNI_StartHandles(1); KNI_DeclareHandle(graphicsHandle); KNI_GetParameterAsObject(3, graphicsHandle); returnValue = (jint)eglCopyBuffers((EGLDisplay) display, (EGLSurface) surface, (NativePixmapType) pixmap); #ifdef DEBUG printf("eglCopyBuffers(0x%x, 0x%x, 0x%x) = %d\n", display, surface, pixmap, returnValue); #endif /* Workaround - use glReadPixels if eglCopyBuffers fails. */ if (returnValue == EGL_FALSE) { pixmap = JSR239_getImagePixmap(graphicsHandle, width, height, 4, 8, 8, 8, 8); if (!pixmap) { KNI_ThrowNew("java.lang.OutOfMemoryException", "eglCopyBuffers"); goto exit; } // Enforce RGBA order of glReadPixels pixmap->aOffset = 24; pixmap->bOffset = 16; pixmap->gOffset = 8; pixmap->rOffset = 0; returnValue = eglCopyBuffersWorkaround((EGLDisplay) display, (EGLSurface) surface, pixmap); flip = 1; } if (returnValue == EGL_TRUE) { JSR239_putWindowContents(graphicsHandle, pixmap, flip); } if (pixmap) { JSR239_destroyPixmap(pixmap); } exit: KNI_EndHandles(); KNI_ReturnInt((jint)returnValue); }
/* private native int getImagePixmap( int displayId , int configId , Graphics imageGraphics , int width , int height ) ; */ KNIEXPORT KNI_RETURNTYPE_INT Java_javax_microedition_khronos_egl_EGL10Impl__1getImagePixmap() { jint displayId = KNI_GetParameterAsInt(1); jint configId = KNI_GetParameterAsInt(2); jint width = KNI_GetParameterAsInt(4); jint height = KNI_GetParameterAsInt(5); jint returnValue; EGLDisplay display = (EGLDisplay)displayId; EGLConfig config = (EGLConfig)configId; EGLint redSize, greenSize, blueSize, alphaSize, bufferSize; KNI_StartHandles(1); KNI_DeclareHandle(graphicsHandle); KNI_GetParameterAsObject(3, graphicsHandle); eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); eglGetConfigAttrib(display, config, EGL_BUFFER_SIZE, &bufferSize); returnValue = (jint)JSR239_getImagePixmap(graphicsHandle, width, height, (jint)((bufferSize + 7)/8), (jint)redSize, (jint)greenSize, (jint)blueSize, (jint)alphaSize); #ifdef DEBUG printf("JSR239_getImagePixmap(0x%x, %d, %d, %d, %d, %d, %d) = 0x%x\n", graphicsHandle, width, height, redSize, greenSize, blueSize, alphaSize, returnValue); #endif KNI_EndHandles(); KNI_ReturnInt(returnValue); }