-#ifdef USE_GL
#include <GL/gl.h>
-#endif /* USE_GL */
#include <glib.h>
#include "render.h"
#include "gradient.h"
#include "../kernel/openbox.h"
#include "color.h"
-void gradient_render(Surface *sf, int w, int h)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 current;
- unsigned int r,g,b;
- int off, x;
-
- switch (sf->data.planar.grad) {
- case Background_Solid: /* already handled */
- return;
- case Background_Vertical:
- gradient_vertical(sf, w, h);
- break;
- case Background_Horizontal:
- gradient_horizontal(sf, w, h);
- break;
- case Background_Diagonal:
- gradient_diagonal(sf, w, h);
- break;
- case Background_CrossDiagonal:
- gradient_crossdiagonal(sf, w, h);
- break;
- case Background_Pyramid:
- gradient_pyramid(sf, w, h);
- break;
- case Background_PipeCross:
- gradient_pipecross(sf, w, h);
- break;
- case Background_Rectangle:
- gradient_rectangle(sf, w, h);
- break;
- default:
- g_message("unhandled gradient");
- return;
- }
-
- if (sf->data.planar.relief == Flat && sf->data.planar.border) {
- r = sf->data.planar.border_color->r;
- g = sf->data.planar.border_color->g;
- b = sf->data.planar.border_color->b;
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- for (off = 0, x = 0; x < w; ++x, off++) {
- *(data + off) = current;
- *(data + off + ((h-1) * w)) = current;
- }
- for (off = 0, x = 0; x < h; ++x, off++) {
- *(data + (off * w)) = current;
- *(data + (off * w) + w - 1) = current;
- }
- }
-
- if (sf->data.planar.relief != Flat) {
- if (sf->data.planar.bevel == Bevel1) {
- for (off = 1, x = 1; x < w - 1; ++x, off++)
- highlight(data + off,
- data + off + (h-1) * w,
- sf->data.planar.relief==Raised);
- for (off = 0, x = 0; x < h; ++x, off++)
- highlight(data + off * w,
- data + off * w + w - 1,
- sf->data.planar.relief==Raised);
- }
-
- if (sf->data.planar.bevel == Bevel2) {
- for (off = 2, x = 2; x < w - 2; ++x, off++)
- highlight(data + off + w,
- data + off + (h-2) * w,
- sf->data.planar.relief==Raised);
- for (off = 1, x = 1; x < h-1; ++x, off++)
- highlight(data + off * w + 1,
- data + off * w + w - 2,
- sf->data.planar.relief==Raised);
- }
- }
-}
-
-
-
-void gradient_vertical(Surface *sf, int w, int h)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 current;
- float dr, dg, db;
- unsigned int r,g,b;
- int x, y;
-
- dr = (float)(sf->data.planar.secondary->r - sf->data.planar.primary->r);
- dr/= (float)h;
-
- dg = (float)(sf->data.planar.secondary->g - sf->data.planar.primary->g);
- dg/= (float)h;
-
- db = (float)(sf->data.planar.secondary->b - sf->data.planar.primary->b);
- db/= (float)h;
-
- for (y = 0; y < h; ++y) {
- r = sf->data.planar.primary->r + (int)(dr * y);
- g = sf->data.planar.primary->g + (int)(dg * y);
- b = sf->data.planar.primary->b + (int)(db * y);
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- for (x = 0; x < w; ++x, ++data)
- *data = current;
- }
-}
-
-void gradient_horizontal(Surface *sf, int w, int h)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 current;
- float dr, dg, db;
- unsigned int r,g,b;
- int x, y;
-
- dr = (float)(sf->data.planar.secondary->r - sf->data.planar.primary->r);
- dr/= (float)w;
-
- dg = (float)(sf->data.planar.secondary->g - sf->data.planar.primary->g);
- dg/= (float)w;
-
- db = (float)(sf->data.planar.secondary->b - sf->data.planar.primary->b);
- db/= (float)w;
-
- for (x = 0; x < w; ++x, ++data) {
- r = sf->data.planar.primary->r + (int)(dr * x);
- g = sf->data.planar.primary->g + (int)(dg * x);
- b = sf->data.planar.primary->b + (int)(db * x);
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- for (y = 0; y < h; ++y)
- *(data + y*w) = current;
- }
-}
-
-void gradient_diagonal(Surface *sf, int w, int h)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int x, y;
-
- for (y = 0; y < h; ++y) {
- drx = (float)(sf->data.planar.secondary->r -
- sf->data.planar.primary->r);
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(sf->data.planar.secondary->g -
- sf->data.planar.primary->g);
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(sf->data.planar.secondary->b -
- sf->data.planar.primary->b);
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (x = 0; x < w; ++x, ++data) {
- r = sf->data.planar.primary->r +
- ((int)(drx * x) + (int)(dry * y))/2;
- g = sf->data.planar.primary->g +
- ((int)(dgx * x) + (int)(dgy * y))/2;
- b = sf->data.planar.primary->b +
- ((int)(dbx * x) + (int)(dby * y))/2;
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- *data = current;
- }
- }
-}
-
-void gradient_crossdiagonal(Surface *sf, int w, int h)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int x, y;
-
- for (y = 0; y < h; ++y) {
- drx = (float)(sf->data.planar.secondary->r -
- sf->data.planar.primary->r);
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(sf->data.planar.secondary->g -
- sf->data.planar.primary->g);
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(sf->data.planar.secondary->b -
- sf->data.planar.primary->b);
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (x = w; x > 0; --x, ++data) {
- r = sf->data.planar.primary->r +
- ((int)(drx * (x-1)) + (int)(dry * y))/2;
- g = sf->data.planar.primary->g +
- ((int)(dgx * (x-1)) + (int)(dgy * y))/2;
- b = sf->data.planar.primary->b +
- ((int)(dbx * (x-1)) + (int)(dby * y))/2;
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- *data = current;
- }
- }
-}
-
-void highlight(pixel32 *x, pixel32 *y, gboolean raised)
-{
- int r, g, b;
-
- pixel32 *up, *down;
- if (raised) {
- up = x;
- down = y;
- } else {
- up = y;
- down = x;
- }
- r = (*up >> default_red_offset) & 0xFF;
- r += r >> 1;
- g = (*up >> default_green_offset) & 0xFF;
- g += g >> 1;
- b = (*up >> default_blue_offset) & 0xFF;
- b += b >> 1;
- if (r > 0xFF) r = 0xFF;
- if (g > 0xFF) g = 0xFF;
- if (b > 0xFF) b = 0xFF;
- *up = (r << default_red_offset) + (g << default_green_offset)
- + (b << default_blue_offset);
-
- r = (*down >> default_red_offset) & 0xFF;
- r = (r >> 1) + (r >> 2);
- g = (*down >> default_green_offset) & 0xFF;
- g = (g >> 1) + (g >> 2);
- b = (*down >> default_blue_offset) & 0xFF;
- b = (b >> 1) + (b >> 2);
- *down = (r << default_red_offset) + (g << default_green_offset)
- + (b << default_blue_offset);
-}
-
-static void create_bevel_colors(Appearance *l)
-{
- int r, g, b;
-
- /* light color */
- r = l->surface.data.planar.primary->r;
- r += r >> 1;
- g = l->surface.data.planar.primary->g;
- g += g >> 1;
- b = l->surface.data.planar.primary->b;
- b += b >> 1;
- if (r > 0xFF) r = 0xFF;
- if (g > 0xFF) g = 0xFF;
- if (b > 0xFF) b = 0xFF;
- g_assert(!l->surface.data.planar.bevel_light);
- l->surface.data.planar.bevel_light = color_new(r, g, b);
- color_allocate_gc(l->surface.data.planar.bevel_light);
-
- /* dark color */
- r = l->surface.data.planar.primary->r;
- r = (r >> 1) + (r >> 2);
- g = l->surface.data.planar.primary->g;
- g = (g >> 1) + (g >> 2);
- b = l->surface.data.planar.primary->b;
- b = (b >> 1) + (b >> 2);
- g_assert(!l->surface.data.planar.bevel_dark);
- l->surface.data.planar.bevel_dark = color_new(r, g, b);
- color_allocate_gc(l->surface.data.planar.bevel_dark);
-}
-
-void gradient_solid(Appearance *l, int x, int y, int w, int h)
-{
- pixel32 pix;
- int i, a, b;
- PlanarSurface *sp = &l->surface.data.planar;
- int left = x, top = y, right = x + w - 1, bottom = y + h - 1;
-
- if (sp->primary->gc == None)
- color_allocate_gc(sp->primary);
- pix = (sp->primary->r << default_red_offset)
- + (sp->primary->g << default_green_offset)
- + (sp->primary->b << default_blue_offset);
-
- for (a = 0; a < l->area.width; a++)
- for (b = 0; b < l->area.height; b++)
- sp->pixel_data[a + b*l->area.width] = pix;
-
- XFillRectangle(ob_display, l->pixmap, sp->primary->gc,
- x, y, w, h);
-
- if (sp->interlaced) {
- if (sp->secondary->gc == None)
- color_allocate_gc(sp->secondary);
- for (i = y; i < h; i += 2)
- XDrawLine(ob_display, l->pixmap, sp->secondary->gc,
- x, i, w, i);
- }
-
- switch (sp->relief) {
- case Raised:
- if (!sp->bevel_dark)
- create_bevel_colors(l);
-
- switch (sp->bevel) {
- case Bevel1:
- XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
- left, bottom, right, bottom);
- XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
- right, bottom, right, top);
-
- XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
- left, top, right, top);
- XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
- left, bottom, left, top);
- break;
- case Bevel2:
- XDrawLine(ob_display, l->pixmap,
- sp->bevel_dark->gc,
- left + 1, bottom - 2, right - 2, bottom - 2);
- XDrawLine(ob_display, l->pixmap,
- sp->bevel_dark->gc,
- right - 2, bottom - 2, right - 2, top + 1);
-
- XDrawLine(ob_display, l->pixmap,
- sp->bevel_light->gc,
- left + 1, top + 1, right - 2, top + 1);
- XDrawLine(ob_display, l->pixmap,
- sp->bevel_light->gc,
- left + 1, bottom - 2, left + 1, top + 1);
- break;
- default:
- g_assert_not_reached(); /* unhandled BevelType */
- }
- break;
- case Sunken:
- if (!sp->bevel_dark)
- create_bevel_colors(l);
-
- switch (sp->bevel) {
- case Bevel1:
- XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
- left, bottom, right, bottom);
- XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
- right, bottom, right, top);
-
- XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
- left, top, right, top);
- XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
- left, bottom, left, top);
- break;
- case Bevel2:
- XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
- left + 1, bottom - 2, right - 2, bottom - 2);
- XDrawLine(ob_display, l->pixmap, sp->bevel_light->gc,
- right - 2, bottom - 2, right - 2, top + 1);
-
- XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
- left + 1, top + 1, right - 2, top + 1);
- XDrawLine(ob_display, l->pixmap, sp->bevel_dark->gc,
- left + 1, bottom - 2, left + 1, top + 1);
-
- break;
- default:
- g_assert_not_reached(); /* unhandled BevelType */
- }
- break;
- case Flat:
- if (sp->border) {
- if (sp->border_color->gc == None)
- color_allocate_gc(sp->border_color);
- XDrawRectangle(ob_display, l->pixmap, sp->border_color->gc,
- left, top, right, bottom);
- }
- break;
- default:
- g_assert_not_reached(); /* unhandled ReliefType */
- }
-}
-
-void gradient_pyramid(Surface *sf, int inw, int inh)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 *end = data + inw*inh - 1;
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int x, y, h=(inh/2) + 1, w=(inw/2) + 1;
- for (y = 0; y < h; ++y) {
- drx = (float)(sf->data.planar.secondary->r -
- sf->data.planar.primary->r);
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(sf->data.planar.secondary->g -
- sf->data.planar.primary->g);
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(sf->data.planar.secondary->b -
- sf->data.planar.primary->b);
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (x = 0; x < w; ++x, data) {
- r = sf->data.planar.primary->r +
- ((int)(drx * x) + (int)(dry * y))/2;
- g = sf->data.planar.primary->g +
- ((int)(dgx * x) + (int)(dgy * y))/2;
- b = sf->data.planar.primary->b +
- ((int)(dbx * x) + (int)(dby * y))/2;
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- *(data+x) = current;
- *(data+inw-x) = current;
- *(end-x) = current;
- *(end-(inw-x)) = current;
- }
- data+=inw;
- end-=inw;
- }
-}
-
-void gradient_rectangle(Surface *sf, int inw, int inh)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 *end = data + inw*inh - 1;
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int x, y, h=(inh/2) + 1, w=(inw/2) + 1;
- int val;
-
- for (y = 0; y < h; ++y) {
- drx = (float)(sf->data.planar.primary->r -
- sf->data.planar.secondary->r);
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(sf->data.planar.primary->g -
- sf->data.planar.secondary->g);
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(sf->data.planar.primary->b -
- sf->data.planar.secondary->b);
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (x = 0; x < w; ++x, data) {
- if ((float)x/(float)w < (float)y/(float)h) val = (int)(drx * x);
- else val = (int)(dry * y);
-
- r = sf->data.planar.secondary->r + val;
- g = sf->data.planar.secondary->g + val;
- b = sf->data.planar.secondary->b + val;
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- *(data+x) = current;
- *(data+inw-x) = current;
- *(end-x) = current;
- *(end-(inw-x)) = current;
- }
- data+=inw;
- end-=inw;
- }
-}
-
-void gradient_pipecross(Surface *sf, int inw, int inh)
-{
- pixel32 *data = sf->data.planar.pixel_data;
- pixel32 *end = data + inw*inh - 1;
- pixel32 current;
- float drx, dgx, dbx, dry, dgy, dby;
- unsigned int r,g,b;
- int x, y, h=(inh/2) + 1, w=(inw/2) + 1;
- int val;
-
- for (y = 0; y < h; ++y) {
- drx = (float)(sf->data.planar.secondary->r -
- sf->data.planar.primary->r);
- dry = drx/(float)h;
- drx/= (float)w;
-
- dgx = (float)(sf->data.planar.secondary->g -
- sf->data.planar.primary->g);
- dgy = dgx/(float)h;
- dgx/= (float)w;
-
- dbx = (float)(sf->data.planar.secondary->b -
- sf->data.planar.primary->b);
- dby = dbx/(float)h;
- dbx/= (float)w;
- for (x = 0; x < w; ++x, data) {
- if ((float)x/(float)w > (float)y/(float)h) val = (int)(drx * x);
- else val = (int)(dry * y);
-
- r = sf->data.planar.primary->r + val;
- g = sf->data.planar.primary->g + val;
- b = sf->data.planar.primary->b + val;
- current = (r << default_red_offset)
- + (g << default_green_offset)
- + (b << default_blue_offset);
- *(data+x) = current;
- *(data+inw-x) = current;
- *(end-x) = current;
- *(end-(inw-x)) = current;
- }
- data+=inw;
- end-=inw;
- }
-}
-#ifdef USE_GL
void render_gl_gradient(Surface *sf, int x, int y, int w, int h)
{
float pr,pg,pb;
return;
}
}
-#endif /* USE_GL */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-
-#ifdef USE_GL
-# include <GL/glx.h>
-#endif
-
+#include <GL/glx.h>
#include <glib.h>
#include "render.h"
#include "gradient.h"
int render_red_mask, render_green_mask, render_blue_mask;
-#ifdef USE_GL
-
GLXContext render_glx_context;
int render_glx_rating(XVisualInfo *v)
rating++;
return rating;
}
-#endif /* USE_GL */
void render_startup(void)
{
render_visual = DefaultVisual(ob_display, ob_screen);
render_colormap = DefaultColormap(ob_display, ob_screen);
-#ifdef USE_GL
vimatch.screen = ob_screen;
vimatch.class = TrueColor;
vilist = XGetVisualInfo(ob_display, VisualScreenMask | VisualClassMask,
paint = gl_paint;
}
}
-#endif /*USE_GL*/
switch (render_visual->class) {
XFree(timage);
}
-void pseudocolor_startup(void)
-{
- XColor icolors[256];
- int tr, tg, tb, n, r, g, b, i, incolors, ii;
- unsigned long dev;
- int cpc, _ncolors;
- g_message("Initializing PseudoColor RenderControl\n");
-
- /* determine the number of colors and the bits-per-color */
- pseudo_bpc = 2; /* XXX THIS SHOULD BE A USER OPTION */
- g_assert(pseudo_bpc >= 1);
- _ncolors = pseudo_ncolors();
-
- if (_ncolors > 1 << render_depth) {
- g_warning("PseudoRenderControl: Invalid colormap size. Resizing.\n");
- pseudo_bpc = 1 << (render_depth/3) >> 3;
- _ncolors = 1 << (pseudo_bpc * 3);
- }
-
- /* build a color cube */
- pseudo_colors = malloc(_ncolors * sizeof(XColor));
- cpc = 1 << pseudo_bpc; /* colors per channel */
-
- for (n = 0, r = 0; r < cpc; r++)
- for (g = 0; g < cpc; g++)
- for (b = 0; b < cpc; b++, n++) {
- tr = (int)(((float)(r)/(float)(cpc-1)) * 0xFF);
- tg = (int)(((float)(g)/(float)(cpc-1)) * 0xFF);
- tb = (int)(((float)(b)/(float)(cpc-1)) * 0xFF);
- pseudo_colors[n].red = tr | tr << 8;
- pseudo_colors[n].green = tg | tg << 8;
- pseudo_colors[n].blue = tb | tb << 8;
- pseudo_colors[n].flags = DoRed|DoGreen|DoBlue; /* used to track
- allocation */
- }
-
- /* allocate the colors */
- for (i = 0; i < _ncolors; i++)
- if (!XAllocColor(ob_display, render_colormap, &pseudo_colors[i]))
- pseudo_colors[i].flags = 0; /* mark it as unallocated */
-
- /* try allocate any colors that failed allocation above */
-
- /* get the allocated values from the X server (only the first 256 XXX why!?)
- */
- incolors = (((1 << render_depth) > 256) ? 256 : (1 << render_depth));
- for (i = 0; i < incolors; i++)
- icolors[i].pixel = i;
- XQueryColors(ob_display, render_colormap, icolors, incolors);
-
- /* try match unallocated ones */
- for (i = 0; i < _ncolors; i++) {
- if (!pseudo_colors[i].flags) { /* if it wasn't allocated... */
- unsigned long closest = 0xffffffff, close = 0;
- for (ii = 0; ii < incolors; ii++) {
- /* find deviations */
- r = (pseudo_colors[i].red - icolors[ii].red) & 0xff;
- g = (pseudo_colors[i].green - icolors[ii].green) & 0xff;
- b = (pseudo_colors[i].blue - icolors[ii].blue) & 0xff;
- /* find a weighted absolute deviation */
- dev = (r * r) + (g * g) + (b * b);
-
- if (dev < closest) {
- closest = dev;
- close = ii;
- }
- }
-
- pseudo_colors[i].red = icolors[close].red;
- pseudo_colors[i].green = icolors[close].green;
- pseudo_colors[i].blue = icolors[close].blue;
- pseudo_colors[i].pixel = icolors[close].pixel;
-
- /* try alloc this closest color, it had better succeed! */
- if (XAllocColor(ob_display, render_colormap, &pseudo_colors[i]))
- pseudo_colors[i].flags = DoRed|DoGreen|DoBlue; /* mark as alloced */
- else
- g_assert(FALSE); /* wtf has gone wrong, its already alloced for
- chissake! */
- }
- }
-}
-
-void x_paint(Window win, Appearance *l)
-{
- int i, transferred = 0, sw;
- pixel32 *source, *dest;
- Pixmap oldp;
- int x = l->area.x;
- int y = l->area.y;
- int w = l->area.width;
- int h = l->area.height;
- Rect tarea; /* area in which to draw textures */
-
- if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return;
-
- g_assert(l->surface.type == Surface_Planar);
-
- oldp = l->pixmap; /* save to free after changing the visible pixmap */
- l->pixmap = XCreatePixmap(ob_display, ob_root, x+w, y+h, render_depth);
- g_assert(l->pixmap != None);
-
- if (l->xftdraw != NULL)
- XftDrawDestroy(l->xftdraw);
- l->xftdraw = XftDrawCreate(ob_display, l->pixmap, render_visual,
- render_colormap);
- g_assert(l->xftdraw != NULL);
-
- g_free(l->surface.data.planar.pixel_data);
- l->surface.data.planar.pixel_data = g_new(pixel32, w * h);
-
-
- if (l->surface.data.planar.grad == Background_ParentRelative) {
- sw = l->surface.data.planar.parent->area.width;
- source = l->surface.data.planar.parent->surface.data.planar.pixel_data
- + l->surface.data.planar.parentx
- + sw * l->surface.data.planar.parenty;
- dest = l->surface.data.planar.pixel_data;
- for (i = 0; i < h; i++, source += sw, dest += w) {
- memcpy(dest, source, w * sizeof(pixel32));
- }
- }
- else if (l->surface.data.planar.grad == Background_Solid)
- gradient_solid(l, x, y, w, h);
- else gradient_render(&l->surface, w, h);
-
- for (i = 0; i < l->textures; i++) {
- tarea = l->texture[i].position;
- if (l->surface.data.planar.grad != Background_ParentRelative) {
- if (l->surface.data.planar.relief != Flat) {
- switch (l->surface.data.planar.bevel) {
- case Bevel1:
- tarea.x += 1; tarea.y += 1;
- tarea.width -= 2; tarea.height -= 2;
- break;
- case Bevel2:
- tarea.x += 2; tarea.y += 2;
- tarea.width -= 4; tarea.height -= 4;
- break;
- }
- } else if (l->surface.data.planar.border) {
- tarea.x += 1; tarea.y += 1;
- tarea.width -= 2; tarea.height -= 2;
- }
- }
-
- switch (l->texture[i].type) {
- case Text:
- if (!transferred) {
- transferred = 1;
- if (l->surface.data.planar.grad != Background_Solid)
- pixel32_to_pixmap(l->surface.data.planar.pixel_data,
- l->pixmap,x,y,w,h);
- }
- if (l->xftdraw == NULL) {
- l->xftdraw = XftDrawCreate(ob_display, l->pixmap,
- render_visual, render_colormap);
- }
- font_draw(l->xftdraw, &l->texture[i].data.text,
- &tarea);
- break;
- case Bitmask:
- if (!transferred) {
- transferred = 1;
- if (l->surface.data.planar.grad != Background_Solid)
- pixel32_to_pixmap(l->surface.data.planar.pixel_data,
- l->pixmap,x,y,w,h);
- }
- if (l->texture[i].data.mask.color->gc == None)
- color_allocate_gc(l->texture[i].data.mask.color);
- mask_draw(l->pixmap, &l->texture[i].data.mask,
- &tarea);
- break;
- case RGBA:
- image_draw(l->surface.data.planar.pixel_data,
- &l->texture[i].data.rgba,
- &tarea, &l->area);
- break;
- }
- }
-
- if (!transferred) {
- transferred = 1;
- if (l->surface.data.planar.grad != Background_Solid)
- pixel32_to_pixmap(l->surface.data.planar.pixel_data, l->pixmap
- ,x,y,w,h);
- }
-
-
- XSetWindowBackgroundPixmap(ob_display, win, l->pixmap);
- XClearWindow(ob_display, win);
- if (oldp != None) XFreePixmap(ob_display, oldp);
-}
-
void render_shutdown(void)
{
}
out = g_new(Appearance, 1);
out->surface.type = type;
out->textures = numtex;
- out->xftdraw = NULL;
if (numtex) out->texture = g_new0(Texture, numtex);
else out->texture = NULL;
- out->pixmap = None;
switch (type) {
case Surface_Planar:
}
copy->textures = orig->textures;
copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture));
- copy->pixmap = None;
- copy->xftdraw = NULL;
return copy;
}
{
if (a) {
PlanarSurface *p;
- if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap);
- if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
if (a->textures)
g_free(a->texture);
if (a->surface.type == Surface_Planar) {
return TRUE;
}
-#ifdef USE_GL
void gl_paint(Window win, Appearance *l)
{
int err;
glXSwapBuffers(ob_display, win);
}
-
-#endif /* USE_GL */