X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Frender.c;h=7be3993e1cda2e6188a88e60ef2280d2fce2c911;hb=a09984bbc076bc37b11058237f51fa15114129e2;hp=f2a0572fb6be06f1874690207e37e542f22179a5;hpb=3f32dfa87e08556d7f6a58efab9b7479e515be26;p=chaz%2Fopenbox diff --git a/render/render.c b/render/render.c index f2a0572f..7be3993e 100644 --- a/render/render.c +++ b/render/render.c @@ -15,27 +15,25 @@ # include #endif -static void pixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h); +static void RrPixel32_to_pixmap(RrAppearance *l, + gint x, gint y, gint w, gint h); void RrPaint(RrAppearance *l, Window win, gint w, gint h) { int i, transferred = 0, sw; - pixel32 *source, *dest; + RrPixel32 *source, *dest; Pixmap oldp; - Rect tarea; /* area in which to draw textures */ + RrRect tarea; /* area in which to draw textures */ gboolean resized; if (w <= 0 || h <= 0) return; resized = (l->w != w || l->h != h); - if (resized) { - oldp = l->pixmap; /* save to free after changing the visible pixmap */ - l->pixmap = XCreatePixmap(RrDisplay(l->inst), - RrRootWindow(l->inst), - w, h, RrDepth(l->inst)); - } else - oldp = None; + oldp = l->pixmap; /* save to free after changing the visible pixmap */ + l->pixmap = XCreatePixmap(RrDisplay(l->inst), + RrRootWindow(l->inst), + w, h, RrDepth(l->inst)); g_assert(l->pixmap != None); l->w = w; @@ -48,23 +46,21 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) g_assert(l->xftdraw != NULL); g_free(l->surface.pixel_data); - l->surface.pixel_data = g_new(pixel32, w * h); + l->surface.pixel_data = g_new(RrPixel32, w * h); if (l->surface.grad == RR_SURFACE_PARENTREL) { g_assert (l->surface.parent); g_assert (l->surface.parent->w); sw = l->surface.parent->w; - source = (l->surface.parent->surface.pixel_data + l->surface.parentx + - sw * l->surface.parenty); + source = (l->surface.parent->surface.pixel_data + + l->surface.parentx + sw * l->surface.parenty); dest = l->surface.pixel_data; for (i = 0; i < h; i++, source += sw, dest += w) { - memcpy(dest, source, w * sizeof(pixel32)); + memcpy(dest, source, w * sizeof(RrPixel32)); } - } else if (l->surface.grad == RR_SURFACE_SOLID) - gradient_solid(l, 0, 0, w, h); - else - gradient_render(&l->surface, w, h); + } else + RrRender(l, w, h); RECT_SET(tarea, 0, 0, w, h); if (l->surface.grad != RR_SURFACE_PARENTREL) { @@ -93,28 +89,28 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) if (!transferred) { transferred = 1; if (l->surface.grad != RR_SURFACE_SOLID) - pixel32_to_pixmap(l, 0, 0, w, h); + RrPixel32_to_pixmap(l, 0, 0, w, h); } if (l->xftdraw == NULL) { l->xftdraw = XftDrawCreate(RrDisplay(l->inst), l->pixmap, RrVisual(l->inst), RrColormap(l->inst)); } - font_draw(l->xftdraw, &l->texture[i].data.text, &tarea); + RrFontDraw(l->xftdraw, &l->texture[i].data.text, &tarea); break; case RR_TEXTURE_MASK: if (!transferred) { transferred = 1; if (l->surface.grad != RR_SURFACE_SOLID) - pixel32_to_pixmap(l, 0, 0, w, h); + RrPixel32_to_pixmap(l, 0, 0, w, h); } if (l->texture[i].data.mask.color->gc == None) - color_allocate_gc(l->texture[i].data.mask.color); + RrColorAllocateGC(l->texture[i].data.mask.color); RrPixmapMaskDraw(l->pixmap, &l->texture[i].data.mask, &tarea); break; case RR_TEXTURE_RGBA: - image_draw(l->surface.pixel_data, - &l->texture[i].data.rgba, &tarea); + RrImageDraw(l->surface.pixel_data, + &l->texture[i].data.rgba, &tarea); break; } } @@ -122,7 +118,7 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) if (!transferred) { transferred = 1; if (l->surface.grad != RR_SURFACE_SOLID) - pixel32_to_pixmap(l, 0, 0, w, h); + RrPixel32_to_pixmap(l, 0, 0, w, h); } @@ -192,6 +188,8 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) spc->interlaced = spo->interlaced; spc->border = spo->border; + spc->parent = NULL; + spc->parentx = spc->parenty = 0; spc->pixel_data = NULL; copy->textures = orig->textures; @@ -224,9 +222,9 @@ void RrAppearanceFree(RrAppearance *a) } -static void pixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h) +static void RrPixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h) { - pixel32 *in, *scratch; + RrPixel32 *in, *scratch; Pixmap out; XImage *im = NULL; im = XCreateImage(RrDisplay(l->inst), RrVisual(l->inst), RrDepth(l->inst), @@ -236,13 +234,13 @@ static void pixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h) in = l->surface.pixel_data; out = l->pixmap; - im->byte_order = render_endian; + im->byte_order = LSBFirst; /* this malloc is a complete waste of time on normal 32bpp as reduce_depth just sets im->data = data and returns */ - scratch = g_new(pixel32, im->width * im->height); + scratch = g_new(RrPixel32, im->width * im->height); im->data = (char*) scratch; - reduce_depth(l->inst, in, im); + RrReduceDepth(l->inst, in, im); XPutImage(RrDisplay(l->inst), out, DefaultGC(RrDisplay(l->inst), RrScreen(l->inst)), im, 0, 0, x, y, w, h); @@ -266,14 +264,10 @@ void RrMinsize(RrAppearance *l, gint *w, gint *h) *h = MAX(*h, l->texture[i].data.mask.mask->height); break; case RR_TEXTURE_TEXT: - m = font_measure_string(l->texture[i].data.text.font, - l->texture[i].data.text.string, - l->texture[i].data.text.shadow, - l->texture[i].data.text.offset); + m = RrFontMeasureString(l->texture[i].data.text.font, + l->texture[i].data.text.string); *w = MAX(*w, m); - m = font_height(l->texture[i].data.text.font, - l->texture[i].data.text.shadow, - l->texture[i].data.text.offset); + m = RrFontHeight(l->texture[i].data.text.font); *h += MAX(*h, m); break; case RR_TEXTURE_RGBA: @@ -305,7 +299,7 @@ void RrMinsize(RrAppearance *l, gint *w, gint *h) gboolean RrPixmapToRGBA(const RrInstance *inst, Pixmap pmap, Pixmap mask, - gint *w, gint *h, pixel32 **data) + gint *w, gint *h, RrPixel32 **data) { Window xr; gint xx, xy; @@ -335,8 +329,8 @@ gboolean RrPixmapToRGBA(const RrInstance *inst, return FALSE; } - *data = g_new(pixel32, pw * ph); - increase_depth(inst, *data, xi); + *data = g_new(RrPixel32, pw * ph); + RrIncreaseDepth(inst, *data, xi); if (mask) { /* apply transparency from the mask */ @@ -344,7 +338,7 @@ gboolean RrPixmapToRGBA(const RrInstance *inst, for (i = 0, y = 0; y < ph; ++y) { for (x = 0; x < pw; ++x, ++i) { if (!((((unsigned)xm->data[di + x / 8]) >> (x % 8)) & 0x1)) - (*data)[i] &= ~(0xff << default_alpha_offset); + (*data)[i] &= ~(0xff << RrDefaultAlphaOffset); } di += xm->bytes_per_line; }