Changeset dcc4cb31 in mainline


Ignore:
Timestamp:
2019-10-17T23:20:18Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e0545de
Parents:
78a71936
Message:

Refine bitmap ops and add tests

Location:
uspace/lib/gfx
Files:
1 added
5 edited

Legend:

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

    r78a71936 rdcc4cb31  
    4343
    4444extern errno_t gfx_bitmap_create(gfx_context_t *, gfx_bitmap_params_t *,
    45      gfx_bitmap_alloc_t *, gfx_bitmap_t **);
    46 extern errno_t gfx_bitmap_delete(gfx_bitmap_t *);
     45    gfx_bitmap_alloc_t *, gfx_bitmap_t **);
     46extern errno_t gfx_bitmap_destroy(gfx_bitmap_t *);
    4747extern errno_t gfx_bitmap_render(gfx_bitmap_t *, gfx_rect_t *, gfx_coord2_t *);
    4848extern errno_t gfx_bitmap_get_alloc(gfx_bitmap_t *, gfx_bitmap_alloc_t *);
  • uspace/lib/gfx/include/types/gfx/ops/context.h

    r78a71936 rdcc4cb31  
    5252        errno_t (*fill_rect)(void *, gfx_rect_t *);
    5353        /** Create bitmap */
    54         errno_t (*bitmap_create)(void *, gfx_bitmap_params_t *, void *,
    55             gfx_bitmap_t **);
    56         /** Delete bitmap */
    57         errno_t (*bitmap_delete)(void *, gfx_bitmap_t *);
     54        errno_t (*bitmap_create)(void *, gfx_bitmap_params_t *,
     55            gfx_bitmap_alloc_t *, void **);
     56        /** Destroy bitmap */
     57        errno_t (*bitmap_destroy)(void *);
    5858        /** Render bitmap */
    59         errno_t (*bitmap_render)(void *, gfx_bitmap_t *, gfx_rect_t *,
    60             gfx_coord2_t *);
     59        errno_t (*bitmap_render)(void *, gfx_rect_t *, gfx_coord2_t *);
    6160        /** Get bitmap allocation info */
    62         errno_t (*bitmap_get_alloc)(void *, gfx_bitmap_t *,
    63             gfx_bitmap_alloc_t *);
     61        errno_t (*bitmap_get_alloc)(void *, gfx_bitmap_alloc_t *);
    6462} gfx_context_ops_t;
    6563
  • uspace/lib/gfx/meson.build

    r78a71936 rdcc4cb31  
    11#
    2 # Copyright (c) 2015 Jiri Svoboda
     2# Copyright (c) 2019 Jiri Svoboda
    33# All rights reserved.
    44#
     
    3535
    3636test_src = files(
     37        'test/bitmap.c',
    3738        'test/color.c',
    3839        'test/main.c',
  • uspace/lib/gfx/src/bitmap.c

    r78a71936 rdcc4cb31  
    5555    gfx_bitmap_alloc_t *alloc, gfx_bitmap_t **rbitmap)
    5656{
    57         return gc->ops->bitmap_create(gc->arg, params, alloc, rbitmap);
     57        void *bm_priv;
     58        gfx_bitmap_t *bitmap;
     59        errno_t rc;
     60
     61        bitmap = calloc(1, sizeof(gfx_bitmap_t));
     62        if (bitmap == NULL)
     63                return ENOMEM;
     64
     65        rc = gc->ops->bitmap_create(gc->arg, params, alloc, &bm_priv);
     66        if (rc != EOK)
     67                return rc;
     68
     69        bitmap->gc = gc;
     70        bitmap->gc_priv = bm_priv;
     71        *rbitmap = bitmap;
     72        return EOK;
    5873}
    5974
    60 /** Delete bitmap from graphics context.
     75/** Destroy bitmap from graphics context.
    6176 *
    6277 * @param bitmap Bitmap
     
    6479 * @return EOK on success, EIO if grahic device connection was lost
    6580 */
    66 errno_t gfx_bitmap_delete(gfx_bitmap_t *bitmap)
     81errno_t gfx_bitmap_destroy(gfx_bitmap_t *bitmap)
    6782{
    68         return bitmap->gc->ops->bitmap_delete(bitmap->gc->arg, bitmap);
     83        errno_t rc;
     84
     85        rc = bitmap->gc->ops->bitmap_destroy(bitmap->gc_priv);
     86        if (rc != EOK)
     87                return rc;
     88
     89        free(bitmap);
     90        return EOK;
    6991}
    7092
     
    80102    gfx_coord2_t *offs)
    81103{
    82         return bitmap->gc->ops->bitmap_render(bitmap->gc->arg, bitmap,
    83             srect, offs);
     104        return bitmap->gc->ops->bitmap_render(bitmap->gc_priv, srect, offs);
    84105}
    85106
     
    93114errno_t gfx_bitmap_get_alloc(gfx_bitmap_t *bitmap, gfx_bitmap_alloc_t *alloc)
    94115{
    95         return bitmap->gc->ops->bitmap_get_alloc(bitmap->gc->arg, bitmap,
    96             alloc);
     116        return bitmap->gc->ops->bitmap_get_alloc(bitmap->gc_priv, alloc);
    97117}
    98118
  • uspace/lib/gfx/test/main.c

    r78a71936 rdcc4cb31  
    3131PCUT_INIT;
    3232
     33PCUT_IMPORT(bitmap);
    3334PCUT_IMPORT(color);
    3435PCUT_IMPORT(render);
Note: See TracChangeset for help on using the changeset viewer.