Changes in / [8596474:7a873f0] in mainline
- Files:
-
- 85 added
- 141 deleted
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
meson/part/initrd_manifest/meson.build
r8596474 r7a873f0 60 60 if CONFIG_FB 61 61 rd_essential += [ 62 'app/ launcher',63 'app/ terminal',62 'app/vlaunch', 63 'app/vterm', 64 64 65 65 'srv/hid/display', -
tools/export.sh
r8596474 r7a873f0 39 39 40 40 EXPORT_LIBS=" \ 41 uspace/lib/ c/libstartfiles.a \41 uspace/lib/libmath.a \ 42 42 uspace/lib/libclui.a \ 43 uspace/lib/libc.a \44 uspace/lib/libcpp.a \45 43 uspace/lib/libdisplay.a \ 46 44 uspace/lib/libgfx.a \ 47 uspace/lib/libgfxfont.a \ 48 uspace/lib/libgfximage.a \ 45 uspace/lib/libgui.a \ 46 uspace/lib/libipcgfx.a \ 47 uspace/lib/libdraw.a \ 48 uspace/lib/libsoftrend.a \ 49 49 uspace/lib/libhound.a \ 50 uspace/lib/libipcgfx.a \51 uspace/lib/libmath.a \52 uspace/lib/libmemgfx.a \53 50 uspace/lib/libpcm.a \ 54 uspace/lib/libpixconv.a \ 51 uspace/lib/libcpp.a \ 52 uspace/lib/libc.a \ 53 uspace/lib/c/libstartfiles.a \ 55 54 uspace/lib/libposix.a \ 56 uspace/lib/libriff.a \57 uspace/lib/libui.a \58 55 " 59 56 -
tools/xcw/bin/helenos-pkg-config
r8596474 r7a873f0 1 1 #!/bin/bash 2 2 # 3 # Copyright (c) 20 20Jiri Svoboda3 # Copyright (c) 2015 Jiri Svoboda 4 4 # All rights reserved. 5 5 # … … 44 44 libmath_libs="$LIB_DIR/libmath.a" 45 45 46 lib ui_cflags="-I$INCLUDE_DIR/libui -I$INCLUDE_DIR/libdisplay -I$INCLUDE_DIR/libgfx -I$INCLUDE_DIR/libipcgfx"47 lib ui_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"46 libgui_cflags="-I$INCLUDE_DIR/libgui -I$INCLUDE_DIR/libdisplay -I$INCLUDE_DIR/libgfx -I$INCLUDE_DIR/libipcgfx" 47 libgui_libs="$LIB_DIR/libgui.a $LIB_DIR/libdisplay.a $LIB_DIR/libipcgfx.a $LIB_DIR/libgfx.a" 48 48 49 lib gfximage_cflags="-I$INCLUDE_DIR/libgfximage"50 lib gfximage_libs="$LIB_DIR/libgfximage.a $LIB_DIR/libpixconv.a"49 libdraw_cflags="-I$INCLUDE_DIR/libdraw" 50 libdraw_libs="$LIB_DIR/libdraw.a $LIB_DIR/libsoftrend.a" 51 51 52 52 libhound_cflags="-I$INCLUDE_DIR/libhound" … … 75 75 (.*) 76 76 case "$1" in 77 (lib ui) ;;78 (lib gfximage) ;;77 (libgui) ;; 78 (libdraw) ;; 79 79 (libmath) ;; 80 80 (libhound) ;; -
tools/xcw/demo/Makefile
r8596474 r7a873f0 50 50 INSTALL = install 51 51 TEST = helenos-test 52 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags lib ui libdraw libmath` \52 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libgui libdraw libmath` \ 53 53 -D_HELENOS_SOURCE 54 LIBS = `helenos-pkg-config --libs lib ui libdraw libmath`54 LIBS = `helenos-pkg-config --libs libgui libdraw libmath` 55 55 PREFIX = `helenos-bld-config --install-dir` 56 56 output = viewer -
uspace/app/barber/barber.c
r8596474 r7a873f0 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda3 2 * Copyright (c) 2014 Martin Decky 4 3 * All rights reserved. … … 34 33 */ 35 34 36 #include < device/led_dev.h>35 #include <stdbool.h> 37 36 #include <errno.h> 38 #include < fibril_synch.h>39 #include < gfximage/tga_gz.h>40 #include < io/pixel.h>37 #include <stdio.h> 38 #include <stdlib.h> 39 #include <task.h> 41 40 #include <loc.h> 42 41 #include <stats.h> 43 #include <stdbool.h>44 #include <stdio.h>45 #include <stdlib.h>46 42 #include <str.h> 47 #include <ui/ui.h> 48 #include <ui/wdecor.h> 49 #include <ui/window.h> 50 #include <ui/image.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> 51 50 #include "images.h" 52 51 … … 73 72 } led_dev_t; 74 73 75 typedef struct { 76 ui_t *ui; 77 } barber_t; 74 static char *winreg = NULL; 78 75 79 76 static fibril_timer_t *led_timer = NULL; … … 92 89 93 90 static fibril_timer_t *frame_timer = NULL; 94 static ui_image_t *frame_img;95 static gfx_bitmap_t *frame_bmp[FRAMES];91 static canvas_t *frame_canvas; 92 static surface_t *frames[FRAMES]; 96 93 97 94 static unsigned int frame = 0; … … 101 98 static void frame_timer_callback(void *); 102 99 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 100 static bool decode_frames(void) 101 { 126 102 for (unsigned int i = 0; i < FRAMES; i++) { 127 rc = decode_tga_gz(gc, images[i].addr, images[i].size, 128 &frame_bmp[i], &rect); 129 if (rc != EOK) { 103 frames[i] = decode_tga_gz(images[i].addr, images[i].size, 0); 104 if (frames[i] == NULL) { 130 105 printf("Unable to decode frame %u.\n", i); 131 106 return false; 132 107 } 133 134 (void) rect;135 108 } 136 109 137 110 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 }148 111 } 149 112 … … 229 192 { 230 193 struct timespec prev; 231 gfx_rect_t rect;232 194 getuptime(&prev); 233 195 … … 236 198 frame = 0; 237 199 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); 200 update_canvas(frame_canvas, frames[frame]); 245 201 246 202 struct timespec cur; … … 299 255 int main(int argc, char *argv[]) 300 256 { 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; 257 const char *display_svc = DISPLAY_DEFAULT; 312 258 int i; 313 259 … … 322 268 } 323 269 324 display_s pec = argv[i++];270 display_svc = argv[i++]; 325 271 } else { 326 272 printf("Invalid option '%s'.\n", argv[i]); … … 349 295 } 350 296 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 } 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); 405 320 406 321 plan_led_timer(); 407 322 plan_frame_timer(0); 408 323 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(); 324 task_retval(0); 325 async_manager(); 418 326 419 327 return 0; -
uspace/app/barber/meson.build
r8596474 r7a873f0 27 27 # 28 28 29 deps = [ ' ui', 'gfximage', 'compress' ]29 deps = [ 'gui', 'draw', 'compress', 'softrend', 'math' ] 30 30 31 31 _images = files( -
uspace/app/gfxdemo/doc/doxygroups.h
r8596474 r7a873f0 1 /** @addtogroup gfxdemo gfxdemo2 * @brief Graphic demo1 /** @addtogroup vdemo vdemo 2 * @brief Demo application 3 3 * @ingroup apps 4 4 */ -
uspace/app/gfxdemo/gfxdemo.c
r8596474 r7a873f0 33 33 */ 34 34 35 #include <canvas.h> 35 36 #include <congfx/console.h> 37 #include <draw/surface.h> 36 38 #include <display.h> 37 39 #include <fibril.h> 40 #include <guigfx/canvas.h> 38 41 #include <gfx/bitmap.h> 39 42 #include <gfx/color.h> 40 43 #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 <ui/ui.h> 51 #include <ui/window.h> 52 #include <ui/wdecor.h> 50 #include <window.h> 53 51 54 52 static void wnd_close_event(void *); … … 60 58 }; 61 59 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_event68 };69 70 60 static bool quit = false; 71 61 … … 119 109 int i, j; 120 110 errno_t rc; 121 122 if (quit)123 return EOK;124 111 125 112 rc = clear_scr(gc, w, h); … … 278 265 gfx_rect_t srect; 279 266 errno_t rc; 280 281 if (quit)282 return EOK;283 267 284 268 rc = clear_scr(gc, w, h); … … 315 299 316 300 if (quit) 317 goto out; 318 } 319 } 320 321 out: 301 break; 302 } 303 } 304 322 305 gfx_bitmap_destroy(bitmap); 323 306 … … 341 324 gfx_coord2_t offs; 342 325 errno_t rc; 343 344 if (quit)345 return EOK;346 326 347 327 rc = clear_scr(gc, w, h); … … 386 366 return rc; 387 367 } 388 389 368 /** Run bitmap color key demo on a graphic context. 390 369 * … … 400 379 gfx_coord2_t offs; 401 380 errno_t rc; 402 403 if (quit)404 return EOK;405 381 406 382 rc = clear_scr(gc, w, h); … … 448 424 } 449 425 450 /** Run text demoon a graphic context.426 /** Run demo loop on a graphic context. 451 427 * 452 428 * @param gc Graphic context … … 454 430 * @param h Height 455 431 */ 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 context658 * @param w Width659 * @param h Height660 */661 432 static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h) 662 433 { … … 677 448 678 449 rc = demo_bitmap_kc(gc, w, h); 679 if (rc != EOK)680 return rc;681 682 rc = demo_text(gc, w, h);683 450 if (rc != EOK) 684 451 return rc; … … 719 486 } 720 487 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; 488 /** Run demo on canvas. */ 489 static errno_t demo_canvas(const char *display_svc) 490 { 491 canvas_gc_t *cgc = NULL; 727 492 gfx_context_t *gc; 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) { 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) { 759 505 printf("Error creating window.\n"); 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 } 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); 770 540 771 541 task_retval(0); 772 542 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; 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; 787 552 } 788 553 … … 845 610 846 611 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)860 612 { 861 613 printf("Keyboard event type=%d key=%d\n", event->type, event->key); … … 901 653 if (rc != EOK) 902 654 return 1; 903 } else if (str_cmp(argv[i], " ui") == 0) {904 rc = demo_ ui(display_svc);655 } else if (str_cmp(argv[i], "canvas") == 0) { 656 rc = demo_canvas(display_svc); 905 657 if (rc != EOK) 906 658 return 1; -
uspace/app/gfxdemo/meson.build
r8596474 r7a873f0 27 27 # 28 28 29 deps = [ 'gfx', 'g fxfont', 'ui', 'congfx', 'ipcgfx', 'display' ]29 deps = [ 'gfx', 'guigfx', 'congfx', 'ipcgfx', 'display' ] 30 30 src = files( 31 31 'gfxdemo.c', -
uspace/app/init/init.c
r8596474 r7a873f0 277 277 } 278 278 279 static int app_start(const char *app , const char *arg)279 static int app_start(const char *app) 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, arg,NULL);285 errno_t rc = task_spawnl(&id, &wait, app, app, 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/ launcher", NULL);474 app_start("/app/ barber", NULL);475 app_start("/app/ terminal", "-topleft");473 app_start("/app/barber"); 474 app_start("/app/vlaunch"); 475 app_start("/app/vterm"); 476 476 } 477 477 } -
uspace/app/meson.build
r8596474 r7a873f0 32 32 'bithenge', 33 33 'blkdump', 34 'calculator',35 34 'contacts', 36 35 'corecfg', … … 44 43 'edit', 45 44 'fdisk', 46 'font edit',45 'fontviewer', 47 46 'getterm', 48 47 'gfxdemo', 49 48 'gunzip', 50 49 'hbench', 51 'hello',52 50 'inet', 53 51 'init', … … 55 53 'killall', 56 54 'kio', 57 'launcher',58 55 'loc', 59 56 'logset', … … 79 76 'sysinst', 80 77 'taskdump', 81 'terminal',82 78 'tester', 83 79 'testread', … … 88 84 'top', 89 85 'trace', 90 'uidemo',91 86 'untar', 92 87 'usbinfo', 88 'vcalc', 89 'vdemo', 93 90 'viewer', 91 'vlaunch', 94 92 'vol', 93 'vterm', 95 94 'vuhid', 96 95 'wavplay', -
uspace/app/viewer/meson.build
r8596474 r7a873f0 27 27 # 28 28 29 deps = [ ' ui', 'gfximage', 'compress' ]29 deps = [ 'gui' ] 30 30 src = files('viewer.c') 31 31 -
uspace/app/viewer/viewer.c
r8596474 r7a873f0 1 1 /* 2 * Copyright (c) 2020 Jiri Svoboda3 2 * Copyright (c) 2013 Martin Decky 4 3 * All rights reserved. … … 34 33 */ 35 34 36 #include <errno.h>37 #include <gfximage/tga.h>38 #include <stdbool.h>39 35 #include <stdio.h> 40 36 #include <stdlib.h> 37 #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> 41 46 #include <str.h> 42 #include <ui/image.h>43 #include <ui/ui.h>44 #include <ui/wdecor.h>45 #include <ui/window.h>46 #include <vfs/vfs.h>47 47 48 48 #define NAME "viewer" 49 49 50 typedef struct { 51 ui_t *ui; 52 } viewer_t; 50 #define WINDOW_WIDTH 1024 51 #define WINDOW_HEIGHT 768 52 53 #define DECORATION_WIDTH 8 54 #define DECORATION_HEIGHT 28 53 55 54 56 static size_t imgs_count; … … 56 58 static char **imgs; 57 59 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 { 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; 92 73 bool update = false; 93 74 … … 114 95 115 96 if (update) { 116 gfx_bitmap_t *lbitmap; 117 gfx_rect_t lrect; 118 119 if (!img_load(window_gc, imgs[imgs_current], &lbitmap, &lrect)) { 97 surface_t *lsface; 98 99 if (!img_load(imgs[imgs_current], &lsface)) { 120 100 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 121 101 exit(4); 122 102 } 123 if (!img_setup( window_gc, lbitmap, &lrect)) {103 if (!img_setup(lsface)) { 124 104 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 125 105 exit(6); … … 128 108 } 129 109 130 static bool img_load(gfx_context_t *gc, const char *fname, 131 gfx_bitmap_t **rbitmap, gfx_rect_t *rect) 110 static bool img_load(const char *fname, surface_t **p_local_surface) 132 111 { 133 112 int fd; … … 159 138 vfs_put(fd); 160 139 161 rc = decode_tga(gc, tga, stat.size, rbitmap, rect);162 if ( rc != EOK) {140 *p_local_surface = decode_tga(tga, stat.size, 0); 141 if (*p_local_surface == NULL) { 163 142 free(tga); 164 143 return false; … … 167 146 free(tga); 168 147 169 img_rect = *rect; 148 surface_get_resolution(*p_local_surface, &img_width, &img_height); 149 170 150 return true; 171 151 } 172 152 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); 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); 158 return false; 159 } 191 160 } else { 192 rc = ui_image_create(ui_res, bmp, rect, &image); 193 if (rc != EOK) { 194 gfx_bitmap_destroy(bmp); 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); 195 165 return false; 196 166 } 197 167 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; 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; 206 175 return true; 207 176 } … … 209 178 static void print_syntax(void) 210 179 { 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"); 180 printf("Syntax: %s [-d <display>] <image-file>...\n", NAME); 214 181 } 215 182 216 183 int main(int argc, char *argv[]) 217 184 { 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; 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; 229 191 int i; 230 192 … … 239 201 } 240 202 241 display_spec = argv[i++]; 242 } else if (str_cmp(argv[i], "-f") == 0) { 243 ++i; 244 fullscreen = true; 203 display_svc = argv[i++]; 245 204 } else { 246 205 printf("Invalid option '%s'.\n", argv[i]); … … 260 219 if (imgs == NULL) { 261 220 printf("Out of memory.\n"); 262 return 1;221 return 2; 263 222 } 264 223 … … 271 230 } 272 231 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)) { 232 if (!img_load(imgs[imgs_current], &lsface)) { 308 233 printf("Cannot load image \"%s\".\n", imgs[imgs_current]); 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); 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)) { 251 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 252 return 6; 253 } 319 254 320 255 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)) { 329 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); 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); 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(); 340 269 341 270 return 0; -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c
r8596474 r7a873f0 383 383 384 384 /* Check that we support all required flags */ 385 if ((params->flags & ~ (bmpf_color_key | bmpf_colorize)) != 0)385 if ((params->flags & ~bmpf_color_key) != 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;395 394 396 395 if (alloc == NULL) { … … 488 487 gfx_rect_clip(&srect, &skfbrect, &crect); 489 488 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 } 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); 530 498 } 531 499 } -
uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.h
r8596474 r7a873f0 68 68 69 69 typedef struct { 70 /* Containing display controller */71 70 amdm37x_dispc_t *dispc; 72 /** Allocation info */73 71 gfx_bitmap_alloc_t alloc; 74 /** @c true if we allocated the bitmap, @c false if allocated by caller */72 gfx_rect_t rect; 75 73 bool myalloc; 76 /** Rectangle covered by bitmap */77 gfx_rect_t rect;78 /** Bitmap flags */79 gfx_bitmap_flags_t flags;80 /** Key color */81 pixel_t key_color;82 74 } amdm37x_bitmap_t; 83 75 -
uspace/drv/fb/amdm37x_dispc/meson.build
r8596474 r7a873f0 29 29 # 30 30 31 deps = [ 'gfx', 'ipcgfx', 'ddev', ' pixconv' ]31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'softrend' ] 32 32 src = files('amdm37x_dispc.c', 'main.c') -
uspace/drv/fb/kfb/meson.build
r8596474 r7a873f0 29 29 # 30 30 31 deps = [ 'gfx', 'ipcgfx', 'ddev', ' pixconv' ]31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'softrend' ] 32 32 src = files('port.c', 'kfb.c') -
uspace/drv/fb/kfb/port.c
r8596474 r7a873f0 50 50 #include <gfx/color.h> 51 51 #include <gfx/coord.h> 52 #include <io/mode.h> 52 53 #include <io/pixelmap.h> 53 54 #include <ipcgfx/server.h> … … 199 200 200 201 /* Check that we support all required flags */ 201 if ((params->flags & ~ (bmpf_color_key | bmpf_colorize)) != 0)202 if ((params->flags & ~bmpf_color_key) != 0) 202 203 return ENOTSUP; 203 204 … … 306 307 307 308 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 }333 321 } else { 334 /* Color key & colorize */335 322 for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) { 336 323 for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) { -
uspace/lib/c/include/io/pixelmap.h
r8596474 r7a873f0 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 = 0 59 */ 60 PIXELMAP_EXTEND_TRANSPARENT_SIDES 61 } pixelmap_extend_t; 44 62 45 63 typedef struct { … … 88 106 } 89 107 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 90 148 #endif 91 149 -
uspace/lib/congfx/src/console.c
r8596474 r7a873f0 207 207 208 208 /* Check that we support all requested flags */ 209 if ((params->flags & ~ (bmpf_color_key | bmpf_colorize)) != 0)209 if ((params->flags & ~bmpf_color_key) != 0) 210 210 return ENOTSUP; 211 211 … … 296 296 297 297 if ((cbm->flags & bmpf_color_key) == 0) { 298 /* Simple copy */299 298 for (y = crect.p0.y; y < crect.p1.y; y++) { 300 299 console_set_pos(cbm->cgc->con, crect.p0.x, y); … … 313 312 } 314 313 } 315 } else if ((cbm->flags & bmpf_colorize) == 0) { 316 /* Color key */ 314 } else { 317 315 for (y = crect.p0.y; y < crect.p1.y; y++) { 318 316 for (x = crect.p0.x; x < crect.p1.x; x++) { … … 334 332 } 335 333 } 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 }359 334 } 360 335 -
uspace/lib/display/include/types/display.h
r8596474 r7a873f0 46 46 #define DISPLAY_DEFAULT NULL 47 47 48 struct display;49 struct display_window;50 51 48 /** Display server session */ 52 typedef struct display display_t; 53 54 /** Display window */ 55 typedef struct display_window display_window_t; 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; 56 61 57 62 /** Display window callbacks */ … … 71 76 } display_wnd_cb_t; 72 77 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 73 92 #endif 74 93 -
uspace/lib/display/include/types/display/wndparams.h
r8596474 r7a873f0 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 ion on the display,43 * the position of which does not relate to its positon 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
r8596474 r7a873f0 38 38 #include <mem.h> 39 39 #include <stdlib.h> 40 #include "../private/display.h"41 40 #include "../private/params.h" 42 41 … … 199 198 /** Destroy display window. 200 199 * 201 * @param window Window or @c NULL200 * @param window Window 202 201 * @return EOK on success or an error code. In both cases @a window must 203 202 * not be accessed anymore … … 207 206 async_exch_t *exch; 208 207 errno_t rc; 209 210 if (window == NULL)211 return EOK;212 208 213 209 exch = async_exchange_begin(window->display->sess); -
uspace/lib/display/test/display.c
r8596474 r7a873f0 38 38 #include <loc.h> 39 39 #include <pcut/pcut.h> 40 #include "../private/display.h"41 40 42 41 PCUT_INIT; … … 332 331 } 333 332 334 /** display_window_destroy() can handle NULL argument */335 PCUT_TEST(window_destroy_null)336 {337 display_window_destroy(NULL);338 }339 340 333 /** display_window_move_req() with server returning error response works. */ 341 334 PCUT_TEST(window_move_req_failure) -
uspace/lib/gfx/include/gfx/coord.h
r8596474 r7a873f0 40 40 #include <types/gfx/coord.h> 41 41 42 extern gfx_coord_t gfx_coord_div_rneg(gfx_coord_t, gfx_coord_t);43 42 extern void gfx_coord2_add(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *); 44 43 extern void gfx_coord2_subtract(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *); … … 52 51 extern void gfx_rect_envelope(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *); 53 52 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 *);55 53 extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *); 56 54 extern void gfx_rect_dims(gfx_rect_t *, gfx_coord2_t *); -
uspace/lib/gfx/include/types/gfx/bitmap.h
r8596474 r7a873f0 47 47 /** Bitmap flags */ 48 48 typedef enum { 49 /** Enable color key */ 50 bmpf_color_key = 0x1, 49 51 /** Directly map GC output into this bitmap */ 50 bmpf_direct_output = 0x1, 51 /** Enable color key */ 52 bmpf_color_key = 0x2, 53 /** Paint non-background pixels with current drawing color */ 54 bmpf_colorize = 0x4 52 bmpf_direct_output = 0x2 55 53 } gfx_bitmap_flags_t; 56 54 -
uspace/lib/gfx/private/color.h
r8596474 r7a873f0 38 38 #define _GFX_PRIVATE_COLOR_H 39 39 40 #include <stdint.h>41 42 40 /** Actual structure of graphics color. 43 41 * -
uspace/lib/gfx/src/bitmap.c
r8596474 r7a873f0 62 62 * 63 63 * @return EOK on success, EINVAL if parameters are invald, 64 * ENOMEM if insufficient resources, EIO if gra phic device connection64 * ENOMEM if insufficient resources, EIO if grahic device connection 65 65 * was lost 66 66 */ … … 92 92 * @param bitmap Bitmap 93 93 * 94 * @return EOK on success, EIO if gra phic device connection was lost94 * @return EOK on success, EIO if grahic 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 phic device connection was lost114 * @return EOK on success, EIO if grahic 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 phic device connection was lost127 * @return EOK on success, EIO if grahic 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
r8596474 r7a873f0 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 useful44 * e.g. for scaling down, where we always need to round towards negative45 * numbers.46 *47 * @param a Dividend48 * @param b Divisor49 * @return Quotient50 */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 62 41 /** Add two vectors. 63 42 * … … 238 217 } 239 218 240 /** Center rectangle on rectangle.241 *242 * Translate rectangle @a a so that its center coincides with the243 * center of rectangle @a b, saving the result in @a dest.244 *245 * @param a Rectnagle to translate246 * @param b Rectangle on which to center247 * @param dest Place to store resulting rectangle248 */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 264 219 /** Sort points of a rectangle. 265 220 * -
uspace/lib/gfx/test/coord.c
r8596474 r7a873f0 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 55 36 /** gfx_coord2_add should add two coordinate vectors */ 56 37 PCUT_TEST(coord2_add) … … 597 578 } 598 579 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 638 580 /** Sort span points that are already sorted should produde indentical points */ 639 581 PCUT_TEST(rect_points_sort_sorted) -
uspace/lib/memgfx/src/memgc.c
r8596474 r7a873f0 225 225 226 226 /* Check that we support all requested flags */ 227 if ((params->flags & ~(bmpf_color_key | bmpf_colorize | 228 bmpf_direct_output)) != 0) 227 if ((params->flags & ~(bmpf_color_key | bmpf_direct_output)) != 0) 229 228 return ENOTSUP; 230 229 … … 368 367 /* Nothing to do */ 369 368 } else if ((mbm->flags & bmpf_color_key) == 0) { 370 /* Simple copy */371 369 for (y = drect.p0.y; y < drect.p1.y; y++) { 372 370 for (x = drect.p0.x; x < drect.p1.x; x++) { … … 377 375 } 378 376 } 379 } else if ((mbm->flags & bmpf_colorize) == 0) { 380 /* Color key */ 377 } else { 381 378 for (y = drect.p0.y; y < drect.p1.y; y++) { 382 379 for (x = drect.p0.x; x < drect.p1.x; x++) { … … 388 385 } 389 386 } 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 }402 387 } 403 388 -
uspace/lib/meson.build
r8596474 r7a873f0 34 34 'math', 35 35 'display', 36 'pixconv', 36 'gui', 37 'draw', 38 'softrend', 37 39 'posix', 38 40 'clui', … … 40 42 'hound', 41 43 'gfx', 42 'gfximage',43 44 'ipcgfx', 44 45 'display', 45 'ui',46 46 ] 47 47 … … 56 56 'crypto', 57 57 'dltest', 58 'fbfont',59 58 'fdisk', 60 59 'fmtutil', … … 68 67 'pcm', 69 68 'pcut', 70 'pixconv',71 69 'posix', 72 'riff',73 70 'scsi', 74 71 'sif', 72 'softrend', 75 73 'trackmod', 76 74 'untar', … … 79 77 'bithenge', 80 78 'congfx', 79 'draw', 81 80 'drv', 82 81 'ext4', 83 'gfxfont',84 'gfximage',85 82 'hound', 86 83 'ipcgfx', … … 98 95 'display', 99 96 100 'ui', 97 'gui', 98 99 'guigfx', 101 100 ] 102 101 -
uspace/srv/hid/display/seat.c
r8596474 r7a873f0 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 97 92 if (seat->focus != NULL) 98 93 ds_window_post_unfocus_event(seat->focus); -
uspace/srv/hid/display/window.c
r8596474 r7a873f0 160 160 ds_display_remove_window(wnd); 161 161 ds_display_add_window(disp, wnd); 162 (void) ds_display_paint(wnd->display, NULL);163 162 } 164 163 -
uspace/srv/hid/rfb/main.c
r8596474 r7a873f0 196 196 197 197 /* Check that we support all required flags */ 198 if ((params->flags & ~ (bmpf_color_key | bmpf_colorize)) != 0)198 if ((params->flags & ~bmpf_color_key) != 0) 199 199 return ENOTSUP; 200 200 … … 287 287 288 288 if ((rfbbm->flags & bmpf_color_key) == 0) { 289 /* Simple copy */290 289 for (y = srect.p0.y; y < srect.p1.y; y++) { 291 290 for (x = srect.p0.x; x < srect.p1.x; x++) { … … 295 294 } 296 295 } 297 } else if ((rfbbm->flags & bmpf_colorize) == 0) { 298 /* Color key */ 296 } else { 299 297 for (y = srect.p0.y; y < srect.p1.y; y++) { 300 298 for (x = srect.p0.x; x < srect.p1.x; x++) { … … 306 304 } 307 305 } 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 }320 306 } 321 307
Note:
See TracChangeset
for help on using the changeset viewer.