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;
    QPixmap* pixmap;

    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 {
        const jint bytes_for_depth = 2;
        const jint bits_per_byte = 8;
        jint min_height;

        pixmap = getGraphicsBuffer(graphicsHandle);

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

#ifdef DEBUG
        printf("JSR239_putWindowContent: pixmap=%p\n", pixmap);
        printf("  pixmap Bpp = %d\n",  pixmap->depth()/bits_per_byte);
        printf("  pixmap width  = %d\n", pixmap->width());
        printf("  pixmap height = %d\n", pixmap->height());
        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, 
                           clipX, clipY, 
                           clipWidth, clipHeight, 
                           clipWidth, clipHeight,
                           flipY);

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

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

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

    KNI_EndHandles();
}
Example #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();
}
Example #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();
}