aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
authorlecoanet2007-03-01 09:02:45 +0000
committerlecoanet2007-03-01 09:02:45 +0000
commit484378a2138ac8777dcf66206ae7c1cde217e36f (patch)
tree6cd511a7f7b519e989e61d3bc8699373cd41a1f3 /generic
parente72eff0d1ebd40a73dcd312e7a9840cfb3599c93 (diff)
downloadtkzinc-484378a2138ac8777dcf66206ae7c1cde217e36f.zip
tkzinc-484378a2138ac8777dcf66206ae7c1cde217e36f.tar.gz
tkzinc-484378a2138ac8777dcf66206ae7c1cde217e36f.tar.bz2
tkzinc-484378a2138ac8777dcf66206ae7c1cde217e36f.tar.xz
Retrofitted the anti aliased font patch under Windows. It seems to be buggy
with ATI cards. It has to do with the X11 porting layer, XGetImage more precisely.
Diffstat (limited to 'generic')
-rw-r--r--generic/Image.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/generic/Image.c b/generic/Image.c
index 0c62211..b354332 100644
--- a/generic/Image.c
+++ b/generic/Image.c
@@ -1135,8 +1135,10 @@ SuckGlyphsFromServer(ZnWInfo *wi,
{
Pixmap offscreen = 0;
XImage *image = NULL;
+#ifdef MAC_OSX_TK
XColor *white, *black;
unsigned long pixel;
+#endif
GC xgc = 0;
unsigned int height, length, pixwidth;
unsigned int i, j, use_max_width;
@@ -1274,16 +1276,29 @@ SuckGlyphsFromServer(ZnWInfo *wi,
glyphsPerGrab = (1 << 12) / (8 * maxSpanLength);
}
pixwidth = glyphsPerGrab * 8 * maxSpanLength;
+#ifdef MAC_OSX_TK
offscreen = Tk_GetPixmap(wi->dpy, RootWindowOfScreen(wi->screen),
(int) pixwidth, (int) height, Tk_Depth(wi->win));
-
+#else
+ offscreen = Tk_GetPixmap(wi->dpy, RootWindowOfScreen(wi->screen),
+ (int) pixwidth, (int) height, 1);
+#endif
xgc = XCreateGC(wi->dpy, offscreen, 0, NULL);
+#ifdef MAC_OSX_TK
white = Tk_GetColor(wi->interp, wi->win, "white");
black = Tk_GetColor(wi->interp, wi->win, "black");
XSetForeground(wi->dpy, xgc, white->pixel);
XSetBackground(wi->dpy, xgc, white->pixel);
+#else
+ XSetForeground(wi->dpy, xgc, WhitePixelOfScreen(wi->screen));
+ XSetBackground(wi->dpy, xgc, WhitePixelOfScreen(wi->screen));
+#endif
XFillRectangle(wi->dpy, offscreen, xgc, 0, 0, pixwidth, height);
+#ifdef MAC_OSX_TK
XSetForeground(wi->dpy, xgc, black->pixel);
+#else
+ XSetForeground(wi->dpy, xgc, BlackPixelOfScreen(wi->screen));
+#endif
XSetFont(wi->dpy, xgc, Tk_FontId(txf->tkfont));
numToGrab = 0;
@@ -1304,8 +1319,11 @@ SuckGlyphsFromServer(ZnWInfo *wi,
}
if ((numToGrab >= glyphsPerGrab) || (i == txf->num_glyphs - 1)) {
- image = XGetImage(wi->dpy, offscreen, 0, 0, pixwidth, height, ~0, ZPixmap);
-
+#ifdef MAC_OSX_TK
+ image = XGetImage(wi->dpy, offscreen, 0, 0, pixwidth, height, AllPlanes, ZPixmap);
+#else
+ image = XGetImage(wi->dpy, offscreen, 0, 0, pixwidth, height, 1, XYPixmap);
+#endif
for (j = 0; j < numToGrab; j++) {
glyph = grabList[j];
width = txf->glyph[glyph].width;
@@ -1324,11 +1342,11 @@ SuckGlyphsFromServer(ZnWInfo *wi,
each pixel from the image which is not that efficient. We
could either do tighter packing in the pixmap or more
efficient extraction from the image. Oh well. */
+#ifdef MAC_OSX_TK
pixel = XGetPixel(image, (int) (j*maxSpanLength*8) + x, y);
-#if defined(MAC_OSX_TK) || defined(_WIN32)
*to = 255 - (pixel & 0xFF);
#else
- if (pixel == black->pixel) {
+ if (XGetPixel(image, (int) (j*maxSpanLength*8) + x, y) == BlackPixelOfScreen(wi->screen)) {
*to = 255;
}
#endif
@@ -1341,10 +1359,18 @@ SuckGlyphsFromServer(ZnWInfo *wi,
numToGrab = 0;
/* do we need to clear the offscreen pixmap to get more? */
if (i < txf->num_glyphs - 1) {
+#ifdef MAC_OSX_TK
XSetForeground(wi->dpy, xgc, white->pixel);
+#else
+ XSetForeground(wi->dpy, xgc, WhitePixelOfScreen(wi->screen));
+#endif
XFillRectangle(wi->dpy, offscreen, xgc, 0, 0,
8 * maxSpanLength * glyphsPerGrab, height);
+#ifdef MAC_OSX_TK
XSetForeground(wi->dpy, xgc, black->pixel);
+#else
+ XSetForeground(wi->dpy, xgc, BlackPixelOfScreen(wi->screen));
+#endif
}
}
@@ -1352,8 +1378,10 @@ SuckGlyphsFromServer(ZnWInfo *wi,
i++;
}
+#ifdef MAC_OSX_TK
Tk_FreeColor(black);
Tk_FreeColor(white);
+#endif
XFreeGC(wi->dpy, xgc);
Tk_FreePixmap(wi->dpy, offscreen);
return;
@@ -1550,10 +1578,11 @@ ZnTexFontTex(ZnTexFontInfo tfi)
glBindTexture(GL_TEXTURE_2D, this->texobj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glGetError();
- /*printf("Demande texture de %d x %d\n", txf->tex_width, txf->tex_height);*/
+ //printf("Demande texture de %d x %d pour %s\n",
+ // txf->tex_width, txf->tex_height, ZnNameOfTexFont(tfi));
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, txf->tex_width,
txf->tex_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE,
txf->teximage);