Changes in / [37d4c91:3541cb9] in mainline
- Files:
-
- 141 added
- 85 deleted
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
meson/part/initrd_manifest/meson.build
r37d4c91 r3541cb9 60 60 if CONFIG_FB 61 61 rd_essential += [ 62 'app/ vlaunch',63 'app/ vterm',62 'app/launcher', 63 'app/terminal', 64 64 65 65 'srv/hid/display', -
tools/export.sh
r37d4c91 r3541cb9 39 39 40 40 EXPORT_LIBS=" \ 41 uspace/lib/ libmath.a \41 uspace/lib/c/libstartfiles.a \ 42 42 uspace/lib/libclui.a \ 43 uspace/lib/libc.a \ 44 uspace/lib/libcpp.a \ 43 45 uspace/lib/libdisplay.a \ 44 46 uspace/lib/libgfx.a \ 45 uspace/lib/libgui.a \ 47 uspace/lib/libgfxfont.a \ 48 uspace/lib/libgfximage.a \ 49 uspace/lib/libhound.a \ 46 50 uspace/lib/libipcgfx.a \ 47 uspace/lib/libdraw.a \ 48 uspace/lib/libsoftrend.a \ 49 uspace/lib/libhound.a \ 51 uspace/lib/libmath.a \ 52 uspace/lib/libmemgfx.a \ 50 53 uspace/lib/libpcm.a \ 51 uspace/lib/libcpp.a \ 52 uspace/lib/libc.a \ 53 uspace/lib/c/libstartfiles.a \ 54 uspace/lib/libpixconv.a \ 54 55 uspace/lib/libposix.a \ 56 uspace/lib/libriff.a \ 57 uspace/lib/libui.a \ 55 58 " 56 59 -
tools/xcw/bin/helenos-pkg-config
r37d4c91 r3541cb9 1 1 #!/bin/bash 2 2 # 3 # Copyright (c) 20 15Jiri Svoboda3 # Copyright (c) 2020 Jiri Svoboda 4 4 # All rights reserved. 5 5 # … … 44 44 libmath_libs="$LIB_DIR/libmath.a" 45 45 46 lib gui_cflags="-I$INCLUDE_DIR/libgui -I$INCLUDE_DIR/libdisplay -I$INCLUDE_DIR/libgfx -I$INCLUDE_DIR/libipcgfx"47 lib gui_libs="$LIB_DIR/libgui.a $LIB_DIR/libdisplay.a $LIB_DIR/libipcgfx.a $LIB_DIR/libgfx.a"46 libui_cflags="-I$INCLUDE_DIR/libui -I$INCLUDE_DIR/libdisplay -I$INCLUDE_DIR/libgfx -I$INCLUDE_DIR/libipcgfx" 47 libui_libs="$LIB_DIR/libui.a $LIB_DIR/libdisplay.a $LIB_DIR/libipcgfx.a $LIB_DIR/libgfx.a $LIB_DIR/libgfxfont.a $LIB_DIR/libriff.a $LIB_DIR/libmemgfx.a" 48 48 49 lib draw_cflags="-I$INCLUDE_DIR/libdraw"50 lib draw_libs="$LIB_DIR/libdraw.a $LIB_DIR/libsoftrend.a"49 libgfximage_cflags="-I$INCLUDE_DIR/libgfximage" 50 libgfximage_libs="$LIB_DIR/libgfximage.a $LIB_DIR/libpixconv.a" 51 51 52 52 libhound_cflags="-I$INCLUDE_DIR/libhound" … … 75 75 (.*) 76 76 case "$1" in 77 (lib gui) ;;78 (lib draw) ;;77 (libui) ;; 78 (libgfximage) ;; 79 79 (libmath) ;; 80 80 (libhound) ;; -
tools/xcw/demo/Makefile
r37d4c91 r3541cb9 50 50 INSTALL = install 51 51 TEST = helenos-test 52 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags lib gui libdraw libmath` \52 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libui libdraw libmath` \ 53 53 -D_HELENOS_SOURCE 54 LIBS = `helenos-pkg-config --libs lib gui libdraw libmath`54 LIBS = `helenos-pkg-config --libs libui libdraw libmath` 55 55 PREFIX = `helenos-bld-config --install-dir` 56 56 output = viewer -
uspace/app/barber/barber.c
r37d4c91 r3541cb9 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2014 Martin Decky 3 4 * All rights reserved. … … 33 34 */ 34 35 36 #include <device/led_dev.h> 37 #include <errno.h> 38 #include <fibril_synch.h> 39 #include <gfximage/tga_gz.h> 40 #include <io/pixel.h> 41 #include <loc.h> 42 #include <stats.h> 35 43 #include <stdbool.h> 36 #include <errno.h>37 44 #include <stdio.h> 38 45 #include <stdlib.h> 39 #include <task.h>40 #include <loc.h>41 #include <stats.h>42 46 #include <str.h> 43 #include <fibril_synch.h> 44 #include <io/pixel.h> 45 #include <device/led_dev.h> 46 #include <window.h> 47 #include <canvas.h> 48 #include <draw/surface.h> 49 #include <draw/codec.h> 47 #include <ui/ui.h> 48 #include <ui/wdecor.h> 49 #include <ui/window.h> 50 #include <ui/image.h> 50 51 #include "images.h" 51 52 … … 72 73 } led_dev_t; 73 74 74 static char *winreg = NULL; 75 typedef struct { 76 ui_t *ui; 77 } barber_t; 75 78 76 79 static fibril_timer_t *led_timer = NULL; … … 89 92 90 93 static fibril_timer_t *frame_timer = NULL; 91 static canvas_t *frame_canvas;92 static surface_t *frames[FRAMES];94 static ui_image_t *frame_img; 95 static gfx_bitmap_t *frame_bmp[FRAMES]; 93 96 94 97 static unsigned int frame = 0; … … 98 101 static void frame_timer_callback(void *); 99 102 100 static bool decode_frames(void) 101 { 103 static void wnd_close(ui_window_t *, void *); 104 105 static ui_window_cb_t window_cb = { 106 .close = wnd_close 107 }; 108 109 /** Window close button was clicked. 110 * 111 * @param window Window 112 * @param arg Argument (launcher) 113 */ 114 static void wnd_close(ui_window_t *window, void *arg) 115 { 116 barber_t *barber = (barber_t *) arg; 117 118 ui_quit(barber->ui); 119 } 120 121 static bool decode_frames(gfx_context_t *gc) 122 { 123 gfx_rect_t rect; 124 errno_t rc; 125 102 126 for (unsigned int i = 0; i < FRAMES; i++) { 103 frames[i] = decode_tga_gz(images[i].addr, images[i].size, 0); 104 if (frames[i] == NULL) { 127 rc = decode_tga_gz(gc, images[i].addr, images[i].size, 128 &frame_bmp[i], &rect); 129 if (rc != EOK) { 105 130 printf("Unable to decode frame %u.\n", i); 106 131 return false; 107 132 } 133 134 (void) rect; 108 135 } 109 136 110 137 return true; 138 } 139 140 static void destroy_frames(void) 141 { 142 unsigned i; 143 144 for (i = 0; i < FRAMES; i++) { 145 gfx_bitmap_destroy(frame_bmp[i]); 146 frame_bmp[i] = NULL; 147 } 111 148 } 112 149 … … 192 229 { 193 230 struct timespec prev; 231 gfx_rect_t rect; 194 232 getuptime(&prev); 195 233 … … 198 236 frame = 0; 199 237 200 update_canvas(frame_canvas, frames[frame]); 238 rect.p0.x = 0; 239 rect.p0.y = 0; 240 rect.p1.x = FRAME_WIDTH; 241 rect.p1.y = FRAME_HEIGHT; 242 243 ui_image_set_bmp(frame_img, frame_bmp[frame], &rect); 244 (void) ui_image_paint(frame_img); 201 245 202 246 struct timespec cur; … … 255 299 int main(int argc, char *argv[]) 256 300 { 257 const char *display_svc = DISPLAY_DEFAULT; 301 const char *display_spec = UI_DISPLAY_DEFAULT; 302 barber_t barber; 303 ui_t *ui; 304 ui_wnd_params_t params; 305 ui_window_t *window; 306 ui_resource_t *ui_res; 307 gfx_rect_t rect; 308 gfx_rect_t wrect; 309 gfx_rect_t app_rect; 310 gfx_context_t *gc; 311 gfx_coord2_t off; 258 312 int i; 259 313 … … 268 322 } 269 323 270 display_s vc = argv[i++];324 display_spec = argv[i++]; 271 325 } else { 272 326 printf("Invalid option '%s'.\n", argv[i]); … … 295 349 } 296 350 297 if (!decode_frames()) 298 return 1; 299 300 winreg = argv[1]; 301 window_t *main_window = window_open(display_svc, NULL, 302 WINDOW_MAIN | WINDOW_DECORATED, "barber"); 303 if (!main_window) { 304 printf("Cannot open main window.\n"); 305 return 1; 306 } 307 308 frame_canvas = create_canvas(window_root(main_window), NULL, 309 FRAME_WIDTH, FRAME_HEIGHT, frames[frame]); 310 311 if (!frame_canvas) { 312 window_close(main_window); 313 printf("Cannot create widgets.\n"); 314 return 1; 315 } 316 317 window_resize(main_window, 0, 0, FRAME_WIDTH + 8, FRAME_HEIGHT + 28, 318 WINDOW_PLACEMENT_RIGHT | WINDOW_PLACEMENT_BOTTOM); 319 window_exec(main_window); 351 rc = ui_create(display_spec, &ui); 352 if (rc != EOK) { 353 printf("Error creating UI on display %s.\n", display_spec); 354 return 1; 355 } 356 357 rect.p0.x = 0; 358 rect.p0.y = 0; 359 rect.p1.x = FRAME_WIDTH; 360 rect.p1.y = FRAME_HEIGHT; 361 362 ui_wnd_params_init(¶ms); 363 params.caption = ""; 364 params.placement = ui_wnd_place_bottom_right; 365 /* 366 * Compute window rectangle such that application area corresponds 367 * to rect 368 */ 369 ui_wdecor_rect_from_app(params.style, &rect, &wrect); 370 off = wrect.p0; 371 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); 372 373 barber.ui = ui; 374 375 rc = ui_window_create(ui, ¶ms, &window); 376 if (rc != EOK) { 377 printf("Error creating window.\n"); 378 return 1; 379 } 380 381 ui_res = ui_window_get_res(window); 382 gc = ui_window_get_gc(window); 383 ui_window_get_app_rect(window, &app_rect); 384 ui_window_set_cb(window, &window_cb, (void *) &barber); 385 386 if (!decode_frames(gc)) 387 return 1; 388 389 rc = ui_image_create(ui_res, frame_bmp[frame], &rect, 390 &frame_img); 391 if (rc != EOK) { 392 printf("Error creating UI.\n"); 393 return 1; 394 } 395 396 ui_image_set_rect(frame_img, &app_rect); 397 398 ui_window_add(window, ui_image_ctl(frame_img)); 399 400 rc = ui_window_paint(window); 401 if (rc != EOK) { 402 printf("Error painting window.\n"); 403 return 1; 404 } 320 405 321 406 plan_led_timer(); 322 407 plan_frame_timer(0); 323 408 324 task_retval(0); 325 async_manager(); 409 ui_run(ui); 410 411 /* Unlink bitmap from image so it is not destroyed along with it */ 412 ui_image_set_bmp(frame_img, NULL, &rect); 413 414 ui_window_destroy(window); 415 ui_destroy(ui); 416 417 destroy_frames(); 326 418 327 419 return 0; -
uspace/app/barber/meson.build
r37d4c91 r3541cb9 27 27 # 28 28 29 deps = [ ' gui', 'draw', 'compress', 'softrend', 'math' ]29 deps = [ 'ui', 'gfximage', 'compress' ] 30 30 31 31 _images = files( -
uspace/app/gfxdemo/doc/doxygroups.h
r37d4c91 r3541cb9 1 /** @addtogroup vdemo vdemo2 * @brief Demo application1 /** @addtogroup gfxdemo gfxdemo 2 * @brief Graphic demo 3 3 * @ingroup apps 4 4 */ -
uspace/app/gfxdemo/gfxdemo.c
r37d4c91 r3541cb9 33 33 */ 34 34 35 #include <canvas.h>36 35 #include <congfx/console.h> 37 #include <draw/surface.h>38 36 #include <display.h> 39 37 #include <fibril.h> 40 #include <guigfx/canvas.h>41 38 #include <gfx/bitmap.h> 42 39 #include <gfx/color.h> 43 40 #include <gfx/render.h> 41 #include <gfx/font.h> 42 #include <gfx/text.h> 43 #include <gfx/typeface.h> 44 44 #include <io/console.h> 45 45 #include <io/pixelmap.h> … … 48 48 #include <str.h> 49 49 #include <task.h> 50 #include <window.h> 50 #include <ui/ui.h> 51 #include <ui/window.h> 52 #include <ui/wdecor.h> 51 53 52 54 static void wnd_close_event(void *); … … 58 60 }; 59 61 62 static void uiwnd_close_event(ui_window_t *, void *); 63 static void uiwnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 64 65 static ui_window_cb_t ui_window_cb = { 66 .close = uiwnd_close_event, 67 .kbd = uiwnd_kbd_event 68 }; 69 60 70 static bool quit = false; 61 71 … … 109 119 int i, j; 110 120 errno_t rc; 121 122 if (quit) 123 return EOK; 111 124 112 125 rc = clear_scr(gc, w, h); … … 265 278 gfx_rect_t srect; 266 279 errno_t rc; 280 281 if (quit) 282 return EOK; 267 283 268 284 rc = clear_scr(gc, w, h); … … 299 315 300 316 if (quit) 301 break;317 goto out; 302 318 } 303 319 } 304 320 321 out: 305 322 gfx_bitmap_destroy(bitmap); 306 323 … … 324 341 gfx_coord2_t offs; 325 342 errno_t rc; 343 344 if (quit) 345 return EOK; 326 346 327 347 rc = clear_scr(gc, w, h); … … 366 386 return rc; 367 387 } 388 368 389 /** Run bitmap color key demo on a graphic context. 369 390 * … … 379 400 gfx_coord2_t offs; 380 401 errno_t rc; 402 403 if (quit) 404 return EOK; 381 405 382 406 rc = clear_scr(gc, w, h); … … 424 448 } 425 449 426 /** Run demo loopon a graphic context.450 /** Run text demo on a graphic context. 427 451 * 428 452 * @param gc Graphic context … … 430 454 * @param h Height 431 455 */ 456 static errno_t demo_text(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 457 { 458 gfx_color_t *color = NULL; 459 gfx_rect_t rect; 460 gfx_typeface_t *tface = NULL; 461 gfx_font_info_t *finfo; 462 gfx_font_t *font = NULL; 463 gfx_coord2_t pos; 464 gfx_text_fmt_t fmt; 465 int i; 466 errno_t rc; 467 468 if (quit) 469 return EOK; 470 471 rc = gfx_typeface_open(gc, "/data/font/helena.tpf", &tface); 472 if (rc != EOK) { 473 printf("Error opening typeface\n"); 474 goto error; 475 } 476 477 finfo = gfx_typeface_first_font(tface); 478 if (finfo == NULL) { 479 printf("Typeface contains no font.\n"); 480 rc = ENOENT; 481 goto error; 482 } 483 484 rc = gfx_font_open(finfo, &font); 485 if (rc != EOK) { 486 printf("Error opening font.\n"); 487 goto error; 488 } 489 490 rc = clear_scr(gc, w, h); 491 if (rc != EOK) 492 goto error; 493 494 /* Vertical bars */ 495 496 for (i = 0; i < 20; i++) { 497 rc = gfx_color_new_rgb_i16(0, 0x8000 * i / 20, 498 0x8000 * i / 20, &color); 499 if (rc != EOK) 500 goto error; 501 502 rc = gfx_set_color(gc, color); 503 if (rc != EOK) 504 goto error; 505 506 rect.p0.x = w * i / 20; 507 rect.p0.y = 0; 508 rect.p1.x = w * (i + 1) / 20; 509 rect.p1.y = h; 510 511 rc = gfx_fill_rect(gc, &rect); 512 if (rc != EOK) 513 goto error; 514 515 gfx_color_delete(color); 516 } 517 518 rc = gfx_color_new_rgb_i16(0, 0, 0x8000, &color); 519 if (rc != EOK) 520 goto error; 521 522 rc = gfx_set_color(gc, color); 523 if (rc != EOK) 524 goto error; 525 526 rect.p0.x = w / 20; 527 rect.p0.y = 2 * h / 15; 528 rect.p1.x = w - w / 20; 529 rect.p1.y = 5 * h / 15; 530 531 rc = gfx_fill_rect(gc, &rect); 532 if (rc != EOK) 533 goto error; 534 535 gfx_color_delete(color); 536 537 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); 538 if (rc != EOK) 539 goto error; 540 541 rc = gfx_set_color(gc, color); 542 if (rc != EOK) 543 goto error; 544 545 gfx_text_fmt_init(&fmt); 546 547 pos.x = rect.p0.x; 548 pos.y = rect.p0.y; 549 rc = gfx_puttext(font, &pos, &fmt, "Top left"); 550 if (rc != EOK) { 551 printf("Error rendering text.\n"); 552 goto error; 553 } 554 555 pos.x = (rect.p0.x + rect.p1.x - 1) / 2; 556 pos.y = rect.p0.y; 557 fmt.halign = gfx_halign_center; 558 rc = gfx_puttext(font, &pos, &fmt, "Top center"); 559 if (rc != EOK) 560 goto error; 561 562 pos.x = rect.p1.x - 1; 563 pos.y = rect.p0.y; 564 fmt.halign = gfx_halign_right; 565 rc = gfx_puttext(font, &pos, &fmt, "Top right"); 566 if (rc != EOK) 567 goto error; 568 569 fmt.valign = gfx_valign_center; 570 571 pos.x = rect.p0.x; 572 pos.y = (rect.p0.y + rect.p1.y - 1) / 2; 573 fmt.halign = gfx_halign_left; 574 rc = gfx_puttext(font, &pos, &fmt, "Center left"); 575 if (rc != EOK) 576 goto error; 577 578 pos.x = (rect.p0.x + rect.p1.x - 1) / 2; 579 pos.y = (rect.p0.y + rect.p1.y - 1) / 2; 580 fmt.halign = gfx_halign_center; 581 rc = gfx_puttext(font, &pos, &fmt, "Center"); 582 if (rc != EOK) 583 goto error; 584 585 pos.x = rect.p1.x - 1; 586 pos.y = (rect.p0.y + rect.p1.y - 1) / 2; 587 fmt.halign = gfx_halign_right; 588 rc = gfx_puttext(font, &pos, &fmt, "Center right"); 589 if (rc != EOK) 590 goto error; 591 592 fmt.valign = gfx_valign_bottom; 593 594 pos.x = rect.p0.x; 595 pos.y = rect.p1.y - 1; 596 fmt.halign = gfx_halign_left; 597 rc = gfx_puttext(font, &pos, &fmt, "Bottom left"); 598 if (rc != EOK) 599 goto error; 600 601 pos.x = (rect.p0.x + rect.p1.x - 1) / 2; 602 pos.y = rect.p1.y - 1; 603 fmt.halign = gfx_halign_center; 604 rc = gfx_puttext(font, &pos, &fmt, "Bottom center"); 605 if (rc != EOK) 606 goto error; 607 608 pos.x = rect.p1.x - 1; 609 pos.y = rect.p1.y - 1; 610 fmt.halign = gfx_halign_right; 611 rc = gfx_puttext(font, &pos, &fmt, "Bottom right"); 612 if (rc != EOK) 613 goto error; 614 615 gfx_color_delete(color); 616 617 gfx_text_fmt_init(&fmt); 618 619 for (i = 0; i < 8; i++) { 620 rc = gfx_color_new_rgb_i16((i & 4) ? 0xffff : 0, 621 (i & 2) ? 0xffff : 0, (i & 1) ? 0xffff : 0, &color); 622 if (rc != EOK) 623 goto error; 624 625 rc = gfx_set_color(gc, color); 626 if (rc != EOK) 627 goto error; 628 629 pos.x = w / 20; 630 pos.y = (7 + i) * h / 15; 631 rc = gfx_puttext(font, &pos, &fmt, "The quick brown fox jumps over the lazy dog."); 632 if (rc != EOK) 633 goto error; 634 635 gfx_color_delete(color); 636 } 637 638 for (i = 0; i < 10; i++) { 639 fibril_usleep(500 * 1000); 640 if (quit) 641 break; 642 } 643 644 gfx_font_close(font); 645 gfx_typeface_destroy(tface); 646 return EOK; 647 error: 648 if (font != NULL) 649 gfx_font_close(font); 650 if (tface != NULL) 651 gfx_typeface_destroy(tface); 652 return rc; 653 } 654 655 /** Run demo loop on a graphic context. 656 * 657 * @param gc Graphic context 658 * @param w Width 659 * @param h Height 660 */ 432 661 static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 433 662 { … … 448 677 449 678 rc = demo_bitmap_kc(gc, w, h); 679 if (rc != EOK) 680 return rc; 681 682 rc = demo_text(gc, w, h); 450 683 if (rc != EOK) 451 684 return rc; … … 486 719 } 487 720 488 /** Run demo on canvas. */ 489 static errno_t demo_canvas(const char *display_svc) 490 { 491 canvas_gc_t *cgc = NULL; 721 /** Run demo on UI. */ 722 static errno_t demo_ui(const char *display_spec) 723 { 724 ui_t *ui = NULL; 725 ui_wnd_params_t params; 726 ui_window_t *window = NULL; 492 727 gfx_context_t *gc; 493 window_t *window = NULL; 494 pixel_t *pixbuf = NULL; 495 surface_t *surface = NULL; 496 canvas_t *canvas = NULL; 497 gfx_coord_t vw, vh; 498 errno_t rc; 499 500 printf("Init canvas..\n"); 501 502 window = window_open(display_svc, NULL, 503 WINDOW_MAIN | WINDOW_DECORATED, "GFX Demo"); 504 if (window == NULL) { 728 gfx_rect_t rect; 729 gfx_rect_t wrect; 730 gfx_coord2_t off; 731 errno_t rc; 732 733 printf("Init UI..\n"); 734 735 rc = ui_create(display_spec, &ui); 736 if (rc != EOK) { 737 printf("Error initializing UI (%s)\n", display_spec); 738 goto error; 739 } 740 741 rect.p0.x = 0; 742 rect.p0.y = 0; 743 rect.p1.x = 400; 744 rect.p1.y = 300; 745 746 ui_wnd_params_init(¶ms); 747 params.caption = "GFX Demo"; 748 749 /* 750 * Compute window rectangle such that application area corresponds 751 * to rect 752 */ 753 ui_wdecor_rect_from_app(params.style, &rect, &wrect); 754 off = wrect.p0; 755 gfx_rect_rtranslate(&off, &wrect, ¶ms.rect); 756 757 rc = ui_window_create(ui, ¶ms, &window); 758 if (rc != EOK) { 505 759 printf("Error creating window.\n"); 506 return -1; 507 } 508 509 vw = 400; 510 vh = 300; 511 512 pixbuf = calloc(vw * vh, sizeof(pixel_t)); 513 if (pixbuf == NULL) { 514 printf("Error allocating memory for pixel buffer.\n"); 515 return ENOMEM; 516 } 517 518 surface = surface_create(vw, vh, pixbuf, 0); 519 if (surface == NULL) { 520 printf("Error creating surface.\n"); 521 return EIO; 522 } 523 524 canvas = create_canvas(window_root(window), NULL, vw, vh, 525 surface); 526 if (canvas == NULL) { 527 printf("Error creating canvas.\n"); 528 return EIO; 529 } 530 531 window_resize(window, 0, 0, vw + 10, vh + 30, WINDOW_PLACEMENT_ANY); 532 window_exec(window); 533 534 printf("Create canvas GC\n"); 535 rc = canvas_gc_create(canvas, surface, &cgc); 536 if (rc != EOK) 537 return rc; 538 539 gc = canvas_gc_get_ctx(cgc); 760 goto error; 761 } 762 763 ui_window_set_cb(window, &ui_window_cb, NULL); 764 765 rc = ui_window_get_app_gc(window, &gc); 766 if (rc != EOK) { 767 printf("Error creating graphic context.\n"); 768 goto error; 769 } 540 770 541 771 task_retval(0); 542 772 543 rc = demo_loop(gc, 400, 300); 544 if (rc != EOK) 545 return rc; 546 547 rc = canvas_gc_delete(cgc); 548 if (rc != EOK) 549 return rc; 550 551 return EOK; 773 rc = demo_loop(gc, rect.p1.x, rect.p1.y); 774 if (rc != EOK) 775 goto error; 776 777 ui_window_destroy(window); 778 ui_destroy(ui); 779 780 return EOK; 781 error: 782 if (window != NULL) 783 ui_window_destroy(window); 784 if (ui != NULL) 785 ui_destroy(ui); 786 return rc; 552 787 } 553 788 … … 610 845 611 846 static void wnd_kbd_event(void *arg, kbd_event_t *event) 847 { 848 printf("Keyboard event type=%d key=%d\n", event->type, event->key); 849 if (event->type == KEY_PRESS) 850 quit = true; 851 } 852 853 static void uiwnd_close_event(ui_window_t *window, void *arg) 854 { 855 printf("Close event\n"); 856 quit = true; 857 } 858 859 static void uiwnd_kbd_event(ui_window_t *window, void *arg, kbd_event_t *event) 612 860 { 613 861 printf("Keyboard event type=%d key=%d\n", event->type, event->key); … … 653 901 if (rc != EOK) 654 902 return 1; 655 } else if (str_cmp(argv[i], " canvas") == 0) {656 rc = demo_ canvas(display_svc);903 } else if (str_cmp(argv[i], "ui") == 0) { 904 rc = demo_ui(display_svc); 657 905 if (rc != EOK) 658 906 return 1; -
uspace/app/gfxdemo/meson.build
r37d4c91 r3541cb9 27 27 # 28 28 29 deps = [ 'gfx', 'g uigfx', 'congfx', 'ipcgfx', 'display' ]29 deps = [ 'gfx', 'gfxfont', 'ui', 'congfx', 'ipcgfx', 'display' ] 30 30 src = files( 31 31 'gfxdemo.c', -
uspace/app/init/init.c
r37d4c91 r3541cb9 277 277 } 278 278 279 static int app_start(const char *app )279 static int app_start(const char *app, const char *arg) 280 280 { 281 281 printf("%s: Spawning %s\n", NAME, app); … … 283 283 task_id_t id; 284 284 task_wait_t wait; 285 errno_t rc = task_spawnl(&id, &wait, app, app, NULL);285 errno_t rc = task_spawnl(&id, &wait, app, app, arg, NULL); 286 286 if (rc != EOK) { 287 287 oom_check(rc, app); … … 471 471 rc = display_server(); 472 472 if (rc == EOK) { 473 app_start("/app/ barber");474 app_start("/app/ vlaunch");475 app_start("/app/ vterm");473 app_start("/app/launcher", NULL); 474 app_start("/app/barber", NULL); 475 app_start("/app/terminal", "-topleft"); 476 476 } 477 477 } -
uspace/app/meson.build
r37d4c91 r3541cb9 32 32 'bithenge', 33 33 'blkdump', 34 'calculator', 34 35 'contacts', 35 36 'corecfg', … … 43 44 'edit', 44 45 'fdisk', 45 'font viewer',46 'fontedit', 46 47 'getterm', 47 48 'gfxdemo', 48 49 'gunzip', 49 50 'hbench', 51 'hello', 50 52 'inet', 51 53 'init', … … 53 55 'killall', 54 56 'kio', 57 'launcher', 55 58 'loc', 56 59 'logset', … … 76 79 'sysinst', 77 80 'taskdump', 81 'terminal', 78 82 'tester', 79 83 'testread', … … 84 88 'top', 85 89 'trace', 90 'uidemo', 86 91 'untar', 87 92 'usbinfo', 88 'vcalc',89 'vdemo',90 93 'viewer', 91 'vlaunch',92 94 'vol', 93 'vterm',94 95 'vuhid', 95 96 'wavplay', -
uspace/app/viewer/meson.build
r37d4c91 r3541cb9 27 27 # 28 28 29 deps = [ ' gui' ]29 deps = [ 'ui', 'gfximage', 'compress' ] 30 30 src = files('viewer.c') 31 31 -
uspace/app/viewer/viewer.c
r37d4c91 r3541cb9 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda 2 3 * Copyright (c) 2013 Martin Decky 3 4 * All rights reserved. … … 33 34 */ 34 35 36 #include <errno.h> 37 #include <gfximage/tga.h> 38 #include <stdbool.h> 35 39 #include <stdio.h> 36 40 #include <stdlib.h> 41 #include <str.h> 42 #include <ui/image.h> 43 #include <ui/ui.h> 44 #include <ui/wdecor.h> 45 #include <ui/window.h> 37 46 #include <vfs/vfs.h> 38 #include <errno.h>39 #include <stdlib.h>40 #include <stdbool.h>41 #include <window.h>42 #include <canvas.h>43 #include <draw/surface.h>44 #include <draw/codec.h>45 #include <task.h>46 #include <str.h>47 47 48 48 #define NAME "viewer" 49 49 50 #define WINDOW_WIDTH 1024 51 #define WINDOW_HEIGHT 768 52 53 #define DECORATION_WIDTH 8 54 #define DECORATION_HEIGHT 28 50 typedef struct { 51 ui_t *ui; 52 } viewer_t; 55 53 56 54 static size_t imgs_count; … … 58 56 static char **imgs; 59 57 60 static window_t *main_window; 61 static surface_t *surface = NULL; 62 static canvas_t *canvas = NULL; 63 64 static surface_coord_t img_width; 65 static surface_coord_t img_height; 66 67 static bool img_load(const char *, surface_t **); 68 static bool img_setup(surface_t *); 69 70 static void on_keyboard_event(widget_t *widget, void *data) 71 { 72 kbd_event_t *event = (kbd_event_t *) data; 58 static ui_window_t *window; 59 static gfx_bitmap_t *bitmap = NULL; 60 static ui_image_t *image = NULL; 61 static gfx_context_t *window_gc; 62 63 static gfx_rect_t img_rect; 64 65 static bool img_load(gfx_context_t *gc, const char *, gfx_bitmap_t **, 66 gfx_rect_t *); 67 static bool img_setup(gfx_context_t *, gfx_bitmap_t *, gfx_rect_t *); 68 69 static void wnd_close(ui_window_t *, void *); 70 static void wnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 71 72 static ui_window_cb_t window_cb = { 73 .close = wnd_close, 74 .kbd = wnd_kbd_event 75 }; 76 77 /** Window close request 78 * 79 * @param window Window 80 * @param arg Argument (calc_t *) 81 */ 82 static void wnd_close(ui_window_t *window, void *arg) 83 { 84 viewer_t *viewer = (viewer_t *) arg; 85 86 ui_quit(viewer->ui); 87 } 88 89 static void wnd_kbd_event(ui_window_t *window, void *arg, 90 kbd_event_t *event) 91 { 73 92 bool update = false; 74 93 … … 95 114 96 115 if (update) { 97 surface_t *lsface; 98 99 if (!img_load(imgs[imgs_current], &lsface)) { 116 gfx_bitmap_t *lbitmap; 117 gfx_rect_t lrect; 118 119 if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) { 100 120 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 101 121 exit(4); 102 122 } 103 if (!img_setup( lsface)) {123 if (!img_setup(window_gc, lbitmap, &lrect)) { 104 124 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 105 125 exit(6); … … 108 128 } 109 129 110 static bool img_load(const char *fname, surface_t **p_local_surface) 130 static bool img_load(gfx_context_t *gc, const char *fname, 131 gfx_bitmap_t **rbitmap, gfx_rect_t *rect) 111 132 { 112 133 int fd; … … 138 159 vfs_put(fd); 139 160 140 *p_local_surface = decode_tga(tga, stat.size, 0);141 if ( *p_local_surface == NULL) {161 rc = decode_tga(gc, tga, stat.size, rbitmap, rect); 162 if (rc != EOK) { 142 163 free(tga); 143 164 return false; … … 146 167 free(tga); 147 168 148 surface_get_resolution(*p_local_surface, &img_width, &img_height); 149 169 img_rect = *rect; 150 170 return true; 151 171 } 152 172 153 static bool img_setup(surface_t *local_surface) 154 { 155 if (canvas != NULL) { 156 if (!update_canvas(canvas, local_surface)) { 157 surface_destroy(local_surface); 173 static bool img_setup(gfx_context_t *gc, gfx_bitmap_t *bmp, gfx_rect_t *rect) 174 { 175 gfx_rect_t arect; 176 gfx_rect_t irect; 177 ui_resource_t *ui_res; 178 errno_t rc; 179 180 ui_res = ui_window_get_res(window); 181 182 ui_window_get_app_rect(window, &arect); 183 184 /* Center image on application area */ 185 gfx_rect_ctr_on_rect(rect, &arect, &irect); 186 187 if (image != NULL) { 188 ui_image_set_bmp(image, bmp, rect); 189 (void) ui_image_paint(image); 190 ui_image_set_rect(image, &irect); 191 } else { 192 rc = ui_image_create(ui_res, bmp, rect, &image); 193 if (rc != EOK) { 194 gfx_bitmap_destroy(bmp); 158 195 return false; 159 196 } 160 } else { 161 canvas = create_canvas(window_root(main_window), NULL, 162 img_width, img_height, local_surface); 163 if (canvas == NULL) { 164 surface_destroy(local_surface); 165 return false; 166 } 167 168 sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event); 169 } 170 171 if (surface != NULL) 172 surface_destroy(surface); 173 174 surface = local_surface; 197 198 ui_image_set_rect(image, &irect); 199 ui_window_add(window, ui_image_ctl(image)); 200 } 201 202 if (bitmap != NULL) 203 gfx_bitmap_destroy(bitmap); 204 205 bitmap = bmp; 175 206 return true; 176 207 } … … 178 209 static void print_syntax(void) 179 210 { 180 printf("Syntax: %s [-d <display>] <image-file>...\n", NAME); 211 printf("Syntax: %s [<options] <image-file>...\n", NAME); 212 printf("\t-d <display-spec> Use the specified display\n"); 213 printf("\t-f Full-screen mode\n"); 181 214 } 182 215 183 216 int main(int argc, char *argv[]) 184 217 { 185 const char *display_svc = DISPLAY_DEFAULT; 186 window_flags_t flags; 187 surface_t *lsface; 188 bool fullscreen; 189 sysarg_t dwidth; 190 sysarg_t dheight; 218 const char *display_spec = DISPLAY_DEFAULT; 219 gfx_bitmap_t *lbitmap; 220 gfx_rect_t lrect; 221 bool fullscreen = false; 222 gfx_rect_t rect; 223 gfx_rect_t wrect; 224 gfx_coord2_t off; 225 ui_t *ui; 226 ui_wnd_params_t params; 227 viewer_t viewer; 228 errno_t rc; 191 229 int i; 192 230 … … 201 239 } 202 240 203 display_svc = argv[i++]; 241 display_spec = argv[i++]; 242 } else if (str_cmp(argv[i], "-f") == 0) { 243 ++i; 244 fullscreen = true; 204 245 } else { 205 246 printf("Invalid option '%s'.\n", argv[i]); … … 219 260 if (imgs == NULL) { 220 261 printf("Out of memory.\n"); 221 return 2;262 return 1; 222 263 } 223 264 … … 230 271 } 231 272 232 if (!img_load(imgs[imgs_current], &lsface)) { 273 rc = ui_create(display_spec, &ui); 274 if (rc != EOK) { 275 printf("Error creating UI on display %s.\n", display_spec); 276 return 1; 277 } 278 279 viewer.ui = ui; 280 281 /* 282 * We don't know the image size yet, so create tiny window and resize 283 * later. 284 */ 285 ui_wnd_params_init(¶ms); 286 params.caption = "Viewer"; 287 params.rect.p0.x = 0; 288 params.rect.p0.y = 0; 289 params.rect.p1.x = 1; 290 params.rect.p1.y = 1; 291 292 if (fullscreen) { 293 params.style &= ~ui_wds_decorated; 294 params.placement = ui_wnd_place_full_screen; 295 } 296 297 rc = ui_window_create(ui, ¶ms, &window); 298 if (rc != EOK) { 299 printf("Error creating window.\n"); 300 return 1; 301 } 302 303 window_gc = ui_window_get_gc(window); 304 305 ui_window_set_cb(window, &window_cb, (void *) &viewer); 306 307 if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) { 233 308 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 234 return 4; 235 } 236 237 fullscreen = ((img_width == WINDOW_WIDTH) && 238 (img_height == WINDOW_HEIGHT)); 239 240 flags = WINDOW_MAIN; 241 if (!fullscreen) 242 flags |= WINDOW_DECORATED; 243 244 main_window = window_open(display_svc, NULL, flags, "viewer"); 245 if (!main_window) { 246 printf("Cannot open main window.\n"); 247 return 5; 248 } 249 250 if (!img_setup(lsface)) { 309 return 1; 310 } 311 312 /* 313 * Compute window rectangle such that application area corresponds 314 * to rect 315 */ 316 ui_wdecor_rect_from_app(params.style, &lrect, &wrect); 317 off = wrect.p0; 318 gfx_rect_rtranslate(&off, &wrect, &rect); 319 320 if (!fullscreen) { 321 rc = ui_window_resize(window, &rect); 322 if (rc != EOK) { 323 printf("Error resizing window.\n"); 324 return 1; 325 } 326 } 327 328 if (!img_setup(window_gc, lbitmap, &lrect)) { 251 329 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 252 return 6; 253 } 254 255 if (!fullscreen) { 256 dwidth = DECORATION_WIDTH; 257 dheight = DECORATION_HEIGHT; 258 } else { 259 dwidth = 0; 260 dheight = 0; 261 } 262 263 window_resize(main_window, 0, 0, img_width + dwidth, 264 img_height + dheight, WINDOW_PLACEMENT_ANY); 265 window_exec(main_window); 266 267 task_retval(0); 268 async_manager(); 330 return 1; 331 } 332 333 rc = ui_window_paint(window); 334 if (rc != EOK) { 335 printf("Error painting window.\n"); 336 return 1; 337 } 338 339 ui_run(ui); 269 340 270 341 return 0; -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
r37d4c91 r3541cb9 383 383 384 384 /* Check that we support all required flags */ 385 if ((params->flags & ~ bmpf_color_key) != 0)385 if ((params->flags & ~(bmpf_color_key | bmpf_colorize)) != 0) 386 386 return ENOTSUP; 387 387 … … 392 392 gfx_coord2_subtract(¶ms->rect.p1, ¶ms->rect.p0, &dim); 393 393 dcbm->rect = params->rect; 394 dcbm->flags = params->flags; 394 395 395 396 if (alloc == NULL) { … … 487 488 gfx_rect_clip(&srect, &skfbrect, &crect); 488 489 489 // XXX bmpf_color_key 490 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 491 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 492 gfx_coord2_subtract(&pos, &dcbm->rect.p0, &sp); 493 gfx_coord2_add(&pos, &offs, &dp); 494 495 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 496 dispc->active_fb.pixel2visual(dispc->fb_data + 497 FB_POS(dispc, dp.x, dp.y), color); 490 if ((dcbm->flags & bmpf_color_key) == 0) { 491 /* Simple copy */ 492 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 493 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 494 gfx_coord2_subtract(&pos, &dcbm->rect.p0, &sp); 495 gfx_coord2_add(&pos, &offs, &dp); 496 497 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 498 dispc->active_fb.pixel2visual(dispc->fb_data + 499 FB_POS(dispc, dp.x, dp.y), color); 500 } 501 } 502 } else if ((dcbm->flags & bmpf_colorize) == 0) { 503 /* Color key */ 504 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 505 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 506 gfx_coord2_subtract(&pos, &dcbm->rect.p0, &sp); 507 gfx_coord2_add(&pos, &offs, &dp); 508 509 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 510 if (color != dcbm->key_color) { 511 dispc->active_fb.pixel2visual(dispc->fb_data + 512 FB_POS(dispc, dp.x, dp.y), color); 513 } 514 } 515 } 516 } else { 517 /* Color key & colorize */ 518 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 519 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 520 gfx_coord2_subtract(&pos, &dcbm->rect.p0, &sp); 521 gfx_coord2_add(&pos, &offs, &dp); 522 523 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 524 if (color != dcbm->key_color) { 525 dispc->active_fb.pixel2visual(dispc->fb_data + 526 FB_POS(dispc, dp.x, dp.y), 527 dcbm->dispc->color); 528 } 529 } 498 530 } 499 531 } -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.h
r37d4c91 r3541cb9 68 68 69 69 typedef struct { 70 /* Containing display controller */ 70 71 amdm37x_dispc_t *dispc; 72 /** Allocation info */ 71 73 gfx_bitmap_alloc_t alloc; 74 /** @c true if we allocated the bitmap, @c false if allocated by caller */ 75 bool myalloc; 76 /** Rectangle covered by bitmap */ 72 77 gfx_rect_t rect; 73 bool myalloc; 78 /** Bitmap flags */ 79 gfx_bitmap_flags_t flags; 80 /** Key color */ 81 pixel_t key_color; 74 82 } amdm37x_bitmap_t; 75 83 -
uspace/drv/fb/amdm37x_dispc/meson.build
r37d4c91 r3541cb9 29 29 # 30 30 31 deps = [ 'gfx', 'ipcgfx', 'ddev', ' softrend' ]31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'pixconv' ] 32 32 src = files('amdm37x_dispc.c', 'main.c') -
uspace/drv/fb/kfb/meson.build
r37d4c91 r3541cb9 29 29 # 30 30 31 deps = [ 'gfx', 'ipcgfx', 'ddev', ' softrend' ]31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'pixconv' ] 32 32 src = files('port.c', 'kfb.c') -
uspace/drv/fb/kfb/port.c
r37d4c91 r3541cb9 50 50 #include <gfx/color.h> 51 51 #include <gfx/coord.h> 52 #include <io/mode.h>53 52 #include <io/pixelmap.h> 54 53 #include <ipcgfx/server.h> … … 200 199 201 200 /* Check that we support all required flags */ 202 if ((params->flags & ~ bmpf_color_key) != 0)201 if ((params->flags & ~(bmpf_color_key | bmpf_colorize)) != 0) 203 202 return ENOTSUP; 204 203 … … 307 306 308 307 if ((kfbbm->flags & bmpf_color_key) != 0) { 308 /* Simple copy */ 309 309 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 310 310 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { … … 319 319 } 320 320 } 321 } else if ((kfbbm->flags & bmpf_colorize) != 0) { 322 /* Color key */ 323 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 324 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { 325 gfx_coord2_subtract(&pos, &kfbbm->rect.p0, &sp); 326 gfx_coord2_add(&pos, &offs, &dp); 327 328 color = pixelmap_get_pixel(&pbm, sp.x, sp.y); 329 kfb->pixel2visual(kfb->addr + 330 FB_POS(kfb, dp.x, dp.y), color); 331 } 332 } 321 333 } else { 334 /* Color key & colorize */ 322 335 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 323 336 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { -
uspace/lib/c/include/io/pixelmap.h
r37d4c91 r3541cb9 42 42 #include <stddef.h> 43 43 #include <io/pixel.h> 44 45 /* Defines how a pixel outside of pixmap rectangle shall be treated */46 typedef enum {47 /* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */48 PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,49 50 /* The pixmap is repeated infinetely */51 PIXELMAP_EXTEND_TILE,52 53 /* If outside of a pixmap, return closest pixel from the edge */54 PIXELMAP_EXTEND_SIDES,55 56 /*57 * If outside of a pixmap, return closest pixel from the edge,58 * with alpha = 059 */60 PIXELMAP_EXTEND_TRANSPARENT_SIDES61 } pixelmap_extend_t;62 44 63 45 typedef struct { … … 106 88 } 107 89 108 static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,109 native_t x, native_t y, pixelmap_extend_t extend)110 {111 bool transparent = false;112 if (extend == PIXELMAP_EXTEND_TILE) {113 x %= pixmap->width;114 y %= pixmap->height;115 } else if (extend == PIXELMAP_EXTEND_SIDES ||116 extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {117 bool transparent_outside =118 (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);119 if (x < 0) {120 x = 0;121 transparent = transparent_outside;122 } else if (((sysarg_t) x) >= pixmap->width) {123 x = pixmap->width - 1;124 transparent = transparent_outside;125 }126 127 if (y < 0) {128 y = 0;129 transparent = transparent_outside;130 } else if (((sysarg_t) y) >= pixmap->height) {131 y = pixmap->height - 1;132 transparent = transparent_outside;133 }134 }135 136 if (x < 0 || ((sysarg_t) x) >= pixmap->width ||137 y < 0 || ((sysarg_t) y) >= pixmap->height)138 return PIXEL(0, 0, 0, 0);139 140 pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);141 142 if (transparent)143 pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));144 145 return pixel;146 }147 148 90 #endif 149 91 -
uspace/lib/congfx/src/console.c
r37d4c91 r3541cb9 207 207 208 208 /* Check that we support all requested flags */ 209 if ((params->flags & ~ bmpf_color_key) != 0)209 if ((params->flags & ~(bmpf_color_key | bmpf_colorize)) != 0) 210 210 return ENOTSUP; 211 211 … … 296 296 297 297 if ((cbm->flags & bmpf_color_key) == 0) { 298 /* Simple copy */ 298 299 for (y = crect.p0.y; y < crect.p1.y; y++) { 299 300 console_set_pos(cbm->cgc->con, crect.p0.x, y); … … 312 313 } 313 314 } 314 } else { 315 } else if ((cbm->flags & bmpf_colorize) == 0) { 316 /* Color key */ 315 317 for (y = crect.p0.y; y < crect.p1.y; y++) { 316 318 for (x = crect.p0.x; x < crect.p1.x; x++) { … … 332 334 } 333 335 } 336 } else { 337 /* Color key & colorize */ 338 console_set_rgb_color(cbm->cgc->con, cbm->cgc->clr, 339 cbm->cgc->clr); 340 341 for (y = crect.p0.y; y < crect.p1.y; y++) { 342 for (x = crect.p0.x; x < crect.p1.x; x++) { 343 344 clr = pixelmap_get_pixel(&pixelmap, 345 x - offs.x - cbm->rect.p0.x, 346 y - offs.y - cbm->rect.p0.y); 347 348 if (clr != cbm->key_color) { 349 console_set_pos(cbm->cgc->con, x, y); 350 rv = fputc('X', cbm->cgc->fout); 351 if (rv < 0) 352 return EIO; 353 354 console_flush(cbm->cgc->con); 355 } 356 357 } 358 } 334 359 } 335 360 -
uspace/lib/display/include/types/display.h
r37d4c91 r3541cb9 46 46 #define DISPLAY_DEFAULT NULL 47 47 48 struct display; 49 struct display_window; 50 48 51 /** Display server session */ 49 typedef struct { 50 /** Session with display server */ 51 async_sess_t *sess; 52 /** Synchronize access to display object */ 53 fibril_mutex_t lock; 54 /** @c true if callback handler terminated */ 55 bool cb_done; 56 /** Signalled when cb_done or ev_pending is changed */ 57 fibril_condvar_t cv; 58 /** Windows (of display_window_t) */ 59 list_t windows; 60 } display_t; 52 typedef struct display display_t; 53 54 /** Display window */ 55 typedef struct display_window display_window_t; 61 56 62 57 /** Display window callbacks */ … … 76 71 } display_wnd_cb_t; 77 72 78 /** Display window */79 typedef struct {80 /** Display associated with the window */81 display_t *display;82 /** Link to @c display->windows */83 link_t lwindows;84 /** Window ID */85 sysarg_t id;86 /** Callback functions */87 display_wnd_cb_t *cb;88 /** Argument to callback functions */89 void *cb_arg;90 } display_window_t;91 92 73 #endif 93 74 -
uspace/lib/display/include/types/display/wndparams.h
r37d4c91 r3541cb9 41 41 * 42 42 * The window's dimensions are determined by the bounding rectangle, 43 * the position of which does not relate to its posit on on the display,43 * the position of which does not relate to its position on the display, 44 44 * it just determines which range of logical coordinates is used 45 45 * by the window. -
uspace/lib/display/src/display.c
r37d4c91 r3541cb9 38 38 #include <mem.h> 39 39 #include <stdlib.h> 40 #include "../private/display.h" 40 41 #include "../private/params.h" 41 42 … … 198 199 /** Destroy display window. 199 200 * 200 * @param window Window 201 * @param window Window or @c NULL 201 202 * @return EOK on success or an error code. In both cases @a window must 202 203 * not be accessed anymore … … 206 207 async_exch_t *exch; 207 208 errno_t rc; 209 210 if (window == NULL) 211 return EOK; 208 212 209 213 exch = async_exchange_begin(window->display->sess); -
uspace/lib/display/test/display.c
r37d4c91 r3541cb9 38 38 #include <loc.h> 39 39 #include <pcut/pcut.h> 40 #include "../private/display.h" 40 41 41 42 PCUT_INIT; … … 331 332 } 332 333 334 /** display_window_destroy() can handle NULL argument */ 335 PCUT_TEST(window_destroy_null) 336 { 337 display_window_destroy(NULL); 338 } 339 333 340 /** display_window_move_req() with server returning error response works. */ 334 341 PCUT_TEST(window_move_req_failure) -
uspace/lib/gfx/include/gfx/coord.h
r37d4c91 r3541cb9 40 40 #include <types/gfx/coord.h> 41 41 42 extern gfx_coord_t gfx_coord_div_rneg(gfx_coord_t, gfx_coord_t); 42 43 extern void gfx_coord2_add(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *); 43 44 extern void gfx_coord2_subtract(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *); … … 51 52 extern void gfx_rect_envelope(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *); 52 53 extern void gfx_rect_clip(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *); 54 extern void gfx_rect_ctr_on_rect(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *); 53 55 extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *); 54 56 extern void gfx_rect_dims(gfx_rect_t *, gfx_coord2_t *); -
uspace/lib/gfx/include/types/gfx/bitmap.h
r37d4c91 r3541cb9 47 47 /** Bitmap flags */ 48 48 typedef enum { 49 /** Directly map GC output into this bitmap */ 50 bmpf_direct_output = 0x1, 49 51 /** Enable color key */ 50 bmpf_color_key = 0x 1,51 /** Directly map GC output into this bitmap*/52 bmpf_ direct_output = 0x252 bmpf_color_key = 0x2, 53 /** Paint non-background pixels with current drawing color */ 54 bmpf_colorize = 0x4 53 55 } gfx_bitmap_flags_t; 54 56 -
uspace/lib/gfx/private/color.h
r37d4c91 r3541cb9 38 38 #define _GFX_PRIVATE_COLOR_H 39 39 40 #include <stdint.h> 41 40 42 /** Actual structure of graphics color. 41 43 * -
uspace/lib/gfx/src/bitmap.c
r37d4c91 r3541cb9 62 62 * 63 63 * @return EOK on success, EINVAL if parameters are invald, 64 * ENOMEM if insufficient resources, EIO if gra hic device connection64 * ENOMEM if insufficient resources, EIO if graphic device connection 65 65 * was lost 66 66 */ … … 92 92 * @param bitmap Bitmap 93 93 * 94 * @return EOK on success, EIO if gra hic device connection was lost94 * @return EOK on success, EIO if graphic device connection was lost 95 95 */ 96 96 errno_t gfx_bitmap_destroy(gfx_bitmap_t *bitmap) … … 112 112 * @param offs Bitmap offset or @c NULL for zero offset 113 113 * 114 * @return EOK on success, EIO if gra hic device connection was lost114 * @return EOK on success, EIO if graphic device connection was lost 115 115 */ 116 116 errno_t gfx_bitmap_render(gfx_bitmap_t *bitmap, gfx_rect_t *srect, … … 125 125 * @param alloc Allocation info structure to fill in 126 126 * 127 * @return EOK on success, EIO if gra hic device connection was lost127 * @return EOK on success, EIO if graphic device connection was lost 128 128 */ 129 129 errno_t gfx_bitmap_get_alloc(gfx_bitmap_t *bitmap, gfx_bitmap_alloc_t *alloc) -
uspace/lib/gfx/src/coord.c
r37d4c91 r3541cb9 39 39 #include <stddef.h> 40 40 41 /** Divide @a a by @a b and round towards negative numbers. 42 * 43 * Regular integer division always rounds towards zero. This is not useful 44 * e.g. for scaling down, where we always need to round towards negative 45 * numbers. 46 * 47 * @param a Dividend 48 * @param b Divisor 49 * @return Quotient 50 */ 51 gfx_coord_t gfx_coord_div_rneg(gfx_coord_t a, gfx_coord_t b) 52 { 53 if ((a > 0 && b > 0) || (a < 0 && b < 0)) { 54 /* Result is non-negative, round towards zero */ 55 return a / b; 56 } else { 57 /* Result is negative, round away from zero */ 58 return (a - b + 1) / b; 59 } 60 } 61 41 62 /** Add two vectors. 42 63 * … … 217 238 } 218 239 240 /** Center rectangle on rectangle. 241 * 242 * Translate rectangle @a a so that its center coincides with the 243 * center of rectangle @a b, saving the result in @a dest. 244 * 245 * @param a Rectnagle to translate 246 * @param b Rectangle on which to center 247 * @param dest Place to store resulting rectangle 248 */ 249 void gfx_rect_ctr_on_rect(gfx_rect_t *a, gfx_rect_t *b, gfx_rect_t *dest) 250 { 251 gfx_coord2_t adim; 252 gfx_coord2_t bdim; 253 254 gfx_rect_dims(a, &adim); 255 gfx_rect_dims(b, &bdim); 256 257 dest->p0.x = b->p0.x + bdim.x / 2 - adim.x / 2; 258 dest->p0.y = b->p0.y + bdim.y / 2 - adim.y / 2; 259 260 dest->p1.x = dest->p0.x + adim.x; 261 dest->p1.y = dest->p0.y + adim.y; 262 } 263 219 264 /** Sort points of a rectangle. 220 265 * -
uspace/lib/gfx/test/coord.c
r37d4c91 r3541cb9 34 34 PCUT_TEST_SUITE(coord); 35 35 36 /** gfx_coord_div_rneg rounds towards negative numbers */ 37 PCUT_TEST(coord_div_rneg) 38 { 39 PCUT_ASSERT_INT_EQUALS(-3, gfx_coord_div_rneg(-7, 3)); 40 PCUT_ASSERT_INT_EQUALS(-2, gfx_coord_div_rneg(-6, 3)); 41 PCUT_ASSERT_INT_EQUALS(-2, gfx_coord_div_rneg(-5, 3)); 42 PCUT_ASSERT_INT_EQUALS(-2, gfx_coord_div_rneg(-4, 3)); 43 PCUT_ASSERT_INT_EQUALS(-1, gfx_coord_div_rneg(-3, 3)); 44 PCUT_ASSERT_INT_EQUALS(-1, gfx_coord_div_rneg(-2, 3)); 45 PCUT_ASSERT_INT_EQUALS(-1, gfx_coord_div_rneg(-1, 3)); 46 PCUT_ASSERT_INT_EQUALS(0, gfx_coord_div_rneg(0, 3)); 47 PCUT_ASSERT_INT_EQUALS(0, gfx_coord_div_rneg(1, 3)); 48 PCUT_ASSERT_INT_EQUALS(0, gfx_coord_div_rneg(2, 3)); 49 PCUT_ASSERT_INT_EQUALS(1, gfx_coord_div_rneg(3, 3)); 50 PCUT_ASSERT_INT_EQUALS(1, gfx_coord_div_rneg(4, 3)); 51 PCUT_ASSERT_INT_EQUALS(1, gfx_coord_div_rneg(5, 3)); 52 PCUT_ASSERT_INT_EQUALS(2, gfx_coord_div_rneg(6, 3)); 53 } 54 36 55 /** gfx_coord2_add should add two coordinate vectors */ 37 56 PCUT_TEST(coord2_add) … … 578 597 } 579 598 599 /** Center rectangle on rectangle */ 600 PCUT_TEST(rect_ctr_on_rect) 601 { 602 gfx_rect_t a; 603 gfx_rect_t b; 604 gfx_rect_t dest; 605 606 /* Dimensions: 20 x 20 */ 607 b.p0.x = 10; 608 b.p0.y = 20; 609 b.p1.x = 30; 610 b.p1.y = 40; 611 612 /* Dimensions: 20 x 20 */ 613 a.p0.x = 100; 614 a.p0.y = 200; 615 a.p1.x = 120; 616 a.p1.y = 220; 617 618 /* Centering rectangle of same size should give us the same rectangle */ 619 gfx_rect_ctr_on_rect(&a, &b, &dest); 620 PCUT_ASSERT_INT_EQUALS(b.p0.x, dest.p0.x); 621 PCUT_ASSERT_INT_EQUALS(b.p0.y, dest.p0.y); 622 PCUT_ASSERT_INT_EQUALS(b.p1.x, dest.p1.x); 623 PCUT_ASSERT_INT_EQUALS(b.p1.y, dest.p1.y); 624 625 /* Dimensions: 10 x 10 */ 626 a.p0.x = 100; 627 a.p0.y = 200; 628 a.p1.x = 110; 629 a.p1.y = 210; 630 631 gfx_rect_ctr_on_rect(&a, &b, &dest); 632 PCUT_ASSERT_INT_EQUALS(15, dest.p0.x); 633 PCUT_ASSERT_INT_EQUALS(25, dest.p0.y); 634 PCUT_ASSERT_INT_EQUALS(25, dest.p1.x); 635 PCUT_ASSERT_INT_EQUALS(35, dest.p1.y); 636 } 637 580 638 /** Sort span points that are already sorted should produde indentical points */ 581 639 PCUT_TEST(rect_points_sort_sorted) -
uspace/lib/memgfx/src/memgc.c
r37d4c91 r3541cb9 225 225 226 226 /* Check that we support all requested flags */ 227 if ((params->flags & ~(bmpf_color_key | bmpf_direct_output)) != 0) 227 if ((params->flags & ~(bmpf_color_key | bmpf_colorize | 228 bmpf_direct_output)) != 0) 228 229 return ENOTSUP; 229 230 … … 367 368 /* Nothing to do */ 368 369 } else if ((mbm->flags & bmpf_color_key) == 0) { 370 /* Simple copy */ 369 371 for (y = drect.p0.y; y < drect.p1.y; y++) { 370 372 for (x = drect.p0.x; x < drect.p1.x; x++) { … … 375 377 } 376 378 } 377 } else { 379 } else if ((mbm->flags & bmpf_colorize) == 0) { 380 /* Color key */ 378 381 for (y = drect.p0.y; y < drect.p1.y; y++) { 379 382 for (x = drect.p0.x; x < drect.p1.x; x++) { … … 385 388 } 386 389 } 390 } else { 391 /* Color key & colorization */ 392 for (y = drect.p0.y; y < drect.p1.y; y++) { 393 for (x = drect.p0.x; x < drect.p1.x; x++) { 394 pixel = pixelmap_get_pixel(&smap, 395 x - mbm->rect.p0.x - offs.x, 396 y - mbm->rect.p0.y - offs.y); 397 if (pixel != mbm->key_color) 398 pixelmap_put_pixel(&dmap, x, y, 399 mbm->mgc->color); 400 } 401 } 387 402 } 388 403 -
uspace/lib/meson.build
r37d4c91 r3541cb9 34 34 'math', 35 35 'display', 36 'gui', 37 'draw', 38 'softrend', 36 'pixconv', 39 37 'posix', 40 38 'clui', … … 42 40 'hound', 43 41 'gfx', 42 'gfximage', 44 43 'ipcgfx', 45 44 'display', 45 'ui', 46 46 ] 47 47 … … 56 56 'crypto', 57 57 'dltest', 58 'fbfont', 58 59 'fdisk', 59 60 'fmtutil', … … 67 68 'pcm', 68 69 'pcut', 70 'pixconv', 69 71 'posix', 72 'riff', 70 73 'scsi', 71 74 'sif', 72 'softrend',73 75 'trackmod', 74 76 'untar', … … 77 79 'bithenge', 78 80 'congfx', 79 'draw',80 81 'drv', 81 82 'ext4', 83 'gfxfont', 84 'gfximage', 82 85 'hound', 83 86 'ipcgfx', … … 95 98 'display', 96 99 97 'gui', 98 99 'guigfx', 100 'ui', 100 101 ] 101 102 -
uspace/srv/hid/display/seat.c
r37d4c91 r3541cb9 90 90 void ds_seat_set_focus(ds_seat_t *seat, ds_window_t *wnd) 91 91 { 92 if (wnd == seat->focus) { 93 /* Focus is not changing */ 94 return; 95 } 96 92 97 if (seat->focus != NULL) 93 98 ds_window_post_unfocus_event(seat->focus); -
uspace/srv/hid/display/window.c
r37d4c91 r3541cb9 160 160 ds_display_remove_window(wnd); 161 161 ds_display_add_window(disp, wnd); 162 (void) ds_display_paint(wnd->display, NULL); 162 163 } 163 164 -
uspace/srv/hid/rfb/main.c
r37d4c91 r3541cb9 196 196 197 197 /* Check that we support all required flags */ 198 if ((params->flags & ~ bmpf_color_key) != 0)198 if ((params->flags & ~(bmpf_color_key | bmpf_colorize)) != 0) 199 199 return ENOTSUP; 200 200 … … 287 287 288 288 if ((rfbbm->flags & bmpf_color_key) == 0) { 289 /* Simple copy */ 289 290 for (y = srect.p0.y; y < srect.p1.y; y++) { 290 291 for (x = srect.p0.x; x < srect.p1.x; x++) { … … 294 295 } 295 296 } 296 } else { 297 } else if ((rfbbm->flags & bmpf_colorize) == 0) { 298 /* Color key */ 297 299 for (y = srect.p0.y; y < srect.p1.y; y++) { 298 300 for (x = srect.p0.x; x < srect.p1.x; x++) { … … 304 306 } 305 307 } 308 } else { 309 /* Color key & colorization */ 310 for (y = srect.p0.y; y < srect.p1.y; y++) { 311 for (x = srect.p0.x; x < srect.p1.x; x++) { 312 color = pixelmap_get_pixel(&pbm, x, y); 313 if (color != rfbbm->key_color) { 314 pixelmap_put_pixel(&rfbbm->rfb->rfb.framebuffer, 315 x + offs.x, y + offs.y, 316 rfbbm->rfb->color); 317 } 318 } 319 } 306 320 } 307 321
Note:
See TracChangeset
for help on using the changeset viewer.