Changeset 6af4b4f in mainline for uspace/srv/hid/display/window.c


Ignore:
Timestamp:
2019-10-05T08:45:25Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
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)
Message:

Introduce ds_display_t, ds_window_t

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/window.c

    rc8cf261 r6af4b4f  
    4141#include <io/log.h>
    4242#include <stdlib.h>
    43 #include "wingc.h"
     43#include "display.h"
     44#include "window.h"
    4445
    45 static errno_t win_gc_set_color(void *, gfx_color_t *);
    46 static errno_t win_gc_fill_rect(void *, gfx_rect_t *);
     46static errno_t ds_window_set_color(void *, gfx_color_t *);
     47static errno_t ds_window_fill_rect(void *, gfx_rect_t *);
    4748
    48 gfx_context_ops_t win_gc_ops = {
    49         .set_color = win_gc_set_color,
    50         .fill_rect = win_gc_fill_rect
     49gfx_context_ops_t ds_window_ops = {
     50        .set_color = ds_window_set_color,
     51        .fill_rect = ds_window_fill_rect
    5152};
    5253
     
    6061 * @return EOK on success or an error code
    6162 */
    62 static errno_t win_gc_set_color(void *arg, gfx_color_t *color)
     63static errno_t ds_window_set_color(void *arg, gfx_color_t *color)
    6364{
    64         win_gc_t *wgc = (win_gc_t *) arg;
     65        ds_window_t *wnd = (ds_window_t *) arg;
    6566
    66         (void) wgc;
     67        (void) wnd;
    6768        log_msg(LOG_DEFAULT, LVL_NOTE, "gc_set_color");
    6869        return EOK;
     
    7172/** Fill rectangle on window GC.
    7273 *
    73  * @param arg Console GC
     74 * @param arg Window GC
    7475 * @param rect Rectangle
    7576 *
    7677 * @return EOK on success or an error code
    7778 */
    78 static errno_t win_gc_fill_rect(void *arg, gfx_rect_t *rect)
     79static errno_t ds_window_fill_rect(void *arg, gfx_rect_t *rect)
    7980{
    80         win_gc_t *wgc = (win_gc_t *) arg;
     81        ds_window_t *wnd = (ds_window_t *) arg;
    8182
    82         (void) wgc;
     83        (void) wnd;
    8384        log_msg(LOG_DEFAULT, LVL_NOTE, "gc_fill_rect");
    8485        return EOK;
    8586}
    8687
    87 /** Create window GC.
     88/** Create window.
    8889 *
    8990 * Create graphics context for rendering into a window.
    9091 *
     92 * @param disp Display to create window on
    9193 * @param rgc Place to store pointer to new GC.
    9294 *
    9395 * @return EOK on success or an error code
    9496 */
    95 errno_t win_gc_create(win_gc_t **rgc)
     97errno_t ds_window_create(ds_display_t *disp, ds_window_t **rgc)
    9698{
    97         win_gc_t *wgc = NULL;
     99        ds_window_t *wnd = NULL;
    98100        gfx_context_t *gc = NULL;
    99101        errno_t rc;
    100102
    101         wgc = calloc(1, sizeof(win_gc_t));
    102         if (wgc == NULL) {
     103        wnd = calloc(1, sizeof(ds_window_t));
     104        if (wnd == NULL) {
    103105                rc = ENOMEM;
    104106                goto error;
    105107        }
    106108
    107         rc = gfx_context_new(&win_gc_ops, wgc, &gc);
     109        rc = gfx_context_new(&ds_window_ops, wnd, &gc);
    108110        if (rc != EOK)
    109111                goto error;
    110112
    111         wgc->gc = gc;
    112         *rgc = wgc;
     113        ds_display_add_window(disp, wnd);
     114
     115        wnd->gc = gc;
     116        *rgc = wnd;
    113117        return EOK;
    114118error:
    115         if (wgc != NULL)
    116                 free(wgc);
     119        if (wnd != NULL)
     120                free(wnd);
    117121        gfx_context_delete(gc);
    118122        return rc;
     
    121125/** Delete window GC.
    122126 *
    123  * @param wgc Console GC
     127 * @param wnd Window GC
    124128 */
    125 errno_t win_gc_delete(win_gc_t *wgc)
     129errno_t ds_window_delete(ds_window_t *wnd)
    126130{
    127131        errno_t rc;
    128132
    129         rc = gfx_context_delete(wgc->gc);
     133        rc = gfx_context_delete(wnd->gc);
    130134        if (rc != EOK)
    131135                return rc;
    132136
    133         free(wgc);
     137        free(wnd);
    134138        return EOK;
    135139}
    136140
    137 /** Get generic graphic context from window GC.
     141/** Get generic graphic context from window.
    138142 *
    139  * @param wgc Console GC
     143 * @param wnd Window
    140144 * @return Graphic context
    141145 */
    142 gfx_context_t *win_gc_get_ctx(win_gc_t *wgc)
     146gfx_context_t *ds_window_get_ctx(ds_window_t *wnd)
    143147{
    144         return wgc->gc;
     148        return wnd->gc;
    145149}
    146150
Note: See TracChangeset for help on using the changeset viewer.