]> Dogcows Code - chaz/openbox/blobdiff - render/mask.c
consistant glib type usage
[chaz/openbox] / render / mask.c
index 8b0f21c04eb83a02629358b77588262f437f99c3..11e589bc8fec26df53fd6da5113c56289d1ed5d0 100644 (file)
@@ -1,3 +1,22 @@
+/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
+
+   mask.c for the Openbox window manager
+   Copyright (c) 2003        Ben Jansens
+   Copyright (c) 2003        Derek Foreman
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   See the COPYING file for a copy of the GNU General Public License.
+*/
+
 #include "render.h"
 #include "color.h"
 #include "mask.h"
@@ -10,7 +29,7 @@ RrPixmapMask *RrPixmapMaskNew(const RrInstance *inst,
     m->width = w;
     m->height = h;
     /* round up to nearest byte */
-    m->data = g_memdup(data, (w * h + 7) / 8);
+    m->data = g_memdup(data, (w + 7) / 8 * h);
     m->mask = XCreateBitmapFromData(RrDisplay(inst), RrRootWindow(inst),
                                     data, w, h);
     return m;
@@ -25,9 +44,9 @@ void RrPixmapMaskFree(RrPixmapMask *m)
     }
 }
 
-void RrPixmapMaskDraw(Pixmap p, const RrTextureMask *m, const Rect *area)
+void RrPixmapMaskDraw(Pixmap p, const RrTextureMask *m, const RrRect *area)
 {
-    int x, y;
+    gint x, y;
     if (m->mask == None) return; /* no mask given */
 
     /* set the clip region */
@@ -37,16 +56,16 @@ void RrPixmapMaskDraw(Pixmap p, const RrTextureMask *m, const Rect *area)
     if (x < 0) x = 0;
     if (y < 0) y = 0;
 
-    XSetClipMask(RrDisplay(m->mask->inst), m->color->gc, m->mask->mask);
-    XSetClipOrigin(RrDisplay(m->mask->inst), m->color->gc, x, y);
+    XSetClipMask(RrDisplay(m->mask->inst), RrColorGC(m->color), m->mask->mask);
+    XSetClipOrigin(RrDisplay(m->mask->inst), RrColorGC(m->color), x, y);
 
     /* fill in the clipped region */
-    XFillRectangle(RrDisplay(m->mask->inst), p, m->color->gc, x, y,
+    XFillRectangle(RrDisplay(m->mask->inst), p, RrColorGC(m->color), x, y,
                    x + m->mask->width, y + m->mask->height);
 
     /* unset the clip region */
-    XSetClipMask(RrDisplay(m->mask->inst), m->color->gc, None);
-    XSetClipOrigin(RrDisplay(m->mask->inst), m->color->gc, 0, 0);
+    XSetClipMask(RrDisplay(m->mask->inst), RrColorGC(m->color), None);
+    XSetClipOrigin(RrDisplay(m->mask->inst), RrColorGC(m->color), 0, 0);
 }
 
 RrPixmapMask *RrPixmapMaskCopy(const RrPixmapMask *src)
@@ -56,7 +75,7 @@ RrPixmapMask *RrPixmapMaskCopy(const RrPixmapMask *src)
     m->width = src->width;
     m->height = src->height;
     /* round up to nearest byte */
-    m->data = g_memdup(src->data, (src->width * src->height + 7) / 8);
+    m->data = g_memdup(src->data, (src->width + 7) / 8 * src->height);
     m->mask = XCreateBitmapFromData(RrDisplay(m->inst), RrRootWindow(m->inst),
                                     m->data, m->width, m->height);
     return m;
This page took 0.021623 seconds and 4 git commands to generate.