Introduce MetaPixmap compatibility wrapper

Similar to the region compatibility shim, we will soon need a
compatibility shim around GdkPixmap/cairo_surface_t. For now, the patch
just introduces the compatibility layer.

This patch also does not include the function
meta_gdk_pixbuf_get_from_pixmap() as that function will need special
treatment in GTK3 anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=630203
This commit is contained in:
Benjamin Otte 2010-09-23 18:56:46 +02:00
parent d212be799a
commit 1083a4c0b7
3 changed files with 22 additions and 16 deletions

View File

@ -24,6 +24,13 @@
#include <gtk/gtk.h>
#define MetaPixmap GdkPixmap
#define meta_pixmap_new(window, w, h) gdk_pixmap_new (window, w, h, -1)
#define meta_pixmap_free(pixmap) g_object_unref (pixmap)
#define meta_pixmap_cairo_create(pixmap) meta_cairo_create (pixmap)
#define meta_cairo_set_source_pixmap(cr, pixmap, x, y) gdk_cairo_set_source_pixmap (cr, pixmap, x, y)
/* This function only exists for GTK2 code. */
cairo_t * meta_cairo_create (GdkDrawable *drawable);

View File

@ -276,7 +276,7 @@ meta_frames_finalize (GObject *object)
typedef struct
{
GdkRectangle rect;
GdkPixmap *pixmap;
MetaPixmap *pixmap;
} CachedFramePiece;
typedef struct
@ -313,7 +313,7 @@ invalidate_cache (MetaFrames *frames,
for (i = 0; i < 4; i++)
if (pixels->piece[i].pixmap)
g_object_unref (pixels->piece[i].pixmap);
meta_pixmap_free (pixels->piece[i].pixmap);
g_free (pixels);
g_hash_table_remove (frames->cache, frame);
@ -2084,22 +2084,22 @@ setup_bg_cr (cairo_t *cr, GdkWindow *window, int x_offset, int y_offset)
/* Returns a pixmap with a piece of the windows frame painted on it.
*/
static GdkPixmap *
static MetaPixmap *
generate_pixmap (MetaFrames *frames,
MetaUIFrame *frame,
GdkRectangle *rect)
{
GdkPixmap *result;
MetaPixmap *result;
cairo_t *cr;
/* do not create a pixmap for nonexisting areas */
if (rect->width <= 0 || rect->height <= 0)
return NULL;
result = gdk_pixmap_new (frame->window,
rect->width, rect->height, -1);
result = meta_pixmap_new (frame->window,
rect->width, rect->height);
cr = meta_cairo_create (result);
cr = meta_pixmap_cairo_create (result);
setup_bg_cr (cr, frame->window, rect->x, rect->y);
cairo_paint (cr);
@ -2270,8 +2270,8 @@ cached_pixels_draw (CachedPixels *pixels,
if (piece->pixmap)
{
gdk_cairo_set_source_pixmap (cr, piece->pixmap,
piece->rect.x, piece->rect.y);
meta_cairo_set_source_pixmap (cr, piece->pixmap,
piece->rect.x, piece->rect.y);
cairo_paint (cr);
region_piece = meta_region_new_from_rectangle (&piece->rect);

View File

@ -943,7 +943,7 @@ static void
run_theme_benchmark (void)
{
GtkWidget* widget;
GdkPixmap *pixmap;
MetaPixmap *pixmap;
int top_height, bottom_height, left_width, right_width;
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
{
@ -1007,12 +1007,11 @@ run_theme_benchmark (void)
/* Creating the pixmap in the loop is right, since
* GDK does the same with its double buffering.
*/
pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
client_width + left_width + right_width,
client_height + top_height + bottom_height,
-1);
pixmap = meta_pixmap_new (gtk_widget_get_window (widget),
client_width + left_width + right_width,
client_height + top_height + bottom_height);
cr = meta_cairo_create (pixmap);
cr = meta_pixmap_cairo_create (pixmap);
meta_theme_draw_frame (global_theme,
widget,
@ -1029,7 +1028,7 @@ run_theme_benchmark (void)
meta_preview_get_icon ());
cairo_destroy (cr);
g_object_unref (G_OBJECT (pixmap));
meta_pixmap_free (pixmap);
++i;
client_width += inc;