Instead of drawing a background pixmap in with gdk_draw_pixmap(), set it
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing a background pixmap in with gdk_draw_pixmap(), set it as a tile pixmap for a GC. This should speed up things considerably and also will hide a bug where text->first_onscreen_ver_pixel is being corrupted, causing the bg pixmap drawing code to generate graphics exposes.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 20 13:06:51 1999 Owen Taylor <otaylor@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtktext.[ch] (clear_[focus_]area): Instead of drawing
|
||||||
|
a background pixmap in with gdk_draw_pixmap(), set
|
||||||
|
it as a tile pixmap for a GC. This should speed
|
||||||
|
up things considerably and also will hide a bug
|
||||||
|
where text->first_onscreen_ver_pixel is being
|
||||||
|
corrupted, causing the bg pixmap drawing code to generate
|
||||||
|
graphics exposes.
|
||||||
|
|
||||||
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
Tue Jan 19 22:15:10 1999 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtklist.c
|
* gtk/gtklist.c
|
||||||
|
|||||||
108
gtk/gtktext.c
108
gtk/gtktext.c
@ -296,6 +296,7 @@ static void delete_expose (GtkText* text,
|
|||||||
guint nchars,
|
guint nchars,
|
||||||
guint old_lines,
|
guint old_lines,
|
||||||
guint old_pixels);
|
guint old_pixels);
|
||||||
|
static GdkGC *create_bg_gc (GtkText *text);
|
||||||
static void clear_area (GtkText *text, GdkRectangle *area);
|
static void clear_area (GtkText *text, GdkRectangle *area);
|
||||||
static void draw_line (GtkText* text,
|
static void draw_line (GtkText* text,
|
||||||
gint pixel_height,
|
gint pixel_height,
|
||||||
@ -669,6 +670,7 @@ gtk_text_init (GtkText *text)
|
|||||||
text->hadj = NULL;
|
text->hadj = NULL;
|
||||||
text->vadj = NULL;
|
text->vadj = NULL;
|
||||||
text->gc = NULL;
|
text->gc = NULL;
|
||||||
|
text->bg_gc = NULL;
|
||||||
text->line_wrap_bitmap = NULL;
|
text->line_wrap_bitmap = NULL;
|
||||||
text->line_arrow_bitmap = NULL;
|
text->line_arrow_bitmap = NULL;
|
||||||
|
|
||||||
@ -1303,6 +1305,9 @@ gtk_text_realize (GtkWidget *widget)
|
|||||||
gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
|
gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
|
||||||
gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]);
|
gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]);
|
||||||
|
|
||||||
|
if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
|
||||||
|
text->bg_gc = create_bg_gc (text);
|
||||||
|
|
||||||
text->line_wrap_bitmap = gdk_bitmap_create_from_data (text->text_area,
|
text->line_wrap_bitmap = gdk_bitmap_create_from_data (text->text_area,
|
||||||
(gchar*) line_wrap_bits,
|
(gchar*) line_wrap_bits,
|
||||||
line_wrap_width,
|
line_wrap_width,
|
||||||
@ -1407,6 +1412,15 @@ gtk_text_style_set (GtkWidget *widget,
|
|||||||
gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
|
gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
|
||||||
gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]);
|
gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]);
|
||||||
|
|
||||||
|
if (text->bg_gc)
|
||||||
|
{
|
||||||
|
gdk_gc_destroy (text->bg_gc);
|
||||||
|
text->bg_gc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
|
||||||
|
text->bg_gc = create_bg_gc (text);
|
||||||
|
|
||||||
recompute_geometry (text);
|
recompute_geometry (text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1448,6 +1462,12 @@ gtk_text_unrealize (GtkWidget *widget)
|
|||||||
gdk_gc_destroy (text->gc);
|
gdk_gc_destroy (text->gc);
|
||||||
text->gc = NULL;
|
text->gc = NULL;
|
||||||
|
|
||||||
|
if (text->bg_gc)
|
||||||
|
{
|
||||||
|
gdk_gc_destroy (text->bg_gc);
|
||||||
|
text->bg_gc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_pixmap_unref (text->line_wrap_bitmap);
|
gdk_pixmap_unref (text->line_wrap_bitmap);
|
||||||
gdk_pixmap_unref (text->line_arrow_bitmap);
|
gdk_pixmap_unref (text->line_arrow_bitmap);
|
||||||
|
|
||||||
@ -1466,47 +1486,16 @@ clear_focus_area (GtkText *text, gint area_x, gint area_y, gint area_width, gint
|
|||||||
gint xthick = TEXT_BORDER_ROOM + widget->style->klass->xthickness;
|
gint xthick = TEXT_BORDER_ROOM + widget->style->klass->xthickness;
|
||||||
|
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint xorig, yorig;
|
|
||||||
gint x, y;
|
|
||||||
|
|
||||||
gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height);
|
gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height);
|
||||||
|
|
||||||
yorig = - text->first_onscreen_ver_pixel + ythick;
|
gdk_gc_set_ts_origin (text->bg_gc,
|
||||||
xorig = - text->first_onscreen_hor_pixel + xthick;
|
(- text->first_onscreen_hor_pixel + xthick) % width,
|
||||||
|
(- text->first_onscreen_ver_pixel + ythick) % height);
|
||||||
|
|
||||||
while (yorig > 0)
|
gdk_draw_rectangle (GTK_WIDGET (text)->window, text->bg_gc, TRUE,
|
||||||
yorig -= height;
|
area_x, area_y, area_width, area_height);
|
||||||
|
|
||||||
while (xorig > 0)
|
|
||||||
xorig -= width;
|
|
||||||
|
|
||||||
for (y = area_y; y < area_y + area_height; )
|
|
||||||
{
|
|
||||||
gint yoff = (y - yorig) % height;
|
|
||||||
gint yw = MIN(height - yoff, (area_y + area_height) - y);
|
|
||||||
|
|
||||||
for (x = area_x; x < area_x + area_width; )
|
|
||||||
{
|
|
||||||
gint xoff = (x - xorig) % width;
|
|
||||||
gint xw = MIN(width - xoff, (area_x + area_width) - x);
|
|
||||||
|
|
||||||
gdk_draw_pixmap (widget->window,
|
|
||||||
text->gc,
|
|
||||||
widget->style->bg_pixmap[GTK_STATE_NORMAL],
|
|
||||||
xoff,
|
|
||||||
yoff,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
xw,
|
|
||||||
yw);
|
|
||||||
|
|
||||||
x += width - xoff;
|
|
||||||
}
|
}
|
||||||
y += height - yoff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_draw_focus (GtkWidget *widget)
|
gtk_text_draw_focus (GtkWidget *widget)
|
||||||
@ -5231,46 +5220,35 @@ draw_cursor (GtkText* text, gint absolute)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GdkGC *
|
||||||
|
create_bg_gc (GtkText *text)
|
||||||
|
{
|
||||||
|
GdkGCValues values;
|
||||||
|
|
||||||
|
values.tile = GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL];
|
||||||
|
values.fill = GDK_TILED;
|
||||||
|
|
||||||
|
return gdk_gc_new_with_values (text->text_area, &values,
|
||||||
|
GDK_GC_FILL | GDK_GC_TILE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clear_area (GtkText *text, GdkRectangle *area)
|
clear_area (GtkText *text, GdkRectangle *area)
|
||||||
{
|
{
|
||||||
GtkWidget *widget = GTK_WIDGET (text);
|
GtkWidget *widget = GTK_WIDGET (text);
|
||||||
|
|
||||||
if (widget->style->bg_pixmap[GTK_STATE_NORMAL])
|
if (text->bg_gc)
|
||||||
{
|
{
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint x = area->x, y = area->y;
|
|
||||||
gint xorig, yorig;
|
|
||||||
|
|
||||||
gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height);
|
gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height);
|
||||||
|
|
||||||
yorig = - text->first_onscreen_ver_pixel;
|
gdk_gc_set_ts_origin (text->bg_gc,
|
||||||
xorig = - text->first_onscreen_hor_pixel;
|
(- text->first_onscreen_hor_pixel) % width,
|
||||||
|
(- text->first_onscreen_ver_pixel) % height);
|
||||||
|
|
||||||
for (y = area->y; y < area->y + area->height; )
|
gdk_draw_rectangle (text->text_area, text->bg_gc, TRUE,
|
||||||
{
|
area->x, area->y, area->width, area->height);
|
||||||
gint yoff = (y - yorig) % height;
|
|
||||||
gint yw = MIN(height - yoff, (area->y + area->height) - y);
|
|
||||||
|
|
||||||
for (x = area->x; x < area->x + area->width; )
|
|
||||||
{
|
|
||||||
gint xoff = (x - xorig) % width;
|
|
||||||
gint xw = MIN(width - xoff, (area->x + area->width) - x);
|
|
||||||
|
|
||||||
gdk_draw_pixmap (text->text_area,
|
|
||||||
text->gc,
|
|
||||||
widget->style->bg_pixmap[GTK_STATE_NORMAL],
|
|
||||||
xoff,
|
|
||||||
yoff,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
xw,
|
|
||||||
yw);
|
|
||||||
|
|
||||||
x += width - xoff;
|
|
||||||
}
|
|
||||||
y += height - yoff;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gdk_window_clear_area (text->text_area, area->x, area->y, area->width, area->height);
|
gdk_window_clear_area (text->text_area, area->x, area->y, area->width, area->height);
|
||||||
|
|||||||
@ -154,6 +154,7 @@ struct _GtkText
|
|||||||
gint timer;
|
gint timer;
|
||||||
|
|
||||||
guint button; /* currently pressed mouse button */
|
guint button; /* currently pressed mouse button */
|
||||||
|
GdkGC *bg_gc; /* gc for drawing background pixmap */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkTextClass
|
struct _GtkTextClass
|
||||||
|
|||||||
Reference in New Issue
Block a user