Changeset 2ab8ab3 in mainline for uspace/lib/gfx


Ignore:
Timestamp:
2021-02-16T18:12:05Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
68a552f
Parents:
ef734b7
Message:

Client-side UI rendering

It is possible to turn on and off and if turned on, one can also
enable or disable window double buffering (currently both options
are build-time).

Location:
uspace/lib/gfx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfx/include/gfx/render.h

    ref734b7 r2ab8ab3  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444extern errno_t gfx_set_color(gfx_context_t *, gfx_color_t *);
    4545extern errno_t gfx_fill_rect(gfx_context_t *, gfx_rect_t *);
     46extern errno_t gfx_update(gfx_context_t *);
    4647
    4748#endif
  • uspace/lib/gfx/include/types/gfx/ops/context.h

    ref734b7 r2ab8ab3  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5151        /** Fill rectangle using the current drawing color */
    5252        errno_t (*fill_rect)(void *, gfx_rect_t *);
     53        /** Update display */
     54        errno_t (*update)(void *);
    5355        /** Create bitmap */
    5456        errno_t (*bitmap_create)(void *, gfx_bitmap_params_t *,
  • uspace/lib/gfx/src/render.c

    ref734b7 r2ab8ab3  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6363}
    6464
     65/** Update display.
     66 *
     67 * Finish any deferred rendering.
     68 *
     69 * @param gc Graphic context
     70 *
     71 * @return EOK on success, ENOMEM if insufficient resources,
     72 *         EIO if grahic device connection was lost
     73 */
     74errno_t gfx_update(gfx_context_t *gc)
     75{
     76        return gc->ops->update(gc->arg);
     77}
     78
    6579/** @}
    6680 */
  • uspace/lib/gfx/test/render.c

    ref734b7 r2ab8ab3  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3232#include <pcut/pcut.h>
    3333#include <mem.h>
     34#include <stdbool.h>
    3435
    3536PCUT_INIT;
     
    3940static errno_t testgc_set_color(void *, gfx_color_t *);
    4041static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     42static errno_t testgc_update(void *);
    4143
    4244static gfx_context_ops_t ops = {
    4345        .set_color = testgc_set_color,
    44         .fill_rect = testgc_fill_rect
     46        .fill_rect = testgc_fill_rect,
     47        .update = testgc_update
    4548};
    4649
     
    4952        gfx_color_t *dclr;
    5053        gfx_rect_t *rect;
     54        bool updated;
    5155} test_gc_t;
    5256
     
    107111}
    108112
     113PCUT_TEST(update)
     114{
     115        errno_t rc;
     116        gfx_context_t *gc = NULL;
     117        test_gc_t tgc;
     118
     119        memset(&tgc, 0, sizeof(tgc));
     120
     121        rc = gfx_context_new(&ops, &tgc, &gc);
     122        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     123
     124        PCUT_ASSERT_FALSE(tgc.updated);
     125        gfx_update(gc);
     126        PCUT_ASSERT_TRUE(tgc.updated);
     127
     128        rc = gfx_context_delete(gc);
     129        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     130}
     131
    109132static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    110133{
     
    125148}
    126149
     150static errno_t testgc_update(void *arg)
     151{
     152        test_gc_t *tgc = (test_gc_t *) arg;
     153
     154        tgc->updated = true;
     155        return EOK;
     156}
     157
    127158PCUT_EXPORT(render);
Note: See TracChangeset for help on using the changeset viewer.