Changeset 9259d20 in mainline
- Timestamp:
- 2019-04-16T09:15:55Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3e828ea
- Parents:
- 045186b
- git-author:
- Jiri Svoboda <jiri@…> (2019-04-15 17:15:29)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-04-16 09:15:55)
- Location:
- uspace
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/gfxdemo/gfxdemo.c
r045186b r9259d20 33 33 */ 34 34 35 #include <fibril.h> 36 #include <gfx/backend/console.h> 35 37 #include <gfx/color.h> 36 38 #include <gfx/render.h> 39 #include <io/console.h> 40 #include <stdlib.h> 37 41 38 42 int main(int argc, char *argv[]) 39 43 { 44 console_ctrl_t *con = NULL; 45 gfx_color_t *color = NULL; 46 gfx_context_t *gc = NULL; 47 gfx_rect_t rect; 48 int i; 49 errno_t rc; 50 51 printf("Init console..\n"); 52 con = console_init(stdin, stdout); 53 if (con == NULL) 54 return 1; 55 56 printf("Create console GC\n"); 57 rc = console_gc_create(con, stdout, &gc); 58 if (rc != EOK) 59 return 1; 60 61 while (true) { 62 rc = gfx_color_new_rgb_i16(rand() % 0x10000, rand() % 0x10000, 63 rand() % 0x10000, &color); 64 if (rc != EOK) 65 return 1; 66 67 rc = gfx_set_color(gc, color); 68 if (rc != EOK) 69 return 1; 70 71 for (i = 0; i < 10; i++) { 72 rect.p0.x = rand() % 79; 73 rect.p0.y = rand() % 24; 74 rect.p1.x = rect.p0.x + rand() % (79 - rect.p0.x); 75 rect.p1.y = rect.p0.y + rand() % (24 - rect.p0.y); 76 77 rc = gfx_fill_rect(gc, &rect); 78 if (rc != EOK) 79 return 1; 80 } 81 82 gfx_color_delete(color); 83 84 fibril_usleep(500 * 1000); 85 } 86 87 // TODO How will we free GC subclass? 88 89 // rc = gfx_context_delete(gc); 90 // if (rc != EOK) 91 // return 1; 92 93 return 0; 40 94 } 41 95 -
uspace/lib/gfx/Makefile
r045186b r9259d20 32 32 33 33 SOURCES = \ 34 src/backend/console.c \ 34 35 src/color.c \ 35 36 src/context.c \ -
uspace/lib/gfx/src/color.c
r045186b r9259d20 36 36 #include <gfx/color.h> 37 37 #include <stdint.h> 38 #include <stdlib.h> 39 #include "private/color.h" 38 40 39 41 /** Create new 16-bit per channel RGB color. … … 53 55 gfx_color_t **rcolor) 54 56 { 57 gfx_color_t *color; 58 59 color = calloc(1, sizeof(gfx_color_t)); 60 if (color == NULL) 61 return ENOMEM; 62 63 color->r = r; 64 color->g = g; 65 color->b = b; 66 67 *rcolor = color; 55 68 return EOK; 56 69 } … … 62 75 void gfx_color_delete(gfx_color_t *color) 63 76 { 64 (void) color;77 free(color); 65 78 } 66 79 -
uspace/lib/gfx/src/context.c
r045186b r9259d20 64 64 /** Delete graphics context. 65 65 * 66 * @param gc Graphics context 66 * @param gc Graphics context or @c NULL 67 67 */ 68 68 errno_t gfx_context_delete(gfx_context_t *gc) 69 69 { 70 if (gc == NULL) 71 return EOK; 72 70 73 free(gc); 71 74 return EOK; -
uspace/lib/gfx/test/render.c
r045186b r9259d20 107 107 } 108 108 109 errno_t testgc_set_color(void *arg, gfx_color_t *color)109 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 110 110 { 111 111 test_gc_t *tgc = (test_gc_t *) arg; … … 116 116 } 117 117 118 errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)118 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect) 119 119 { 120 120 test_gc_t *tgc = (test_gc_t *) arg;
Note:
See TracChangeset
for help on using the changeset viewer.