Changeset c79545e in mainline
- Timestamp:
- 2020-01-19T10:00:11Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2012fe0
- Parents:
- 946a666
- Location:
- uspace/srv/hid/display
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/ddev.c
r946a666 rc79545e 94 94 ds_display_add_ddev(display, ddev); 95 95 96 rc = ds_display_paint_bg(display, NULL); 97 if (rc != EOK) 98 return rc; 99 96 100 *rddev = ddev; 97 101 return EOK; -
uspace/srv/hid/display/display.c
r946a666 rc79545e 36 36 #include <errno.h> 37 37 #include <gfx/context.h> 38 #include <gfx/render.h> 38 39 #include <io/log.h> 39 40 #include <stdlib.h> … … 52 53 { 53 54 ds_display_t *disp; 55 errno_t rc; 54 56 55 57 disp = calloc(1, sizeof(ds_display_t)); 56 58 if (disp == NULL) 57 59 return ENOMEM; 60 61 rc = gfx_color_new_rgb_i16(0x8000, 0xc800, 0xffff, &disp->bg_color); 62 if (rc != EOK) { 63 free(disp); 64 return ENOMEM; 65 } 58 66 59 67 list_initialize(&disp->clients); … … 74 82 assert(list_empty(&disp->clients)); 75 83 assert(list_empty(&disp->seats)); 84 gfx_color_delete(disp->bg_color); 76 85 free(disp); 77 86 } … … 401 410 } 402 411 412 /** Paint display background. 413 * 414 * @param display Display 415 * @param rect Bounding rectangle or @c NULL to repaint entire display 416 */ 417 errno_t ds_display_paint_bg(ds_display_t *disp, gfx_rect_t *rect) 418 { 419 gfx_rect_t dsrect; 420 gfx_rect_t crect; 421 gfx_context_t *gc; 422 errno_t rc; 423 424 dsrect.p0.x = 0; 425 dsrect.p0.y = 0; 426 dsrect.p1.x = 1024; 427 dsrect.p1.y = 768; 428 429 if (rect != NULL) 430 gfx_rect_clip(&dsrect, rect, &crect); 431 else 432 crect = dsrect; 433 434 gc = ds_display_get_gc(disp); // XXX 435 436 rc = gfx_set_color(gc, disp->bg_color); 437 if (rc != EOK) 438 return rc; 439 440 return gfx_fill_rect(gc, &crect); 441 } 442 403 443 /** @} 404 444 */ -
uspace/srv/hid/display/display.h
r946a666 rc79545e 39 39 #include <errno.h> 40 40 #include <gfx/context.h> 41 #include <gfx/coord.h> 41 42 #include <io/kbd_event.h> 42 43 #include "types/display/client.h" … … 69 70 extern ds_ddev_t *ds_display_next_ddev(ds_ddev_t *); 70 71 extern gfx_context_t *ds_display_get_gc(ds_display_t *); 72 extern errno_t ds_display_paint_bg(ds_display_t *, gfx_rect_t *); 71 73 72 74 #endif -
uspace/srv/hid/display/seat.c
r946a666 rc79545e 139 139 * @param len Cross length 140 140 * @param w Cross extra width 141 * @param br Brightness (0 to 65535)141 * @param color Color 142 142 * 143 143 * @return EOK on success or an error code 144 144 */ 145 145 static errno_t ds_seat_draw_cross(ds_seat_t *seat, gfx_coord_t len, 146 gfx_coord_t w, uint16_t br) 147 { 148 gfx_color_t *color = NULL; 146 gfx_coord_t w, gfx_color_t *color) 147 { 149 148 gfx_context_t *gc; 150 149 gfx_rect_t rect, r0; … … 154 153 if (gc == NULL) 155 154 return EOK; 156 157 rc = gfx_color_new_rgb_i16(br, br, br, &color);158 if (rc != EOK)159 goto error;160 155 161 156 rc = gfx_set_color(gc, color); … … 183 178 goto error; 184 179 185 gfx_color_delete(color);186 180 return EOK; 187 181 error: 188 if (color != NULL)189 gfx_color_delete(color);190 182 return rc; 191 183 } … … 201 193 { 202 194 errno_t rc; 203 204 rc = ds_seat_draw_cross(seat, 8, 1, 0); 195 gfx_color_t *black = NULL; 196 gfx_color_t *white; 197 198 rc = gfx_color_new_rgb_i16(0, 0, 0, &black); 199 if (rc != EOK) 200 goto error; 201 202 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &white); 203 if (rc != EOK) 204 goto error; 205 206 rc = ds_seat_draw_cross(seat, 8, 1, shown ? black : 207 seat->display->bg_color); 205 208 if (rc != EOK) 206 209 return rc; 207 210 208 rc = ds_seat_draw_cross(seat, 8, 0, shown ? 65535 : 0); 211 rc = ds_seat_draw_cross(seat, 8, 0, shown ? white : 212 seat->display->bg_color); 209 213 if (rc != EOK) 210 214 return rc; 211 215 212 216 return EOK; 217 error: 218 if (black != NULL) 219 gfx_color_delete(black); 220 return rc; 213 221 } 214 222 -
uspace/srv/hid/display/types/display/display.h
r946a666 rc79545e 38 38 39 39 #include <adt/list.h> 40 #include <gfx/color.h> 40 41 #include <io/input.h> 41 42 #include "window.h" … … 65 66 /** Display devices (of ds_ddev_t) */ 66 67 list_t ddevs; 68 69 /** Background color */ 70 gfx_color_t *bg_color; 67 71 } ds_display_t; 68 72 -
uspace/srv/hid/display/window.c
r946a666 rc79545e 420 420 (int) event->hpos, (int) event->vpos); 421 421 422 gfx_rect_translate(&wnd->dpos, &wnd->rect, &drect); 423 424 gc = ds_display_get_gc(wnd->display); // XXX 425 if (gc != NULL) { 426 gfx_set_color(gc, wnd->display->bg_color); 427 gfx_fill_rect(gc, &drect); 428 } 429 422 430 assert(wnd->state == dsw_moving); 423 431 pos.x = event->hpos; … … 428 436 gfx_rect_translate(&nwpos, &wnd->rect, &drect); 429 437 438 wnd->orig_pos = pos; 439 wnd->dpos = nwpos; 440 430 441 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color); 431 442 if (rc != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.