Changeset c79545e in mainline


Ignore:
Timestamp:
2020-01-19T10:00:11Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2012fe0
Parents:
946a666
Message:

Paint desktop background with a solid color

Location:
uspace/srv/hid/display
Files:
6 edited

Legend:

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

    r946a666 rc79545e  
    9494        ds_display_add_ddev(display, ddev);
    9595
     96        rc = ds_display_paint_bg(display, NULL);
     97        if (rc != EOK)
     98                return rc;
     99
    96100        *rddev = ddev;
    97101        return EOK;
  • uspace/srv/hid/display/display.c

    r946a666 rc79545e  
    3636#include <errno.h>
    3737#include <gfx/context.h>
     38#include <gfx/render.h>
    3839#include <io/log.h>
    3940#include <stdlib.h>
     
    5253{
    5354        ds_display_t *disp;
     55        errno_t rc;
    5456
    5557        disp = calloc(1, sizeof(ds_display_t));
    5658        if (disp == NULL)
    5759                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        }
    5866
    5967        list_initialize(&disp->clients);
     
    7482        assert(list_empty(&disp->clients));
    7583        assert(list_empty(&disp->seats));
     84        gfx_color_delete(disp->bg_color);
    7685        free(disp);
    7786}
     
    401410}
    402411
     412/** Paint display background.
     413 *
     414 * @param display Display
     415 * @param rect Bounding rectangle or @c NULL to repaint entire display
     416 */
     417errno_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
    403443/** @}
    404444 */
  • uspace/srv/hid/display/display.h

    r946a666 rc79545e  
    3939#include <errno.h>
    4040#include <gfx/context.h>
     41#include <gfx/coord.h>
    4142#include <io/kbd_event.h>
    4243#include "types/display/client.h"
     
    6970extern ds_ddev_t *ds_display_next_ddev(ds_ddev_t *);
    7071extern gfx_context_t *ds_display_get_gc(ds_display_t *);
     72extern errno_t ds_display_paint_bg(ds_display_t *, gfx_rect_t *);
    7173
    7274#endif
  • uspace/srv/hid/display/seat.c

    r946a666 rc79545e  
    139139 * @param len Cross length
    140140 * @param w Cross extra width
    141  * @param br Brightness (0 to 65535)
     141 * @param color Color
    142142 *
    143143 * @return EOK on success or an error code
    144144 */
    145145static 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{
    149148        gfx_context_t *gc;
    150149        gfx_rect_t rect, r0;
     
    154153        if (gc == NULL)
    155154                return EOK;
    156 
    157         rc = gfx_color_new_rgb_i16(br, br, br, &color);
    158         if (rc != EOK)
    159                 goto error;
    160155
    161156        rc = gfx_set_color(gc, color);
     
    183178                goto error;
    184179
    185         gfx_color_delete(color);
    186180        return EOK;
    187181error:
    188         if (color != NULL)
    189                 gfx_color_delete(color);
    190182        return rc;
    191183}
     
    201193{
    202194        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);
    205208        if (rc != EOK)
    206209                return rc;
    207210
    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);
    209213        if (rc != EOK)
    210214                return rc;
    211215
    212216        return EOK;
     217error:
     218        if (black != NULL)
     219                gfx_color_delete(black);
     220        return rc;
    213221}
    214222
  • uspace/srv/hid/display/types/display/display.h

    r946a666 rc79545e  
    3838
    3939#include <adt/list.h>
     40#include <gfx/color.h>
    4041#include <io/input.h>
    4142#include "window.h"
     
    6566        /** Display devices (of ds_ddev_t) */
    6667        list_t ddevs;
     68
     69        /** Background color */
     70        gfx_color_t *bg_color;
    6771} ds_display_t;
    6872
  • uspace/srv/hid/display/window.c

    r946a666 rc79545e  
    420420            (int) event->hpos, (int) event->vpos);
    421421
     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
    422430        assert(wnd->state == dsw_moving);
    423431        pos.x = event->hpos;
     
    428436        gfx_rect_translate(&nwpos, &wnd->rect, &drect);
    429437
     438        wnd->orig_pos = pos;
     439        wnd->dpos = nwpos;
     440
    430441        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
    431442        if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.