Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 65160d7 in mainline


Ignore:
Timestamp:
2019-12-16T12:32:03Z (11 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
c2250702
Parents:
3434233
git-author:
Jiri Svoboda <jiri@…> (2019-12-15 12:31:56)
git-committer:
Jiri Svoboda <jiri@…> (2019-12-16 12:32:03)
Message:

Clip rendering operations to window interior

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

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/types/display/window.h

    r3434233 r65160d7  
    8080        /** Display bitmap */
    8181        gfx_bitmap_t *bitmap;
     82        /** Bounding rectangle */
     83        gfx_rect_t rect;
    8284} ds_window_bitmap_t;
    8385
  • uspace/srv/hid/display/window.c

    r3434233 r65160d7  
    9292{
    9393        ds_window_t *wnd = (ds_window_t *) arg;
     94        gfx_rect_t crect;
    9495        gfx_rect_t drect;
    9596
    9697        log_msg(LOG_DEFAULT, LVL_NOTE, "gc_fill_rect");
    97         gfx_rect_translate(&wnd->dpos, rect, &drect);
     98        gfx_rect_clip(rect, &wnd->rect, &crect);
     99        gfx_rect_translate(&wnd->dpos, &crect, &drect);
    98100        return gfx_fill_rect(ds_display_get_gc(wnd->display), &drect);
    99101}
     
    124126
    125127        cbm->wnd = wnd;
     128        cbm->rect = params->rect;
    126129        *rbm = (void *)cbm;
    127130        return EOK;
     
    158161        ds_window_bitmap_t *cbm = (ds_window_bitmap_t *)bm;
    159162        gfx_coord2_t doffs;
    160 
    161         if (offs0 != NULL)
    162                 gfx_coord2_add(&cbm->wnd->dpos, offs0, &doffs);
    163         else
    164                 doffs = cbm->wnd->dpos;
     163        gfx_coord2_t offs;
     164        gfx_rect_t srect;
     165        gfx_rect_t swrect;
     166        gfx_rect_t crect;
     167
     168        if (srect0 != NULL) {
     169                /* Clip source rectangle to bitmap rectangle */
     170                gfx_rect_clip(srect0, &cbm->rect, &srect);
     171        } else {
     172                /* Source is entire bitmap rectangle */
     173                srect = cbm->rect;
     174        }
     175
     176        if (offs0 != NULL) {
     177                offs = *offs0;
     178        } else {
     179                offs.x = 0;
     180                offs.y = 0;
     181        }
     182
     183        /* Transform window rectangle back to bitmap coordinate system */
     184        gfx_rect_rtranslate(&offs, &cbm->wnd->rect, &swrect);
     185
     186        /* Clip so that transformed rectangle will be inside the window */
     187        gfx_rect_clip(&srect, &swrect, &crect);
     188
     189        /* Offset for rendering on screen = window pos + offs */
     190        gfx_coord2_add(&cbm->wnd->dpos, &offs, &doffs);
    165191
    166192        return gfx_bitmap_render(cbm->bitmap, srect0, &doffs);
Note: See TracChangeset for help on using the changeset viewer.