Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/gfxdemo/gfxdemo.c

    rda15002 r232bf2c  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7373static gfx_coord_t vpad;
    7474
     75/** Determine if we are running in text mode.
     76 *
     77 * @param w Screen width
     78 * @param h Screen height
     79 * @return @c true iff we are running in text mode
     80 */
     81static bool demo_is_text(gfx_coord_t w, gfx_coord_t h)
     82{
     83        // XXX Need a proper way to determine text mode
     84        return w <= 80;
     85}
     86
    7587/** Clear screen.
    7688 *
     
    215227
    216228        if (font != NULL) {
    217                 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
    218                 if (rc != EOK)
    219                         goto error;
     229                if (demo_is_text(w, h)) {
     230                        rc = gfx_color_new_ega(0x1e, &color);
     231                        if (rc != EOK)
     232                                goto error;
     233                } else {
     234                        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
     235                        if (rc != EOK)
     236                                goto error;
     237                }
    220238
    221239                gfx_text_fmt_init(&fmt);
     
    660678        gfx_color_delete(color);
    661679
    662         rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
    663         if (rc != EOK)
    664                 goto error;
     680        if (demo_is_text(w, h)) {
     681                rc = gfx_color_new_ega(0x1f, &color);
     682                if (rc != EOK)
     683                        goto error;
     684        } else {
     685                rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
     686                if (rc != EOK)
     687                        goto error;
     688        }
    665689
    666690        gfx_text_fmt_init(&fmt);
     
    682706                goto error;
    683707
    684         pos.x = rect.p1.x - 1;
     708        pos.x = rect.p1.x;
    685709        pos.y = rect.p0.y;
    686710        fmt.halign = gfx_halign_right;
     
    705729                goto error;
    706730
    707         pos.x = rect.p1.x - 1;
     731        pos.x = rect.p1.x;
    708732        pos.y = (rect.p0.y + rect.p1.y - 1) / 2;
    709733        fmt.halign = gfx_halign_right;
     
    722746
    723747        pos.x = (rect.p0.x + rect.p1.x - 1) / 2;
    724         pos.y = rect.p1.y - 1;
     748        pos.y = rect.p1.y;
    725749        fmt.halign = gfx_halign_center;
    726750        rc = gfx_puttext(font, &pos, &fmt, "Bottom center");
     
    728752                goto error;
    729753
    730         pos.x = rect.p1.x - 1;
    731         pos.y = rect.p1.y - 1;
     754        pos.x = rect.p1.x;
     755        pos.y = rect.p1.y;
    732756        fmt.halign = gfx_halign_right;
    733757        rc = gfx_puttext(font, &pos, &fmt, "Bottom right");
     
    740764
    741765        for (i = 0; i < 8; i++) {
    742                 rc = gfx_color_new_rgb_i16((i & 4) ? 0xffff : 0,
    743                     (i & 2) ? 0xffff : 0, (i & 1) ? 0xffff : 0, &color);
    744                 if (rc != EOK)
    745                         goto error;
     766                if (demo_is_text(w, h)) {
     767                        rc = gfx_color_new_ega(i != 0 ? i : 0x10, &color);
     768                        if (rc != EOK)
     769                                goto error;
     770                } else {
     771                        rc = gfx_color_new_rgb_i16((i & 4) ? 0xffff : 0,
     772                            (i & 2) ? 0xffff : 0, (i & 1) ? 0xffff : 0, &color);
     773                        if (rc != EOK)
     774                                goto error;
     775                }
    746776
    747777                fmt.color = color;
     
    10991129        errno_t rc;
    11001130        const char *display_svc = DISPLAY_DEFAULT;
     1131        const char *ui_display_spec = UI_DISPLAY_DEFAULT;
    11011132        int i;
    11021133
     
    11111142                        }
    11121143
    1113                         display_svc = argv[i++];
     1144                        display_svc = ui_display_spec = argv[i++];
    11141145                } else {
    11151146                        printf("Invalid option '%s'.\n", argv[i]);
     
    11281159                        return 1;
    11291160        } else if (str_cmp(argv[i], "ui") == 0) {
    1130                 rc = demo_ui(display_svc);
     1161                rc = demo_ui(ui_display_spec);
    11311162                if (rc != EOK)
    11321163                        return 1;
Note: See TracChangeset for help on using the changeset viewer.