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);
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);
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);
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);
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);
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
<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
#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
#include "gdkwindow.h"
#include "gdkinternals.h"
#include "gdkwindowimpl.h"
-#include "gdkpixmap.h"
#include "gdkdrawable.h"
#include "gdktypes.h"
#include "gdkscreen.h"
GdkColormap *colormap;
GdkScreen *screen;
- GdkPixmap *pixmap;
+ cairo_surface_t *surface;
GdkWindow *embedder;
};
{
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);
}
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
- return _gdk_drawable_ref_cairo_surface (offscreen->pixmap);
+ return cairo_surface_reference (offscreen->surface);
}
static GdkColormap*
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
}
/**
- * 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;
return NULL;
offscreen = GDK_OFFSCREEN_WINDOW (private->impl);
- return offscreen->pixmap;
+ return offscreen->surface;
}
static void
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);
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))
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);
*/
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);
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);
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);
#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
*
* 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
}
/**
- * 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)));
}
/**
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;
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
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);
{
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);
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);
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);
}