]> Dogcows Code - chaz/openbox/blobdiff - render/image.c
change the menu plugin interface, no need for the create/destroy functions any more.
[chaz/openbox] / render / image.c
index e0c5540fa0e29b279492c3a0bdfaf40d99fd8257..2ec710438cd32632cb8f09aabd97c7404373b1f9 100644 (file)
@@ -1,19 +1,15 @@
-#include <glib.h>
-#include "../kernel/geom.h"
+#include "geom.h"
 #include "image.h"
+#include "color.h"
 
-void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
-                Rect *surarea)
-{
-    gulong *draw = rgba->data;
-    guint c, i, e, t, sfw, sfh;
-    sfw = position->width;
-    sfh = position->height;
+#include <glib.h>
 
-    /* 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);
+void RrImageDraw(RrPixel32 *target, RrTextureRGBA *rgba, RrRect *area)
+{
+    RrPixel32 *draw = rgba->data;
+    gint c, i, e, t, sfw, sfh;
+    sfw = area->width;
+    sfh = area->height;
 
     g_assert(rgba->data != NULL);
 
@@ -28,7 +24,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
         /* scale it and cache it */
         if (rgba->cache != NULL)
             g_free(rgba->cache);
-        rgba->cache = g_new(unsigned long, sfw * sfh);
+        rgba->cache = g_new(RrPixel32, sfw * sfh);
         rgba->cwidth = sfw;
         rgba->cheight = sfh;
         for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) {
@@ -47,30 +43,31 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
             draw = rgba->cache;
 
         /* apply the alpha channel */
-        for (i = 0, c = 0, t = position->x, e = sfw*sfh; i < e; ++i, ++t) {
+        for (i = 0, c = 0, t = area->x, e = sfw*sfh; i < e; ++i, ++t) {
             guchar alpha, r, g, b, bgr, bgg, bgb;
 
-            alpha = draw[i] >> 24;
-            r = draw[i] >> 16;
-            g = draw[i] >> 8;
-            b = draw[i];
+            alpha = draw[i] >> RrDefaultAlphaOffset;
+            r = draw[i] >> RrDefaultRedOffset;
+            g = draw[i] >> RrDefaultGreenOffset;
+            b = draw[i] >> RrDefaultBlueOffset;
 
             if (c >= sfw) {
                 c = 0;
-                t += surarea->width - sfw;
+                t += area->width - sfw;
             }
 
             /* background color */
-            bgr = target[t] >> default_red_shift;
-            bgg = target[t] >> default_green_shift;
-            bgb = target[t] >> default_blue_shift;
+            bgr = target[t] >> RrDefaultRedOffset;
+            bgg = target[t] >> RrDefaultGreenOffset;
+            bgb = target[t] >> RrDefaultBlueOffset;
 
             r = bgr + (((r - bgr) * alpha) >> 8);
             g = bgg + (((g - bgg) * alpha) >> 8);
             b = bgb + (((b - bgb) * alpha) >> 8);
 
-            target[t] = (r << default_red_shift) | (g << default_green_shift) |
-                (b << default_blue_shift);
+            target[t] = (r << RrDefaultRedOffset)
+                      | (g << RrDefaultGreenOffset)
+                      | (b << RrDefaultBlueOffset);
         }
     }
 }
This page took 0.027216 seconds and 4 git commands to generate.