Optimize the case where a component is entirely transparent by skipping

Sun Jan 27 23:58:13 2002  Owen Taylor  <otaylor@redhat.com>

        * pixbuf-render.c (compute_hint): Optimize the case
        where a component is entirely transparent by skipping
        drawing it.

        * pixbuf-rc-style.c (theme_parse_image): Catch case
        where background or overlay border/stretch are specified
        without a background image.

        * pixbuf-render.c (theme_pixbuf_destroy): Actually free
        the structure and filename.
This commit is contained in:
Owen Taylor 2002-01-28 05:34:17 +00:00 committed by Owen Taylor
parent 624b01a92e
commit 6090d199a5
6 changed files with 55 additions and 8 deletions

View File

@ -1,3 +1,16 @@
Sun Jan 27 23:58:13 2002 Owen Taylor <otaylor@redhat.com>
* pixbuf-render.c (compute_hint): Optimize the case
where a component is entirely transparent by skipping
drawing it.
* pixbuf-rc-style.c (theme_parse_image): Catch case
where background or overlay border/stretch are specified
without a background image.
* pixbuf-render.c (theme_pixbuf_destroy): Actually free
the structure and filename.
=================== Move back into gtk-engines ====================
Sat Jan 19 02:45:17 2002 Owen Taylor <otaylor@redhat.com>

View File

@ -14,3 +14,7 @@ libpixmap_la_SOURCES = \
pixbuf.h
libpixmap_la_LDFLAGS = -avoid-version -module
dist-hook:
cp -pr examples $(distdir); \
find $(distdir)/examples -name 'CVS' -print | xargs rm -rf

View File

@ -659,9 +659,10 @@ draw_box (GtkStyle *style,
match_data.state = state;
if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
x, y, width, height))
x, y, width, height)) {
parent_class->draw_box (style, window, state, shadow, area, widget, detail,
x, y, width, height);
}
}
static void

View File

@ -664,6 +664,20 @@ theme_parse_image(GtkSettings *settings,
token = g_scanner_get_next_token(scanner);
if (data->background && !data->background->filename)
{
g_scanner_warn (scanner, "Background image options specified without filename");
theme_pixbuf_destroy (data->background);
data->background = NULL;
}
if (data->overlay && !data->overlay->filename)
{
g_scanner_warn (scanner, "Overlay image options specified without filename");
theme_pixbuf_destroy (data->overlay);
data->overlay = NULL;
}
if (token != G_TOKEN_RIGHT_CURLY)
{
/* error - cleanup for exit */

View File

@ -180,6 +180,9 @@ pixbuf_render (GdkPixbuf *src,
rect.width = dest_width;
rect.height = dest_height;
if (hints & THEME_MISSING)
return;
/* FIXME: Because we use the mask to shape windows, we don't use
* clip_rect to clip what we draw to the mask, only to clip
* what we actually draw. But this leads to the horrible ineffiency
@ -290,8 +293,8 @@ theme_pixbuf_new (void)
void
theme_pixbuf_destroy (ThemePixbuf *theme_pb)
{
if (theme_pb->pixbuf)
g_cache_remove (pixbuf_cache, theme_pb->pixbuf);
theme_pixbuf_set_filename (theme_pb, NULL);
g_free (theme_pb);
}
void
@ -307,7 +310,10 @@ theme_pixbuf_set_filename (ThemePixbuf *theme_pb,
if (theme_pb->filename)
g_free (theme_pb->filename);
theme_pb->filename = g_strdup (filename);
if (filename)
theme_pb->filename = g_strdup (filename);
else
theme_pb->filename = NULL;
}
static guint
@ -318,7 +324,7 @@ compute_hint (GdkPixbuf *pixbuf,
gint y1)
{
int i, j;
int hints = THEME_CONSTANT_ROWS | THEME_CONSTANT_COLS;
int hints = THEME_CONSTANT_ROWS | THEME_CONSTANT_COLS | THEME_MISSING;
int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
guchar *data = gdk_pixbuf_get_pixels (pixbuf);
@ -340,13 +346,21 @@ compute_hint (GdkPixbuf *pixbuf,
for (j = x0 + 1; j < x1 ; j++)
{
if (n_channels != 4 || p[4] != 0)
{
hints &= ~THEME_MISSING;
if (!(hints & THEME_CONSTANT_ROWS))
goto cols;
}
if (r != *(p++) ||
g != *(p++) ||
b != *(p++) ||
(n_channels == 4 && a != *(p++)))
(n_channels != 4 && a != *(p++)))
{
hints &= ~THEME_CONSTANT_ROWS;
goto cols;
if (!(hints & THEME_MISSING))
goto cols;
}
}
}

View File

@ -121,7 +121,8 @@ typedef enum {
typedef enum {
THEME_CONSTANT_ROWS = 1 << 0,
THEME_CONSTANT_COLS = 1 << 1
THEME_CONSTANT_COLS = 1 << 1,
THEME_MISSING = 1 << 2
} ThemeRenderHints;
struct _ThemePixbuf