From 046359b7eb3c41c58dfac4d24ec7878906475a6c Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Sun, 25 May 2003 21:06:54 +0000 Subject: [PATCH] once again it compiles. no, it does not work much has been removed. --- render/font.c | 52 +---- render/font.h | 3 +- render/gradient.c | 523 ---------------------------------------------- render/gradient.h | 11 - render/render.c | 214 +------------------ render/render.h | 5 - 6 files changed, 9 insertions(+), 799 deletions(-) diff --git a/render/font.c b/render/font.c index db4e8483..efd89a6e 100644 --- a/render/font.c +++ b/render/font.c @@ -4,7 +4,6 @@ #include "kernel/gettext.h" #define _(str) gettext(str) -#include #include #include @@ -14,63 +13,31 @@ void font_startup(void) { -#ifdef DEBUG - int version; -#endif /* DEBUG */ - if (!XftInit(0)) { - g_warning(_("Couldn't initialize Xft.\n")); - exit(3); - } -#ifdef DEBUG - version = XftGetVersion(); - g_message("Using Xft %d.%d.%d (Built against %d.%d.%d).", - version / 10000 % 100, version / 100 % 100, version % 100, - XFT_MAJOR, XFT_MINOR, XFT_REVISION); -#endif } static void measure_height(ObFont *f) { - XGlyphInfo info; char *str; /* XXX add some extended UTF8 characters in here? */ str = "12345678900-qwertyuiopasdfghjklzxcvbnm" "!@#$%^&*()_+QWERTYUIOPASDFGHJKLZXCVBNM" "`~[]\\;',./{}|:\"<>?"; - +/* XftTextExtentsUtf8(ob_display, f->xftfont, (FcChar8*)str, strlen(str), &info); f->height = (signed) info.height; - +*/ /* measure an elipses */ - XftTextExtentsUtf8(ob_display, f->xftfont, +/* XftTextExtentsUtf8(ob_display, f->xftfont, (FcChar8*)ELIPSES, strlen(ELIPSES), &info); f->elipses_length = (signed) info.xOff; +*/ } ObFont *font_open(char *fontstring) { ObFont *out; - XftFont *xf; - - if ((xf = XftFontOpenName(ob_display, ob_screen, fontstring))) { - out = g_new(ObFont, 1); - out->xftfont = xf; - measure_height(out); - return out; - } - g_warning(_("Unable to load font: %s\n"), fontstring); - g_warning(_("Trying fallback font: %s\n"), "sans"); - - if ((xf = XftFontOpenName(ob_display, ob_screen, "sans"))) { - out = g_new(ObFont, 1); - out->xftfont = xf; - measure_height(out); - return out; - } - g_warning(_("Unable to load font: %s\n"), "sans"); - g_warning(_("Aborting!.\n")); exit(3); /* can't continue without a font */ } @@ -78,19 +45,12 @@ ObFont *font_open(char *fontstring) void font_close(ObFont *f) { if (f) { - XftFontClose(ob_display, f->xftfont); g_free(f); } } int font_measure_string(ObFont *f, char *str, int shadow, int offset) { - XGlyphInfo info; - - XftTextExtentsUtf8(ob_display, f->xftfont, - (FcChar8*)str, strlen(str), &info); - - return (signed) info.xOff + (shadow ? offset : 0); } int font_height(ObFont *f, int shadow, int offset) @@ -100,9 +60,10 @@ int font_height(ObFont *f, int shadow, int offset) int font_max_char_width(ObFont *f) { - return (signed) f->xftfont->max_advance_width; + return 0; } +#if 0 void font_draw(XftDraw *d, TextureText *t, Rect *position) { int x,y,w,h; @@ -182,3 +143,4 @@ void font_draw(XftDraw *d, TextureText *t, Rect *position) (FcChar8*)text->str, l); return; } +#endif diff --git a/render/font.h b/render/font.h index 6a5d4c65..0b95e006 100644 --- a/render/font.h +++ b/render/font.h @@ -1,6 +1,5 @@ #ifndef __font_h #define __font_h -#include #include "render.h" #include "kernel/geom.h" @@ -10,5 +9,5 @@ void font_close(ObFont *f); int font_measure_string(ObFont *f, char *str, int shadow, int offset); int font_height(ObFont *f, int shadow, int offset); int font_max_char_width(ObFont *f); -void font_draw(XftDraw *d, TextureText *t, Rect *position); +/*void font_draw(XftDraw *d, TextureText *t, Rect *position);*/ #endif /* __font_h */ diff --git a/render/gradient.c b/render/gradient.c index 31d4c730..8afa4b79 100644 --- a/render/gradient.c +++ b/render/gradient.c @@ -1,532 +1,10 @@ -#ifdef USE_GL #include -#endif /* USE_GL */ #include #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; @@ -755,4 +233,3 @@ void render_gl_gradient(Surface *sf, int x, int y, int w, int h) return; } } -#endif /* USE_GL */ diff --git a/render/gradient.h b/render/gradient.h index bbadcd0d..86f2aab7 100644 --- a/render/gradient.h +++ b/render/gradient.h @@ -3,17 +3,6 @@ #include "render.h" -void gradient_render(Surface *sf, int w, int h); -void gradient_vertical(Surface *sf, int w, int h); -void gradient_horizontal(Surface *sf, int w, int h); -void gradient_diagonal(Surface *sf, int w, int h); -void gradient_crossdiagonal(Surface *sf, int w, int h); -void gradient_pyramid(Surface *sf, int w, int h); -void gradient_pipecross(Surface *sf, int w, int h); -void gradient_rectangle(Surface *sf, int w, int h); -void gradient_solid(Appearance *l, int x, int y, int w, int h); -void highlight(pixel32 *x, pixel32 *y, gboolean raised); - void render_gl_gradient(Surface *sf, int x, int y, int w, int h); #endif /* __gradient_h */ diff --git a/render/render.c b/render/render.c index 712ed7fb..08a3855f 100644 --- a/render/render.c +++ b/render/render.c @@ -1,10 +1,6 @@ #include #include - -#ifdef USE_GL -# include -#endif - +#include #include #include "render.h" #include "gradient.h" @@ -30,8 +26,6 @@ int render_red_shift, render_green_shift, render_blue_shift; int render_red_mask, render_green_mask, render_blue_mask; -#ifdef USE_GL - GLXContext render_glx_context; int render_glx_rating(XVisualInfo *v) @@ -82,7 +76,6 @@ int render_glx_rating(XVisualInfo *v) rating++; return rating; } -#endif /* USE_GL */ void render_startup(void) { @@ -94,7 +87,6 @@ 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, @@ -128,7 +120,6 @@ void render_startup(void) paint = gl_paint; } } -#endif /*USE_GL*/ switch (render_visual->class) { @@ -176,200 +167,6 @@ void truecolor_startup(void) 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) { } @@ -382,10 +179,8 @@ Appearance *appearance_new(SurfaceType type, int numtex) 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: @@ -450,8 +245,6 @@ Appearance *appearance_copy(Appearance *orig) } copy->textures = orig->textures; copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture)); - copy->pixmap = None; - copy->xftdraw = NULL; return copy; } @@ -459,8 +252,6 @@ void appearance_free(Appearance *a) { 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) { @@ -595,7 +386,6 @@ gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask, return TRUE; } -#ifdef USE_GL void gl_paint(Window win, Appearance *l) { int err; @@ -643,5 +433,3 @@ g_assert(err != 0); glXSwapBuffers(ob_display, win); } - -#endif /* USE_GL */ diff --git a/render/render.h b/render/render.h index 16f5c31c..bd64f111 100644 --- a/render/render.h +++ b/render/render.h @@ -2,8 +2,6 @@ #define __render_h #include -#define _XFT_NO_COMPAT_ /* no Xft 1 API */ -#include #include #include "color.h" #include "kernel/geom.h" @@ -78,7 +76,6 @@ typedef struct Surface { } Surface; typedef struct { - XftFont *xftfont; int height; int elipses_length; } ObFont; @@ -137,8 +134,6 @@ typedef struct Appearance { Rect area; int textures; Texture *texture; - Pixmap pixmap; - XftDraw *xftdraw; } Appearance; extern Visual *render_visual; -- 2.34.1