Changeset 0008c0f in mainline for uspace/srv/hid/display/window.c
- Timestamp:
- 2019-10-26T23:30:51Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 587b4cb
- Parents:
- 7b882c1f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/window.c
r7b882c1f r0008c0f 36 36 */ 37 37 38 #include <gfx/bitmap.h> 38 39 #include <gfx/color.h> 40 #include <gfx/coord.h> 39 41 #include <gfx/context.h> 40 42 #include <gfx/render.h> … … 46 48 static errno_t ds_window_set_color(void *, gfx_color_t *); 47 49 static errno_t ds_window_fill_rect(void *, gfx_rect_t *); 50 static errno_t ds_window_bitmap_create(void *, gfx_bitmap_params_t *, 51 gfx_bitmap_alloc_t *, void **); 52 static errno_t ds_window_bitmap_destroy(void *); 53 static errno_t ds_window_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *); 54 static errno_t ds_window_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *); 48 55 49 56 gfx_context_ops_t ds_window_ops = { 50 57 .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 52 63 }; 53 64 … … 82 93 log_msg(LOG_DEFAULT, LVL_NOTE, "gc_fill_rect"); 83 94 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 */ 105 errno_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; 123 error: 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 */ 134 static 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 */ 150 static 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 */ 164 static 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); 84 169 } 85 170
Note:
See TracChangeset
for help on using the changeset viewer.