Changeset 7358f5b in mainline


Ignore:
Timestamp:
2020-09-30T19:13:31Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
38a4b6d
Parents:
57d923e1
Message:

gfx_glyph_transfer is copying too much

We were using the entire destination bitmap rectangle as destination
instead of just the glyph rectangle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfxfont/src/glyph.c

    r57d923e1 r7358f5b  
    274274 * @param glyph Glyph
    275275 * @param offs Offset in new font bitmap
    276  * @param dest New font bitmap
    277  * @param drect Bounding rectangle for @a dest
     276 * @param dbmp New font bitmap
     277 * @param dbrect Bounding rectangle for @a dbmp
    278278 *
    279279 * @return EOK on success or an error code
    280280 */
    281281errno_t gfx_glyph_transfer(gfx_glyph_t *glyph, gfx_coord_t offs,
    282     gfx_bitmap_t *dest, gfx_rect_t *drect)
     282    gfx_bitmap_t *dbmp, gfx_rect_t *dbrect)
    283283{
    284284        pixelmap_t smap;
     
    286286        gfx_bitmap_alloc_t salloc;
    287287        gfx_bitmap_alloc_t dalloc;
     288        gfx_rect_t drect;
    288289        gfx_coord_t x, y;
     290        gfx_coord2_t off2;
    289291        pixel_t pixel;
    290292        errno_t rc;
     
    294296                return rc;
    295297
    296         rc = gfx_bitmap_get_alloc(dest, &dalloc);
     298        rc = gfx_bitmap_get_alloc(dbmp, &dalloc);
    297299        if (rc != EOK)
    298300                return rc;
     
    302304        smap.data = salloc.pixels;
    303305
    304         dmap.width = drect->p1.x;
    305         dmap.height = drect->p1.y;
     306        dmap.width = dbrect->p1.x;
     307        dmap.height = dbrect->p1.y;
    306308        dmap.data = dalloc.pixels;
    307309
    308         for (y = drect->p0.y; y < drect->p1.y; y++) {
    309                 for (x = drect->p0.x; x < drect->p1.x; x++) {
     310        /* Compute destination rectangle */
     311        off2.x = offs;
     312        off2.y = 0;
     313        gfx_rect_translate(&off2, &glyph->rect, &drect);
     314        assert(gfx_rect_is_inside(&drect, dbrect));
     315
     316        for (y = drect.p0.y; y < drect.p1.y; y++) {
     317                for (x = drect.p0.x; x < drect.p1.x; x++) {
    310318                        pixel = pixelmap_get_pixel(&smap, x, y);
    311319                        pixelmap_put_pixel(&dmap, x + offs, y, pixel);
Note: See TracChangeset for help on using the changeset viewer.