diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-05-09 16:57:17 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-05-09 16:57:17 +0000 |
| commit | f26f23de50cb7941a7702198e3b4d1b2f9de062e (patch) | |
| tree | ec1d73c8e977d86e9231676c51e684a3415e7a0e /render/image.c | |
| parent | 60065663ba9dc448dcf90fd200cd459bcdb9ef9c (diff) | |
all my changes while i was offline.
better alt-tabbing. better transient handling. i dont even know. lots of fucking cool shit so WATCH the FUCK OUT.
Diffstat (limited to 'render/image.c')
| -rw-r--r-- | render/image.c | 110 |
1 files changed, 58 insertions, 52 deletions
diff --git a/render/image.c b/render/image.c index bdc51eed..e0c5540f 100644 --- a/render/image.c +++ b/render/image.c @@ -5,66 +5,72 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position, Rect *surarea) { - unsigned long *draw = rgba->data; - int c, sfw, sfh; - unsigned int i, e; - sfw = position->width; - sfh = position->height; + gulong *draw = rgba->data; + guint c, i, e, t, sfw, sfh; + sfw = position->width; + sfh = position->height; - /* it would be nice if this worked, but this function is well broken in these - cercumstances. */ - g_assert(position->width == surarea->width && - position->height == surarea->height); + /* it would be nice if this worked, but this function is well broken in + these circumstances. */ + g_assert(position->width == surarea->width && + position->height == surarea->height); - g_assert(rgba->data != NULL); + g_assert(rgba->data != NULL); - if ((rgba->width != sfw || rgba->height != sfh) && - (rgba->width != rgba->cwidth || rgba->height != rgba->cheight)) { - double dx = rgba->width / (double)sfw; - double dy = rgba->height / (double)sfh; - double px = 0.0; - double py = 0.0; - int iy = 0; + if ((rgba->width != sfw || rgba->height != sfh) && + (rgba->width != rgba->cwidth || rgba->height != rgba->cheight)) { + double dx = rgba->width / (double)sfw; + double dy = rgba->height / (double)sfh; + double px = 0.0; + double py = 0.0; + int iy = 0; - /* scale it and cache it */ - if (rgba->cache != NULL) - g_free(rgba->cache); - rgba->cache = g_new(unsigned long, sfw * sfh); - rgba->cwidth = sfw; - rgba->cheight = sfh; - for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) { - rgba->cache[i] = rgba->data[(int)px + iy]; - if (++c >= sfw) { - c = 0; - px = 0; - py += dy; - iy = (int)py * rgba->width; - } else - px += dx; - } + /* scale it and cache it */ + if (rgba->cache != NULL) + g_free(rgba->cache); + rgba->cache = g_new(unsigned long, sfw * sfh); + rgba->cwidth = sfw; + rgba->cheight = sfh; + for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) { + rgba->cache[i] = rgba->data[(int)px + iy]; + if (++c >= sfw) { + c = 0; + px = 0; + py += dy; + iy = (int)py * rgba->width; + } else + px += dx; + } + + /* do we use the cache we may have just created, or the original? */ + if (rgba->width != sfw || rgba->height != sfh) + draw = rgba->cache; + + /* apply the alpha channel */ + for (i = 0, c = 0, t = position->x, e = sfw*sfh; i < e; ++i, ++t) { + guchar alpha, r, g, b, bgr, bgg, bgb; -/* do we use the cache we may have just created, or the original? */ - if (rgba->width != sfw || rgba->height != sfh) - draw = rgba->cache; + alpha = draw[i] >> 24; + r = draw[i] >> 16; + g = draw[i] >> 8; + b = draw[i]; - /* apply the alpha channel */ - for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) { - unsigned char alpha = draw[i] >> 24; - unsigned char r = draw[i] >> 16; - unsigned char g = draw[i] >> 8; - unsigned char b = draw[i]; + if (c >= sfw) { + c = 0; + t += surarea->width - sfw; + } - /* background color */ - unsigned char bgr = target[i] >> default_red_shift; - unsigned char bgg = target[i] >> default_green_shift; - unsigned char bgb = target[i] >> default_blue_shift; + /* background color */ + bgr = target[t] >> default_red_shift; + bgg = target[t] >> default_green_shift; + bgb = target[t] >> default_blue_shift; - r = bgr + (((r - bgr) * alpha) >> 8); - g = bgg + (((g - bgg) * alpha) >> 8); - b = bgb + (((b - bgb) * alpha) >> 8); + r = bgr + (((r - bgr) * alpha) >> 8); + g = bgg + (((g - bgg) * alpha) >> 8); + b = bgb + (((b - bgb) * alpha) >> 8); - target[i] = (r << default_red_shift) | (g << default_green_shift) | - (b << default_blue_shift); + target[t] = (r << default_red_shift) | (g << default_green_shift) | + (b << default_blue_shift); + } } - } } |
