Changeset 62018a0 in mainline for uspace/srv/hid/display/cursor.c


Ignore:
Timestamp:
2020-06-24T12:32:04Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8630748
Parents:
2fc1e6d
git-author:
Jiri Svoboda <jiri@…> (2020-06-23 18:31:47)
git-committer:
Jiri Svoboda <jiri@…> (2020-06-24 12:32:04)
Message:

Properly clip cursor when repainting a part of the display

Not doing so was causing excessively large update rectangles, increasing
CPU usage and display artifacts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/cursor.c

    r2fc1e6d r62018a0  
    8989 * @param cursor Cusor to paint
    9090 * @param pos Position to paint at
     91 * @param clip Clipping rectangle or @c NULL
    9192 * @return EOK on success or an error code
    9293 */
    93 errno_t ds_cursor_paint(ds_cursor_t *cursor, gfx_coord2_t *pos)
     94errno_t ds_cursor_paint(ds_cursor_t *cursor, gfx_coord2_t *pos,
     95    gfx_rect_t *clip)
    9496{
    9597        gfx_context_t *dgc;
     
    98100        gfx_bitmap_alloc_t alloc;
    99101        gfx_coord2_t dims;
     102        gfx_rect_t sclip;
     103        gfx_rect_t srect;
    100104        pixelmap_t pixelmap;
    101105        pixel_t pixel;
     
    150154        }
    151155
    152         return gfx_bitmap_render(cursor->bitmap, NULL, pos);
     156        /* Determine source rectangle */
     157        if (clip == NULL) {
     158                srect = cursor->rect;
     159        } else {
     160                gfx_rect_rtranslate(pos, clip, &sclip);
     161                gfx_rect_clip(&cursor->rect, &sclip, &srect);
     162        }
     163
     164        if (!gfx_rect_is_empty(&srect)) {
     165                rc = gfx_bitmap_render(cursor->bitmap, &srect, pos);
     166                if (rc != EOK)
     167                        return rc;
     168        }
     169
     170        return EOK;
    153171error:
    154172        return rc;
Note: See TracChangeset for help on using the changeset viewer.