Changeset c8cf261 in mainline for uspace/app/gfxdemo/gfxdemo.c
- Timestamp:
- 2019-10-03T09:10:01Z (6 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/gfxdemo/gfxdemo.c
raac5069 rc8cf261 36 36 #include <congfx/console.h> 37 37 #include <draw/surface.h> 38 #include <display.h> 38 39 #include <fibril.h> 39 40 #include <guigfx/canvas.h> … … 117 118 static errno_t demo_canvas(void) 118 119 { 119 console_ctrl_t *con = NULL;120 120 canvas_gc_t *cgc = NULL; 121 121 gfx_context_t *gc; … … 128 128 129 129 printf("Init canvas..\n"); 130 con = console_init(stdin, stdout);131 if (con == NULL)132 return EIO;133 130 134 131 window = window_open("comp:0/winreg", NULL, … … 145 142 if (pixbuf == NULL) { 146 143 printf("Error allocating memory for pixel buffer.\n"); 147 return -1;144 return ENOMEM; 148 145 } 149 146 … … 151 148 if (surface == NULL) { 152 149 printf("Error creating surface.\n"); 153 return -1;150 return EIO; 154 151 } 155 152 … … 158 155 if (canvas == NULL) { 159 156 printf("Error creating canvas.\n"); 160 return -1;157 return EIO; 161 158 } 162 159 … … 182 179 } 183 180 181 /** Run demo on display server. */ 182 static 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 184 219 static void print_syntax(void) 185 220 { 186 printf("syntax: gfxdemo {canvas|console }\n");221 printf("syntax: gfxdemo {canvas|console|display}\n"); 187 222 } 188 223 … … 202 237 } else if (str_cmp(argv[1], "canvas") == 0) { 203 238 rc = demo_canvas(); 239 if (rc != EOK) 240 return 1; 241 } else if (str_cmp(argv[1], "display") == 0) { 242 rc = demo_display(); 204 243 if (rc != EOK) 205 244 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.