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:
parent
d212be799a
commit
1083a4c0b7
@ -24,6 +24,13 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#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. */
|
/* This function only exists for GTK2 code. */
|
||||||
cairo_t * meta_cairo_create (GdkDrawable *drawable);
|
cairo_t * meta_cairo_create (GdkDrawable *drawable);
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ meta_frames_finalize (GObject *object)
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
GdkPixmap *pixmap;
|
MetaPixmap *pixmap;
|
||||||
} CachedFramePiece;
|
} CachedFramePiece;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -313,7 +313,7 @@ invalidate_cache (MetaFrames *frames,
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
if (pixels->piece[i].pixmap)
|
if (pixels->piece[i].pixmap)
|
||||||
g_object_unref (pixels->piece[i].pixmap);
|
meta_pixmap_free (pixels->piece[i].pixmap);
|
||||||
|
|
||||||
g_free (pixels);
|
g_free (pixels);
|
||||||
g_hash_table_remove (frames->cache, frame);
|
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.
|
/* Returns a pixmap with a piece of the windows frame painted on it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static GdkPixmap *
|
static MetaPixmap *
|
||||||
generate_pixmap (MetaFrames *frames,
|
generate_pixmap (MetaFrames *frames,
|
||||||
MetaUIFrame *frame,
|
MetaUIFrame *frame,
|
||||||
GdkRectangle *rect)
|
GdkRectangle *rect)
|
||||||
{
|
{
|
||||||
GdkPixmap *result;
|
MetaPixmap *result;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
/* do not create a pixmap for nonexisting areas */
|
/* do not create a pixmap for nonexisting areas */
|
||||||
if (rect->width <= 0 || rect->height <= 0)
|
if (rect->width <= 0 || rect->height <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result = gdk_pixmap_new (frame->window,
|
result = meta_pixmap_new (frame->window,
|
||||||
rect->width, rect->height, -1);
|
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);
|
setup_bg_cr (cr, frame->window, rect->x, rect->y);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
@ -2270,7 +2270,7 @@ cached_pixels_draw (CachedPixels *pixels,
|
|||||||
|
|
||||||
if (piece->pixmap)
|
if (piece->pixmap)
|
||||||
{
|
{
|
||||||
gdk_cairo_set_source_pixmap (cr, piece->pixmap,
|
meta_cairo_set_source_pixmap (cr, piece->pixmap,
|
||||||
piece->rect.x, piece->rect.y);
|
piece->rect.x, piece->rect.y);
|
||||||
cairo_paint (cr);
|
cairo_paint (cr);
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ static void
|
|||||||
run_theme_benchmark (void)
|
run_theme_benchmark (void)
|
||||||
{
|
{
|
||||||
GtkWidget* widget;
|
GtkWidget* widget;
|
||||||
GdkPixmap *pixmap;
|
MetaPixmap *pixmap;
|
||||||
int top_height, bottom_height, left_width, right_width;
|
int top_height, bottom_height, left_width, right_width;
|
||||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
|
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
|
||||||
{
|
{
|
||||||
@ -1007,12 +1007,11 @@ run_theme_benchmark (void)
|
|||||||
/* Creating the pixmap in the loop is right, since
|
/* Creating the pixmap in the loop is right, since
|
||||||
* GDK does the same with its double buffering.
|
* GDK does the same with its double buffering.
|
||||||
*/
|
*/
|
||||||
pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
|
pixmap = meta_pixmap_new (gtk_widget_get_window (widget),
|
||||||
client_width + left_width + right_width,
|
client_width + left_width + right_width,
|
||||||
client_height + top_height + bottom_height,
|
client_height + top_height + bottom_height);
|
||||||
-1);
|
|
||||||
|
|
||||||
cr = meta_cairo_create (pixmap);
|
cr = meta_pixmap_cairo_create (pixmap);
|
||||||
|
|
||||||
meta_theme_draw_frame (global_theme,
|
meta_theme_draw_frame (global_theme,
|
||||||
widget,
|
widget,
|
||||||
@ -1029,7 +1028,7 @@ run_theme_benchmark (void)
|
|||||||
meta_preview_get_icon ());
|
meta_preview_get_icon ());
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
g_object_unref (G_OBJECT (pixmap));
|
meta_pixmap_free (pixmap);
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
client_width += inc;
|
client_width += inc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user