vte r2144 - in trunk: . src
- From: behdad svn gnome org
- To: svn-commits-list gnome org
- Subject: vte r2144 - in trunk: . src
- Date: Fri, 14 Nov 2008 11:38:00 +0000 (UTC)
Author: behdad
Date: Fri Nov 14 11:37:59 2008
New Revision: 2144
URL: http://svn.gnome.org/viewvc/vte?rev=2144&view=rev
Log:
2008-11-14 Behdad Esfahbod <behdad gnome org>
* src/vte.c (vte_terminal_ensure_font):
* src/vtedraw.c (_vte_draw_new), (_vte_draw_free),
(_vte_draw_set_background_opacity),
(_vte_draw_set_background_color), (_vte_draw_set_text_font),
(_vte_draw_get_text_metrics), (_vte_draw_get_char_width),
(_vte_draw_char), (_vte_draw_draw_rectangle),
(_vte_draw_set_scroll):
* src/vtedraw.h:
* src/vteft2.c (_vte_ft2_destroy), (_vte_ft2_start),
(_vte_ft2_end), (_vte_ft2_set_background_image), (_vte_ft2_clear),
(_vte_ft2_set_text_font), (_vte_ft2_get_text_metrics),
(_vte_ft2_get_char_width), (_vte_ft2_draw_text),
(_vte_ft2_draw_has_char), (_vte_ft2_draw_rectangle),
(_vte_ft2_fill_rectangle):
* src/vtegl.c (_vte_gl_destroy), (_vte_gl_get_visual),
(_vte_gl_start), (_vte_gl_end), (_vte_gl_set_background_image),
(_vte_gl_clear), (_vte_gl_set_text_font),
(_vte_gl_get_text_metrics), (_vte_gl_get_char_width),
(_vte_gl_draw_text), (_vte_gl_draw_has_char), (_vte_gl_rectangle):
* src/vtepango.c (_vte_pango_set_text_font),
(_vte_pango_get_text_metrics):
* src/vtepangox.c (_vte_pangox_create), (_vte_pangox_destroy),
(_vte_pangox_start), (_vte_pangox_end),
(_vte_pangox_set_background_image), (_vte_pangox_clip),
(_vte_pangox_clear), (_vte_pangox_set_text_font),
(_vte_pangox_get_text_metrics), (_vte_pangox_get_using_fontconfig),
(_vte_pangox_draw_text), (_vte_pangox_draw_has_char),
(_vte_pangox_draw_rectangle), (_vte_pangox_fill_rectangle):
* src/vtepangox.h:
* src/vteskel.c (_vte_skel_clear), (_vte_skel_get_text_metrics),
(_vte_skel_draw_text), (_vte_skel_fill_rectangle):
* src/vtexft.c (_vte_xft_set_text_font),
(_vte_xft_get_text_metrics), (_vte_xft_draw_text):
Remove unneeded draw methods.
Modified:
trunk/ChangeLog
trunk/src/vte.c
trunk/src/vtedraw.c
trunk/src/vtedraw.h
trunk/src/vteft2.c
trunk/src/vtegl.c
trunk/src/vtepango.c
trunk/src/vtepangox.c
trunk/src/vtepangox.h
trunk/src/vteskel.c
trunk/src/vtexft.c
Modified: trunk/src/vte.c
==============================================================================
--- trunk/src/vte.c (original)
+++ trunk/src/vte.c Fri Nov 14 11:37:59 2008
@@ -7270,16 +7270,15 @@
terminal->pvt->fontantialias);
}
if (terminal->pvt->fontdirty) {
+ gint width, height, ascent;
terminal->pvt->fontdirty = FALSE;
_vte_draw_set_text_font (terminal->pvt->draw,
terminal->pvt->fontdesc,
terminal->pvt->fontantialias);
+ _vte_draw_get_text_metrics (terminal->pvt->draw,
+ &width, &height, &ascent);
vte_terminal_apply_metrics(terminal,
- _vte_draw_get_text_width (terminal->pvt->draw),
- _vte_draw_get_text_height (terminal->pvt->draw),
- _vte_draw_get_text_ascent (terminal->pvt->draw),
- _vte_draw_get_text_height (terminal->pvt->draw) -
- _vte_draw_get_text_ascent (terminal->pvt->draw));
+ width, height, ascent, height - ascent);
}
}
}
Modified: trunk/src/vtedraw.c
==============================================================================
--- trunk/src/vtedraw.c (original)
+++ trunk/src/vtedraw.c Fri Nov 14 11:37:59 2008
@@ -51,7 +51,7 @@
&_vte_draw_pango,
#ifndef X_DISPLAY_MISSING
#ifdef HAVE_PANGOX
- &_vte_draw_pango_x,
+ &_vte_draw_pangox,
#endif /* HAVE_PANGOX */
#endif /* !X_DISPLAY_MISSING */
};
@@ -161,7 +161,8 @@
"draw_new (%s)\n", draw->impl->name);
_vte_debug_print (VTE_DEBUG_MISC, "Using %s.\n", draw->impl->name);
- draw->impl->create (draw, draw->widget);
+ if (draw->impl->create)
+ draw->impl->create (draw, draw->widget);
return draw;
}
@@ -170,7 +171,9 @@
_vte_draw_free (struct _vte_draw *draw)
{
_vte_debug_print (VTE_DEBUG_DRAW, "draw_free\n");
- draw->impl->destroy (draw);
+
+ if (draw->impl->destroy)
+ draw->impl->destroy (draw);
if (draw->widget != NULL) {
g_object_unref (draw->widget);
@@ -247,9 +250,6 @@
{
draw->bg_opacity = opacity;
_vte_draw_update_requires_clear (draw);
-
- if (draw->impl->set_background_opacity)
- draw->impl->set_background_opacity (draw, opacity);
}
void
@@ -257,9 +257,6 @@
GdkColor *color)
{
draw->bg_color = *color;
-
- if (draw->impl->set_background_color)
- draw->impl->set_background_color (draw, color);
}
void
@@ -314,45 +311,26 @@
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias)
{
- g_return_if_fail (draw->impl->set_text_font != NULL);
-
_vte_debug_print (VTE_DEBUG_DRAW, "draw_set_text_font (aa=%d)\n",
anti_alias);
- draw->impl->set_text_font (draw, fontdesc, anti_alias);
+ if (draw->impl->set_text_font)
+ draw->impl->set_text_font (draw, fontdesc, anti_alias);
}
-int
-_vte_draw_get_text_width (struct _vte_draw *draw)
+void
+_vte_draw_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
{
- int width = 0;
+ gint swidth = 0, sheight = 0, sascent = 0;
- if (draw->impl->get_text_width)
- width = draw->impl->get_text_width (draw);
+ g_return_if_fail (draw->impl->get_text_metrics != NULL);
- return width ? width : draw->width;
-}
-
-int
-_vte_draw_get_text_height (struct _vte_draw *draw)
-{
- int height = 0;
+ draw->impl->get_text_metrics (draw, &swidth, &sheight, &sascent);
- if (draw->impl->get_text_height)
- height = draw->impl->get_text_height (draw);
-
- return height ? height : draw->height;
-}
-
-int
-_vte_draw_get_text_ascent (struct _vte_draw *draw)
-{
- int ascent = 0;
-
- if (draw->impl->get_text_ascent)
- ascent = draw->impl->get_text_ascent (draw);
-
- return ascent ? ascent : draw->ascent;
+ if (width) *width = swidth;
+ if (height) *height = sheight;
+ if (ascent) *ascent = sascent;
}
int
@@ -363,7 +341,10 @@
if (draw->impl->get_char_width)
width = draw->impl->get_char_width (draw, c, columns);
- return width ? width : _vte_draw_get_text_width (draw) * columns;
+ if (width == 0)
+ _vte_draw_get_text_metrics (draw, &width, NULL, NULL);
+
+ return width;
}
gboolean
@@ -409,21 +390,15 @@
{
gboolean has_char;
- g_return_val_if_fail (draw->started == TRUE, FALSE);
-
_vte_debug_print (VTE_DEBUG_DRAW,
"draw_char ('%c', color=(%d,%d,%d,%d))\n",
request->c,
color->red, color->green, color->blue,
alpha);
- if (draw->impl->draw_char)
- has_char = draw->impl->draw_char (draw, request, color, alpha);
- else {
- has_char =_vte_draw_has_char (draw, request->c);
- if (has_char)
- _vte_draw_text (draw, request, 1, color, alpha);
- }
+ has_char =_vte_draw_has_char (draw, request->c);
+ if (has_char)
+ _vte_draw_text (draw, request, 1, color, alpha);
return has_char;
}
@@ -463,7 +438,6 @@
GdkColor *color, guchar alpha)
{
g_return_if_fail (draw->started == TRUE);
- g_return_if_fail (draw->impl->draw_rectangle != NULL);
_vte_debug_print (VTE_DEBUG_DRAW,
"draw_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%d))\n",
@@ -471,7 +445,18 @@
color->red, color->green, color->blue,
alpha);
- draw->impl->draw_rectangle (draw, x, y, width, height, color, alpha);
+ if (draw->impl->draw_rectangle)
+ draw->impl->draw_rectangle (draw, x, y, width, height, color, alpha);
+ else {
+ if (width > 0) {
+ _vte_draw_fill_rectangle (draw, x, y, width-1, 1, color, alpha);
+ _vte_draw_fill_rectangle (draw, x+1, y+height-1, width-1, 1, color, alpha);
+ }
+ if (height > 0) {
+ _vte_draw_fill_rectangle (draw, x, y+1, 1, height-1, color, alpha);
+ _vte_draw_fill_rectangle (draw, x+width-1, y, 1, height-1, color, alpha);
+ }
+ }
}
void
@@ -483,7 +468,4 @@
draw->scrollx = x;
draw->scrolly = y;
-
- if (draw->impl->set_scroll)
- draw->impl->set_scroll (draw, x, y);
}
Modified: trunk/src/vtedraw.h
==============================================================================
--- trunk/src/vtedraw.h (original)
+++ trunk/src/vtedraw.h Fri Nov 14 11:37:59 2008
@@ -62,31 +62,24 @@
GdkColormap* (*get_colormap)(struct _vte_draw *draw);
void (*start)(struct _vte_draw *draw);
void (*end)(struct _vte_draw *draw);
- void (*set_background_opacity)(struct _vte_draw *, guint16);
- void (*set_background_color)(struct _vte_draw *, GdkColor *);
void (*set_background_image)(struct _vte_draw *,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation);
- gboolean always_requires_clear;
void (*clip)(struct _vte_draw *, GdkRegion *);
+ gboolean always_requires_clear;
void (*clear)(struct _vte_draw *, gint, gint, gint, gint);
void (*set_text_font)(struct _vte_draw *,
const PangoFontDescription *,
VteTerminalAntiAlias);
- int (*get_text_width)(struct _vte_draw *);
- int (*get_text_height)(struct _vte_draw *);
- int (*get_text_ascent)(struct _vte_draw *);
+ void (*get_text_metrics)(struct _vte_draw *, gint *, gint *, gint *);
int (*get_char_width)(struct _vte_draw *, gunichar c, int columns);
gboolean (*get_using_fontconfig)(struct _vte_draw *);
void (*draw_text)(struct _vte_draw *,
struct _vte_draw_text_request *, gsize,
GdkColor *, guchar);
- gboolean (*draw_char)(struct _vte_draw *,
- struct _vte_draw_text_request *,
- GdkColor *, guchar);
gboolean (*has_char)(struct _vte_draw *, gunichar);
void (*draw_rectangle)(struct _vte_draw *,
gint, gint, gint, gint,
@@ -94,7 +87,6 @@
void (*fill_rectangle)(struct _vte_draw *,
gint, gint, gint, gint,
GdkColor *, guchar);
- void (*set_scroll)(struct _vte_draw *, gint, gint);
};
struct _vte_draw {
@@ -112,10 +104,6 @@
const struct _vte_draw_impl *impl;
- /* impl should set these */
- gint width, height, ascent;
-
-
/* for use by impl */
gpointer impl_data;
};
@@ -158,9 +146,8 @@
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias);
/* Read font metrics. */
-int _vte_draw_get_text_width(struct _vte_draw *draw);
-int _vte_draw_get_text_height(struct _vte_draw *draw);
-int _vte_draw_get_text_ascent(struct _vte_draw *draw);
+void _vte_draw_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent);
int _vte_draw_get_char_width(struct _vte_draw *draw, gunichar c, int columns);
gboolean _vte_draw_get_using_fontconfig(struct _vte_draw *draw);
Modified: trunk/src/vteft2.c
==============================================================================
--- trunk/src/vteft2.c (original)
+++ trunk/src/vteft2.c Fri Nov 14 11:37:59 2008
@@ -52,26 +52,28 @@
static void
_vte_ft2_destroy(struct _vte_draw *draw)
{
- struct _vte_ft2_data *data;
- data = (struct _vte_ft2_data*) draw->impl_data;
+ struct _vte_ft2_data *data = draw->impl_data;
+
if (data->cache != NULL) {
_vte_glyph_cache_free(data->cache);
}
+
if (data->rgb != NULL) {
_vte_rgb_buffer_free(data->rgb);
}
+
if (data->pixbuf != NULL) {
g_object_unref(data->pixbuf);
}
+
g_slice_free(struct _vte_ft2_data, data);
}
static void
_vte_ft2_start(struct _vte_draw *draw)
{
- struct _vte_ft2_data *data;
+ struct _vte_ft2_data *data = draw->impl_data;
guint width, height;
- data = (struct _vte_ft2_data*) draw->impl_data;
width = draw->widget->allocation.width;
height = draw->widget->allocation.height;
@@ -87,10 +89,10 @@
static void
_vte_ft2_end(struct _vte_draw *draw)
{
- struct _vte_ft2_data *data;
+ struct _vte_ft2_data *data = draw->impl_data;
GtkWidget *widget;
GtkStateType state;
- data = (struct _vte_ft2_data*) draw->impl_data;
+
widget = draw->widget;
state = GTK_WIDGET_STATE(widget);
if (data->right < data->left) {
@@ -110,6 +112,7 @@
data->rgb,
data->left, data->top);
}
+
gdk_gc_set_clip_region(widget->style->fg_gc[state], NULL);
}
@@ -121,14 +124,12 @@
const GdkColor *color,
double saturation)
{
- struct _vte_ft2_data *data;
+ struct _vte_ft2_data *data = draw->impl_data;
GdkPixbuf *bgpixbuf;
GdkScreen *screen;
screen = gtk_widget_get_screen(draw->widget);
- data = (struct _vte_ft2_data*) draw->impl_data;
-
bgpixbuf = vte_bg_get_pixbuf(vte_bg_get_for_screen(screen),
type, pixbuf, file,
color, saturation);
@@ -162,8 +163,7 @@
_vte_ft2_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height)
{
- struct _vte_ft2_data *data;
- data = (struct _vte_ft2_data*) draw->impl_data;
+ struct _vte_ft2_data *data = draw->impl_data;
if (data->pixbuf != NULL) {
/* Tile a pixbuf in. */
@@ -183,9 +183,7 @@
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias)
{
- struct _vte_ft2_data *data;
-
- data = (struct _vte_ft2_data*) draw->impl_data;
+ struct _vte_ft2_data *data = draw->impl_data;
if (data->cache != NULL) {
_vte_glyph_cache_free(data->cache);
@@ -201,38 +199,23 @@
data->cache->ascent);
}
-static int
-_vte_ft2_get_text_width(struct _vte_draw *draw)
-{
- struct _vte_ft2_data *data;
- data = (struct _vte_ft2_data*) draw->impl_data;
- return data->cache->width;
-}
-
-static int
-_vte_ft2_get_text_height(struct _vte_draw *draw)
-{
- struct _vte_ft2_data *data;
- data = (struct _vte_ft2_data*) draw->impl_data;
- return data->cache->height;
-}
-
-static int
-_vte_ft2_get_text_ascent(struct _vte_draw *draw)
+static void
+_vte_ft2_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
{
- struct _vte_ft2_data *data;
- data = (struct _vte_ft2_data*) draw->impl_data;
- return data->cache->ascent;
+ struct _vte_ft2_data *data = draw->impl_data;
+
+ *width = data->cache->width;
+ *height = data->cache->height;
+ *ascent = data->cache->ascent;
}
static int
_vte_ft2_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
- struct _vte_ft2_data *data;
+ struct _vte_ft2_data *data = draw->impl_data;
const struct _vte_glyph *glyph;
- data = (struct _vte_ft2_data*) draw->impl_data;
-
glyph = _vte_glyph_get(data->cache, c);
if (glyph == NULL)
return 0;
@@ -251,11 +234,9 @@
struct _vte_draw_text_request *requests, gsize n_requests,
GdkColor *color, guchar alpha)
{
- struct _vte_ft2_data *data;
+ struct _vte_ft2_data *data = draw->impl_data;
gsize i, j;
- data = (struct _vte_ft2_data*) draw->impl_data;
-
for (i = 0; i < n_requests; i++) {
if (requests[i].c == (gunichar)-1 ||
requests[i].c == 32 /* space */)
@@ -286,9 +267,7 @@
static gboolean
_vte_ft2_draw_has_char(struct _vte_draw *draw, gunichar c)
{
- struct _vte_ft2_data *data;
-
- data = (struct _vte_ft2_data*) draw->impl_data;
+ struct _vte_ft2_data *data = draw->impl_data;
if (data->cache != NULL) {
if (_vte_glyph_get(data->cache, c) != NULL) {
@@ -303,9 +282,7 @@
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha)
{
- struct _vte_ft2_data *data;
-
- data = (struct _vte_ft2_data*) draw->impl_data;
+ struct _vte_ft2_data *data = draw->impl_data;
_vte_rgb_draw_color(data->rgb,
x, y,
@@ -331,9 +308,7 @@
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha)
{
- struct _vte_ft2_data *data;
-
- data = (struct _vte_ft2_data*) draw->impl_data;
+ struct _vte_ft2_data *data = draw->impl_data;
_vte_rgb_draw_color(data->rgb, x, y, width, height, color);
update_bbox(data, x, y, width, height);
@@ -348,22 +323,16 @@
NULL, /* get_colormap */
_vte_ft2_start,
_vte_ft2_end,
- NULL, /* set_background_opacity */
- NULL, /* set_background_color */
_vte_ft2_set_background_image,
- FALSE, /* always_require_clear */
_vte_ft2_clip,
+ FALSE, /* always_requires_clear */
_vte_ft2_clear,
_vte_ft2_set_text_font,
- _vte_ft2_get_text_width,
- _vte_ft2_get_text_height,
- _vte_ft2_get_text_ascent,
+ _vte_ft2_get_text_metrics,
_vte_ft2_get_char_width,
_vte_ft2_get_using_fontconfig,
_vte_ft2_draw_text,
- NULL, /* draw_char */
_vte_ft2_draw_has_char,
_vte_ft2_draw_rectangle,
- _vte_ft2_fill_rectangle,
- NULL /* set_scroll */
+ _vte_ft2_fill_rectangle
};
Modified: trunk/src/vtegl.c
==============================================================================
--- trunk/src/vtegl.c (original)
+++ trunk/src/vtegl.c Fri Nov 14 11:37:59 2008
@@ -150,9 +150,7 @@
static void
_vte_gl_destroy(struct _vte_draw *draw)
{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
+ struct _vte_gl_data *data = draw->impl_data;
_vte_buffer_free(data->buffer);
@@ -172,10 +170,9 @@
static GdkVisual *
_vte_gl_get_visual(struct _vte_draw *draw)
{
+ struct _vte_gl_data *data = draw->impl_data;
GdkScreen *gscreen;
- struct _vte_gl_data *data;
- data = (struct _vte_gl_data*) draw->impl_data;
gscreen = gdk_screen_get_default();
#ifdef VTE_DEBUG
g_print("Using GLX-capable visual 0x%02lx.\n",
@@ -194,11 +191,9 @@
static void
_vte_gl_start(struct _vte_draw *draw)
{
- struct _vte_gl_data *data;
+ struct _vte_gl_data *data = draw->impl_data;
gint width, height;
- data = (struct _vte_gl_data*) draw->impl_data;
-
data->glwindow = gdk_x11_drawable_get_xid(draw->widget->window);
width = draw->widget->allocation.width;
height = draw->widget->allocation.height;
@@ -215,9 +210,7 @@
static void
_vte_gl_end(struct _vte_draw *draw)
{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
+ struct _vte_gl_data *data = draw->impl_data;
glXMakeCurrent(data->display, data->glwindow, data->context);
glXSwapBuffers(data->display, data->glwindow);
@@ -233,13 +226,12 @@
const GdkColor *tint,
double saturation)
{
- struct _vte_gl_data *data;
+ struct _vte_gl_data *data = draw->impl_data;
GdkPixbuf *bgpixbuf;
GdkScreen *screen;
screen = gtk_widget_get_screen(draw->widget);
- data = (struct _vte_gl_data*) draw->impl_data;
bgpixbuf = vte_bg_get_pixbuf(vte_bg_get_for_screen(screen),
type, pixbuf, file,
tint, saturation);
@@ -252,14 +244,12 @@
static void
_vte_gl_clear(struct _vte_draw *draw, gint x, gint y, gint width, gint height)
{
- struct _vte_gl_data *data;
+ struct _vte_gl_data *data = draw->impl_data;
long xstop, ystop, i, j;
int pixbufw, pixbufh, w, h, channels, stride;
GLenum format = 0;
guchar *pixels;
- data = (struct _vte_gl_data*) draw->impl_data;
-
glXMakeCurrent(data->display, data->glwindow, data->context);
if (data->bgpixbuf != NULL) {
@@ -343,9 +333,8 @@
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
- struct _vte_gl_data *data;
+ struct _vte_gl_data *data = draw->impl_data;
- data = (struct _vte_gl_data*) draw->impl_data;
if (data->cache != NULL) {
_vte_glyph_cache_free(data->cache);
data->cache = NULL;
@@ -359,41 +348,23 @@
NULL);
}
-static int
-_vte_gl_get_text_width(struct _vte_draw *draw)
-{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
- return data->cache->width;
-}
-
-static int
-_vte_gl_get_text_height(struct _vte_draw *draw)
-{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
- return data->cache->height;
-}
-
-static int
-_vte_gl_get_text_ascent(struct _vte_draw *draw)
+static void
+_vte_gl_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
- return data->cache->ascent;
+ struct _vte_gl_data *data = draw->impl_data;
+
+ *width = data->cache->width;
+ *height = data->cache->height;
+ *ascent = data->cache->ascent;
}
static int
_vte_gl_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
{
- struct _vte_gl_data *data;
+ struct _vte_gl_data *data = draw->impl_data;
const struct _vte_glyph *glyph;
- data = (struct _vte_gl_data*) draw->impl_data;
-
glyph = _vte_glyph_get(data->cache, c);
if (glyph == NULL)
return 0;
@@ -406,15 +377,13 @@
struct _vte_draw_text_request *requests, gsize n_requests,
GdkColor *color, guchar alpha)
{
- struct _vte_gl_data *data;
+ struct _vte_gl_data *data = draw->impl_data;
const struct _vte_glyph *glyph;
guint16 a, r, g, b;
guint i, j;
int k, x, y, w, pad, rows, columns, src, dest;
guchar *pixels;
- data = (struct _vte_gl_data*) draw->impl_data;
-
glXMakeCurrent(data->display, data->glwindow, data->context);
r = color->red >> 8;
@@ -481,9 +450,7 @@
static gboolean
_vte_gl_draw_has_char(struct _vte_draw *draw, gunichar c)
{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
+ struct _vte_gl_data *data = draw->impl_data;
if (data->cache != NULL) {
if (_vte_glyph_get(data->cache, c) != NULL) {
@@ -499,9 +466,7 @@
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha)
{
- struct _vte_gl_data *data;
-
- data = (struct _vte_gl_data*) draw->impl_data;
+ struct _vte_gl_data *data = draw->impl_data;
glXMakeCurrent(data->display, data->glwindow, data->context);
@@ -542,24 +507,18 @@
_vte_gl_get_colormap,
_vte_gl_start,
_vte_gl_end,
- NULL, /* set_background_opacity */
- NULL, /* set_background_color */
_vte_gl_set_background_image,
- TRUE, /* always_requires_clear */
NULL, /* clip */
+ TRUE, /* always_requires_clear */
_vte_gl_clear,
_vte_gl_set_text_font,
- _vte_gl_get_text_width,
- _vte_gl_get_text_height,
- _vte_gl_get_text_ascent,
+ _vte_gl_get_text_metrics,
_vte_gl_get_char_width,
NULL, /* get_using_fontconfig */
_vte_gl_draw_text,
- NULL, /* draw_char */
_vte_gl_draw_has_char,
_vte_gl_draw_rectangle,
- _vte_gl_fill_rectangle,
- NULL /* set_scroll */
+ _vte_gl_fill_rectangle
};
#endif
Modified: trunk/src/vtepango.c
==============================================================================
--- trunk/src/vtepango.c (original)
+++ trunk/src/vtepango.c Fri Nov 14 11:37:59 2008
@@ -38,6 +38,7 @@
PangoFontDescription *font;
PangoLayout *layout;
GdkGC *gc;
+ gint width, height, ascent;
};
static void
@@ -225,16 +226,16 @@
VTE_DRAW_SINGLE_WIDE_CHARACTERS,
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS));
pango_layout_get_extents(layout, &ink, &logical);
- draw->width = logical.width;
- draw->width = howmany(draw->width,
+ data->width = logical.width;
+ data->width = howmany(data->width,
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS));
iter = pango_layout_get_iter(layout);
- draw->height = PANGO_PIXELS(logical.height);
- draw->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
+ data->height = PANGO_PIXELS(logical.height);
+ data->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
pango_layout_iter_free(iter);
/* Estimate for CJK characters. */
- full_width = draw->width * 2;
+ full_width = data->width * 2;
full_string = g_string_new(NULL);
for (i = 0; i < G_N_ELEMENTS(full_codepoints); i++) {
g_string_append_unichar(full_string, full_codepoints[i]);
@@ -245,29 +246,40 @@
g_string_free(full_string, TRUE);
/* If they're the same, then we have a screwy font. */
- if (full_width == draw->width) {
+ if (full_width == data->width) {
/* add 1 to round up when dividing by 2 */
- draw->width = (draw->width + 1) / 2;
+ data->width = (data->width + 1) / 2;
}
- draw->width = PANGO_PIXELS(draw->width);
+ data->width = PANGO_PIXELS(data->width);
iter = pango_layout_get_iter(layout);
- if (draw->height == 0) {
- draw->height = PANGO_PIXELS(logical.height);
+ if (data->height == 0) {
+ data->height = PANGO_PIXELS(logical.height);
}
- if (draw->ascent == 0) {
- draw->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
+ if (data->ascent == 0) {
+ data->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
}
pango_layout_iter_free(iter);
_vte_debug_print(VTE_DEBUG_MISC,
"VtePango font metrics = %dx%d (%d).\n",
- draw->width, draw->height, draw->ascent);
+ data->width, data->height, data->ascent);
g_object_unref(layout);
}
static void
+_vte_pango_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
+{
+ struct _vte_pango_data *data = draw->impl_data;
+
+ *width = data->width;
+ *height = data->height;
+ *ascent = data->ascent;
+}
+
+static void
_vte_pango_draw_text(struct _vte_draw *draw,
struct _vte_draw_text_request *requests, gsize n_requests,
GdkColor *color, guchar alpha)
@@ -352,22 +364,16 @@
NULL, /* get_colormap */
_vte_pango_start,
_vte_pango_end,
- NULL, /* set_background_opacity */
- NULL, /* set_background_color */
_vte_pango_set_background_image,
- FALSE, /* always_requires_clear */
_vte_pango_clip,
+ FALSE, /* always_requires_clear */
_vte_pango_clear,
_vte_pango_set_text_font,
- NULL, /* get_text_width */
- NULL, /* get_text_height */
- NULL, /* get_text_ascent */
+ _vte_pango_get_text_metrics,
NULL, /* get_char_width */
NULL, /* get_using_fontconfig */
_vte_pango_draw_text,
- NULL, /* draw_char */
_vte_pango_draw_has_char,
_vte_pango_draw_rectangle,
- _vte_pango_fill_rectangle,
- NULL /* set_scroll */
+ _vte_pango_fill_rectangle
};
Modified: trunk/src/vtepangox.c
==============================================================================
--- trunk/src/vtepangox.c (original)
+++ trunk/src/vtepangox.c Fri Nov 14 11:37:59 2008
@@ -34,7 +34,7 @@
#include "vtedraw.h"
#include "vtepangox.h"
-struct _vte_pango_x_data
+struct _vte_pangox_data
{
GdkPixmap *pixmap;
gint pixmapw, pixmaph;
@@ -44,15 +44,16 @@
PangoContext *ctx;
Drawable drawable;
int x_offs, y_offs;
+ gint width, height, ascent;
};
static void
-_vte_pango_x_create(struct _vte_draw *draw, GtkWidget *widget)
+_vte_pangox_create(struct _vte_draw *draw, GtkWidget *widget)
{
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
- draw->impl_data = g_slice_new(struct _vte_pango_x_data);
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ draw->impl_data = g_slice_new(struct _vte_pangox_data);
+ data = (struct _vte_pangox_data*) draw->impl_data;
data->pixmap = NULL;
data->pixmapw = data->pixmaph = 0;
@@ -63,10 +64,10 @@
}
static void
-_vte_pango_x_destroy(struct _vte_draw *draw)
+_vte_pangox_destroy(struct _vte_draw *draw)
{
- struct _vte_pango_x_data *data;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ struct _vte_pangox_data *data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
if (data->pixmap != NULL) {
g_object_unref(data->pixmap);
@@ -84,18 +85,18 @@
g_object_unref(data->ctx);
}
- g_slice_free(struct _vte_pango_x_data, draw->impl_data);
+ g_slice_free(struct _vte_pangox_data, draw->impl_data);
}
static void
-_vte_pango_x_start(struct _vte_draw *draw)
+_vte_pangox_start(struct _vte_draw *draw)
{
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
Display *display;
GdkDrawable *drawable;
int x_offs, y_offs;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
display = gdk_x11_drawable_get_xdisplay(draw->widget->window);
if (data->ctx != NULL) {
@@ -128,10 +129,10 @@
}
static void
-_vte_pango_x_end(struct _vte_draw *draw)
+_vte_pangox_end(struct _vte_draw *draw)
{
- struct _vte_pango_x_data *data;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ struct _vte_pangox_data *data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
data->drawable = -1;
data->x_offs = 0;
@@ -154,7 +155,7 @@
}
static void
-_vte_pango_x_set_background_image(struct _vte_draw *draw,
+_vte_pangox_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
@@ -162,12 +163,12 @@
double saturation)
{
GdkPixmap *pixmap;
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
GdkScreen *screen;
screen = gtk_widget_get_screen (draw->widget);
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
pixmap = vte_bg_get_pixmap(vte_bg_get_for_screen(screen),
type, pixbuf, file,
color, saturation,
@@ -187,20 +188,20 @@
}
static void
-_vte_pango_x_clip(struct _vte_draw *draw, GdkRegion *region)
+_vte_pangox_clip(struct _vte_draw *draw, GdkRegion *region)
{
- struct _vte_pango_x_data *data = draw->impl_data;
+ struct _vte_pangox_data *data = draw->impl_data;
gdk_gc_set_clip_region(data->gc, region);
}
static void
-_vte_pango_x_clear(struct _vte_draw *draw,
+_vte_pangox_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height)
{
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
gint i, j, h, w, xstop, ystop;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
if ((data->pixmap == NULL) ||
(data->pixmapw == 0) ||
@@ -240,7 +241,7 @@
}
static void
-_vte_pango_x_set_text_font(struct _vte_draw *draw,
+_vte_pangox_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
@@ -253,9 +254,9 @@
GString *full_string;
gint full_width;
guint i;
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
display = gdk_x11_display_get_xdisplay(gtk_widget_get_display(draw->widget));
if (data->ctx != NULL) {
@@ -275,12 +276,12 @@
VTE_DRAW_SINGLE_WIDE_CHARACTERS,
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS));
pango_layout_get_extents(layout, &ink, &logical);
- draw->width = logical.width;
- draw->width = howmany(draw->width,
+ data->width = logical.width;
+ data->width = howmany(data->width,
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS));
iter = pango_layout_get_iter(layout);
- draw->height = PANGO_PIXELS(logical.height);
- draw->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
+ data->height = PANGO_PIXELS(logical.height);
+ data->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
pango_layout_iter_free(iter);
/* Estimate for CJK characters. */
@@ -294,48 +295,59 @@
g_string_free(full_string, TRUE);
/* If they're the same, then we have a screwy font. */
- if (full_width == draw->width) {
+ if (full_width == data->width) {
/* add 1 to round up when dividing by 2 */
- draw->width = (draw->width + 1) / 2;
+ data->width = (data->width + 1) / 2;
}
- draw->width = PANGO_PIXELS(draw->width);
+ data->width = PANGO_PIXELS(data->width);
iter = pango_layout_get_iter(layout);
- if (draw->height == 0) {
- draw->height = PANGO_PIXELS(logical.height);
+ if (data->height == 0) {
+ data->height = PANGO_PIXELS(logical.height);
}
- if (draw->ascent == 0) {
- draw->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
+ if (data->ascent == 0) {
+ data->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
}
pango_layout_iter_free(iter);
_vte_debug_print(VTE_DEBUG_MISC,
"VtePangoX font metrics = %dx%d (%d).\n",
- draw->width, draw->height, draw->ascent);
+ data->width, data->height, data->ascent);
g_object_unref(layout);
g_object_unref(ctx);
}
+static void
+_vte_pangox_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
+{
+ struct _vte_pangox_data *data = draw->impl_data;
+
+ *width = data->width;
+ *height = data->height;
+ *ascent = data->ascent;
+}
+
static gboolean
-_vte_pango_x_get_using_fontconfig(struct _vte_draw *draw)
+_vte_pangox_get_using_fontconfig(struct _vte_draw *draw)
{
return FALSE;
}
static void
-_vte_pango_x_draw_text(struct _vte_draw *draw,
+_vte_pangox_draw_text(struct _vte_draw *draw,
struct _vte_draw_text_request *requests,
gsize n_requests,
GdkColor *color, guchar alpha)
{
Display *display;
GC gc;
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
char buf[VTE_UTF8_BPC];
gsize i, length;
GdkColor wcolor;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
wcolor = *color;
gdk_rgb_find_color(gdk_drawable_get_colormap(draw->widget->window),
@@ -357,21 +369,21 @@
}
static gboolean
-_vte_pango_x_draw_has_char(struct _vte_draw *draw, gunichar c)
+_vte_pangox_draw_has_char(struct _vte_draw *draw, gunichar c)
{
return FALSE;
}
static void
-_vte_pango_x_draw_rectangle(struct _vte_draw *draw,
+_vte_pangox_draw_rectangle(struct _vte_draw *draw,
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha)
{
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
GdkColor wcolor;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
wcolor = *color;
gdk_rgb_find_color(gdk_drawable_get_colormap(draw->widget->window),
@@ -383,14 +395,14 @@
}
static void
-_vte_pango_x_fill_rectangle(struct _vte_draw *draw,
+_vte_pangox_fill_rectangle(struct _vte_draw *draw,
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha)
{
- struct _vte_pango_x_data *data;
+ struct _vte_pangox_data *data;
GdkColor wcolor;
- data = (struct _vte_pango_x_data*) draw->impl_data;
+ data = (struct _vte_pangox_data*) draw->impl_data;
wcolor = *color;
gdk_rgb_find_color(gdk_drawable_get_colormap(draw->widget->window),
&wcolor);
@@ -399,33 +411,27 @@
x, y, width, height);
}
-const struct _vte_draw_impl _vte_draw_pango_x = {
+const struct _vte_draw_impl _vte_draw_pangox = {
"pangox",
NULL, /* check */
- _vte_pango_x_create,
- _vte_pango_x_destroy,
+ _vte_pangox_create,
+ _vte_pangox_destroy,
NULL, /* get_visual */
NULL, /* get_colormap */
- _vte_pango_x_start,
- _vte_pango_x_end,
- NULL, /* set_background_opacity */
- NULL, /* set_background_color */
- _vte_pango_x_set_background_image,
+ _vte_pangox_start,
+ _vte_pangox_end,
+ _vte_pangox_set_background_image,
+ _vte_pangox_clip,
FALSE, /* always_requires_clear */
- _vte_pango_x_clip,
- _vte_pango_x_clear,
- _vte_pango_x_set_text_font,
- NULL, /* get_text_width */
- NULL, /* get_text_height */
- NULL, /* get_text_ascent */
+ _vte_pangox_clear,
+ _vte_pangox_set_text_font,
+ _vte_pangox_get_text_metrics,
NULL, /* get_char_width */
- _vte_pango_x_get_using_fontconfig,
- _vte_pango_x_draw_text,
- NULL, /* draw_char */
- _vte_pango_x_draw_has_char,
- _vte_pango_x_draw_rectangle,
- _vte_pango_x_fill_rectangle,
- NULL /* set_scroll */
+ _vte_pangox_get_using_fontconfig,
+ _vte_pangox_draw_text,
+ _vte_pangox_draw_has_char,
+ _vte_pangox_draw_rectangle,
+ _vte_pangox_fill_rectangle
};
#endif
Modified: trunk/src/vtepangox.h
==============================================================================
--- trunk/src/vtepangox.h (original)
+++ trunk/src/vtepangox.h Fri Nov 14 11:37:59 2008
@@ -26,7 +26,7 @@
G_BEGIN_DECLS
-extern const struct _vte_draw_impl _vte_draw_pango_x;
+extern const struct _vte_draw_impl _vte_draw_pangox;
G_END_DECLS
Modified: trunk/src/vteskel.c
==============================================================================
--- trunk/src/vteskel.c (original)
+++ trunk/src/vteskel.c Fri Nov 14 11:37:59 2008
@@ -27,127 +27,19 @@
#include "vtebg.h"
#include "vtedraw.h"
-struct _vte_skel_data
-{
- GdkColor color;
- guint16 opacity;
- gint scrollx, scrolly;
-};
-
-static gboolean
-_vte_skel_check(struct _vte_draw *draw, GtkWidget *widget)
-{
- return TRUE; /* null output; useful for testing */
-}
-
-static void
-_vte_skel_create(struct _vte_draw *draw, GtkWidget *widget)
-{
- draw->impl_data = g_slice_new0(struct _vte_skel_data);
-}
-
-static void
-_vte_skel_destroy(struct _vte_draw *draw)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-
- g_slice_free(struct _vte_skel_data, draw->impl_data);
-}
-
-static GdkVisual *
-_vte_skel_get_visual(struct _vte_draw *draw)
-{
- return gtk_widget_get_visual(draw->widget);
-}
-
-static GdkColormap *
-_vte_skel_get_colormap(struct _vte_draw *draw)
-{
- return gtk_widget_get_colormap(draw->widget);
-}
-
-static void
-_vte_skel_start(struct _vte_draw *draw)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
-static void
-_vte_skel_end(struct _vte_draw *draw)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
-static void
-_vte_skel_set_background_color(struct _vte_draw *draw, GdkColor *color, guint16 opacity)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
- data->color = *color;
- data->opacity = opacity;
-}
-
-static void
-_vte_skel_set_background_image(struct _vte_draw *draw,
- enum VteBgSourceType type,
- GdkPixbuf *pixbuf,
- const char *filename,
- const GdkColor *tint,
- double saturation)
-{
- struct _vte_skel_data *data;
-
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
static void
_vte_skel_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height)
{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
-static void
-_vte_skel_set_text_font(struct _vte_draw *draw,
- const PangoFontDescription *fontdesc,
- VteTerminalAntiAlias antialias)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
-static int
-_vte_skel_get_text_width(struct _vte_draw *draw)
-{
- return draw->width;
-}
-
-static int
-_vte_skel_get_text_height(struct _vte_draw *draw)
-{
- return draw->height;
-}
-
-static int
-_vte_skel_get_text_ascent(struct _vte_draw *draw)
-{
- return draw->ascent;
-}
-
-static int
-_vte_skel_get_char_width(struct _vte_draw *draw, gunichar c, int columns)
-{
- return _vte_skel_get_text_width(draw) * columns;
+ g_message ("_vte_skel_clear: %d,%d+%d,%d",
+ x, y, width, height);
}
-static gboolean
-_vte_skel_get_using_fontconfig(struct _vte_draw *draw)
+void
+_vte_skel_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
{
- return FALSE;
+ g_message ("_vte_skel_get_text_metrics");
}
static void
@@ -155,33 +47,8 @@
struct _vte_draw_text_request *requests, gsize n_requests,
GdkColor *color, guchar alpha)
{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
-static gboolean
-_vte_skel_draw_char(struct _vte_draw *draw,
- struct _vte_draw_text_request *request,
- GdkColor *color, guchar alpha)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
- return FALSE;
-}
-
-static gboolean
-_vte_skel_draw_has_char(struct _vte_draw *draw, gunichar c)
-{
- return FALSE;
-}
-
-static void
-_vte_skel_draw_rectangle(struct _vte_draw *draw,
- gint x, gint y, gint width, gint height,
- GdkColor *color, guchar alpha)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
+ g_message ("_vte_skel_draw_text: %d chars",
+ n_requests);
}
static void
@@ -189,43 +56,29 @@
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha)
{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
-}
-
-static void
-_vte_skel_set_scroll(struct _vte_draw *draw, gint x, gint y)
-{
- struct _vte_skel_data *data;
- data = (struct _vte_skel_data*) draw->impl_data;
- data->scrollx = x;
- data->scrolly = y;
+ g_message ("_vte_skel_fill_rectangle: %d,%d+%d,%d",
+ x, y, width, height);
}
const struct _vte_draw_impl _vte_draw_skel = {
"null",
- _vte_skel_check,
- _vte_skel_create,
- _vte_skel_destroy,
- _vte_skel_get_visual,
- _vte_skel_get_colormap,
- _vte_skel_start,
- _vte_skel_end,
- _vte_skel_set_background_color,
- _vte_skel_set_background_image,
- TRUE,
- NULL,
+ NULL, /* check */
+ NULL, /* create */
+ NULL, /* destroy */
+ NULL, /* get_visual */
+ NULL, /* get_colormap */
+ NULL, /* start */
+ NULL, /* end */
+ NULL, /* set_background_image */
+ NULL, /* clip */
+ TRUE, /* always_requires_clear */
_vte_skel_clear,
- _vte_skel_set_text_font,
- _vte_skel_get_text_width,
- _vte_skel_get_text_height,
- _vte_skel_get_text_ascent,
- _vte_skel_get_char_width,
- _vte_skel_get_using_fontconfig,
+ NULL, /* set_text_font */
+ _vte_skel_get_text_metrics,
+ NULL, /* get_char_width */
+ NULL, /* get_using_fontconfig */
_vte_skel_draw_text,
- _vte_skel_draw_char,
- _vte_skel_draw_has_char,
- _vte_skel_draw_rectangle,
- _vte_skel_fill_rectangle,
- _vte_skel_set_scroll,
+ NULL, /* draw_has_char */
+ NULL, /* draw_rectangle */
+ _vte_skel_fill_rectangle
};
Modified: trunk/src/vtexft.c
==============================================================================
--- trunk/src/vtexft.c (original)
+++ trunk/src/vtexft.c Fri Nov 14 11:37:59 2008
@@ -619,11 +619,7 @@
data->locked_fonts[0] = ptr_array_zeroed_new (1 + data->font->patterns->len);
data->locked_fonts[1] = ptr_array_zeroed_new (1 + data->font->patterns->len);
- if (data->font->have_metrics) {
- draw->width = data->font->width;
- draw->height = data->font->height;
- draw->ascent = data->font->ascent;
- } else {
+ if (!data->font->have_metrics) {
XftFont *font, *prev_font;
XGlyphInfo extents;
gunichar wide_chars[] = {VTE_DRAW_DOUBLE_WIDE_CHARACTERS};
@@ -632,9 +628,9 @@
FcChar32 c;
GPtrArray *locked_fonts;
- draw->width = 1;
- draw->height = 1;
- draw->ascent = 1;
+ data->font->width = 1;
+ data->font->height = 1;
+ data->font->ascent = 1;
locked_fonts = data->locked_fonts [data->cur_locked_fonts&1];
@@ -662,10 +658,10 @@
}
}
if (n > 0) {
- draw->width = howmany (width, n);
- draw->height = (font != NULL) ?
+ data->font->width = howmany (width, n);
+ data->font->height = (font != NULL) ?
font->ascent + font->descent : height;
- draw->ascent = (font != NULL) ?
+ data->font->ascent = (font != NULL) ?
font->ascent : height;
}
/* Estimate a typical cell width by looking at double-width
@@ -679,10 +675,10 @@
if (font != NULL) {
if (n && prev_font != font) {/* font change */
width = howmany (width, n);
- if (width >= draw->width -1 &&
- width <= draw->width + 1){
+ if (width >= data->font->width -1 &&
+ width <= data->font->width + 1){
/* add 1 to round up when dividing by 2 */
- draw->width = (draw->width + 1) / 2;
+ data->font->width = (data->font->width + 1) / 2;
break;
}
n = width = 0;
@@ -696,28 +692,36 @@
}
if (n > 0) {
width = howmany (width, n);
- if (width >= draw->width -1 &&
- width <= draw->width + 1){
+ if (width >= data->font->width -1 &&
+ width <= data->font->width + 1){
/* add 1 to round up when dividing by 2 */
- draw->width = (draw->width + 1) / 2;
+ data->font->width = (data->font->width + 1) / 2;
}
}
gdk_error_trap_pop ();
- data->font->width = draw->width;
- data->font->height = draw->height;
- data->font->ascent = draw->ascent;
data->font->have_metrics = TRUE;
_vte_debug_print (VTE_DEBUG_MISC,
"VteXft font metrics = %dx%d (%d),"
" width range [%d, %d].\n",
- draw->width, draw->height, draw->ascent,
+ data->font->width, data->font->height, data->font->ascent,
min, max);
}
}
+static void
+_vte_xft_get_text_metrics(struct _vte_draw *draw,
+ gint *width, gint *height, gint *ascent)
+{
+ struct _vte_xft_data *data = draw->impl_data;
+
+ *width = data->font->width;
+ *height = data->font->height;
+ *ascent = data->font->ascent;
+}
+
static int
_vte_xft_get_char_width (struct _vte_draw *draw, gunichar c, int columns)
{
@@ -789,8 +793,8 @@
* font, to work around a bug which appears to be in Xft and which I
* haven't pinned down yet." */
x_off = -data->x_offs;
- y_off = draw->ascent - data->y_offs;
- char_width = draw->width;
+ y_off = data->font->ascent - data->y_offs;
+ char_width = data->font->width;
do {
j = 0;
do {
@@ -934,22 +938,16 @@
NULL, /* get_colormap */
_vte_xft_start,
_vte_xft_end,
- NULL, /* set_background_opacity */
- NULL, /* set_background_color */
_vte_xft_set_background_image,
- FALSE, /* always_requires_clear */
_vte_xft_clip,
+ FALSE, /* always_requires_clear */
_vte_xft_clear,
_vte_xft_set_text_font,
- NULL, /* get_text_width */
- NULL, /* get_text_height */
- NULL, /* get_text_ascent */
+ _vte_xft_get_text_metrics,
_vte_xft_get_char_width,
NULL, /* get_using_fontconfig */
_vte_xft_draw_text,
- NULL, /* draw_char */
_vte_xft_draw_has_char,
_vte_xft_draw_rectangle,
- _vte_xft_fill_rectangle,
- NULL /* set_scroll */
+ _vte_xft_fill_rectangle
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]