Changeset c2250702 in mainline


Ignore:
Timestamp:
2019-12-16T13:31:42Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fb420e48
Parents:
65160d7
git-author:
Jiri Svoboda <jiri@…> (2019-12-15 13:23:28)
git-committer:
Jiri Svoboda <jiri@…> (2019-12-16 13:31:42)
Message:

Clip KFB render operations to KFB interior

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/fb/kfb/port.c

    r65160d7 rc2250702  
    6868
    6969        sysarg_t paddr;
    70         sysarg_t width;
    71         sysarg_t height;
     70        gfx_rect_t rect;
    7271        size_t offset;
    7372        size_t scanline;
     
    154153{
    155154        kfb_t *kfb = (kfb_t *) arg;
     155        gfx_rect_t crect;
    156156        gfx_coord_t x, y;
    157157
    158         // XXX We should handle p0.x > p1.x and p0.y > p1.y
    159 
    160         for (y = rect->p0.y; y < rect->p1.y; y++) {
    161                 for (x = rect->p0.x; x < rect->p1.x; x++) {
     158        /* Make sure we have a sorted, clipped rectangle */
     159        gfx_rect_clip(rect, &kfb->rect, &crect);
     160
     161        for (y = crect.p0.y; y < crect.p1.y; y++) {
     162                for (x = crect.p0.x; x < crect.p1.x; x++) {
    162163                        kfb->pixel2visual(kfb->addr + FB_POS(kfb, x, y),
    163164                            kfb->color);
     
    242243        gfx_rect_t srect;
    243244        gfx_rect_t drect;
     245        gfx_rect_t skfbrect;
     246        gfx_rect_t crect;
    244247        gfx_coord2_t offs;
    245248        gfx_coord2_t bmdim;
     
    251254        pixel_t color;
    252255
     256        /* Clip source rectangle to bitmap bounds */
     257
    253258        if (srect0 != NULL)
    254                 srect = *srect0;
     259                gfx_rect_clip(srect0, &kfbbm->rect, &srect);
    255260        else
    256261                srect = kfbbm->rect;
     
    272277        pbm.data = kfbbm->alloc.pixels;
    273278
    274         for (pos.y = srect.p0.y; pos.y < srect.p1.y; pos.y++) {
    275                 for (pos.x = srect.p0.x; pos.x < srect.p1.x; pos.x++) {
     279        /* Transform KFB bounding rectangle back to bitmap coordinate system */
     280        gfx_rect_rtranslate(&offs, &kfb->rect, &skfbrect);
     281
     282        /*
     283         * Make sure we have a sorted source rectangle, clipped so that
     284         * destination lies within KFB bounding rectangle
     285         */
     286        gfx_rect_clip(&srect, &skfbrect, &crect);
     287
     288        for (pos.y = crect.p0.y; pos.y < crect.p1.y; pos.y++) {
     289                for (pos.x = crect.p0.x; pos.x < crect.p1.x; pos.x++) {
    276290                        gfx_coord2_subtract(&pos, &kfbbm->rect.p0, &sp);
    277291                        gfx_coord2_add(&pos, &offs, &dp);
     
    429443        kfb->fun = fun;
    430444
    431         kfb->width = width;
    432         kfb->height = height;
     445        kfb->rect.p0.x = 0;
     446        kfb->rect.p0.y = 0;
     447        kfb->rect.p1.x = width;
     448        kfb->rect.p1.y = height;
     449
    433450        kfb->paddr = paddr;
    434451        kfb->offset = offset;
  • uspace/lib/gfx/src/coord.c

    r65160d7 rc2250702  
    145145 *
    146146 * If the two rectangles do not intersect, the result will be an empty
    147  * rectangle (check with gfx_rect_is_empty()).
     147 * rectangle (check with gfx_rect_is_empty()). The resulting rectangle
     148 * is always sorted.
    148149 *
    149150 * @param rect Source rectangle
  • uspace/srv/hid/display/seat.c

    r65160d7 rc2250702  
    5959
    6060        ds_display_add_seat(display, seat);
    61         seat->pntpos.x = 10;
    62         seat->pntpos.y = 10;
     61        seat->pntpos.x = 0;
     62        seat->pntpos.y = 0;
    6363
    6464        *rseat = seat;
     
    242242                printf("PTD_MOVE\n");
    243243                gfx_coord2_add(&seat->pntpos, &event->dmove, &npos);
    244                 if (npos.x < 10)
    245                         npos.x = 10;
    246                 if (npos.y < 10)
    247                         npos.y = 10;
    248                 if (npos.x > 1024 - 10)
    249                         npos.x = 1024 - 10;
    250                 if (npos.y > 768 - 10)
    251                         npos.y = 768 - 10;
     244                if (npos.x < 0)
     245                        npos.x = 0;
     246                if (npos.y < 0)
     247                        npos.y = 0;
     248                if (npos.x > 1024)
     249                        npos.x = 1024;
     250                if (npos.y > 768)
     251                        npos.y = 768;
    252252
    253253                printf("clear pointer\n");
Note: See TracChangeset for help on using the changeset viewer.