Changeset afcf704 in mainline for uspace/lib/memgfx/src/memgc.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/memgfx/src/memgc.c
r28f8f6f2 rafcf704 37 37 */ 38 38 39 #include <as.h> 39 40 #include <assert.h> 40 41 #include <gfx/color.h> … … 223 224 errno_t rc; 224 225 226 /* Check that we support all requested flags */ 227 if ((params->flags & ~(bmpf_color_key | bmpf_direct_output)) != 0) 228 return ENOTSUP; 229 225 230 mbm = calloc(1, sizeof(mem_gc_bitmap_t)); 226 231 if (mbm == NULL) … … 232 237 mbm->key_color = params->key_color; 233 238 234 if (alloc == NULL) { 239 if ((params->flags & bmpf_direct_output) != 0) { 240 /* Caller cannot specify allocation for direct output */ 241 if (alloc != NULL) { 242 rc = EINVAL; 243 goto error; 244 } 245 246 /* Bounding rectangle must be within GC bounding rectangle */ 247 if (!gfx_rect_is_inside(&mbm->rect, &mgc->rect)) { 248 rc = EINVAL; 249 goto error; 250 } 251 252 mbm->alloc = mgc->alloc; 253 254 /* Don't free pixel array when destroying bitmap */ 255 mbm->myalloc = false; 256 } else if (alloc == NULL) { 257 #if 0 258 /* 259 * TODO: If the bitmap is not required to be sharable, 260 * we could allocate it with a simple malloc. 261 * Need to have a bitmap flag specifying that the 262 * allocation should be sharable. IPC GC could 263 * automatically add this flag 264 */ 235 265 mbm->alloc.pitch = dim.x * sizeof(uint32_t); 236 266 mbm->alloc.off0 = 0; … … 242 272 goto error; 243 273 } 274 #endif 275 mbm->alloc.pitch = dim.x * sizeof(uint32_t); 276 mbm->alloc.off0 = 0; 277 mbm->alloc.pixels = as_area_create(AS_AREA_ANY, 278 dim.x * dim.y * sizeof(uint32_t), AS_AREA_READ | 279 AS_AREA_WRITE | AS_AREA_CACHEABLE, AS_AREA_UNPAGED); 280 mbm->myalloc = true; 281 282 if (mbm->alloc.pixels == AS_MAP_FAILED) { 283 rc = ENOMEM; 284 goto error; 285 } 244 286 } else { 245 287 mbm->alloc = *alloc; … … 263 305 { 264 306 mem_gc_bitmap_t *mbm = (mem_gc_bitmap_t *)bm; 265 if (mbm->myalloc) 307 if (mbm->myalloc) { 308 #if 0 309 /* TODO: if we alloc allocating the bitmap with malloc */ 266 310 free(mbm->alloc.pixels); 311 #endif 312 as_area_destroy(mbm->alloc.pixels); 313 } 267 314 268 315 free(mbm); … … 317 364 dmap.data = mbm->mgc->alloc.pixels; 318 365 319 if ((mbm->flags & bmpf_color_key) == 0) { 366 if ((mbm->flags & bmpf_direct_output) != 0) { 367 /* Nothing to do */ 368 } else if ((mbm->flags & bmpf_color_key) == 0) { 320 369 for (y = drect.p0.y; y < drect.p1.y; y++) { 321 370 for (x = drect.p0.x; x < drect.p1.x; x++) {
Note:
See TracChangeset
for help on using the changeset viewer.