diff options
Diffstat (limited to 'render')
| -rw-r--r-- | render/color.c | 85 | ||||
| -rw-r--r-- | render/font.c | 2 | ||||
| -rw-r--r-- | render/mask.c | 8 | ||||
| -rw-r--r-- | render/render.c | 12 | ||||
| -rw-r--r-- | render/test.c | 10 |
5 files changed, 59 insertions, 58 deletions
diff --git a/render/color.c b/render/color.c index 10ad5e3b..0d3f8132 100644 --- a/render/color.c +++ b/render/color.c @@ -17,7 +17,7 @@ color_rgb *color_parse(char *colorname) XColor xcol; g_assert(colorname != NULL); - // get rgb values from colorname + /* get rgb values from colorname */ xcol.red = 0; xcol.green = 0; @@ -50,56 +50,57 @@ color_rgb *color_new(int r, int g, int b) return NULL; } -//XXX same color could be pointed to twice, this might have to be a refcount +/*XXX same color could be pointed to twice, this might have to be a refcount*/ void color_free(color_rgb *c) { if (c->gc != None) XFreeGC(ob_display, c->gc); - free(c); + g_free(c); } void reduce_depth(pixel32 *data, XImage *im) { - // since pixel32 is the largest possible pixel size, we can share the array - int r, g, b; - int x,y; - pixel16 *p = (pixel16*) data; - switch (im->bits_per_pixel) { - case 32: - if ((render_red_offset != default_red_shift) || - (render_blue_offset != default_blue_shift) || - (render_green_offset != default_green_shift)) { - for (y = 0; y < im->height; y++) { - for (x = 0; x < im->width; x++) { - r = (data[x] >> default_red_shift) & 0xFF; - g = (data[x] >> default_green_shift) & 0xFF; - b = (data[x] >> default_blue_shift) & 0xFF; - data[x] = (r << render_red_offset) + (g << render_green_offset) + - (b << render_blue_offset); + /* since pixel32 is the largest possible pixel size, we can share the + array*/ + int r, g, b; + int x,y; + pixel16 *p = (pixel16*) data; + switch (im->bits_per_pixel) { + case 32: + if ((render_red_offset != default_red_shift) || + (render_blue_offset != default_blue_shift) || + (render_green_offset != default_green_shift)) { + for (y = 0; y < im->height; y++) { + for (x = 0; x < im->width; x++) { + r = (data[x] >> default_red_shift) & 0xFF; + g = (data[x] >> default_green_shift) & 0xFF; + b = (data[x] >> default_blue_shift) & 0xFF; + data[x] = (r << render_red_offset) + (g << render_green_offset) + + (b << render_blue_offset); + } + data += im->width; + } } - data += im->width; - } - } - break; - case 16: - for (y = 0; y < im->height; y++) { - for (x = 0; x < im->width; x++) { - r = (data[x] >> default_red_shift) & 0xFF; - r = r >> render_red_shift; - g = (data[x] >> default_green_shift) & 0xFF; - g = g >> render_green_shift; - b = (data[x] >> default_blue_shift) & 0xFF; - b = b >> render_blue_shift; - p[x] = (r << render_red_offset) - + (g << render_green_offset) - + (b << render_blue_offset); - } - data += im->width; - p += im->bytes_per_line/2; + break; + case 16: + for (y = 0; y < im->height; y++) { + for (x = 0; x < im->width; x++) { + r = (data[x] >> default_red_shift) & 0xFF; + r = r >> render_red_shift; + g = (data[x] >> default_green_shift) & 0xFF; + g = g >> render_green_shift; + b = (data[x] >> default_blue_shift) & 0xFF; + b = b >> render_blue_shift; + p[x] = (r << render_red_offset) + + (g << render_green_offset) + + (b << render_blue_offset); + } + data += im->width; + p += im->bytes_per_line/2; + } + break; + default: + g_message("your bit depth is currently unhandled\n"); } - break; - default: - g_message("your bit depth is currently unhandled\n"); - } } diff --git a/render/font.c b/render/font.c index d9bc4987..405cf1c3 100644 --- a/render/font.c +++ b/render/font.c @@ -62,7 +62,7 @@ ObFont *font_open(char *fontstring) g_warning(_("Unable to load font: %s\n"), "fixed"); g_warning(_("Aborting!.\n")); - exit(3); // can't continue without a font + exit(3); /* can't continue without a font */ } void font_close(ObFont *f) diff --git a/render/mask.c b/render/mask.c index 868c7612..5f5aa263 100644 --- a/render/mask.c +++ b/render/mask.c @@ -19,19 +19,19 @@ void pixmap_mask_free(pixmap_mask *m) void mask_draw(Pixmap p, TextureMask *m, int width, int height) { int x, y; - if (m->mask == None) return; // no mask given + if (m->mask == None) return; /* no mask given */ - // set the clip region + /* set the clip region */ x = (width - m->mask->w) / 2; y = (height - m->mask->h) / 2; XSetClipMask(ob_display, m->color->gc, m->mask->mask); XSetClipOrigin(ob_display, m->color->gc, x, y); - // fill in the clipped region + /* fill in the clipped region */ XFillRectangle(ob_display, p, m->color->gc, x, y, x + m->mask->w, y + m->mask->h); - // unset the clip region + /* unset the clip region */ XSetClipMask(ob_display, m->color->gc, None); XSetClipOrigin(ob_display, m->color->gc, 0, 0); } diff --git a/render/render.c b/render/render.c index df0ed282..7129974c 100644 --- a/render/render.c +++ b/render/render.c @@ -24,8 +24,8 @@ void render_startup(void) if (render_depth < 8) { XVisualInfo vinfo_template, *vinfo_return; - // search for a TrueColor Visual... if we can't find one... - // we will use the default visual for the screen + /* search for a TrueColor Visual... if we can't find one... + we will use the default visual for the screen */ int vinfo_nitems; int best = -1; @@ -40,7 +40,7 @@ void render_startup(void) for (i = 0; i < vinfo_nitems; ++i) { if (vinfo_return[i].depth > max_depth) { if (max_depth == 24 && vinfo_return[i].depth > 24) - break; // prefer 24 bit over 32 + break; /* prefer 24 bit over 32 */ max_depth = vinfo_return[i].depth; best = i; } @@ -66,7 +66,7 @@ void truecolor_startup(void) timage = XCreateImage(ob_display, render_visual, render_depth, ZPixmap, 0, NULL, 1, 1, 32, 0); g_assert(timage != NULL); - // find the offsets for each color in the visual's masks + /* find the offsets for each color in the visual's masks */ red_mask = timage->red_mask; green_mask = timage->green_mask; blue_mask = timage->blue_mask; @@ -122,8 +122,8 @@ void x_paint(Window win, Appearance *l, int x, int y, int w, int h) ZPixmap, 0, NULL, w, h, 32, 0); g_assert(im != NULL); im->byte_order = endian; - im->data = (unsigned char *)l->surface.data.planar.pixel_data; - reduce_depth(im->data, im); + im->data = (char *)l->surface.data.planar.pixel_data; + reduce_depth((pixel32*)im->data, im); XPutImage(ob_display, l->pixmap, DefaultGC(ob_display, ob_screen), im, 0, 0, x, y, w, h); im->data = NULL; diff --git a/render/test.c b/render/test.c index b42f553d..459d2662 100644 --- a/render/test.c +++ b/render/test.c @@ -41,11 +41,11 @@ int main() win = XCreateWindow(ob_display, RootWindow(ob_display, 0) , 10, 10, w, h, 10, - CopyFromParent, // depth - CopyFromParent, // class - CopyFromParent, // visual - 0, // valuemask - 0); // attributes + CopyFromParent, /* depth */ + CopyFromParent, /* class */ + CopyFromParent, /* visual */ + 0, /* valuemask */ + 0); /* attributes */ XMapWindow(ob_display, win); XSelectInput(ob_display, win, ExposureMask | StructureNotifyMask); root = RootWindow (ob_display, DefaultScreen (ob_display)); |
