Changeset 65160d7 in mainline for uspace/srv/hid/display/window.c


Ignore:
Timestamp:
2019-12-16T12:32:03Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.