Esempio n. 1
0
/**
 * Helper function.
 * Retrieve buffer for the specified graphics.
 *
 * @param graphicshandle   A KNI handle to a graphics object.
 * @return A pointer to the graphics buffer.
 */
static gxj_pixel_type* getGraphicsBuffer(jobject graphicsHandle) {
    gxj_screen_buffer sbuf;
    gxj_screen_buffer* gimg;
    gxj_pixel_type* dbuffer;

    gimg = GXJ_GET_GRAPHICS_SCREEN_BUFFER(graphicsHandle, &sbuf);
    if (gimg == NULL) {
        dbuffer = gxj_system_screen_buffer.pixelData;
    } else {
        dbuffer = gimg->pixelData;
    }

    return dbuffer;
}
Esempio n. 2
0
/* Copy engine buffer back to MIDP */
void
JSR239_putWindowContents(jobject graphicsHandle,
                         jint delta_height,
                         JSR239_Pixmap *src, jint flipY) {

    void* s;
    void* d;

    KNI_StartHandles(1);
    KNI_DeclareHandle(GraphicsClassHandle);

#ifdef DEBUG
    printf("JSR239_putWindowContents >>\n");
#endif

    KNI_FindClass("javax/microedition/lcdui/Graphics", GraphicsClassHandle);
    if (!KNI_IsInstanceOf(graphicsHandle, GraphicsClassHandle)) {
#ifdef DEBUG
        printf("JSR239_putWindowContents only implemented for graphicsHandle "
               "instanceof Graphics!\n");
#endif
    } else {
        gxj_screen_buffer sbuf;
        gxj_screen_buffer* gimg;

        // Obtain the dimensions of the destination.
        jint dest_width = lcdlf_get_screen_width();
        jint dest_height = lcdlf_get_screen_height();

        jint min_height = 0;
        
        gimg = GXJ_GET_GRAPHICS_SCREEN_BUFFER(graphicsHandle, &sbuf);
        if (gimg != NULL) {
            dest_width = gimg->width;
            dest_height= gimg->height;
        }

#ifdef DEBUG
        printf("JSR239_putWindowContents:\n"); 
        printf("  src Bpp    = %d\n", src->pixelBytes);
        printf("  src width  = %d\n", src->width);
        printf("  src height = %d\n", src->height);
        printf("  min height = %d\n", min_height);
#endif

        /* IMPL_NOTE: get clip sizes into account. */
        copyToScreenBuffer(src, delta_height, flipY);

        /* src->screen_buffer is an output of copyToScreenBuffer function. */
        s = (void*)src->screen_buffer;
        d = (void*)getGraphicsBuffer(graphicsHandle);

        min_height = (dest_height > src->height) ? src->height : dest_height;

        if ((src->width  != dest_width) ||
            (sizeof(gxj_pixel_type) != 2)) {
#ifdef DEBUG
        printf("JSR239: offscreen buffer data is incorrect.\n");
#endif
        } else {
            /* Source data must be in 16bit 565 format. */
            JSR239_memcpy(d, s,
                dest_width * min_height * sizeof(gxj_pixel_type));
        }
    }

#ifdef DEBUG
    printf("JSR239_putWindowContents <<\n");
#endif

    KNI_EndHandles();
}
Esempio n. 3
0
/* Copy engine buffer back to MIDP */
void
JSR239_putWindowContents(jobject graphicsHandle,
                         jint delta_height,
                         JSR239_Pixmap *src, 
                         jint clipX, jint clipY, 
                         jint clipWidth, jint clipHeight,
                         jint flipY) {

    void* s;
    void* d;

    KNI_StartHandles(1);
    KNI_DeclareHandle(GraphicsClassHandle);

#ifdef DEBUG
    printf("JSR239_putWindowContents >>\n");
#endif

    KNI_FindClass("javax/microedition/lcdui/Graphics", GraphicsClassHandle);
    if (!KNI_IsInstanceOf(graphicsHandle, GraphicsClassHandle)) {
#ifdef DEBUG
        printf("JSR239_putWindowContents only implemented for graphicsHandle "
               "instanceof Graphics!\n");
#endif
    } else {
        gxj_screen_buffer sbuf;
        gxj_screen_buffer* gimg;

        // Obtain the dimensions of the destination.
        // Revisit: multiple displays support. Obtain Id of display render surfane is
        // bound to. Consider recalculations when display got changed.
        int displayId    = lcdlf_get_current_hardwareId();
        jint dest_width  = lcdlf_get_screen_width(displayId);
        jint dest_height = lcdlf_get_screen_height(displayId);
        jint min_height  = 0;
        gxj_pixel_type* srcPtr;
        gxj_pixel_type* dstPtr;
        
        gimg = GXJ_GET_GRAPHICS_SCREEN_BUFFER(graphicsHandle, &sbuf);
        if (gimg != NULL) {
            dest_width = gimg->width;
            dest_height= gimg->height;
        }                

        /* src->screen_buffer is an output of copyToScreenBuffer function. */
        s = (void*)src->screen_buffer;
        d = (void*)getGraphicsBuffer(graphicsHandle);

        min_height = (dest_height > src->height) ? src->height : dest_height;

#ifdef DEBUG
        printf("JSR239_putWindowContents:\n"); 
        printf("  src        = %d\n", src->pixels);
        printf("  src Bpp    = %d\n", src->pixelBytes);
        printf("  src width  = %d\n", src->width);
        printf("  src height = %d\n", src->height);
        printf("  min height = %d\n", min_height);
        printf("  dst        = %d\n", d);     
        printf("  dst width  = %d\n", clipWidth);
        printf("  dst height = %d\n", clipHeight);
#endif

        srcPtr = (gxj_pixel_type *)s;
        dstPtr = (gxj_pixel_type *)d;

        if ((dest_width * min_height <= src->width * src->height) && 
            (sizeof(gxj_pixel_type) == 2)) {
            /* Source data must be in 16bit 565 format. */
           JSR239_memcpy(s, d,
               dest_width * min_height * sizeof(gxj_pixel_type));

           /* IMPL_NOTE: get clip sizes into account. */
           copyToScreenBuffer(src, delta_height, 
                              clipX, clipY, clipWidth, clipHeight,
                              dest_width, dest_height,
                              flipY);

            /* Source data must be in 16bit 565 format. */
           JSR239_memcpy(d, s,
               dest_width * min_height * sizeof(gxj_pixel_type));        
        } else {
#ifdef DEBUG
        printf("JSR239: offscreen buffer data is incorrect.\n");
#endif
        }
    }

#ifdef DEBUG
    printf("JSR239_putWindowContents <<\n");
#endif

    KNI_EndHandles();
}