Changeset e1f2079 in mainline


Ignore:
Timestamp:
2020-02-14T19:54:40Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b0a94854
Parents:
b252e87
Message:

Get display resolution by querying display device

Location:
uspace
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/fb/kfb/kfb.h

    rb252e87 re1f2079  
    4141#define NAME  "kfb"
    4242
    43 extern ddf_dev_ops_t graph_vsl_device_ops;
    44 extern ddf_dev_ops_t graph_rnd_device_ops;
    45 
    4643#endif
    4744
  • uspace/drv/fb/kfb/port.c

    rb252e87 re1f2079  
    4343#include <as.h>
    4444#include <ddev_srv.h>
     45#include <ddev/info.h>
    4546#include <ddi.h>
    4647#include <ddf/log.h>
     
    9394
    9495static errno_t kfb_ddev_get_gc(void *, sysarg_t *, sysarg_t *);
     96static errno_t kfb_ddev_get_info(void *, ddev_info_t *);
    9597
    9698static errno_t kfb_gc_set_color(void *, gfx_color_t *);
     
    103105
    104106static ddev_ops_t kfb_ddev_ops = {
    105         .get_gc = kfb_ddev_get_gc
     107        .get_gc = kfb_ddev_get_gc,
     108        .get_info = kfb_ddev_get_info
    106109};
    107110
     
    121124        *arg2 = ddf_fun_get_handle(kfb->fun);
    122125        *arg3 = 42;
     126        return EOK;
     127}
     128
     129static errno_t kfb_ddev_get_info(void *arg, ddev_info_t *info)
     130{
     131        kfb_t *kfb = (kfb_t *) arg;
     132
     133        ddev_info_init(info);
     134        info->rect = kfb->rect;
    123135        return EOK;
    124136}
  • uspace/lib/gfx/include/gfx/coord.h

    rb252e87 re1f2079  
    4242extern void gfx_coord2_add(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *);
    4343extern void gfx_coord2_subtract(gfx_coord2_t *, gfx_coord2_t *, gfx_coord2_t *);
     44extern void gfx_coord2_clip(gfx_coord2_t *, gfx_rect_t *, gfx_coord2_t *);
    4445extern void gfx_span_points_sort(gfx_coord_t, gfx_coord_t, gfx_coord_t *,
    4546    gfx_coord_t *);
  • uspace/lib/gfx/src/coord.c

    rb252e87 re1f2079  
    6262}
    6363
     64void gfx_coord2_clip(gfx_coord2_t *a, gfx_rect_t *clip, gfx_coord2_t *d)
     65{
     66        gfx_rect_t sclip;
     67        gfx_coord2_t t;
     68
     69        gfx_rect_points_sort(clip, &sclip);
     70
     71        t.x = min(a->x, clip->p1.x - 1);
     72        t.y = min(a->y, clip->p1.y - 1);
     73
     74        d->x = max(clip->p0.x, t.x);
     75        d->y = max(clip->p0.y, t.y);
     76}
     77
    6478/** Sort points of a span.
    6579 *
  • uspace/lib/gfx/test/coord.c

    rb252e87 re1f2079  
    6868}
    6969
     70/** gfx_coord2_clip with point to lower-left of clipping rectangle */
     71PCUT_TEST(coord2_clip_ll)
     72{
     73        gfx_coord2_t p;
     74        gfx_coord2_t cp;
     75        gfx_rect_t rect;
     76
     77        p.x = 1;
     78        p.y = 2;
     79
     80        rect.p0.x = 3;
     81        rect.p0.y = 4;
     82        rect.p1.x = 5;
     83        rect.p1.y = 6;
     84
     85        gfx_coord2_clip(&p, &rect, &cp);
     86
     87        PCUT_ASSERT_INT_EQUALS(3, cp.x);
     88        PCUT_ASSERT_INT_EQUALS(4, cp.y);
     89}
     90
     91/** gfx_coord2_clip with point inside the clipping rectangle */
     92PCUT_TEST(coord2_clip_mm)
     93{
     94        gfx_coord2_t p;
     95        gfx_coord2_t cp;
     96        gfx_rect_t rect;
     97
     98        p.x = 2;
     99        p.y = 3;
     100
     101        rect.p0.x = 1;
     102        rect.p0.y = 2;
     103        rect.p1.x = 3;
     104        rect.p1.y = 4;
     105
     106        gfx_coord2_clip(&p, &rect, &cp);
     107
     108        PCUT_ASSERT_INT_EQUALS(2, cp.x);
     109        PCUT_ASSERT_INT_EQUALS(3, cp.y);
     110}
     111
     112/** gfx_coord2_clip with point to upper-right of clipping rectangle */
     113PCUT_TEST(coord2_clip_hh)
     114{
     115        gfx_coord2_t p;
     116        gfx_coord2_t cp;
     117        gfx_rect_t rect;
     118
     119        p.x = 5;
     120        p.y = 6;
     121
     122        rect.p0.x = 1;
     123        rect.p0.y = 2;
     124        rect.p1.x = 3;
     125        rect.p1.y = 4;
     126
     127        gfx_coord2_clip(&p, &rect, &cp);
     128
     129        PCUT_ASSERT_INT_EQUALS(2, cp.x);
     130        PCUT_ASSERT_INT_EQUALS(3, cp.y);
     131}
     132
    70133/** gfx_rect_translate should translate rectangle */
    71134PCUT_TEST(rect_translate)
  • uspace/srv/hid/display/ddev.c

    rb252e87 re1f2079  
    3737#include <ddev.h>
    3838#include <errno.h>
     39#include <io/log.h>
    3940#include <stdio.h>
    4041#include <stdlib.h>
     
    5354{
    5455        ds_ddev_t *ddev;
     56        ddev_info_t info;
    5557        gfx_context_t *gc;
    5658        ddev_t *dd = NULL;
     
    7173                return rc;
    7274        }
     75
     76        rc = ddev_get_info(dd, &info);
     77        if (rc != EOK) {
     78                printf("Error getting information for display device '%s'.\n",
     79                    name);
     80                free(name);
     81                ddev_close(dd);
     82                return rc;
     83        }
     84
     85        log_msg(LOG_DEFAULT, LVL_NOTE, "Device rectangle for '%s': "
     86            "%d,%d,%d,%d\n", name, info.rect.p0.x, info.rect.p0.y,
     87            info.rect.p1.x, info.rect.p1.y);
    7388
    7489        rc = ddev_get_gc(dd, &gc);
     
    91106        ddev->dd = dd;
    92107        ddev->gc = gc;
     108        ddev->info = info;
    93109
    94110        ds_display_add_ddev(display, ddev);
  • uspace/srv/hid/display/display.c

    rb252e87 re1f2079  
    384384        assert(!link_used(&ddev->lddevs));
    385385
     386        /* Set display dimensions to dimensions of first display device */
     387        if (gfx_rect_is_empty(&disp->rect))
     388                disp->rect = ddev->info.rect;
     389
    386390        ddev->display = disp;
    387391        list_append(&ddev->lddevs, &disp->ddevs);
     
    447451errno_t ds_display_paint_bg(ds_display_t *disp, gfx_rect_t *rect)
    448452{
    449         gfx_rect_t dsrect;
    450453        gfx_rect_t crect;
    451454        gfx_context_t *gc;
    452455        errno_t rc;
    453456
    454         dsrect.p0.x = 0;
    455         dsrect.p0.y = 0;
    456         dsrect.p1.x = 1024;
    457         dsrect.p1.y = 768;
    458 
    459457        if (rect != NULL)
    460                 gfx_rect_clip(&dsrect, rect, &crect);
     458                gfx_rect_clip(&disp->rect, rect, &crect);
    461459        else
    462                 crect = dsrect;
     460                crect = disp->rect;
    463461
    464462        gc = ds_display_get_gc(disp); // XXX
  • uspace/srv/hid/display/seat.c

    rb252e87 re1f2079  
    253253errno_t ds_seat_post_ptd_event(ds_seat_t *seat, ptd_event_t *event)
    254254{
     255        ds_display_t *disp = seat->display;
    255256        gfx_coord2_t npos;
    256257        ds_window_t *wnd;
     
    287288
    288289                gfx_coord2_add(&seat->pntpos, &event->dmove, &npos);
    289                 if (npos.x < 0)
    290                         npos.x = 0;
    291                 if (npos.y < 0)
    292                         npos.y = 0;
    293                 if (npos.x > 1024)
    294                         npos.x = 1024;
    295                 if (npos.y > 768)
    296                         npos.y = 768;
     290                gfx_coord2_clip(&npos, &disp->rect, &npos);
    297291
    298292                printf("clear pointer\n");
  • uspace/srv/hid/display/types/display/ddev.h

    rb252e87 re1f2079  
    5252        /** Device GC */
    5353        gfx_context_t *gc;
     54        /** Display device information */
     55        ddev_info_t info;
    5456        /** Service ID */
    5557        service_id_t svc_id;
  • uspace/srv/hid/display/types/display/display.h

    rb252e87 re1f2079  
    3939#include <adt/list.h>
    4040#include <gfx/color.h>
     41#include <gfx/coord.h>
    4142#include <io/input.h>
    4243#include "window.h"
     
    6970        /** Background color */
    7071        gfx_color_t *bg_color;
     72
     73        /** Bounding rectangle */
     74        gfx_rect_t rect;
    7175} ds_display_t;
    7276
  • uspace/srv/hid/rfb/main.c

    rb252e87 re1f2079  
    2727 */
    2828
     29#include <ddev/info.h>
    2930#include <ddev_srv.h>
    3031#include <errno.h>
     
    4647#define NAME "rfb"
    4748
     49static errno_t rfb_ddev_get_gc(void *, sysarg_t *, sysarg_t *);
     50static errno_t rfb_ddev_get_info(void *, ddev_info_t *);
     51
    4852static errno_t rfb_gc_set_color(void *, gfx_color_t *);
    4953static errno_t rfb_gc_fill_rect(void *, gfx_rect_t *);
     
    5559
    5660static ddev_ops_t rfb_ddev_ops = {
     61        .get_gc = rfb_ddev_get_gc,
     62        .get_info = rfb_ddev_get_info
    5763};
    5864
     
    103109        rfb->damage_rect.width = new_rect.p1.x - new_rect.p0.x;
    104110        rfb->damage_rect.height = new_rect.p1.y - new_rect.p1.y;
     111}
     112
     113static errno_t rfb_ddev_get_gc(void *arg, sysarg_t *arg2, sysarg_t *arg3)
     114{
     115        *arg2 = 0;
     116        *arg3 = 42;
     117        return EOK;
     118}
     119
     120static errno_t rfb_ddev_get_info(void *arg, ddev_info_t *info)
     121{
     122        rfb_t *rfb = (rfb_t *) arg;
     123
     124        ddev_info_init(info);
     125
     126        info->rect.p0.x = 0;
     127        info->rect.p0.y = 0;
     128        info->rect.p1.x = rfb->width;
     129        info->rect.p1.y = rfb->height;
     130
     131        return EOK;
    105132}
    106133
     
    284311static void client_connection(ipc_call_t *icall, void *arg)
    285312{
     313        rfb_t *rfb = (rfb_t *) arg;
    286314        ddev_srv_t srv;
    287315        sysarg_t svc_id;
     
    295323                ddev_srv_initialize(&srv);
    296324                srv.ops = &rfb_ddev_ops;
    297                 srv.arg = arg;
     325                srv.arg = (void *) rfb;
    298326
    299327                /* Handle connection */
    300328                ddev_conn(icall, &srv);
    301329        } else {
    302                 rc = gfx_context_new(&rfb_gc_ops, arg, &gc);
     330                rc = gfx_context_new(&rfb_gc_ops, (void *) rfb, &gc);
    303331                if (rc != EOK) {
    304332                        async_answer_0(icall, ENOMEM);
Note: See TracChangeset for help on using the changeset viewer.