forked from AuroraMiddleware/gtk
API: Change offscreen windows to use a cairo_surface_t
This requires changes to all the offscreen surface getters that used to return a GdkPixmap before.
This commit is contained in:
parent
ebdf26e1d8
commit
332652f702
@ -485,13 +485,13 @@ gtk_rotated_bin_expose (GtkWidget *widget,
|
||||
window = gtk_widget_get_window (widget);
|
||||
if (event->window == window)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
cairo_surface_t *surface;
|
||||
GtkAllocation child_area;
|
||||
cairo_t *cr;
|
||||
|
||||
if (bin->child && gtk_widget_get_visible (bin->child))
|
||||
{
|
||||
pixmap = gdk_offscreen_window_get_pixmap (bin->offscreen_window);
|
||||
surface = gdk_offscreen_window_get_surface (bin->offscreen_window);
|
||||
gtk_widget_get_allocation (bin->child, &child_area);
|
||||
|
||||
cr = gdk_cairo_create (window);
|
||||
@ -508,11 +508,11 @@ gtk_rotated_bin_expose (GtkWidget *widget,
|
||||
cairo_translate (cr, -child_area.width / 2, -child_area.height / 2);
|
||||
|
||||
/* clip */
|
||||
gdk_drawable_get_size (pixmap, &width, &height);
|
||||
gdk_drawable_get_size (bin->offscreen_window, &width, &height);
|
||||
cairo_rectangle (cr, 0, 0, width, height);
|
||||
cairo_clip (cr);
|
||||
/* paint */
|
||||
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
@ -389,15 +389,15 @@ gtk_mirror_bin_expose (GtkWidget *widget,
|
||||
window = gtk_widget_get_window (widget);
|
||||
if (event->window == window)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
cairo_matrix_t matrix;
|
||||
cairo_pattern_t *mask;
|
||||
|
||||
if (bin->child && gtk_widget_get_visible (bin->child))
|
||||
{
|
||||
pixmap = gdk_offscreen_window_get_pixmap (bin->offscreen_window);
|
||||
gdk_drawable_get_size (pixmap, &width, &height);
|
||||
surface = gdk_offscreen_window_get_surface (bin->offscreen_window);
|
||||
gdk_drawable_get_size (bin->offscreen_window, &width, &height);
|
||||
|
||||
cr = gdk_cairo_create (window);
|
||||
|
||||
@ -407,7 +407,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
|
||||
cairo_clip (cr);
|
||||
|
||||
/* paint the offscreen child */
|
||||
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
@ -420,7 +420,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
|
||||
cairo_rectangle (cr, 0, height, width, height);
|
||||
cairo_clip (cr);
|
||||
|
||||
gdk_cairo_set_source_pixmap (cr, pixmap, 0, height);
|
||||
cairo_set_source_surface (cr, surface, 0, height);
|
||||
|
||||
/* create linear gradient as mask-pattern to fade out the source */
|
||||
mask = cairo_pattern_create_linear (0.0, height, 0.0, 2*height);
|
||||
|
@ -530,7 +530,7 @@ GdkPointerHooks
|
||||
gdk_set_pointer_hooks
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_offscreen_window_get_pixmap
|
||||
gdk_offscreen_window_get_surface
|
||||
gdk_offscreen_window_set_embedder
|
||||
gdk_offscreen_window_get_embedder
|
||||
gdk_window_geometry_changed
|
||||
|
@ -2266,7 +2266,7 @@ GTK_OBJECT_UNSET_FLAGS
|
||||
<TITLE>GtkOffscreenWindow</TITLE>
|
||||
GtkOffscreenWindow
|
||||
gtk_offscreen_window_new
|
||||
gtk_offscreen_window_get_pixmap
|
||||
gtk_offscreen_window_get_surface
|
||||
gtk_offscreen_window_get_pixbuf
|
||||
<SUBSECTION Standard>
|
||||
GTK_OFFSCREEN_WINDOW
|
||||
|
@ -668,7 +668,7 @@ gdk_window_get_device_position
|
||||
|
||||
#if IN_HEADER(__GDK_WINDOW_H__)
|
||||
#if IN_FILE(__GDK_OFFSCREEN_WINDOW_C__)
|
||||
gdk_offscreen_window_get_pixmap
|
||||
gdk_offscreen_window_get_surface
|
||||
gdk_offscreen_window_set_embedder
|
||||
gdk_offscreen_window_get_embedder
|
||||
#endif
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "gdkwindow.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkwindowimpl.h"
|
||||
#include "gdkpixmap.h"
|
||||
#include "gdkdrawable.h"
|
||||
#include "gdktypes.h"
|
||||
#include "gdkscreen.h"
|
||||
@ -55,7 +54,7 @@ struct _GdkOffscreenWindow
|
||||
GdkColormap *colormap;
|
||||
GdkScreen *screen;
|
||||
|
||||
GdkPixmap *pixmap;
|
||||
cairo_surface_t *surface;
|
||||
GdkWindow *embedder;
|
||||
};
|
||||
|
||||
@ -86,7 +85,7 @@ gdk_offscreen_window_finalize (GObject *object)
|
||||
{
|
||||
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (object);
|
||||
|
||||
g_object_unref (offscreen->pixmap);
|
||||
cairo_surface_destroy (offscreen->surface);
|
||||
|
||||
G_OBJECT_CLASS (gdk_offscreen_window_parent_class)->finalize (object);
|
||||
}
|
||||
@ -138,7 +137,7 @@ gdk_offscreen_window_ref_cairo_surface (GdkDrawable *drawable)
|
||||
{
|
||||
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
|
||||
|
||||
return _gdk_drawable_ref_cairo_surface (offscreen->pixmap);
|
||||
return cairo_surface_reference (offscreen->surface);
|
||||
}
|
||||
|
||||
static GdkColormap*
|
||||
@ -241,11 +240,10 @@ _gdk_offscreen_window_new (GdkWindow *window,
|
||||
offscreen->colormap = gdk_colormap_new (visual, FALSE);
|
||||
}
|
||||
|
||||
offscreen->pixmap = gdk_pixmap_new ((GdkDrawable *)private->parent,
|
||||
private->width,
|
||||
private->height,
|
||||
private->depth);
|
||||
gdk_drawable_set_colormap (offscreen->pixmap, offscreen->colormap);
|
||||
offscreen->surface = gdk_window_create_similar_surface ((GdkWindow *)private->parent,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
private->width,
|
||||
private->height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -399,19 +397,17 @@ gdk_offscreen_window_get_device_state (GdkWindow *window,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_offscreen_window_get_pixmap:
|
||||
* gdk_offscreen_window_get_surface:
|
||||
* @window: a #GdkWindow
|
||||
*
|
||||
* Gets the offscreen pixmap that an offscreen window renders into.
|
||||
* Gets the offscreen surface that an offscreen window renders into.
|
||||
* If you need to keep this around over window resizes, you need to
|
||||
* add a reference to it.
|
||||
*
|
||||
* Returns: The offscreen pixmap, or %NULL if not offscreen
|
||||
*
|
||||
* Since: 2.18
|
||||
* Returns: The offscreen surface, or %NULL if not offscreen
|
||||
*/
|
||||
GdkPixmap *
|
||||
gdk_offscreen_window_get_pixmap (GdkWindow *window)
|
||||
cairo_surface_t *
|
||||
gdk_offscreen_window_get_surface (GdkWindow *window)
|
||||
{
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkOffscreenWindow *offscreen;
|
||||
@ -422,7 +418,7 @@ gdk_offscreen_window_get_pixmap (GdkWindow *window)
|
||||
return NULL;
|
||||
|
||||
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
|
||||
return offscreen->pixmap;
|
||||
return offscreen->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -450,7 +446,7 @@ gdk_offscreen_window_move_resize_internal (GdkWindow *window,
|
||||
GdkWindowObject *private = (GdkWindowObject *)window;
|
||||
GdkOffscreenWindow *offscreen;
|
||||
gint dx, dy, dw, dh;
|
||||
GdkPixmap *old_pixmap;
|
||||
cairo_surface_t *old_surface;
|
||||
|
||||
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
|
||||
|
||||
@ -478,16 +474,18 @@ gdk_offscreen_window_move_resize_internal (GdkWindow *window,
|
||||
private->width = width;
|
||||
private->height = height;
|
||||
|
||||
old_pixmap = offscreen->pixmap;
|
||||
offscreen->pixmap = gdk_pixmap_new (GDK_DRAWABLE (old_pixmap),
|
||||
width,
|
||||
height,
|
||||
private->depth);
|
||||
old_surface = offscreen->surface;
|
||||
offscreen->surface = cairo_surface_create_similar (old_surface,
|
||||
cairo_surface_get_content (old_surface),
|
||||
width,
|
||||
height);
|
||||
|
||||
cr = gdk_cairo_create (offscreen->pixmap);
|
||||
gdk_cairo_set_source_pixmap (cr, old_pixmap, 0, 0);
|
||||
cr = cairo_create (offscreen->surface);
|
||||
cairo_set_source_surface (cr, old_surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
cairo_surface_destroy (old_surface);
|
||||
}
|
||||
|
||||
if (GDK_WINDOW_IS_MAPPED (private))
|
||||
@ -661,13 +659,10 @@ gdk_offscreen_window_translate (GdkWindow *window,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (((GdkWindowObject *) window)->impl);
|
||||
cairo_t *cr;
|
||||
|
||||
/* Can't use gdk_cairo_create here due to clipping */
|
||||
surface = _gdk_drawable_ref_cairo_surface (window);
|
||||
cr = cairo_create (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
cr = cairo_create (offscreen->surface);
|
||||
|
||||
area = cairo_region_copy (area);
|
||||
|
||||
@ -679,7 +674,7 @@ gdk_offscreen_window_translate (GdkWindow *window,
|
||||
*/
|
||||
cairo_push_group (cr);
|
||||
|
||||
gdk_cairo_set_source_pixmap (cr, window, dx, dy);
|
||||
cairo_set_source_surface (cr, offscreen->surface, dx, dy);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_pop_group_to_source (cr);
|
||||
|
@ -3004,7 +3004,7 @@ gdk_window_end_paint (GdkWindow *window)
|
||||
full_clip = cairo_region_copy (private->clip_region_with_children);
|
||||
cairo_region_intersect (full_clip, paint->region);
|
||||
|
||||
cr = gdk_cairo_create (private->impl);
|
||||
cr = gdk_cairo_create (window);
|
||||
cairo_set_source_surface (cr, paint->surface, 0, 0);
|
||||
gdk_cairo_region (cr, full_clip);
|
||||
cairo_fill (cr);
|
||||
|
@ -846,7 +846,8 @@ GdkPointerHooks *gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks);
|
||||
GdkWindow *gdk_get_default_root_window (void);
|
||||
|
||||
/* Offscreen redirection */
|
||||
GdkPixmap *gdk_offscreen_window_get_pixmap (GdkWindow *window);
|
||||
cairo_surface_t *
|
||||
gdk_offscreen_window_get_surface (GdkWindow *window);
|
||||
void gdk_offscreen_window_set_embedder (GdkWindow *window,
|
||||
GdkWindow *embedder);
|
||||
GdkWindow *gdk_offscreen_window_get_embedder (GdkWindow *window);
|
||||
|
@ -2085,7 +2085,7 @@ gtk_object_get_type G_GNUC_CONST
|
||||
#if IN_FILE(__GTK_OFFSCREEN_WINDOW_C__)
|
||||
gtk_offscreen_window_get_type G_GNUC_CONST
|
||||
gtk_offscreen_window_new
|
||||
gtk_offscreen_window_get_pixmap
|
||||
gtk_offscreen_window_get_surface
|
||||
gtk_offscreen_window_get_pixbuf
|
||||
#endif
|
||||
#endif
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
* The idea is to take a widget and manually set the state of it,
|
||||
* add it to a GtkOffscreenWindow and then retrieve the snapshot
|
||||
* as a #GdkPixmap or #GdkPixbuf.
|
||||
* as a #cairo_surface_t or #GdkPixbuf.
|
||||
*
|
||||
* GtkOffscreenWindow derives from #GtkWindow only as an implementation
|
||||
* detail. Applications should not use any API specific to #GtkWindow
|
||||
@ -270,24 +270,24 @@ gtk_offscreen_window_new (void)
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_offscreen_window_get_pixmap:
|
||||
* gtk_offscreen_window_get_surface:
|
||||
* @offscreen: the #GtkOffscreenWindow contained widget.
|
||||
*
|
||||
* Retrieves a snapshot of the contained widget in the form of
|
||||
* a #GdkPixmap. If you need to keep this around over window
|
||||
* a #cairo_surface_t. If you need to keep this around over window
|
||||
* resizes then you should add a reference to it.
|
||||
*
|
||||
* Returns: (transfer none): A #GdkPixmap pointer to the offscreen pixmap,
|
||||
* or %NULL.
|
||||
* Returns: (transfer none): A #cairo_surface_t pointer to the offscreen
|
||||
* surface, or %NULL.
|
||||
*
|
||||
* Since: 2.20
|
||||
*/
|
||||
GdkPixmap *
|
||||
gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen)
|
||||
cairo_surface_t *
|
||||
gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
|
||||
|
||||
return gdk_offscreen_window_get_pixmap (gtk_widget_get_window (GTK_WIDGET (offscreen)));
|
||||
return gdk_offscreen_window_get_surface (gtk_widget_get_window (GTK_WIDGET (offscreen)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,22 +306,24 @@ gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen)
|
||||
GdkPixbuf *
|
||||
gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen)
|
||||
{
|
||||
GdkPixmap *pixmap = NULL;
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GdkWindow *window;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
|
||||
|
||||
pixmap = gdk_offscreen_window_get_pixmap (gtk_widget_get_window (GTK_WIDGET (offscreen)));
|
||||
window = gtk_widget_get_window (GTK_WIDGET (offscreen));
|
||||
surface = gdk_offscreen_window_get_surface (window);
|
||||
|
||||
if (pixmap != NULL)
|
||||
if (surface != NULL)
|
||||
{
|
||||
gint width, height;
|
||||
|
||||
gdk_drawable_get_size (pixmap, &width, &height);
|
||||
gdk_drawable_get_size (window, &width, &height);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL,
|
||||
0, 0, 0, 0,
|
||||
width, height);
|
||||
pixbuf = gdk_pixbuf_get_from_surface (NULL, surface,
|
||||
0, 0, 0, 0,
|
||||
width, height);
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
|
@ -49,11 +49,11 @@ struct _GtkOffscreenWindowClass
|
||||
GtkWindowClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_offscreen_window_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_offscreen_window_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *gtk_offscreen_window_new (void);
|
||||
GdkPixmap *gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen);
|
||||
GdkPixbuf *gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen);
|
||||
GtkWidget *gtk_offscreen_window_new (void);
|
||||
cairo_surface_t *gtk_offscreen_window_get_surface (GtkOffscreenWindow *offscreen);
|
||||
GdkPixbuf *gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -598,19 +598,19 @@ gtk_offscreen_box_expose (GtkWidget *widget,
|
||||
window = gtk_widget_get_window (widget);
|
||||
if (event->window == window)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
cairo_surface_t *surface;
|
||||
GtkAllocation child_area;
|
||||
cairo_t *cr;
|
||||
int start_y = 0;
|
||||
|
||||
if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1))
|
||||
{
|
||||
pixmap = gdk_offscreen_window_get_pixmap (offscreen_box->offscreen_window1);
|
||||
surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window1);
|
||||
gtk_widget_get_allocation (offscreen_box->child1, &child_area);
|
||||
|
||||
cr = gdk_cairo_create (window);
|
||||
|
||||
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
@ -622,7 +622,7 @@ gtk_offscreen_box_expose (GtkWidget *widget,
|
||||
{
|
||||
gint w, h;
|
||||
|
||||
pixmap = gdk_offscreen_window_get_pixmap (offscreen_box->offscreen_window2);
|
||||
surface = gdk_offscreen_window_get_surface (offscreen_box->offscreen_window2);
|
||||
gtk_widget_get_allocation (offscreen_box->child2, &child_area);
|
||||
|
||||
cr = gdk_cairo_create (window);
|
||||
@ -634,12 +634,12 @@ gtk_offscreen_box_expose (GtkWidget *widget,
|
||||
cairo_translate (cr, -child_area.width / 2, -child_area.height / 2);
|
||||
|
||||
/* clip */
|
||||
gdk_drawable_get_size (pixmap, &w, &h);
|
||||
gdk_drawable_get_size (offscreen_box->offscreen_window2, &w, &h);
|
||||
cairo_rectangle (cr, 0, 0, w, h);
|
||||
cairo_clip (cr);
|
||||
|
||||
/* paint */
|
||||
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
|
||||
cairo_set_source_surface (cr, surface, 0, 0);
|
||||
cairo_paint (cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
@ -6,15 +6,15 @@ da_expose (GtkWidget *widget,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkOffscreenWindow *offscreen = (GtkOffscreenWindow *)user_data;
|
||||
GdkPixmap *pixmap;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
||||
if (gtk_widget_is_drawable (widget))
|
||||
{
|
||||
pixmap = gtk_offscreen_window_get_pixmap (offscreen);
|
||||
surface = gtk_offscreen_window_get_surface (offscreen);
|
||||
|
||||
cr = gdk_cairo_create (gtk_widget_get_window (widget));
|
||||
gdk_cairo_set_source_pixmap (cr, pixmap, 50, 50);
|
||||
cairo_set_source_surface (cr, surface, 50, 50);
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user