Changeset 8aef01c in mainline
- Timestamp:
- 2020-06-07T10:18:14Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a65b0c8
- Parents:
- 6301a24f
- git-author:
- Jiri Svoboda <jiri@…> (2020-06-07 10:11:32)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-06-07 10:18:14)
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r6301a24f r8aef01c 608 608 ! [(PLATFORM=ia32|PLATFORM=amd64|MACHINE=beagleboardxm)&CONFIG_HID_OUT!=none&CONFIG_FB=y] CONFIG_BFB_BPP (choice) 609 609 610 % Display double buffering 611 ! [CONFIG_FB=y] CONFIG_DISP_DOUBLE_BUF (y/n) 612 610 613 % Start AP processors by the loader 611 614 ! [PLATFORM=sparc64&CONFIG_SMP=y] CONFIG_AP (y/n) -
uspace/lib/memgfx/src/memgc.c
r6301a24f r8aef01c 284 284 gfx_rect_t drect; 285 285 gfx_coord2_t offs; 286 gfx_coord2_t dim;287 286 gfx_coord_t x, y; 288 287 pixelmap_t smap; … … 305 304 gfx_rect_translate(&offs, &srect, &drect); 306 305 307 gfx_coord2_subtract(&drect.p1, &drect.p0, &dim); 308 309 assert(mbm->rect.p0.x == 0); 310 assert(mbm->rect.p0.y == 0); 311 assert(mbm->alloc.pitch == mbm->rect.p1.x * (int)sizeof(uint32_t)); 312 smap.width = mbm->rect.p1.x; 313 smap.height = mbm->rect.p1.y; 306 assert(mbm->alloc.pitch == (mbm->rect.p1.x - mbm->rect.p0.x) * 307 (int)sizeof(uint32_t)); 308 smap.width = mbm->rect.p1.x - mbm->rect.p0.x; 309 smap.height = mbm->rect.p1.y - mbm->rect.p0.y; 314 310 smap.data = mbm->alloc.pixels; 315 311 … … 324 320 for (y = drect.p0.y; y < drect.p1.y; y++) { 325 321 for (x = drect.p0.x; x < drect.p1.x; x++) { 326 pixel = pixelmap_get_pixel(&smap, x - offs.x, 327 y - offs.y); 322 pixel = pixelmap_get_pixel(&smap, 323 x - mbm->rect.p0.x - offs.x, 324 y - mbm->rect.p0.y - offs.y); 328 325 pixelmap_put_pixel(&dmap, x, y, pixel); 329 326 } … … 332 329 for (y = drect.p0.y; y < drect.p1.y; y++) { 333 330 for (x = drect.p0.x; x < drect.p1.x; x++) { 334 pixel = pixelmap_get_pixel(&smap, x - offs.x, 335 y - offs.y); 331 pixel = pixelmap_get_pixel(&smap, 332 x - mbm->rect.p0.x - offs.x, 333 y - mbm->rect.p0.y - offs.y); 336 334 if (pixel != mbm->key_color) 337 335 pixelmap_put_pixel(&dmap, x, y, pixel); -
uspace/srv/hid/display/ddev.c
r6301a24f r8aef01c 59 59 { 60 60 ds_ddev_t *ddev; 61 errno_t rc; 61 62 62 63 ddev = calloc(1, sizeof(ds_ddev_t)); … … 70 71 ddev->info = *info; 71 72 72 ds_display_add_ddev(display, ddev); 73 rc = ds_display_add_ddev(display, ddev); 74 if (rc != EOK) { 75 free(ddev); 76 return rc; 77 } 73 78 74 79 *rddev = ddev; -
uspace/srv/hid/display/display.c
r6301a24f r8aef01c 35 35 36 36 #include <errno.h> 37 #include <gfx/bitmap.h> 37 38 #include <gfx/context.h> 38 39 #include <gfx/render.h> 39 40 #include <io/log.h> 41 #include <memgfx/memgc.h> 40 42 #include <stdlib.h> 41 43 #include "client.h" … … 46 48 #include "display.h" 47 49 50 static gfx_context_t *ds_display_get_unbuf_gc(ds_display_t *); 51 static void ds_display_update_cb(void *, gfx_rect_t *); 52 48 53 /** Create display. 49 54 * 50 55 * @param gc Graphics context for displaying output 56 * @param flags Display flags 51 57 * @param rdisp Place to store pointer to new display. 52 58 * @return EOK on success, ENOMEM if out of memory 53 59 */ 54 errno_t ds_display_create(gfx_context_t *gc, ds_display_t **rdisp) 60 errno_t ds_display_create(gfx_context_t *gc, ds_display_flags_t flags, 61 ds_display_t **rdisp) 55 62 { 56 63 ds_display_t *disp; … … 86 93 list_initialize(&disp->seats); 87 94 list_initialize(&disp->windows); 95 disp->flags = flags; 88 96 *rdisp = disp; 89 97 return EOK; … … 423 431 } 424 432 433 /** Allocate back buffer for display. 434 * 435 * @param disp Display 436 * @return EOK on success or if no back buffer is required, otherwise 437 * an error code. 438 */ 439 static errno_t ds_display_alloc_backbuf(ds_display_t *disp) 440 { 441 gfx_context_t *ugc; 442 gfx_bitmap_params_t params; 443 gfx_bitmap_alloc_t alloc; 444 errno_t rc; 445 446 /* Allocate backbuffer */ 447 if ((disp->flags & df_disp_double_buf) == 0) { 448 /* Not double buffering. Nothing to do. */ 449 return EOK; 450 } 451 452 ugc = ds_display_get_unbuf_gc(disp); 453 454 gfx_bitmap_params_init(¶ms); 455 params.rect = disp->rect; 456 457 rc = gfx_bitmap_create(ugc, ¶ms, NULL, 458 &disp->backbuf); 459 if (rc != EOK) 460 goto error; 461 462 rc = gfx_bitmap_get_alloc(disp->backbuf, &alloc); 463 if (rc != EOK) 464 goto error; 465 466 rc = mem_gc_create(&disp->rect, &alloc, 467 ds_display_update_cb, (void *) disp, &disp->bbgc); 468 if (rc != EOK) 469 goto error; 470 471 disp->dirty_rect.p0.x = 0; 472 disp->dirty_rect.p0.y = 0; 473 disp->dirty_rect.p1.x = 0; 474 disp->dirty_rect.p1.y = 0; 475 476 return EOK; 477 error: 478 if (disp->backbuf != NULL) { 479 gfx_bitmap_destroy(disp->backbuf); 480 disp->backbuf = NULL; 481 } 482 483 return rc; 484 } 485 425 486 /** Add display device to display. 426 487 * 427 488 * @param disp Display 428 489 * @param ddev Display device 429 */ 430 void ds_display_add_ddev(ds_display_t *disp, ds_ddev_t *ddev) 431 { 490 * @return EOK on success, or an error code 491 */ 492 errno_t ds_display_add_ddev(ds_display_t *disp, ds_ddev_t *ddev) 493 { 494 errno_t rc; 495 432 496 assert(ddev->display == NULL); 433 497 assert(!link_used(&ddev->lddevs)); 434 498 435 /* Set display dimensions to dimensions of first display device */436 if (gfx_rect_is_empty(&disp->rect))437 disp->rect = ddev->info.rect;438 439 499 ddev->display = disp; 440 500 list_append(&ddev->lddevs, &disp->ddevs); 501 502 /* First display device */ 503 if (gfx_rect_is_empty(&disp->rect)) { 504 /* Set screen dimensions */ 505 disp->rect = ddev->info.rect; 506 507 /* Allocate backbuffer */ 508 rc = ds_display_alloc_backbuf(disp); 509 if (rc != EOK) 510 goto error; 511 } 512 513 return EOK; 514 error: 515 disp->rect.p0.x = 0; 516 disp->rect.p0.y = 0; 517 disp->rect.p1.x = 0; 518 disp->rect.p1.y = 0; 519 list_remove(&ddev->lddevs); 520 return rc; 441 521 } 442 522 … … 506 586 507 587 // XXX 508 gfx_context_t *ds_display_get_gc(ds_display_t *display)588 static gfx_context_t *ds_display_get_unbuf_gc(ds_display_t *display) 509 589 { 510 590 ds_ddev_t *ddev; … … 515 595 516 596 return ddev->gc; 597 } 598 599 // XXX 600 gfx_context_t *ds_display_get_gc(ds_display_t *display) 601 { 602 if ((display->flags & df_disp_double_buf) != 0) 603 return mem_gc_get_ctx(display->bbgc); 604 else 605 return ds_display_get_unbuf_gc(display); 517 606 } 518 607 … … 542 631 543 632 return gfx_fill_rect(gc, &crect); 633 } 634 635 /** Update front buffer from back buffer. 636 * 637 * If the display is not double-buffered, no action is taken. 638 * 639 * @param disp Display 640 * @return EOK on success, or an error code 641 */ 642 static errno_t ds_display_update(ds_display_t *disp) 643 { 644 errno_t rc; 645 646 if (disp->backbuf == NULL) { 647 /* Not double-buffered, nothing to do. */ 648 return EOK; 649 } 650 651 rc = gfx_bitmap_render(disp->backbuf, &disp->dirty_rect, NULL); 652 if (rc != EOK) 653 return rc; 654 655 disp->dirty_rect.p0.x = 0; 656 disp->dirty_rect.p0.y = 0; 657 disp->dirty_rect.p1.x = 0; 658 disp->dirty_rect.p1.y = 0; 659 660 return EOK; 544 661 } 545 662 … … 590 707 } 591 708 592 return EOK; 709 return ds_display_update(disp); 710 } 711 712 /** Display update callback. 713 * 714 * Called by backbuffer memory GC when something is rendered into it. 715 * Updates the display's dirty rectangle. 716 * 717 * @param arg Argument (display cast as void *) 718 * @param rect Rectangle to update 719 */ 720 static void ds_display_update_cb(void *arg, gfx_rect_t *rect) 721 { 722 ds_display_t *disp = (ds_display_t *) arg; 723 gfx_rect_t env; 724 725 gfx_rect_envelope(&disp->dirty_rect, rect, &env); 726 disp->dirty_rect = env; 593 727 } 594 728 -
uspace/srv/hid/display/display.h
r6301a24f r8aef01c 49 49 #include "types/display/seat.h" 50 50 51 extern errno_t ds_display_create(gfx_context_t *, ds_display_t **); 51 extern errno_t ds_display_create(gfx_context_t *, ds_display_flags_t, 52 ds_display_t **); 52 53 extern void ds_display_destroy(ds_display_t *); 53 54 extern void ds_display_lock(ds_display_t *); … … 72 73 extern ds_seat_t *ds_display_first_seat(ds_display_t *); 73 74 extern ds_seat_t *ds_display_next_seat(ds_seat_t *); 74 extern voidds_display_add_ddev(ds_display_t *, ds_ddev_t *);75 extern errno_t ds_display_add_ddev(ds_display_t *, ds_ddev_t *); 75 76 extern void ds_display_remove_ddev(ds_ddev_t *); 76 77 extern ds_ddev_t *ds_display_first_ddev(ds_display_t *); -
uspace/srv/hid/display/main.c
r6301a24f r8aef01c 59 59 static void display_client_ev_pending(void *); 60 60 61 #ifdef CONFIG_DISP_DOUBLE_BUF 62 /* 63 * Double buffering is one way to provide flicker-free display. 64 */ 65 static ds_display_flags_t disp_flags = df_disp_double_buf; 66 #else 67 /* 68 * With double buffering disabled, wet screen flicker since front-to-back 69 * rendering is not implemented. 70 */ 71 static ds_display_flags_t disp_flags = df_none; 72 #endif 73 61 74 static ds_client_cb_t display_client_cb = { 62 75 .ev_pending = display_client_ev_pending … … 81 94 log_msg(LOG_DEFAULT, LVL_DEBUG, "display_srv_init()"); 82 95 83 rc = ds_display_create(NULL, &disp);96 rc = ds_display_create(NULL, disp_flags, &disp); 84 97 if (rc != EOK) 85 98 goto error; -
uspace/srv/hid/display/test/client.c
r6301a24f r8aef01c 62 62 errno_t rc; 63 63 64 rc = ds_display_create(NULL, &disp);64 rc = ds_display_create(NULL, df_none, &disp); 65 65 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 66 66 … … 87 87 errno_t rc; 88 88 89 rc = ds_display_create(NULL, &disp);89 rc = ds_display_create(NULL, df_none, &disp); 90 90 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 91 91 … … 132 132 errno_t rc; 133 133 134 rc = ds_display_create(NULL, &disp);134 rc = ds_display_create(NULL, df_none, &disp); 135 135 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 136 136 … … 175 175 errno_t rc; 176 176 177 rc = ds_display_create(NULL, &disp);177 rc = ds_display_create(NULL, df_none, &disp); 178 178 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 179 179 … … 222 222 errno_t rc; 223 223 224 rc = ds_display_create(NULL, &disp);224 rc = ds_display_create(NULL, df_none, &disp); 225 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 226 … … 270 270 errno_t rc; 271 271 272 rc = ds_display_create(NULL, &disp);272 rc = ds_display_create(NULL, df_none, &disp); 273 273 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 274 274 … … 327 327 errno_t rc; 328 328 329 rc = ds_display_create(NULL, &disp);329 rc = ds_display_create(NULL, df_none, &disp); 330 330 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 331 331 … … 382 382 errno_t rc; 383 383 384 rc = ds_display_create(NULL, &disp);384 rc = ds_display_create(NULL, df_none, &disp); 385 385 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 386 386 … … 438 438 errno_t rc; 439 439 440 rc = ds_display_create(NULL, &disp);440 rc = ds_display_create(NULL, df_none, &disp); 441 441 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 442 442 … … 486 486 errno_t rc; 487 487 488 rc = ds_display_create(NULL, &disp);488 rc = ds_display_create(NULL, df_none, &disp); 489 489 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 490 490 -
uspace/srv/hid/display/test/cursor.c
r6301a24f r8aef01c 71 71 errno_t rc; 72 72 73 rc = ds_display_create(NULL, &disp);73 rc = ds_display_create(NULL, df_none, &disp); 74 74 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 75 75 … … 97 97 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 98 98 99 rc = ds_display_create(gc, &disp);99 rc = ds_display_create(gc, df_none, &disp); 100 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 101 101 … … 130 130 errno_t rc; 131 131 132 rc = ds_display_create(NULL, &disp);132 rc = ds_display_create(NULL, df_none, &disp); 133 133 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 134 134 -
uspace/srv/hid/display/test/display.c
r6301a24f r8aef01c 61 61 errno_t rc; 62 62 63 rc = ds_display_create(NULL, &disp);63 rc = ds_display_create(NULL, df_none, &disp); 64 64 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 65 65 … … 75 75 errno_t rc; 76 76 77 rc = ds_display_create(NULL, &disp);77 rc = ds_display_create(NULL, df_none, &disp); 78 78 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 79 79 … … 102 102 errno_t rc; 103 103 104 rc = ds_display_create(NULL, &disp);104 rc = ds_display_create(NULL, df_none, &disp); 105 105 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 106 106 … … 166 166 errno_t rc; 167 167 168 rc = ds_display_create(NULL, &disp);168 rc = ds_display_create(NULL, df_none, &disp); 169 169 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 170 170 … … 212 212 errno_t rc; 213 213 214 rc = ds_display_create(NULL, &disp);214 rc = ds_display_create(NULL, df_none, &disp); 215 215 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 216 216 … … 241 241 errno_t rc; 242 242 243 rc = ds_display_create(NULL, &disp);243 rc = ds_display_create(NULL, df_none, &disp); 244 244 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 245 245 … … 289 289 errno_t rc; 290 290 291 rc = ds_display_create(NULL, &disp);291 rc = ds_display_create(NULL, df_none, &disp); 292 292 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 293 293 … … 357 357 errno_t rc; 358 358 359 rc = ds_display_create(NULL, &disp);359 rc = ds_display_create(NULL, df_none, &disp); 360 360 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 361 361 -
uspace/srv/hid/display/test/seat.c
r6301a24f r8aef01c 66 66 errno_t rc; 67 67 68 rc = ds_display_create(NULL, &disp);68 rc = ds_display_create(NULL, df_none, &disp); 69 69 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 70 70 … … 104 104 errno_t rc; 105 105 106 rc = ds_display_create(NULL, &disp);106 rc = ds_display_create(NULL, df_none, &disp); 107 107 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 108 108 … … 152 152 errno_t rc; 153 153 154 rc = ds_display_create(NULL, &disp);154 rc = ds_display_create(NULL, df_none, &disp); 155 155 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 156 156 … … 205 205 errno_t rc; 206 206 207 rc = ds_display_create(NULL, &disp);207 rc = ds_display_create(NULL, df_none, &disp); 208 208 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 209 209 … … 272 272 errno_t rc; 273 273 274 rc = ds_display_create(NULL, &disp);274 rc = ds_display_create(NULL, df_none, &disp); 275 275 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 276 276 … … 362 362 errno_t rc; 363 363 364 rc = ds_display_create(NULL, &disp);364 rc = ds_display_create(NULL, df_none, &disp); 365 365 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 366 366 -
uspace/srv/hid/display/test/window.c
r6301a24f r8aef01c 63 63 errno_t rc; 64 64 65 rc = ds_display_create(NULL, &disp);65 rc = ds_display_create(NULL, df_none, &disp); 66 66 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 67 67 … … 109 109 errno_t rc; 110 110 111 rc = ds_display_create(NULL, &disp);111 rc = ds_display_create(NULL, df_none, &disp); 112 112 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 113 113 … … 146 146 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 147 147 148 rc = ds_display_create(gc, &disp);148 rc = ds_display_create(gc, df_none, &disp); 149 149 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 150 150 … … 192 192 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 193 193 194 rc = ds_display_create(gc, &disp);194 rc = ds_display_create(gc, df_none, &disp); 195 195 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 196 196 … … 260 260 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 261 261 262 rc = ds_display_create(gc, &disp);262 rc = ds_display_create(gc, df_none, &disp); 263 263 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 264 264 … … 303 303 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 304 304 305 rc = ds_display_create(gc, &disp);305 rc = ds_display_create(gc, df_none, &disp); 306 306 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 307 307 … … 349 349 errno_t rc; 350 350 351 rc = ds_display_create(NULL, &disp);351 rc = ds_display_create(NULL, df_none, &disp); 352 352 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 353 353 … … 614 614 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 615 615 616 rc = ds_display_create(gc, &disp);616 rc = ds_display_create(gc, df_none, &disp); 617 617 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 618 618 -
uspace/srv/hid/display/types/display/display.h
r6301a24f r8aef01c 42 42 #include <gfx/coord.h> 43 43 #include <io/input.h> 44 #include <memgfx/memgc.h> 44 45 #include <types/display/cursor.h> 45 46 #include "cursor.h" 46 47 #include "window.h" 48 49 /** Display flags */ 50 typedef enum { 51 /** No flags enabled */ 52 df_none = 0, 53 /** Use double buffer for display */ 54 df_disp_double_buf = 0x1 55 } ds_display_flags_t; 47 56 48 57 /** Display server display */ … … 84 93 /** Bounding rectangle */ 85 94 gfx_rect_t rect; 95 96 /** Backbuffer bitmap or @c NULL if not double-buffering */ 97 gfx_bitmap_t *backbuf; 98 99 /** Backbuffer GC or @c NULL if not double-buffering */ 100 mem_gc_t *bbgc; 101 102 /** Backbuffer dirty rectangle */ 103 gfx_rect_t dirty_rect; 104 105 /** Display flags */ 106 ds_display_flags_t flags; 86 107 } ds_display_t; 87 108
Note:
See TracChangeset
for help on using the changeset viewer.