Changeset c8cf261 in mainline for uspace/app/gfxdemo/gfxdemo.c


Ignore:
Timestamp:
2019-10-03T09:10:01Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6af4b4f
Parents:
aac5069
git-author:
Jiri Svoboda <jiri@…> (2019-10-02 17:09:46)
git-committer:
Jiri Svoboda <jiri@…> (2019-10-03 09:10:01)
Message:

Display server scaffolding

File:
1 edited

Legend:

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

    raac5069 rc8cf261  
    3636#include <congfx/console.h>
    3737#include <draw/surface.h>
     38#include <display.h>
    3839#include <fibril.h>
    3940#include <guigfx/canvas.h>
     
    117118static errno_t demo_canvas(void)
    118119{
    119         console_ctrl_t *con = NULL;
    120120        canvas_gc_t *cgc = NULL;
    121121        gfx_context_t *gc;
     
    128128
    129129        printf("Init canvas..\n");
    130         con = console_init(stdin, stdout);
    131         if (con == NULL)
    132                 return EIO;
    133130
    134131        window = window_open("comp:0/winreg", NULL,
     
    145142        if (pixbuf == NULL) {
    146143                printf("Error allocating memory for pixel buffer.\n");
    147                 return -1;
     144                return ENOMEM;
    148145        }
    149146
     
    151148        if (surface == NULL) {
    152149                printf("Error creating surface.\n");
    153                 return -1;
     150                return EIO;
    154151        }
    155152
     
    158155        if (canvas == NULL) {
    159156                printf("Error creating canvas.\n");
    160                 return -1;
     157                return EIO;
    161158        }
    162159
     
    182179}
    183180
     181/** Run demo on display server. */
     182static errno_t demo_display(void)
     183{
     184        display_t *display = NULL;
     185        gfx_context_t *gc;
     186        display_window_t *window = NULL;
     187        errno_t rc;
     188
     189        printf("Init display..\n");
     190
     191        rc = display_open(NULL, &display);
     192        if (rc != EOK) {
     193                printf("Error opening display.\n");
     194                return rc;
     195        }
     196
     197        rc = display_window_create(display, &window);
     198        if (rc != EOK) {
     199                printf("Error creating window.\n");
     200                return rc;
     201        }
     202
     203        rc = display_window_get_gc(window, &gc);
     204        if (rc != EOK) {
     205                printf("Error getting graphics context.\n");
     206        }
     207
     208        rc = demo_rects(gc, 400, 300);
     209        if (rc != EOK)
     210                return rc;
     211
     212        rc = gfx_context_delete(gc);
     213        if (rc != EOK)
     214                return rc;
     215
     216        return EOK;
     217}
     218
    184219static void print_syntax(void)
    185220{
    186         printf("syntax: gfxdemo {canvas|console}\n");
     221        printf("syntax: gfxdemo {canvas|console|display}\n");
    187222}
    188223
     
    202237        } else if (str_cmp(argv[1], "canvas") == 0) {
    203238                rc = demo_canvas();
     239                if (rc != EOK)
     240                        return 1;
     241        } else if (str_cmp(argv[1], "display") == 0) {
     242                rc = demo_display();
    204243                if (rc != EOK)
    205244                        return 1;
Note: See TracChangeset for help on using the changeset viewer.