Changeset d410328 in mainline for uspace/srv/fb/fb.c


Ignore:
Timestamp:
2008-12-22T22:32:53Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7c64e23
Parents:
a728ed3
Message:

Slightly faster draw_fill_rect() (although 2x VRAM access).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fb/fb.c

    ra728ed3 rd410328  
    224224}
    225225
    226 /** Draw a filled rectangle. */
     226/** Draw a filled rectangle.
     227 *
     228 * @note Need real implementation that does not access VRAM twice.
     229 */
    227230static void draw_filled_rect(unsigned int x0, unsigned int y0, unsigned int x1,
    228231    unsigned int y1, uint32_t color)
    229232{
    230233        unsigned int x, y;
     234        unsigned int copy_bytes;
     235
     236        uint8_t *sp, *dp;
    231237        uint8_t cbuf[4];
    232238
     239        if (y0 >= y1 || x0 >= x1) return;
    233240        screen.rgb_conv(cbuf, color);
    234241
    235         for (y = y0; y < y1; y++) {
    236                 for (x = x0; x < x1; x++) {
    237                         memcpy(&screen.fb_addr[FB_POS(x, y)], cbuf,
    238                             screen.pixelbytes);
    239                 }
     242        sp = &screen.fb_addr[FB_POS(x0, y0)];
     243        dp = sp;
     244
     245        /* Draw the first line. */
     246        for (x = x0; x < x1; x++) {
     247                memcpy(dp, cbuf, screen.pixelbytes);
     248                dp += screen.pixelbytes;
     249        }
     250
     251        dp = sp + screen.scanline;
     252        copy_bytes = (x1 - x0) * screen.pixelbytes;
     253
     254        /* Draw the remaining lines by copying. */
     255        for (y = y0 + 1; y < y1; y++) {
     256                memcpy(dp, sp, copy_bytes);
     257                dp += screen.scanline;
    240258        }
    241259}
Note: See TracChangeset for help on using the changeset viewer.