Changes in / [8596474:7a873f0] in mainline


Ignore:
Files:
85 added
141 deleted
35 edited

Legend:

Unmodified
Added
Removed
  • meson/part/initrd_manifest/meson.build

    r8596474 r7a873f0  
    6060if CONFIG_FB
    6161        rd_essential += [
    62                 'app/launcher',
    63                 'app/terminal',
     62                'app/vlaunch',
     63                'app/vterm',
    6464
    6565                'srv/hid/display',
  • tools/export.sh

    r8596474 r7a873f0  
    3939
    4040EXPORT_LIBS=" \
    41         uspace/lib/c/libstartfiles.a \
     41        uspace/lib/libmath.a \
    4242        uspace/lib/libclui.a \
    43         uspace/lib/libc.a \
    44         uspace/lib/libcpp.a \
    4543        uspace/lib/libdisplay.a \
    4644        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 \
    4949        uspace/lib/libhound.a \
    50         uspace/lib/libipcgfx.a \
    51         uspace/lib/libmath.a \
    52         uspace/lib/libmemgfx.a \
    5350        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 \
    5554        uspace/lib/libposix.a \
    56         uspace/lib/libriff.a \
    57         uspace/lib/libui.a \
    5855"
    5956
  • tools/xcw/bin/helenos-pkg-config

    r8596474 r7a873f0  
    11#!/bin/bash
    22#
    3 # Copyright (c) 2020 Jiri Svoboda
     3# Copyright (c) 2015 Jiri Svoboda
    44# All rights reserved.
    55#
     
    4444libmath_libs="$LIB_DIR/libmath.a"
    4545
    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"
     46libgui_cflags="-I$INCLUDE_DIR/libgui -I$INCLUDE_DIR/libdisplay -I$INCLUDE_DIR/libgfx -I$INCLUDE_DIR/libipcgfx"
     47libgui_libs="$LIB_DIR/libgui.a $LIB_DIR/libdisplay.a $LIB_DIR/libipcgfx.a $LIB_DIR/libgfx.a"
    4848
    49 libgfximage_cflags="-I$INCLUDE_DIR/libgfximage"
    50 libgfximage_libs="$LIB_DIR/libgfximage.a $LIB_DIR/libpixconv.a"
     49libdraw_cflags="-I$INCLUDE_DIR/libdraw"
     50libdraw_libs="$LIB_DIR/libdraw.a $LIB_DIR/libsoftrend.a"
    5151
    5252libhound_cflags="-I$INCLUDE_DIR/libhound"
     
    7575        (.*)
    7676            case "$1" in
    77             (libui) ;;
    78             (libgfximage) ;;
     77            (libgui) ;;
     78            (libdraw) ;;
    7979            (libmath) ;;
    8080            (libhound) ;;
  • tools/xcw/demo/Makefile

    r8596474 r7a873f0  
    5050INSTALL = install
    5151TEST = helenos-test
    52 CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libui libdraw libmath` \
     52CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libgui libdraw libmath` \
    5353    -D_HELENOS_SOURCE
    54 LIBS = `helenos-pkg-config --libs libui libdraw libmath`
     54LIBS = `helenos-pkg-config --libs libgui libdraw libmath`
    5555PREFIX = `helenos-bld-config --install-dir`
    5656output = viewer
  • uspace/app/barber/barber.c

    r8596474 r7a873f0  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
    32 * Copyright (c) 2014 Martin Decky
    43 * All rights reserved.
     
    3433 */
    3534
    36 #include <device/led_dev.h>
     35#include <stdbool.h>
    3736#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>
    4140#include <loc.h>
    4241#include <stats.h>
    43 #include <stdbool.h>
    44 #include <stdio.h>
    45 #include <stdlib.h>
    4642#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>
    5150#include "images.h"
    5251
     
    7372} led_dev_t;
    7473
    75 typedef struct {
    76         ui_t *ui;
    77 } barber_t;
     74static char *winreg = NULL;
    7875
    7976static fibril_timer_t *led_timer = NULL;
     
    9289
    9390static fibril_timer_t *frame_timer = NULL;
    94 static ui_image_t *frame_img;
    95 static gfx_bitmap_t *frame_bmp[FRAMES];
     91static canvas_t *frame_canvas;
     92static surface_t *frames[FRAMES];
    9693
    9794static unsigned int frame = 0;
     
    10198static void frame_timer_callback(void *);
    10299
    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 
     100static bool decode_frames(void)
     101{
    126102        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) {
    130105                        printf("Unable to decode frame %u.\n", i);
    131106                        return false;
    132107                }
    133 
    134                 (void) rect;
    135108        }
    136109
    137110        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         }
    148111}
    149112
     
    229192{
    230193        struct timespec prev;
    231         gfx_rect_t rect;
    232194        getuptime(&prev);
    233195
     
    236198                frame = 0;
    237199
    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]);
    245201
    246202        struct timespec cur;
     
    299255int main(int argc, char *argv[])
    300256{
    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;
    312258        int i;
    313259
     
    322268                        }
    323269
    324                         display_spec = argv[i++];
     270                        display_svc = argv[i++];
    325271                } else {
    326272                        printf("Invalid option '%s'.\n", argv[i]);
     
    349295        }
    350296
    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(&params);
    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, &params.rect);
    372 
    373         barber.ui = ui;
    374 
    375         rc = ui_window_create(ui, &params, &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);
    405320
    406321        plan_led_timer();
    407322        plan_frame_timer(0);
    408323
    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();
    418326
    419327        return 0;
  • uspace/app/barber/meson.build

    r8596474 r7a873f0  
    2727#
    2828
    29 deps = [ 'ui', 'gfximage', 'compress' ]
     29deps = [ 'gui', 'draw', 'compress', 'softrend', 'math' ]
    3030
    3131_images = files(
  • uspace/app/gfxdemo/doc/doxygroups.h

    r8596474 r7a873f0  
    1 /** @addtogroup gfxdemo gfxdemo
    2  * @brief Graphic demo
     1/** @addtogroup vdemo vdemo
     2 * @brief Demo application
    33 * @ingroup apps
    44 */
  • uspace/app/gfxdemo/gfxdemo.c

    r8596474 r7a873f0  
    3333 */
    3434
     35#include <canvas.h>
    3536#include <congfx/console.h>
     37#include <draw/surface.h>
    3638#include <display.h>
    3739#include <fibril.h>
     40#include <guigfx/canvas.h>
    3841#include <gfx/bitmap.h>
    3942#include <gfx/color.h>
    4043#include <gfx/render.h>
    41 #include <gfx/font.h>
    42 #include <gfx/text.h>
    43 #include <gfx/typeface.h>
    4444#include <io/console.h>
    4545#include <io/pixelmap.h>
     
    4848#include <str.h>
    4949#include <task.h>
    50 #include <ui/ui.h>
    51 #include <ui/window.h>
    52 #include <ui/wdecor.h>
     50#include <window.h>
    5351
    5452static void wnd_close_event(void *);
     
    6058};
    6159
    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 
    7060static bool quit = false;
    7161
     
    119109        int i, j;
    120110        errno_t rc;
    121 
    122         if (quit)
    123                 return EOK;
    124111
    125112        rc = clear_scr(gc, w, h);
     
    278265        gfx_rect_t srect;
    279266        errno_t rc;
    280 
    281         if (quit)
    282                 return EOK;
    283267
    284268        rc = clear_scr(gc, w, h);
     
    315299
    316300                        if (quit)
    317                                 goto out;
    318                 }
    319         }
    320 
    321 out:
     301                                break;
     302                }
     303        }
     304
    322305        gfx_bitmap_destroy(bitmap);
    323306
     
    341324        gfx_coord2_t offs;
    342325        errno_t rc;
    343 
    344         if (quit)
    345                 return EOK;
    346326
    347327        rc = clear_scr(gc, w, h);
     
    386366        return rc;
    387367}
    388 
    389368/** Run bitmap color key demo on a graphic context.
    390369 *
     
    400379        gfx_coord2_t offs;
    401380        errno_t rc;
    402 
    403         if (quit)
    404                 return EOK;
    405381
    406382        rc = clear_scr(gc, w, h);
     
    448424}
    449425
    450 /** Run text demo on a graphic context.
     426/** Run demo loop on a graphic context.
    451427 *
    452428 * @param gc Graphic context
     
    454430 * @param h Height
    455431 */
    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  */
    661432static errno_t demo_loop(gfx_context_t *gc, gfx_coord_t w, gfx_coord_t h)
    662433{
     
    677448
    678449                rc = demo_bitmap_kc(gc, w, h);
    679                 if (rc != EOK)
    680                         return rc;
    681 
    682                 rc = demo_text(gc, w, h);
    683450                if (rc != EOK)
    684451                        return rc;
     
    719486}
    720487
    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. */
     489static errno_t demo_canvas(const char *display_svc)
     490{
     491        canvas_gc_t *cgc = NULL;
    727492        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(&params);
    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, &params.rect);
    756 
    757         rc = ui_window_create(ui, &params, &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) {
    759505                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);
    770540
    771541        task_retval(0);
    772542
    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;
    787552}
    788553
     
    845610
    846611static 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)
    860612{
    861613        printf("Keyboard event type=%d key=%d\n", event->type, event->key);
     
    901653                if (rc != EOK)
    902654                        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);
    905657                if (rc != EOK)
    906658                        return 1;
  • uspace/app/gfxdemo/meson.build

    r8596474 r7a873f0  
    2727#
    2828
    29 deps = [ 'gfx', 'gfxfont', 'ui', 'congfx', 'ipcgfx', 'display' ]
     29deps = [ 'gfx', 'guigfx', 'congfx', 'ipcgfx', 'display' ]
    3030src = files(
    3131        'gfxdemo.c',
  • uspace/app/init/init.c

    r8596474 r7a873f0  
    277277}
    278278
    279 static int app_start(const char *app, const char *arg)
     279static int app_start(const char *app)
    280280{
    281281        printf("%s: Spawning %s\n", NAME, app);
     
    283283        task_id_t id;
    284284        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);
    286286        if (rc != EOK) {
    287287                oom_check(rc, app);
     
    471471                rc = display_server();
    472472                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");
    476476                }
    477477        }
  • uspace/app/meson.build

    r8596474 r7a873f0  
    3232        'bithenge',
    3333        'blkdump',
    34         'calculator',
    3534        'contacts',
    3635        'corecfg',
     
    4443        'edit',
    4544        'fdisk',
    46         'fontedit',
     45        'fontviewer',
    4746        'getterm',
    4847        'gfxdemo',
    4948        'gunzip',
    5049        'hbench',
    51         'hello',
    5250        'inet',
    5351        'init',
     
    5553        'killall',
    5654        'kio',
    57         'launcher',
    5855        'loc',
    5956        'logset',
     
    7976        'sysinst',
    8077        'taskdump',
    81         'terminal',
    8278        'tester',
    8379        'testread',
     
    8884        'top',
    8985        'trace',
    90         'uidemo',
    9186        'untar',
    9287        'usbinfo',
     88        'vcalc',
     89        'vdemo',
    9390        'viewer',
     91        'vlaunch',
    9492        'vol',
     93        'vterm',
    9594        'vuhid',
    9695        'wavplay',
  • uspace/app/viewer/meson.build

    r8596474 r7a873f0  
    2727#
    2828
    29 deps = [ 'ui', 'gfximage', 'compress' ]
     29deps = [ 'gui' ]
    3030src = files('viewer.c')
    3131
  • uspace/app/viewer/viewer.c

    r8596474 r7a873f0  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
    32 * Copyright (c) 2013 Martin Decky
    43 * All rights reserved.
     
    3433 */
    3534
    36 #include <errno.h>
    37 #include <gfximage/tga.h>
    38 #include <stdbool.h>
    3935#include <stdio.h>
    4036#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>
    4146#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>
    4747
    4848#define NAME  "viewer"
    4949
    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
    5355
    5456static size_t imgs_count;
     
    5658static char **imgs;
    5759
    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 {
     60static window_t *main_window;
     61static surface_t *surface = NULL;
     62static canvas_t *canvas = NULL;
     63
     64static surface_coord_t img_width;
     65static surface_coord_t img_height;
     66
     67static bool img_load(const char *, surface_t **);
     68static bool img_setup(surface_t *);
     69
     70static void on_keyboard_event(widget_t *widget, void *data)
     71{
     72        kbd_event_t *event = (kbd_event_t *) data;
    9273        bool update = false;
    9374
     
    11495
    11596        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)) {
    120100                        printf("Cannot load image \"%s\".\n", imgs[imgs_current]);
    121101                        exit(4);
    122102                }
    123                 if (!img_setup(window_gc, lbitmap, &lrect)) {
     103                if (!img_setup(lsface)) {
    124104                        printf("Cannot setup image \"%s\".\n", imgs[imgs_current]);
    125105                        exit(6);
     
    128108}
    129109
    130 static bool img_load(gfx_context_t *gc, const char *fname,
    131     gfx_bitmap_t **rbitmap, gfx_rect_t *rect)
     110static bool img_load(const char *fname, surface_t **p_local_surface)
    132111{
    133112        int fd;
     
    159138        vfs_put(fd);
    160139
    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) {
    163142                free(tga);
    164143                return false;
     
    167146        free(tga);
    168147
    169         img_rect = *rect;
     148        surface_get_resolution(*p_local_surface, &img_width, &img_height);
     149
    170150        return true;
    171151}
    172152
    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);
     153static 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                }
    191160        } 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);
    195165                        return false;
    196166                }
    197167
    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;
    206175        return true;
    207176}
     
    209178static void print_syntax(void)
    210179{
    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);
    214181}
    215182
    216183int main(int argc, char *argv[])
    217184{
    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;
    229191        int i;
    230192
     
    239201                        }
    240202
    241                         display_spec = argv[i++];
    242                 } else if (str_cmp(argv[i], "-f") == 0) {
    243                         ++i;
    244                         fullscreen = true;
     203                        display_svc = argv[i++];
    245204                } else {
    246205                        printf("Invalid option '%s'.\n", argv[i]);
     
    260219        if (imgs == NULL) {
    261220                printf("Out of memory.\n");
    262                 return 1;
     221                return 2;
    263222        }
    264223
     
    271230        }
    272231
    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(&params);
    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, &params, &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)) {
    308233                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        }
    319254
    320255        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();
    340269
    341270        return 0;
  • uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.c

    r8596474 r7a873f0  
    383383
    384384        /* 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)
    386386                return ENOTSUP;
    387387
     
    392392        gfx_coord2_subtract(&params->rect.p1, &params->rect.p0, &dim);
    393393        dcbm->rect = params->rect;
    394         dcbm->flags = params->flags;
    395394
    396395        if (alloc == NULL) {
     
    488487        gfx_rect_clip(&srect, &skfbrect, &crect);
    489488
    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);
    530498                }
    531499        }
  • uspace/drv/fb/amdm37x_dispc/amdm37x_dispc.h

    r8596474 r7a873f0  
    6868
    6969typedef struct {
    70         /* Containing display controller */
    7170        amdm37x_dispc_t *dispc;
    72         /** Allocation info */
    7371        gfx_bitmap_alloc_t alloc;
    74         /** @c true if we allocated the bitmap, @c false if allocated by caller */
     72        gfx_rect_t rect;
    7573        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;
    8274} amdm37x_bitmap_t;
    8375
  • uspace/drv/fb/amdm37x_dispc/meson.build

    r8596474 r7a873f0  
    2929#
    3030
    31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'pixconv' ]
     31deps = [ 'gfx', 'ipcgfx', 'ddev', 'softrend' ]
    3232src = files('amdm37x_dispc.c', 'main.c')
  • uspace/drv/fb/kfb/meson.build

    r8596474 r7a873f0  
    2929#
    3030
    31 deps = [ 'gfx', 'ipcgfx', 'ddev', 'pixconv' ]
     31deps = [ 'gfx', 'ipcgfx', 'ddev', 'softrend' ]
    3232src = files('port.c', 'kfb.c')
  • uspace/drv/fb/kfb/port.c

    r8596474 r7a873f0  
    5050#include <gfx/color.h>
    5151#include <gfx/coord.h>
     52#include <io/mode.h>
    5253#include <io/pixelmap.h>
    5354#include <ipcgfx/server.h>
     
    199200
    200201        /* 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)
    202203                return ENOTSUP;
    203204
     
    306307
    307308        if ((kfbbm->flags & bmpf_color_key) != 0) {
    308                 /* Simple copy */
    309309                for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) {
    310310                        for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) {
     
    319319                        }
    320320                }
    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                 }
    333321        } else {
    334                 /* Color key & colorize */
    335322                for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) {
    336323                        for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) {
  • uspace/lib/c/include/io/pixelmap.h

    r8596474 r7a873f0  
    4242#include <stddef.h>
    4343#include <io/pixel.h>
     44
     45/* Defines how a pixel outside of pixmap rectangle shall be treated */
     46typedef 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;
    4462
    4563typedef struct {
     
    88106}
    89107
     108static 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
    90148#endif
    91149
  • uspace/lib/congfx/src/console.c

    r8596474 r7a873f0  
    207207
    208208        /* 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)
    210210                return ENOTSUP;
    211211
     
    296296
    297297        if ((cbm->flags & bmpf_color_key) == 0) {
    298                 /* Simple copy */
    299298                for (y = crect.p0.y; y < crect.p1.y; y++) {
    300299                        console_set_pos(cbm->cgc->con, crect.p0.x, y);
     
    313312                        }
    314313                }
    315         } else if ((cbm->flags & bmpf_colorize) == 0) {
    316                 /* Color key */
     314        } else {
    317315                for (y = crect.p0.y; y < crect.p1.y; y++) {
    318316                        for (x = crect.p0.x; x < crect.p1.x; x++) {
     
    334332                        }
    335333                }
    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                 }
    359334        }
    360335
  • uspace/lib/display/include/types/display.h

    r8596474 r7a873f0  
    4646#define DISPLAY_DEFAULT NULL
    4747
    48 struct display;
    49 struct display_window;
    50 
    5148/** Display server session */
    52 typedef struct display display_t;
    53 
    54 /** Display window */
    55 typedef struct display_window display_window_t;
     49typedef 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;
    5661
    5762/** Display window callbacks */
     
    7176} display_wnd_cb_t;
    7277
     78/** Display window */
     79typedef 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
    7392#endif
    7493
  • uspace/lib/display/include/types/display/wndparams.h

    r8596474 r7a873f0  
    4141 *
    4242 * The window's dimensions are determined by the bounding rectangle,
    43  * the position of which does not relate to its position on the display,
     43 * the position of which does not relate to its positon on the display,
    4444 * it just determines which range of logical coordinates is used
    4545 * by the window.
  • uspace/lib/display/src/display.c

    r8596474 r7a873f0  
    3838#include <mem.h>
    3939#include <stdlib.h>
    40 #include "../private/display.h"
    4140#include "../private/params.h"
    4241
     
    199198/** Destroy display window.
    200199 *
    201  * @param window Window or @c NULL
     200 * @param window Window
    202201 * @return EOK on success or an error code. In both cases @a window must
    203202 *         not be accessed anymore
     
    207206        async_exch_t *exch;
    208207        errno_t rc;
    209 
    210         if (window == NULL)
    211                 return EOK;
    212208
    213209        exch = async_exchange_begin(window->display->sess);
  • uspace/lib/display/test/display.c

    r8596474 r7a873f0  
    3838#include <loc.h>
    3939#include <pcut/pcut.h>
    40 #include "../private/display.h"
    4140
    4241PCUT_INIT;
     
    332331}
    333332
    334 /** display_window_destroy() can handle NULL argument */
    335 PCUT_TEST(window_destroy_null)
    336 {
    337         display_window_destroy(NULL);
    338 }
    339 
    340333/** display_window_move_req() with server returning error response works. */
    341334PCUT_TEST(window_move_req_failure)
  • uspace/lib/gfx/include/gfx/coord.h

    r8596474 r7a873f0  
    4040#include <types/gfx/coord.h>
    4141
    42 extern gfx_coord_t gfx_coord_div_rneg(gfx_coord_t, gfx_coord_t);
    4342extern void gfx_coord2_add(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *);
    4443extern void gfx_coord2_subtract(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *);
     
    5251extern void gfx_rect_envelope(gfx_rect_t *, gfx_rect_t *, gfx_rect_t *);
    5352extern 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 *);
    5553extern void gfx_rect_points_sort(gfx_rect_t *, gfx_rect_t *);
    5654extern void gfx_rect_dims(gfx_rect_t *, gfx_coord2_t *);
  • uspace/lib/gfx/include/types/gfx/bitmap.h

    r8596474 r7a873f0  
    4747/** Bitmap flags */
    4848typedef enum {
     49        /** Enable color key */
     50        bmpf_color_key = 0x1,
    4951        /** 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
    5553} gfx_bitmap_flags_t;
    5654
  • uspace/lib/gfx/private/color.h

    r8596474 r7a873f0  
    3838#define _GFX_PRIVATE_COLOR_H
    3939
    40 #include <stdint.h>
    41 
    4240/** Actual structure of graphics color.
    4341 *
  • uspace/lib/gfx/src/bitmap.c

    r8596474 r7a873f0  
    6262 *
    6363 * @return EOK on success, EINVAL if parameters are invald,
    64  *         ENOMEM if insufficient resources, EIO if graphic device connection
     64 *         ENOMEM if insufficient resources, EIO if grahic device connection
    6565 *         was lost
    6666 */
     
    9292 * @param bitmap Bitmap
    9393 *
    94  * @return EOK on success, EIO if graphic device connection was lost
     94 * @return EOK on success, EIO if grahic device connection was lost
    9595 */
    9696errno_t gfx_bitmap_destroy(gfx_bitmap_t *bitmap)
     
    112112 * @param offs Bitmap offset or @c NULL for zero offset
    113113 *
    114  * @return EOK on success, EIO if graphic device connection was lost
     114 * @return EOK on success, EIO if grahic device connection was lost
    115115 */
    116116errno_t gfx_bitmap_render(gfx_bitmap_t *bitmap, gfx_rect_t *srect,
     
    125125 * @param alloc Allocation info structure to fill in
    126126 *
    127  * @return EOK on success, EIO if graphic device connection was lost
     127 * @return EOK on success, EIO if grahic device connection was lost
    128128 */
    129129errno_t gfx_bitmap_get_alloc(gfx_bitmap_t *bitmap, gfx_bitmap_alloc_t *alloc)
  • uspace/lib/gfx/src/coord.c

    r8596474 r7a873f0  
    3939#include <stddef.h>
    4040
    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 
    6241/** Add two vectors.
    6342 *
     
    238217}
    239218
    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 
    264219/** Sort points of a rectangle.
    265220 *
  • uspace/lib/gfx/test/coord.c

    r8596474 r7a873f0  
    3434PCUT_TEST_SUITE(coord);
    3535
    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 
    5536/** gfx_coord2_add should add two coordinate vectors */
    5637PCUT_TEST(coord2_add)
     
    597578}
    598579
    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 
    638580/** Sort span points that are already sorted should produde indentical points */
    639581PCUT_TEST(rect_points_sort_sorted)
  • uspace/lib/memgfx/src/memgc.c

    r8596474 r7a873f0  
    225225
    226226        /* 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)
    229228                return ENOTSUP;
    230229
     
    368367                /* Nothing to do */
    369368        } else if ((mbm->flags & bmpf_color_key) == 0) {
    370                 /* Simple copy */
    371369                for (y = drect.p0.y; y < drect.p1.y; y++) {
    372370                        for (x = drect.p0.x; x < drect.p1.x; x++) {
     
    377375                        }
    378376                }
    379         } else if ((mbm->flags & bmpf_colorize) == 0) {
    380                 /* Color key */
     377        } else {
    381378                for (y = drect.p0.y; y < drect.p1.y; y++) {
    382379                        for (x = drect.p0.x; x < drect.p1.x; x++) {
     
    388385                        }
    389386                }
    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                 }
    402387        }
    403388
  • uspace/lib/meson.build

    r8596474 r7a873f0  
    3434        'math',
    3535        'display',
    36         'pixconv',
     36        'gui',
     37        'draw',
     38        'softrend',
    3739        'posix',
    3840        'clui',
     
    4042        'hound',
    4143        'gfx',
    42         'gfximage',
    4344        'ipcgfx',
    4445        'display',
    45         'ui',
    4646]
    4747
     
    5656        'crypto',
    5757        'dltest',
    58         'fbfont',
    5958        'fdisk',
    6059        'fmtutil',
     
    6867        'pcm',
    6968        'pcut',
    70         'pixconv',
    7169        'posix',
    72         'riff',
    7370        'scsi',
    7471        'sif',
     72        'softrend',
    7573        'trackmod',
    7674        'untar',
     
    7977        'bithenge',
    8078        'congfx',
     79        'draw',
    8180        'drv',
    8281        'ext4',
    83         'gfxfont',
    84         'gfximage',
    8582        'hound',
    8683        'ipcgfx',
     
    9895        'display',
    9996
    100         'ui',
     97        'gui',
     98
     99        'guigfx',
    101100]
    102101
  • uspace/srv/hid/display/seat.c

    r8596474 r7a873f0  
    9090void ds_seat_set_focus(ds_seat_t *seat, ds_window_t *wnd)
    9191{
    92         if (wnd == seat->focus) {
    93                 /* Focus is not changing */
    94                 return;
    95         }
    96 
    9792        if (seat->focus != NULL)
    9893                ds_window_post_unfocus_event(seat->focus);
  • uspace/srv/hid/display/window.c

    r8596474 r7a873f0  
    160160        ds_display_remove_window(wnd);
    161161        ds_display_add_window(disp, wnd);
    162         (void) ds_display_paint(wnd->display, NULL);
    163162}
    164163
  • uspace/srv/hid/rfb/main.c

    r8596474 r7a873f0  
    196196
    197197        /* 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)
    199199                return ENOTSUP;
    200200
     
    287287
    288288        if ((rfbbm->flags & bmpf_color_key) == 0) {
    289                 /* Simple copy */
    290289                for (y = srect.p0.y; y < srect.p1.y; y++) {
    291290                        for (x = srect.p0.x; x < srect.p1.x; x++) {
     
    295294                        }
    296295                }
    297         } else if ((rfbbm->flags & bmpf_colorize) == 0) {
    298                 /* Color key */
     296        } else {
    299297                for (y = srect.p0.y; y < srect.p1.y; y++) {
    300298                        for (x = srect.p0.x; x < srect.p1.x; x++) {
     
    306304                        }
    307305                }
    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                 }
    320306        }
    321307
Note: See TracChangeset for help on using the changeset viewer.