Changeset afcf704 in mainline for uspace/lib/ipcgfx/src/client.c
- Timestamp:
- 2020-06-14T22:23:34Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c45d8696
- Parents:
- 28f8f6f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ipcgfx/src/client.c
r28f8f6f2 rafcf704 108 108 } 109 109 110 /** Create bitmap in IPC GC.110 /** Create normal bitmap in IPC GC. 111 111 * 112 112 * @param arg IPC GC … … 116 116 * @return EOK on success or an error code 117 117 */ 118 errno_t ipc_gc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 118 static errno_t ipc_gc_bitmap_create_normal(void *arg, 119 gfx_bitmap_params_t *params, 119 120 gfx_bitmap_alloc_t *alloc, void **rbm) 120 121 { … … 209 210 } 210 211 212 /** Create direct output bitmap in IPC GC. 213 * 214 * @param arg IPC GC 215 * @param params Bitmap params 216 * @param alloc Bitmap allocation info or @c NULL 217 * @param rbm Place to store pointer to new bitmap 218 * @return EOK on success or an error code 219 */ 220 static errno_t ipc_gc_bitmap_create_direct_output(void *arg, 221 gfx_bitmap_params_t *params, 222 gfx_bitmap_alloc_t *alloc, void **rbm) 223 { 224 ipc_gc_t *ipcgc = (ipc_gc_t *) arg; 225 ipc_gc_bitmap_t *ipcbm = NULL; 226 gfx_coord2_t dim; 227 async_exch_t *exch = NULL; 228 void *pixels; 229 ipc_call_t answer; 230 size_t asize; 231 aid_t req; 232 errno_t rc; 233 234 /* Cannot specify allocation for direct output bitmap */ 235 if (alloc != NULL) 236 return EINVAL; 237 238 ipcbm = calloc(1, sizeof(ipc_gc_bitmap_t)); 239 if (ipcbm == NULL) 240 return ENOMEM; 241 242 gfx_coord2_subtract(¶ms->rect.p1, ¶ms->rect.p0, &dim); 243 ipcbm->rect = params->rect; 244 245 ipcbm->alloc.pitch = dim.x * sizeof(uint32_t); 246 ipcbm->alloc.off0 = 0; 247 ipcbm->myalloc = true; 248 249 asize = PAGES2SIZE(SIZE2PAGES(ipcbm->alloc.pitch * dim.y)); 250 251 exch = async_exchange_begin(ipcgc->sess); 252 req = async_send_0(exch, GC_BITMAP_CREATE_DOUTPUT, &answer); 253 rc = async_data_write_start(exch, params, sizeof (gfx_bitmap_params_t)); 254 if (rc != EOK) { 255 async_forget(req); 256 goto error; 257 } 258 259 rc = async_share_in_start_0_0(exch, asize, &pixels); 260 if (rc != EOK) { 261 async_forget(req); 262 goto error; 263 } 264 async_exchange_end(exch); 265 exch = NULL; 266 267 async_wait_for(req, &rc); 268 if (rc != EOK) 269 goto error; 270 271 ipcbm->ipcgc = ipcgc; 272 ipcbm->bmp_id = ipc_get_arg1(&answer); 273 ipcbm->alloc.pixels = pixels; 274 *rbm = (void *)ipcbm; 275 return EOK; 276 error: 277 if (exch != NULL) 278 async_exchange_end(exch); 279 if (ipcbm != NULL) { 280 if (ipcbm->alloc.pixels != NULL) 281 as_area_destroy(ipcbm->alloc.pixels); 282 free(ipcbm); 283 } 284 return rc; 285 } 286 287 /** Create bitmap in IPC GC. 288 * 289 * @param arg IPC GC 290 * @param params Bitmap params 291 * @param alloc Bitmap allocation info or @c NULL 292 * @param rbm Place to store pointer to new bitmap 293 * @return EOK on success or an error code 294 */ 295 errno_t ipc_gc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 296 gfx_bitmap_alloc_t *alloc, void **rbm) 297 { 298 if ((params->flags & bmpf_direct_output) != 0) { 299 return ipc_gc_bitmap_create_direct_output(arg, params, alloc, 300 rbm); 301 } else { 302 return ipc_gc_bitmap_create_normal(arg, params, alloc, rbm); 303 } 304 } 305 211 306 /** Destroy bitmap in IPC GC. 212 307 *
Note:
See TracChangeset
for help on using the changeset viewer.