Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1215db9 in mainline for uspace/lib/memgfx/src/memgc.c


Ignore:
Timestamp:
2021-06-26T23:30:18Z (5 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
e87415e6
Parents:
bb14312
Message:

Memory GC needs to be able to forward cursor control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/memgfx/src/memgc.c

    rbb14312 r1215db9  
    5757static errno_t mem_gc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
    5858static errno_t mem_gc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
     59static errno_t mem_gc_cursor_get_pos(void *, gfx_coord2_t *);
     60static errno_t mem_gc_cursor_set_pos(void *, gfx_coord2_t *);
     61static errno_t mem_gc_cursor_set_visible(void *, bool);
    5962static void mem_gc_invalidate_rect(mem_gc_t *, gfx_rect_t *);
    6063
     
    6770        .bitmap_destroy = mem_gc_bitmap_destroy,
    6871        .bitmap_render = mem_gc_bitmap_render,
    69         .bitmap_get_alloc = mem_gc_bitmap_get_alloc
     72        .bitmap_get_alloc = mem_gc_bitmap_get_alloc,
     73        .cursor_get_pos = mem_gc_cursor_get_pos,
     74        .cursor_set_pos = mem_gc_cursor_set_pos,
     75        .cursor_set_visible = mem_gc_cursor_set_visible
    7076};
    7177
     
    152158        mem_gc_t *mgc = (mem_gc_t *) arg;
    153159
    154         mgc->update(mgc->cb_arg);
     160        mgc->cb->update(mgc->cb_arg);
    155161        return EOK;
    156162}
     
    162168 * @param rect Bounding rectangle
    163169 * @param alloc Allocation info
    164  * @param update_cb Function called to update a rectangle
    165  * @param cb_arg Argument to callback function
     170 * @param cb Pointer to memory GC callbacks
     171 * @param cb_arg Argument to callback functions
    166172 * @param rgc Place to store pointer to new memory GC
    167173 *
     
    169175 */
    170176errno_t mem_gc_create(gfx_rect_t *rect, gfx_bitmap_alloc_t *alloc,
    171     mem_gc_invalidate_cb_t invalidate_cb, mem_gc_update_cb_t update_cb,
    172     void *cb_arg, mem_gc_t **rgc)
     177    mem_gc_cb_t *cb, void *cb_arg, mem_gc_t **rgc)
    173178{
    174179        mem_gc_t *mgc = NULL;
     
    191196        mgc->alloc = *alloc;
    192197
    193         mgc->invalidate = invalidate_cb;
    194         mgc->update = update_cb;
     198        mgc->cb = cb;
    195199        mgc->cb_arg = cb_arg;
    196200
     
    246250static void mem_gc_invalidate_rect(mem_gc_t *mgc, gfx_rect_t *rect)
    247251{
    248         mgc->invalidate(mgc->cb_arg, rect);
     252        mgc->cb->invalidate(mgc->cb_arg, rect);
    249253}
    250254
     
    464468}
    465469
     470/** Get cursor position on memory GC.
     471 *
     472 * @param arg Memory GC
     473 * @param pos Place to store position
     474 *
     475 * @return EOK on success or an error code
     476 */
     477static errno_t mem_gc_cursor_get_pos(void *arg, gfx_coord2_t *pos)
     478{
     479        mem_gc_t *mgc = (mem_gc_t *) arg;
     480
     481        if (mgc->cb->cursor_get_pos != NULL)
     482                return mgc->cb->cursor_get_pos(mgc->cb_arg, pos);
     483        else
     484                return ENOTSUP;
     485}
     486
     487/** Set cursor position on memory GC.
     488 *
     489 * @param arg Memory GC
     490 * @param pos New position
     491 *
     492 * @return EOK on success or an error code
     493 */
     494static errno_t mem_gc_cursor_set_pos(void *arg, gfx_coord2_t *pos)
     495{
     496        mem_gc_t *mgc = (mem_gc_t *) arg;
     497
     498        if (mgc->cb->cursor_set_pos != NULL)
     499                return mgc->cb->cursor_set_pos(mgc->cb_arg, pos);
     500        else
     501                return ENOTSUP;
     502}
     503
     504/** Set cursor visibility on memory GC.
     505 *
     506 * @param arg Memory GC
     507 * @param visible @c true iff cursor should be made visible
     508 *
     509 * @return EOK on success or an error code
     510 */
     511static errno_t mem_gc_cursor_set_visible(void *arg, bool visible)
     512{
     513        mem_gc_t *mgc = (mem_gc_t *) arg;
     514
     515        if (mgc->cb->cursor_set_visible != NULL)
     516                return mgc->cb->cursor_set_visible(mgc->cb_arg, visible);
     517        else
     518                return ENOTSUP;
     519}
     520
    466521/** @}
    467522 */
Note: See TracChangeset for help on using the changeset viewer.