X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Frender.c;h=0cc4ea53162440cc9df58d031baaf9f3e87097f7;hb=45520c3244dd37982916f896a78a201fcf40457f;hp=8ed3c86874d8eb99e4024b6937d769220275bdca;hpb=5929a63f952cdedaec13f056d04062c34b566105;p=chaz%2Fopenbox diff --git a/render/render.c b/render/render.c index 8ed3c868..0cc4ea53 100644 --- a/render/render.c +++ b/render/render.c @@ -15,28 +15,25 @@ # include #endif -static void RrPixel32_to_pixmap(RrAppearance *l, - gint x, gint y, gint w, gint h); +static void pixel_data_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; 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,21 +45,21 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) RrVisual(l->inst), RrColormap(l->inst)); g_assert(l->xftdraw != NULL); - g_free(l->surface.RrPixel_data); - l->surface.RrPixel_data = g_new(RrPixel32, w * h); + g_free(l->surface.pixel_data); + 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.RrPixel_data + l->surface.parentx + - sw * l->surface.parenty); - dest = l->surface.RrPixel_data; + 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(RrPixel32)); } - }else + } else RrRender(l, w, h); RECT_SET(tarea, 0, 0, w, h); @@ -92,7 +89,7 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) if (!transferred) { transferred = 1; if (l->surface.grad != RR_SURFACE_SOLID) - RrPixel32_to_pixmap(l, 0, 0, w, h); + pixel_data_to_pixmap(l, 0, 0, w, h); } if (l->xftdraw == NULL) { l->xftdraw = XftDrawCreate(RrDisplay(l->inst), l->pixmap, @@ -100,19 +97,36 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) RrColormap(l->inst)); } RrFontDraw(l->xftdraw, &l->texture[i].data.text, &tarea); - break; + break; + case RR_TEXTURE_LINE_ART: + if (!transferred) { + transferred = 1; + if (l->surface.grad != RR_SURFACE_SOLID) + pixel_data_to_pixmap(l, 0, 0, w, h); + } + g_message("%d %d -> %d %d", + l->texture[i].data.lineart.x1, + l->texture[i].data.lineart.y1, + l->texture[i].data.lineart.x2, + l->texture[i].data.lineart.y2); + XDrawLine(RrDisplay(l->inst), l->pixmap, + RrColorGC(l->texture[i].data.lineart.color), + l->texture[i].data.lineart.x1, + l->texture[i].data.lineart.y1, + l->texture[i].data.lineart.x2, + l->texture[i].data.lineart.y2); + break; case RR_TEXTURE_MASK: if (!transferred) { transferred = 1; if (l->surface.grad != RR_SURFACE_SOLID) - RrPixel32_to_pixmap(l, 0, 0, w, h); + pixel_data_to_pixmap(l, 0, 0, w, h); } - if (l->texture[i].data.mask.color->gc == None) - RrColorAllocateGC(l->texture[i].data.mask.color); RrPixmapMaskDraw(l->pixmap, &l->texture[i].data.mask, &tarea); - break; + break; case RR_TEXTURE_RGBA: - RrImageDraw(l->surface.RrPixel_data, + g_assert(!transferred); + RrImageDraw(l->surface.pixel_data, &l->texture[i].data.rgba, &tarea); break; } @@ -121,10 +135,9 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) if (!transferred) { transferred = 1; if (l->surface.grad != RR_SURFACE_SOLID) - RrPixel32_to_pixmap(l, 0, 0, w, h); + pixel_data_to_pixmap(l, 0, 0, w, h); } - XSetWindowBackgroundPixmap(RrDisplay(l->inst), win, l->pixmap); XClearWindow(RrDisplay(l->inst), win); if (oldp) XFreePixmap(RrDisplay(l->inst), oldp); @@ -146,6 +159,7 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) { RrSurface *spo, *spc; RrAppearance *copy = g_new(RrAppearance, 1); + gint i; copy->inst = orig->inst; @@ -175,6 +189,13 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) spo->border_color->b); else spc->border_color = NULL; + if (spo->interlace_color != NULL) + spc->interlace_color = RrColorNew(copy->inst, + spo->interlace_color->r, + spo->interlace_color->g, + spo->interlace_color->b); + else spc->interlace_color = NULL; + if (spo->bevel_dark != NULL) spc->bevel_dark = RrColorNew(copy->inst, spo->bevel_dark->r, @@ -191,11 +212,18 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) spc->interlaced = spo->interlaced; spc->border = spo->border; - spc->RrPixel_data = NULL; + spc->parent = NULL; + spc->parentx = spc->parenty = 0; + spc->pixel_data = NULL; copy->textures = orig->textures; copy->texture = g_memdup(orig->texture, orig->textures * sizeof(RrTexture)); + for (i = 0; i < copy->textures; ++i) + if (copy->texture[i].type == RR_TEXTURE_RGBA) { + g_free(copy->texture[i].data.rgba.cache); + copy->texture[i].data.rgba.cache = NULL; + } copy->pixmap = None; copy->xftdraw = NULL; copy->w = copy->h = 0; @@ -204,26 +232,35 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) void RrAppearanceFree(RrAppearance *a) { + gint i; + if (a) { RrSurface *p; if (a->pixmap != None) XFreePixmap(RrDisplay(a->inst), a->pixmap); if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw); + for (i = 0; i < a->textures; ++i) + if (a->texture[i].type == RR_TEXTURE_RGBA) { + g_free(a->texture[i].data.rgba.cache); + a->texture[i].data.rgba.cache = NULL; + } if (a->textures) g_free(a->texture); p = &a->surface; RrColorFree(p->primary); RrColorFree(p->secondary); RrColorFree(p->border_color); + RrColorFree(p->interlace_color); RrColorFree(p->bevel_dark); RrColorFree(p->bevel_light); - g_free(p->RrPixel_data); + g_free(p->pixel_data); g_free(a); } } -static void RrPixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h) +static void pixel_data_to_pixmap(RrAppearance *l, + gint x, gint y, gint w, gint h) { RrPixel32 *in, *scratch; Pixmap out; @@ -232,10 +269,10 @@ static void RrPixel32_to_pixmap(RrAppearance *l, gint x, gint y, gint w, gint h) ZPixmap, 0, NULL, w, h, 32, 0); g_assert(im != NULL); - in = l->surface.RrPixel_data; + in = l->surface.pixel_data; out = l->pixmap; - im->byte_order = RrEndian; + 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 */ @@ -266,19 +303,21 @@ void RrMinsize(RrAppearance *l, gint *w, gint *h) break; case RR_TEXTURE_TEXT: m = RrFontMeasureString(l->texture[i].data.text.font, - l->texture[i].data.text.string, - l->texture[i].data.text.shadow, - l->texture[i].data.text.offset); + l->texture[i].data.text.string); *w = MAX(*w, m); - m = RrFontHeight(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: *w += MAX(*w, l->texture[i].data.rgba.width); *h += MAX(*h, l->texture[i].data.rgba.height); break; + case RR_TEXTURE_LINE_ART: + *w += MAX(*w, MAX(l->texture[i].data.lineart.x1, + l->texture[i].data.lineart.x2)); + *h += MAX(*h, MAX(l->texture[i].data.lineart.y1, + l->texture[i].data.lineart.y2)); + break; } }