Changeset bea947f in mainline for uspace/srv/hid/rfb/main.c


Ignore:
Timestamp:
2020-05-24T17:59:02Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b3b00b6
Parents:
ef20a91
Message:

Implement bitmap color key to allow transparent cursor background

This seems to be the simplest solution of them all. It will work
on any bit depth except 1 bit per pixel (monochrome), where we would
need to extend the bitmap with a bit mask instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/rfb/main.c

    ref20a91 rbea947f  
    7272        gfx_bitmap_alloc_t alloc;
    7373        gfx_rect_t rect;
     74        gfx_bitmap_flags_t flags;
     75        pixel_t key_color;
    7476        bool myalloc;
    7577} rfb_bitmap_t;
     
    199201        gfx_coord2_subtract(&params->rect.p1, &params->rect.p0, &dim);
    200202        rfbbm->rect = params->rect;
     203        rfbbm->flags = params->flags;
     204        rfbbm->key_color = params->key_color;
    201205
    202206        if (alloc == NULL) {
     
    278282        pbm.data = rfbbm->alloc.pixels;
    279283
    280         for (y = srect.p0.y; y < srect.p1.y; y++) {
    281                 for (x = srect.p0.x; x < srect.p1.x; x++) {
    282                         color = pixelmap_get_pixel(&pbm, x, y);
    283                         pixelmap_put_pixel(&rfbbm->rfb->rfb.framebuffer,
    284                             x + offs.x, y + offs.y, color);
     284        if ((rfbbm->flags & bmpf_color_key) == 0) {
     285                for (y = srect.p0.y; y < srect.p1.y; y++) {
     286                        for (x = srect.p0.x; x < srect.p1.x; x++) {
     287                                color = pixelmap_get_pixel(&pbm, x, y);
     288                                pixelmap_put_pixel(&rfbbm->rfb->rfb.framebuffer,
     289                                    x + offs.x, y + offs.y, color);
     290                        }
     291                }
     292        } else {
     293                for (y = srect.p0.y; y < srect.p1.y; y++) {
     294                        for (x = srect.p0.x; x < srect.p1.x; x++) {
     295                                color = pixelmap_get_pixel(&pbm, x, y);
     296                                if (color != rfbbm->key_color) {
     297                                        pixelmap_put_pixel(&rfbbm->rfb->rfb.framebuffer,
     298                                            x + offs.x, y + offs.y, color);
     299                                }
     300                        }
    285301                }
    286302        }
Note: See TracChangeset for help on using the changeset viewer.