Changeset 6af4b4f in mainline for uspace/srv/hid/display/window.c
- Timestamp:
- 2019-10-05T08:45:25Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bef51cf
- Parents:
- c8cf261
- git-author:
- Jiri Svoboda <jiri@…> (2019-10-04 17:52:54)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-10-05 08:45:25)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/window.c
rc8cf261 r6af4b4f 41 41 #include <io/log.h> 42 42 #include <stdlib.h> 43 #include "wingc.h" 43 #include "display.h" 44 #include "window.h" 44 45 45 static errno_t win_gc_set_color(void *, gfx_color_t *);46 static errno_t win_gc_fill_rect(void *, gfx_rect_t *);46 static errno_t ds_window_set_color(void *, gfx_color_t *); 47 static errno_t ds_window_fill_rect(void *, gfx_rect_t *); 47 48 48 gfx_context_ops_t win_gc_ops = {49 .set_color = win_gc_set_color,50 .fill_rect = win_gc_fill_rect49 gfx_context_ops_t ds_window_ops = { 50 .set_color = ds_window_set_color, 51 .fill_rect = ds_window_fill_rect 51 52 }; 52 53 … … 60 61 * @return EOK on success or an error code 61 62 */ 62 static errno_t win_gc_set_color(void *arg, gfx_color_t *color)63 static errno_t ds_window_set_color(void *arg, gfx_color_t *color) 63 64 { 64 win_gc_t *wgc = (win_gc_t *) arg;65 ds_window_t *wnd = (ds_window_t *) arg; 65 66 66 (void) w gc;67 (void) wnd; 67 68 log_msg(LOG_DEFAULT, LVL_NOTE, "gc_set_color"); 68 69 return EOK; … … 71 72 /** Fill rectangle on window GC. 72 73 * 73 * @param arg ConsoleGC74 * @param arg Window GC 74 75 * @param rect Rectangle 75 76 * 76 77 * @return EOK on success or an error code 77 78 */ 78 static errno_t win_gc_fill_rect(void *arg, gfx_rect_t *rect)79 static errno_t ds_window_fill_rect(void *arg, gfx_rect_t *rect) 79 80 { 80 win_gc_t *wgc = (win_gc_t *) arg;81 ds_window_t *wnd = (ds_window_t *) arg; 81 82 82 (void) w gc;83 (void) wnd; 83 84 log_msg(LOG_DEFAULT, LVL_NOTE, "gc_fill_rect"); 84 85 return EOK; 85 86 } 86 87 87 /** Create window GC.88 /** Create window. 88 89 * 89 90 * Create graphics context for rendering into a window. 90 91 * 92 * @param disp Display to create window on 91 93 * @param rgc Place to store pointer to new GC. 92 94 * 93 95 * @return EOK on success or an error code 94 96 */ 95 errno_t win_gc_create(win_gc_t **rgc)97 errno_t ds_window_create(ds_display_t *disp, ds_window_t **rgc) 96 98 { 97 win_gc_t *wgc= NULL;99 ds_window_t *wnd = NULL; 98 100 gfx_context_t *gc = NULL; 99 101 errno_t rc; 100 102 101 w gc = calloc(1, sizeof(win_gc_t));102 if (w gc== NULL) {103 wnd = calloc(1, sizeof(ds_window_t)); 104 if (wnd == NULL) { 103 105 rc = ENOMEM; 104 106 goto error; 105 107 } 106 108 107 rc = gfx_context_new(& win_gc_ops, wgc, &gc);109 rc = gfx_context_new(&ds_window_ops, wnd, &gc); 108 110 if (rc != EOK) 109 111 goto error; 110 112 111 wgc->gc = gc; 112 *rgc = wgc; 113 ds_display_add_window(disp, wnd); 114 115 wnd->gc = gc; 116 *rgc = wnd; 113 117 return EOK; 114 118 error: 115 if (w gc!= NULL)116 free(w gc);119 if (wnd != NULL) 120 free(wnd); 117 121 gfx_context_delete(gc); 118 122 return rc; … … 121 125 /** Delete window GC. 122 126 * 123 * @param w gc ConsoleGC127 * @param wnd Window GC 124 128 */ 125 errno_t win_gc_delete(win_gc_t *wgc)129 errno_t ds_window_delete(ds_window_t *wnd) 126 130 { 127 131 errno_t rc; 128 132 129 rc = gfx_context_delete(w gc->gc);133 rc = gfx_context_delete(wnd->gc); 130 134 if (rc != EOK) 131 135 return rc; 132 136 133 free(w gc);137 free(wnd); 134 138 return EOK; 135 139 } 136 140 137 /** Get generic graphic context from window GC.141 /** Get generic graphic context from window. 138 142 * 139 * @param w gc Console GC143 * @param wnd Window 140 144 * @return Graphic context 141 145 */ 142 gfx_context_t * win_gc_get_ctx(win_gc_t *wgc)146 gfx_context_t *ds_window_get_ctx(ds_window_t *wnd) 143 147 { 144 return w gc->gc;148 return wnd->gc; 145 149 } 146 150
Note:
See TracChangeset
for help on using the changeset viewer.