Changeset 7dba813 in mainline


Ignore:
Timestamp:
2012-11-22T09:03:39Z (11 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ba733e83
Parents:
8e6ec6e
Message:

Resolved Ticket #485 (Desktop is slow). GUI is usable in Qemu/non-KVM as long as windows are not transparent, rotated or scaled (i.e. if user limits himself only to translation and resizing).

Location:
uspace
Files:
10 edited

Legend:

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

    r8e6ec6e r7dba813  
    163163                /* Faster damage routine ignoring offsets. */
    164164                for (sysarg_t y = y0; y < height + y0; ++y) {
     165                        pixel_t *pixel = pixelmap_pixel_at(map, x0, y);
    165166                        for (sysarg_t x = x0; x < width + x0; ++x) {
    166                                 kfb.pixel2visual(kfb.addr + FB_POS(x, y),
    167                                     *pixelmap_pixel_at(map, x, y));
     167                                kfb.pixel2visual(kfb.addr + FB_POS(x, y), *pixel++);
    168168                        }
    169169                }
  • uspace/lib/draw/drawctx.c

    r8e6ec6e r7dba813  
    129129        }
    130130
    131         bool clipped = false;
    132         bool masked = false;
    133 
    134         for (sysarg_t _y = y; _y < y + height; ++_y) {
    135                 for (sysarg_t _x = x; _x < x + width; ++_x) {
    136                         if (context->shall_clip) {
    137                                 clipped = _x < context->clip_x && _x >= context->clip_width
    138                                     && _y < context->clip_y && _y >= context->clip_height;
    139                         }
    140                        
    141                         if (context->mask) {
    142                                 pixel_t p = surface_get_pixel(context->mask, _x, _y);
    143                                 masked = p > 0 ? false : true;
    144                         }
    145 
    146                         if (!clipped && !masked) {
    147                                 pixel_t p_src = source_determine_pixel(context->source, _x, _y);
    148                                 pixel_t p_dst = surface_get_pixel(context->surface, _x, _y);
    149                                 pixel_t p_res = context->compose(p_src, p_dst);
    150                                 surface_put_pixel(context->surface, _x, _y, p_res);
     131        bool transfer_fast = source_is_fast(context->source)
     132            && (context->shall_clip == false)
     133            && (context->mask == NULL)
     134            && (context->compose == compose_src || context->compose == compose_over);
     135
     136        if (transfer_fast) {
     137
     138                for (sysarg_t _y = y; _y < y + height; ++_y) {
     139                        pixel_t *src = source_direct_access(context->source, x, _y);
     140                        pixel_t *dst = pixelmap_pixel_at(surface_pixmap_access(context->surface), x, _y);
     141                        if (src && dst) {
     142                                sysarg_t count = width;
     143                                while (count-- != 0) {
     144                                        *dst++ = *src++;
     145                                }
    151146                        }
    152147                }
     148                surface_add_damaged_region(context->surface, x, y, width, height);
     149
     150        } else {
     151
     152                bool clipped = false;
     153                bool masked = false;
     154                for (sysarg_t _y = y; _y < y + height; ++_y) {
     155                        for (sysarg_t _x = x; _x < x + width; ++_x) {
     156                                if (context->shall_clip) {
     157                                        clipped = _x < context->clip_x && _x >= context->clip_width
     158                                            && _y < context->clip_y && _y >= context->clip_height;
     159                                }
     160
     161                                if (context->mask) {
     162                                        pixel_t p = surface_get_pixel(context->mask, _x, _y);
     163                                        masked = p > 0 ? false : true;
     164                                }
     165
     166                                if (!clipped && !masked) {
     167                                        pixel_t p_src = source_determine_pixel(context->source, _x, _y);
     168                                        pixel_t p_dst = surface_get_pixel(context->surface, _x, _y);
     169                                        pixel_t p_res = context->compose(p_src, p_dst);
     170                                        surface_put_pixel(context->surface, _x, _y, p_res);
     171                                }
     172                        }
     173                }
     174
    153175        }
    154176}
  • uspace/lib/draw/source.c

    r8e6ec6e r7dba813  
    9090}
    9191
     92bool source_is_fast(source_t *source)
     93{
     94        return (source->mask == NULL)
     95            && (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0))
     96            && (source->texture != NULL)
     97            && (source->texture_tile == false)
     98            && transform_is_fast(&source->transform);
     99}
     100
     101pixel_t *source_direct_access(source_t *source, double x, double y)
     102{
     103        assert(source_is_fast(source));
     104
     105        long _x = (long) (x + source->transform.m[0][2]);
     106        long _y = (long) (y + source->transform.m[1][2]);
     107
     108        pixelmap_t *pixmap = surface_pixmap_access(source->texture);
     109        if (_x < 0 || _x >= (long) pixmap->width || _y < 0 || _y >= (long) pixmap->height) {
     110                return NULL;
     111        }
     112
     113        return pixelmap_pixel_at(pixmap, (sysarg_t) _x, (sysarg_t) _y);
     114}
     115
    92116pixel_t source_determine_pixel(source_t *source, double x, double y)
    93117{
  • uspace/lib/draw/source.h

    r8e6ec6e r7dba813  
    7171extern void source_set_mask(source_t *, surface_t *, bool);
    7272
     73extern bool source_is_fast(source_t *);
     74extern pixel_t *source_direct_access(source_t *, double, double);
    7375extern pixel_t source_determine_pixel(source_t *, double, double);
    7476
  • uspace/lib/draw/surface.c

    r8e6ec6e r7dba813  
    143143}
    144144
     145void surface_add_damaged_region(surface_t *surface, surface_coord_t x, surface_coord_t y,
     146    surface_coord_t width, surface_coord_t height)
     147{
     148        surface->dirty_x_lo = surface->dirty_x_lo > x ? x : surface->dirty_x_lo;
     149        surface->dirty_y_lo = surface->dirty_y_lo > y ? y : surface->dirty_y_lo;
     150
     151        surface_coord_t x_hi = x + width - 1;
     152        surface_coord_t y_hi = y + height - 1;
     153
     154        surface->dirty_x_hi = surface->dirty_x_hi < x_hi ? x_hi : surface->dirty_x_hi;
     155        surface->dirty_y_hi = surface->dirty_y_hi < y_hi ? y_hi : surface->dirty_y_hi;
     156}
     157
    145158void surface_reset_damaged_region(surface_t *surface)
    146159{
  • uspace/lib/draw/surface.h

    r8e6ec6e r7dba813  
    6161extern void surface_get_damaged_region(surface_t *, surface_coord_t *, surface_coord_t *,
    6262    surface_coord_t *, surface_coord_t *);
     63extern void surface_add_damaged_region(surface_t *, surface_coord_t , surface_coord_t ,
     64    surface_coord_t , surface_coord_t );
    6365extern void surface_reset_damaged_region(surface_t *);
    6466
  • uspace/lib/gui/terminal.c

    r8e6ec6e r7dba813  
    196196        uint16_t glyph = fb_font_glyph(field->ch);
    197197       
    198         // FIXME: This font drawing routine is shamelessly
    199         //        suboptimal. It should be optimized for
    200         //        aligned memory transfers, etc.
    201        
    202198        for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
    203                 for (unsigned int x = 0; x < FONT_WIDTH; x++) {
    204                         pixel_t pixel =
    205                             (fb_font[glyph][y] & (1 << (7 - x))) ? fgcolor : bgcolor;
    206                         surface_put_pixel(surface, bx + x, by + y, pixel);
     199                pixel_t *dst = pixelmap_pixel_at(
     200                    surface_pixmap_access(surface), bx, by + y);
     201                int count = FONT_WIDTH;
     202                while (count-- != 0) {
     203                        *dst++ = (fb_font[glyph][y] & (1 << count)) ? fgcolor : bgcolor;
    207204                }
    208205        }
     206        surface_add_damaged_region(surface, bx, by, FONT_WIDTH, FONT_SCANLINES);
    209207}
    210208
  • uspace/lib/softrend/transform.c

    r8e6ec6e r7dba813  
    136136}
    137137
     138bool transform_is_fast(transform_t *t)
     139{
     140        return (t->m[0][0] == 1) && (t->m[0][1] == 0)
     141            && (t->m[1][0] == 0) && (t->m[1][1] == 1)
     142            && ((t->m[0][2] - ((long) t->m[0][2])) == 0.0)
     143            && ((t->m[1][2] - ((long) t->m[1][2])) == 0.0);
     144}
     145
    138146void transform_apply_linear(const transform_t *t, double *x, double *y)
    139147{
  • uspace/lib/softrend/transform.h

    r8e6ec6e r7dba813  
    3737#define SOFTREND_TRANSFORM_H_
    3838
     39#include <bool.h>
     40
    3941#ifndef PI
    4042#define PI 3.141592653589793
     
    5355extern void transform_rotate(transform_t *, double);
    5456
     57extern bool transform_is_fast(transform_t *);
     58
    5559extern void transform_apply_linear(const transform_t *, double *, double *);
    5660extern void transform_apply_affine(const transform_t *, double *, double *);
  • uspace/srv/hid/compositor/compositor.c

    r8e6ec6e r7dba813  
    314314                        /* Paint background color. */
    315315                        for (sysarg_t y = y_dmg_vp - vp->pos.y; y <  y_dmg_vp - vp->pos.y + h_dmg_vp; ++y) {
    316                                 for (sysarg_t x = x_dmg_vp - vp->pos.x; x < x_dmg_vp - vp->pos.x + w_dmg_vp; ++x) {
    317                                         surface_put_pixel(vp->surface, x, y, bg_color);
     316                                pixel_t *dst = pixelmap_pixel_at(
     317                                    surface_pixmap_access(vp->surface), x_dmg_vp - vp->pos.x, y);
     318                                sysarg_t count = w_dmg_vp;
     319                                while (count-- != 0) {
     320                                        *dst++ = bg_color;
    318321                                }
    319322                        }
     323                        surface_add_damaged_region(vp->surface,
     324                            x_dmg_vp - vp->pos.x, y_dmg_vp - vp->pos.y, w_dmg_vp, h_dmg_vp);
    320325
    321326                        transform_t transform;
     
    381386                                if (isec_ptr) {
    382387                                        /* Pointer is currently painted directly by copying pixels.
    383                                          * However, it is possible to draw the painter similarly
     388                                         * However, it is possible to draw the pointer similarly
    384389                                         * as window by using drawctx_transfer. It would allow
    385390                                         * more sophisticated control over drawing, but would also
    386391                                         * cost more regarding the performance. */
    387392
    388                                         pixel_t pix = 0;
    389393                                        sysarg_t x_vp = x_dmg_ptr - vp->pos.x;
    390394                                        sysarg_t y_vp = y_dmg_ptr - vp->pos.y;
     
    393397
    394398                                        for (sysarg_t y = 0; y < h_dmg_ptr; ++y) {
    395                                                 for (sysarg_t x = 0; x < w_dmg_ptr; ++x) {
    396                                                         pix = surface_get_pixel(sf_ptr, x_ptr + x, y_ptr + y);
    397                                                         if (ALPHA(pix) == 255) {
    398                                                                 surface_put_pixel(vp->surface, x_vp + x, y_vp + y, pix);
    399                                                         }
     399                                                pixel_t *src = pixelmap_pixel_at(
     400                                                    surface_pixmap_access(sf_ptr), x_ptr, y_ptr + y);
     401                                                pixel_t *dst = pixelmap_pixel_at(
     402                                                    surface_pixmap_access(vp->surface), x_vp, y_vp + y);
     403                                                sysarg_t count = w_dmg_ptr;
     404                                                while (count-- != 0) {
     405                                                        *dst = (*src & 0xff000000) ? *src : *dst;
     406                                                        ++dst; ++src;
    400407                                                }
    401408                                        }
     409                                        surface_add_damaged_region(vp->surface, x_vp, y_vp, w_dmg_ptr, h_dmg_ptr);
    402410                                }
    403411                        }
Note: See TracChangeset for help on using the changeset viewer.