예제 #1
0
void JSR239_getWindowContents(JSR239_Pixmap *dst,
                              jobject srcGraphicsHandle, 
                              jint srcWidth, jint srcHeight,
                              jint deltaHeight) {

    QPixmap* pixmap;
    void* src;

    KNI_StartHandles(1);
    KNI_DeclareHandle(GraphicsClassHandle);

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

    KNI_FindClass("javax/microedition/lcdui/Graphics", GraphicsClassHandle);

    if (!KNI_IsInstanceOf(graphicsHandle, GraphicsClassHandle)) {
#ifdef DEBUG
        printf("JSR239_getWindowContents only implemented for graphicsHandle "
                "instanceof Graphics!\n");
#endif
    } else {
        pixmap = getGraphicsBuffer(graphicsHandle);

#ifdef DEBUG
        printf("JSR239_getWindowContents: pixmap=%p\n", pixmap);
        printf("  pixmap Bpp = %d\n", pixmap->depth()/8);
        printf("  pixmap width  = %d\n", pixmap->width());
        printf("  pixmap height = %d\n", pixmap->height());
        printf("  dst Bpp = %d\n", dst->pixelBytes);
        printf("  dst width  = %d\n", dst->width);
        printf("  dst height = %d\n", dst->height);
#endif

        src = (void*)pixmap->scanLine(0);

        /* IMPL_NOTE: get clip sizes into account. */
        copyFromScreenBuffer(dst,
                             src, srcWidth, srcHeight,
                             deltaHeight);
    }

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

    KNI_EndHandles();
}
예제 #2
0
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();
}