Changeset 045186b in mainline
- Timestamp:
- 2019-04-15T15:45:04Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9259d20
- Parents:
- d6dc9a12
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
rd6dc9a12 r045186b 105 105 uspace/app/fontviewer/fontviewer 106 106 uspace/app/getterm/getterm 107 uspace/app/gfxdemo/gfxdemo 107 108 uspace/app/gunzip/gunzip 108 109 uspace/app/hbench/hbench … … 386 387 uspace/lib/c/arch/sparc64/_link.ld 387 388 uspace/lib/c/test-libc 389 uspace/lib/gfx/test-libgfx 388 390 uspace/lib/label/test-liblabel 389 391 uspace/lib/math/test-libmath -
boot/Makefile.common
rd6dc9a12 r045186b 191 191 edit \ 192 192 fdisk \ 193 gfxdemo \ 193 194 gunzip \ 194 195 hbench \ -
uspace/Makefile
rd6dc9a12 r045186b 49 49 app/fontviewer \ 50 50 app/getterm \ 51 app/gfxdemo \ 51 52 app/gunzip \ 52 53 app/hbench \ -
uspace/lib/gfx/Makefile
rd6dc9a12 r045186b 33 33 SOURCES = \ 34 34 src/color.c \ 35 src/context.c \ 35 36 src/render.c 36 37 -
uspace/lib/gfx/include/gfx/context.h
rd6dc9a12 r045186b 41 41 #define _GFX_CONTEXT_H 42 42 43 #include <errno.h> 43 44 #include <types/gfx/context.h> 45 #include <types/gfx/ops/context.h> 46 47 extern errno_t gfx_context_new(gfx_context_ops_t *, void *, 48 gfx_context_t **); 49 extern errno_t gfx_context_delete(gfx_context_t *); 44 50 45 51 #endif -
uspace/lib/gfx/src/render.c
rd6dc9a12 r045186b 35 35 36 36 #include <gfx/render.h> 37 #include "../private/context.h" 37 38 38 39 /** Set drawing color. … … 46 47 errno_t gfx_set_color(gfx_context_t *gc, gfx_color_t *color) 47 48 { 48 return EOK;49 return gc->ops->set_color(gc->arg, color); 49 50 } 50 51 … … 59 60 errno_t gfx_fill_rect(gfx_context_t *gc, gfx_rect_t *rect) 60 61 { 61 return EOK;62 return gc->ops->fill_rect(gc->arg, rect); 62 63 } 63 64 -
uspace/lib/gfx/test/render.c
rd6dc9a12 r045186b 28 28 29 29 #include <gfx/color.h> 30 #include <gfx/context.h> 30 31 #include <gfx/render.h> 31 32 #include <pcut/pcut.h> 33 #include <mem.h> 32 34 33 35 PCUT_INIT; 34 36 35 37 PCUT_TEST_SUITE(render); 38 39 static errno_t testgc_set_color(void *, gfx_color_t *); 40 static errno_t testgc_fill_rect(void *, gfx_rect_t *); 41 42 static gfx_context_ops_t ops = { 43 .set_color = testgc_set_color, 44 .fill_rect = testgc_fill_rect 45 }; 46 47 /** Test graphics context data */ 48 typedef struct { 49 gfx_color_t *dclr; 50 gfx_rect_t *rect; 51 } test_gc_t; 36 52 37 53 PCUT_TEST(set_color) … … 40 56 gfx_color_t *color; 41 57 gfx_context_t *gc = NULL; 58 test_gc_t tgc; 59 60 memset(&tgc, 0, sizeof(tgc)); 61 62 rc = gfx_context_new(&ops, &tgc, &gc); 63 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 42 64 43 65 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); … … 46 68 rc = gfx_set_color(gc, color); 47 69 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 70 PCUT_ASSERT_EQUALS(color, tgc.dclr); 71 PCUT_ASSERT_NULL(tgc.rect); 48 72 49 73 gfx_color_delete(color); 74 75 rc = gfx_context_delete(gc); 76 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 50 77 } 51 78 … … 56 83 gfx_rect_t rect; 57 84 gfx_context_t *gc = NULL; 85 test_gc_t tgc; 86 87 memset(&tgc, 0, sizeof(tgc)); 88 89 rc = gfx_context_new(&ops, &tgc, &gc); 90 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 58 91 59 92 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); … … 62 95 rc = gfx_set_color(gc, color); 63 96 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 97 PCUT_ASSERT_EQUALS(color, tgc.dclr); 64 98 65 99 rc = gfx_fill_rect(gc, &rect); 66 100 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 101 PCUT_ASSERT_EQUALS(&rect, tgc.rect); 67 102 68 103 gfx_color_delete(color); 104 105 rc = gfx_context_delete(gc); 106 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 107 } 108 109 errno_t testgc_set_color(void *arg, gfx_color_t *color) 110 { 111 test_gc_t *tgc = (test_gc_t *) arg; 112 113 /* Technically we should copy the data */ 114 tgc->dclr = color; 115 return EOK; 116 } 117 118 errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect) 119 { 120 test_gc_t *tgc = (test_gc_t *) arg; 121 122 /* Technically we should copy the data */ 123 tgc->rect = rect; 124 return EOK; 69 125 } 70 126
Note:
See TracChangeset
for help on using the changeset viewer.