Changeset 0008c0f in mainline for uspace/srv/hid/display/window.c


Ignore:
Timestamp:
2019-10-26T23:30:51Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
587b4cb
Parents:
7b882c1f
Message:

Bitmaps in IPC GC and in display server

File:
1 edited

Legend:

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

    r7b882c1f r0008c0f  
    3636 */
    3737
     38#include <gfx/bitmap.h>
    3839#include <gfx/color.h>
     40#include <gfx/coord.h>
    3941#include <gfx/context.h>
    4042#include <gfx/render.h>
     
    4648static errno_t ds_window_set_color(void *, gfx_color_t *);
    4749static errno_t ds_window_fill_rect(void *, gfx_rect_t *);
     50static errno_t ds_window_bitmap_create(void *, gfx_bitmap_params_t *,
     51    gfx_bitmap_alloc_t *, void **);
     52static errno_t ds_window_bitmap_destroy(void *);
     53static errno_t ds_window_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
     54static errno_t ds_window_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    4855
    4956gfx_context_ops_t ds_window_ops = {
    5057        .set_color = ds_window_set_color,
    51         .fill_rect = ds_window_fill_rect
     58        .fill_rect = ds_window_fill_rect,
     59        .bitmap_create = ds_window_bitmap_create,
     60        .bitmap_destroy = ds_window_bitmap_destroy,
     61        .bitmap_render = ds_window_bitmap_render,
     62        .bitmap_get_alloc = ds_window_bitmap_get_alloc
    5263};
    5364
     
    8293        log_msg(LOG_DEFAULT, LVL_NOTE, "gc_fill_rect");
    8394        return gfx_fill_rect(wnd->display->gc, rect);
     95}
     96
     97/** Create bitmap in canvas GC.
     98 *
     99 * @param arg Canvas GC
     100 * @param params Bitmap params
     101 * @param alloc Bitmap allocation info or @c NULL
     102 * @param rbm Place to store pointer to new bitmap
     103 * @return EOK on success or an error code
     104 */
     105errno_t ds_window_bitmap_create(void *arg, gfx_bitmap_params_t *params,
     106    gfx_bitmap_alloc_t *alloc, void **rbm)
     107{
     108        ds_window_t *wnd = (ds_window_t *) arg;
     109        ds_window_bitmap_t *cbm = NULL;
     110        errno_t rc;
     111
     112        cbm = calloc(1, sizeof(ds_window_bitmap_t));
     113        if (cbm == NULL)
     114                return ENOMEM;
     115
     116        rc = gfx_bitmap_create(wnd->display->gc, params, alloc, &cbm->bitmap);
     117        if (rc != EOK)
     118                goto error;
     119
     120        cbm->wnd = wnd;
     121        *rbm = (void *)cbm;
     122        return EOK;
     123error:
     124        if (cbm != NULL)
     125                free(cbm);
     126        return rc;
     127}
     128
     129/** Destroy bitmap in canvas GC.
     130 *
     131 * @param bm Bitmap
     132 * @return EOK on success or an error code
     133 */
     134static errno_t ds_window_bitmap_destroy(void *bm)
     135{
     136        ds_window_bitmap_t *cbm = (ds_window_bitmap_t *)bm;
     137
     138        gfx_bitmap_destroy(cbm->bitmap);
     139        free(cbm);
     140        return EOK;
     141}
     142
     143/** Render bitmap in canvas GC.
     144 *
     145 * @param bm Bitmap
     146 * @param srect0 Source rectangle or @c NULL
     147 * @param offs0 Offset or @c NULL
     148 * @return EOK on success or an error code
     149 */
     150static errno_t ds_window_bitmap_render(void *bm, gfx_rect_t *srect0,
     151    gfx_coord2_t *offs0)
     152{
     153        ds_window_bitmap_t *cbm = (ds_window_bitmap_t *)bm;
     154
     155        return gfx_bitmap_render(cbm->bitmap, srect0, offs0);
     156}
     157
     158/** Get allocation info for bitmap in canvas GC.
     159 *
     160 * @param bm Bitmap
     161 * @param alloc Place to store allocation info
     162 * @return EOK on success or an error code
     163 */
     164static errno_t ds_window_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
     165{
     166        ds_window_bitmap_t *cbm = (ds_window_bitmap_t *)bm;
     167
     168        return gfx_bitmap_get_alloc(cbm->bitmap, alloc);
    84169}
    85170
Note: See TracChangeset for help on using the changeset viewer.