* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#include "config.h"
+#include <math.h>
+#include <pango/pangocairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "gdkcairo.h"
#include "gdkdrawable.h"
#include "gdkinternals.h"
#include "gdkwindow.h"
-
-static GdkDrawable* gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height,
- gint *composite_x_offset,
- gint *composite_y_offset);
-
-static void gdk_drawable_class_init (GdkDrawableClass *klass);
-
-GType
-gdk_drawable_get_type (void)
-{
- static GType object_type = 0;
-
- if (!object_type)
- {
- static const GTypeInfo object_info =
- {
- sizeof (GdkDrawableClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gdk_drawable_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GdkDrawable),
- 0, /* n_preallocs */
- (GInstanceInitFunc) NULL,
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT,
- "GdkDrawable",
- &object_info, 0);
- }
-
- return object_type;
-}
+#include "gdkscreen.h"
+#include "gdkpixbuf.h"
+
+
+static GdkDrawable* gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gint *composite_x_offset,
+ gint *composite_y_offset);
+static cairo_region_t * gdk_drawable_real_get_visible_region (GdkDrawable *drawable);
+static void gdk_drawable_real_draw_drawable (GdkDrawable *drawable,
+ GdkGC *gc,
+ GdkDrawable *src,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height);
+
+
+G_DEFINE_ABSTRACT_TYPE (GdkDrawable, gdk_drawable, G_TYPE_OBJECT)
static void
gdk_drawable_class_init (GdkDrawableClass *klass)
{
klass->get_composite_drawable = gdk_drawable_real_get_composite_drawable;
+ /* Default implementation for clip and visible region is the same */
+ klass->get_clip_region = gdk_drawable_real_get_visible_region;
+ klass->get_visible_region = gdk_drawable_real_get_visible_region;
+ klass->draw_drawable = gdk_drawable_real_draw_drawable;
}
-/* Manipulation of drawables
- */
-
-void
-gdk_drawable_set_data (GdkDrawable *drawable,
- const gchar *key,
- gpointer data,
- GDestroyNotify destroy_func)
+static void
+gdk_drawable_init (GdkDrawable *drawable)
{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-
- g_object_set_qdata_full (G_OBJECT (drawable),
- g_quark_from_string (key),
- data,
- destroy_func);
}
-gpointer
-gdk_drawable_get_data (GdkDrawable *drawable,
- const gchar *key)
-{
- g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
-
- return g_object_get_qdata (G_OBJECT (drawable),
- g_quark_try_string (key));
-}
+/* Manipulation of drawables
+ */
+/**
+ * gdk_drawable_get_size:
+ * @drawable: a #GdkDrawable
+ * @width: (out) (allow-none): location to store drawable's width, or %NULL
+ * @height: (out) (allow-none): location to store drawable's height, or %NULL
+ *
+ * Fills *@width and *@height with the size of @drawable.
+ * @width or @height can be %NULL if you only want the other one.
+ *
+ * On the X11 platform, if @drawable is a #GdkWindow, the returned
+ * size is the size reported in the most-recently-processed configure
+ * event, rather than the current size on the X server.
+ *
+ **/
void
gdk_drawable_get_size (GdkDrawable *drawable,
gint *width,
GDK_DRAWABLE_GET_CLASS (drawable)->get_size (drawable, width, height);
}
+/**
+ * gdk_drawable_get_visual:
+ * @drawable: a #GdkDrawable
+ *
+ * Gets the #GdkVisual describing the pixel format of @drawable.
+ *
+ * Return value: a #GdkVisual
+ **/
GdkVisual*
gdk_drawable_get_visual (GdkDrawable *drawable)
{
return GDK_DRAWABLE_GET_CLASS (drawable)->get_visual (drawable);
}
+/**
+ * gdk_drawable_get_depth:
+ * @drawable: a #GdkDrawable
+ *
+ * Obtains the bit depth of the drawable, that is, the number of bits
+ * that make up a pixel in the drawable's visual. Examples are 8 bits
+ * per pixel, 24 bits per pixel, etc.
+ *
+ * Return value: number of bits per pixel
+ **/
gint
gdk_drawable_get_depth (GdkDrawable *drawable)
{
return GDK_DRAWABLE_GET_CLASS (drawable)->get_depth (drawable);
}
+/**
+ * gdk_drawable_get_screen:
+ * @drawable: a #GdkDrawable
+ *
+ * Gets the #GdkScreen associated with a #GdkDrawable.
+ *
+ * Return value: the #GdkScreen associated with @drawable
+ *
+ * Since: 2.2
+ **/
+GdkScreen*
+gdk_drawable_get_screen(GdkDrawable *drawable)
+{
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+ return GDK_DRAWABLE_GET_CLASS (drawable)->get_screen (drawable);
+}
+
+/**
+ * gdk_drawable_get_display:
+ * @drawable: a #GdkDrawable
+ *
+ * Gets the #GdkDisplay associated with a #GdkDrawable.
+ *
+ * Return value: the #GdkDisplay associated with @drawable
+ *
+ * Since: 2.2
+ **/
+GdkDisplay*
+gdk_drawable_get_display (GdkDrawable *drawable)
+{
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+
+ return gdk_screen_get_display (gdk_drawable_get_screen (drawable));
+}
+
+/**
+ * gdk_drawable_set_colormap:
+ * @drawable: a #GdkDrawable
+ * @colormap: a #GdkColormap
+ *
+ * Sets the colormap associated with @drawable. Normally this will
+ * happen automatically when the drawable is created; you only need to
+ * use this function if the drawable-creating function did not have a
+ * way to determine the colormap, and you then use drawable operations
+ * that require a colormap. The colormap for all drawables and
+ * graphics contexts you intend to use together should match. i.e.
+ * when using a #GdkGC to draw to a drawable, or copying one drawable
+ * to another, the colormaps should match.
+ *
+ **/
void
gdk_drawable_set_colormap (GdkDrawable *drawable,
GdkColormap *cmap)
{
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
+ g_return_if_fail (cmap == NULL || gdk_drawable_get_depth (drawable)
+ == cmap->visual->depth);
GDK_DRAWABLE_GET_CLASS (drawable)->set_colormap (drawable, cmap);
}
+/**
+ * gdk_drawable_get_colormap:
+ * @drawable: a #GdkDrawable
+ *
+ * Gets the colormap for @drawable, if one is set; returns
+ * %NULL otherwise.
+ *
+ * Return value: the colormap, or %NULL
+ **/
GdkColormap*
gdk_drawable_get_colormap (GdkDrawable *drawable)
{
return GDK_DRAWABLE_GET_CLASS (drawable)->get_colormap (drawable);
}
-GdkDrawable*
-gdk_drawable_ref (GdkDrawable *drawable)
-{
- return (GdkDrawable *) g_object_ref (G_OBJECT (drawable));
-}
-
-void
-gdk_drawable_unref (GdkDrawable *drawable)
-{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-
- g_object_unref (G_OBJECT (drawable));
-}
-
/* Drawing
*/
-void
-gdk_draw_point (GdkDrawable *drawable,
- GdkGC *gc,
- gint x,
- gint y)
-{
- GdkPoint point;
-
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (GDK_IS_GC (gc));
-
- point.x = x;
- point.y = y;
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_points (drawable, gc, &point, 1);
-}
-
-void
-gdk_draw_line (GdkDrawable *drawable,
- GdkGC *gc,
- gint x1,
- gint y1,
- gint x2,
- gint y2)
-{
- GdkSegment segment;
-
- g_return_if_fail (drawable != NULL);
- g_return_if_fail (gc != NULL);
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (GDK_IS_GC (gc));
-
- segment.x1 = x1;
- segment.y1 = y1;
- segment.x2 = x2;
- segment.y2 = y2;
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_segments (drawable, gc, &segment, 1);
-}
-
-void
-gdk_draw_rectangle (GdkDrawable *drawable,
- GdkGC *gc,
- gint filled,
- gint x,
- gint y,
- gint width,
- gint height)
-{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (GDK_IS_GC (gc));
- if (width < 0 || height < 0)
- {
- gint real_width;
- gint real_height;
-
- gdk_drawable_get_size (drawable, &real_width, &real_height);
-
- if (width < 0)
- width = real_width;
- if (height < 0)
- height = real_height;
- }
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_rectangle (drawable, gc, filled, x, y,
- width, height);
-}
-
-void
-gdk_draw_arc (GdkDrawable *drawable,
- GdkGC *gc,
- gint filled,
- gint x,
- gint y,
- gint width,
- gint height,
- gint angle1,
- gint angle2)
-{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (GDK_IS_GC (gc));
-
- if (width < 0 || height < 0)
- {
- gint real_width;
- gint real_height;
-
- gdk_drawable_get_size (drawable, &real_width, &real_height);
-
- if (width < 0)
- width = real_width;
- if (height < 0)
- height = real_height;
- }
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_arc (drawable, gc, filled,
- x, y, width, height, angle1, angle2);
-}
-
-void
-gdk_draw_polygon (GdkDrawable *drawable,
- GdkGC *gc,
- gint filled,
- GdkPoint *points,
- gint npoints)
-{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (GDK_IS_GC (gc));
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_polygon (drawable, gc, filled,
- points, npoints);
-}
-
-/* gdk_draw_string
+/**
+ * gdk_draw_drawable:
+ * @drawable: a #GdkDrawable
+ * @gc: a #GdkGC sharing the drawable's visual and colormap
+ * @src: the source #GdkDrawable, which may be the same as @drawable
+ * @xsrc: X position in @src of rectangle to draw
+ * @ysrc: Y position in @src of rectangle to draw
+ * @xdest: X position in @drawable where the rectangle should be drawn
+ * @ydest: Y position in @drawable where the rectangle should be drawn
+ * @width: width of rectangle to draw, or -1 for entire @src width
+ * @height: height of rectangle to draw, or -1 for entire @src height
*
- * Modified by Li-Da Lho to draw 16 bits and Multibyte strings
+ * Copies the @width x @height region of @src at coordinates (@xsrc,
+ * @ysrc) to coordinates (@xdest, @ydest) in @drawable.
+ * @width and/or @height may be given as -1, in which case the entire
+ * @src drawable will be copied.
*
- * Interface changed: add "GdkFont *font" to specify font or fontset explicitely
- */
-void
-gdk_draw_string (GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const gchar *string)
-{
- gdk_draw_text (drawable, font, gc, x, y, string, _gdk_font_strlen (font, string));
-}
-
-/* gdk_draw_text
- *
- * Modified by Li-Da Lho to draw 16 bits and Multibyte strings
+ * Most fields in @gc are not used for this operation, but notably the
+ * clip mask or clip region will be honored.
*
- * Interface changed: add "GdkFont *font" to specify font or fontset explicitely
- */
-void
-gdk_draw_text (GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const gchar *text,
- gint text_length)
-{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (font != NULL);
- g_return_if_fail (GDK_IS_GC (gc));
- g_return_if_fail (text != NULL);
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_text (drawable, font, gc, x, y, text, text_length);
-}
-
-void
-gdk_draw_text_wc (GdkDrawable *drawable,
- GdkFont *font,
- GdkGC *gc,
- gint x,
- gint y,
- const GdkWChar *text,
- gint text_length)
-{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (font != NULL);
- g_return_if_fail (GDK_IS_GC (gc));
- g_return_if_fail (text != NULL);
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_text_wc (drawable, font, gc, x, y, text, text_length);
-}
-
+ * The source and destination drawables must have the same visual and
+ * colormap, or errors will result. (On X11, failure to match
+ * visual/colormap results in a BadMatch error from the X server.)
+ * A common cause of this problem is an attempt to draw a bitmap to
+ * a color drawable. The way to draw a bitmap is to set the bitmap as
+ * the stipple on the #GdkGC, set the fill mode to %GDK_STIPPLED, and
+ * then draw the rectangle.
+ **/
void
gdk_draw_drawable (GdkDrawable *drawable,
GdkGC *gc,
gint composite_y_offset = 0;
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (src != NULL);
+ g_return_if_fail (GDK_IS_DRAWABLE (src));
g_return_if_fail (GDK_IS_GC (gc));
if (width < 0 || height < 0)
&composite_x_offset,
&composite_y_offset);
-
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable (drawable, gc, composite,
- xsrc - composite_x_offset,
- ysrc - composite_y_offset,
- xdest, ydest,
- width, height);
-
- g_object_unref (G_OBJECT (composite));
+ /* TODO: For non-native windows this may copy stuff from other overlapping
+ windows. We should clip that and (for windows with bg != None) clear that
+ area in the destination instead. */
+
+ if (GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable_with_src)
+ GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable_with_src (drawable, gc,
+ composite,
+ xsrc - composite_x_offset,
+ ysrc - composite_y_offset,
+ xdest, ydest,
+ width, height,
+ src);
+ else /* backwards compat for old out-of-tree implementations of GdkDrawable (are there any?) */
+ GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable (drawable, gc,
+ composite,
+ xsrc - composite_x_offset,
+ ysrc - composite_y_offset,
+ xdest, ydest,
+ width, height);
+
+ g_object_unref (composite);
}
-void
-gdk_draw_image (GdkDrawable *drawable,
- GdkGC *gc,
- GdkImage *image,
- gint xsrc,
- gint ysrc,
- gint xdest,
- gint ydest,
- gint width,
- gint height)
+static GdkDrawable *
+gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gint *composite_x_offset,
+ gint *composite_y_offset)
{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (image != NULL);
- g_return_if_fail (GDK_IS_GC (gc));
-
- if (width == -1)
- width = image->width;
- if (height == -1)
- height = image->height;
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_image (drawable, gc, image, xsrc, ysrc,
- xdest, ydest, width, height);
+ *composite_x_offset = 0;
+ *composite_y_offset = 0;
+
+ return g_object_ref (drawable);
}
-void
-gdk_draw_points (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints)
+/**
+ * gdk_drawable_get_clip_region:
+ * @drawable: a #GdkDrawable
+ *
+ * Computes the region of a drawable that potentially can be written
+ * to by drawing primitives. This region will not take into account
+ * the clip region for the GC, and may also not take into account
+ * other factors such as if the window is obscured by other windows,
+ * but no area outside of this region will be affected by drawing
+ * primitives.
+ *
+ * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy()
+ * when you are done.
+ **/
+cairo_region_t *
+gdk_drawable_get_clip_region (GdkDrawable *drawable)
{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail ((points != NULL) && (npoints > 0));
- g_return_if_fail (GDK_IS_GC (gc));
- g_return_if_fail (npoints >= 0);
-
- if (npoints == 0)
- return;
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_points (drawable, gc, points, npoints);
+ return GDK_DRAWABLE_GET_CLASS (drawable)->get_clip_region (drawable);
}
-void
-gdk_draw_segments (GdkDrawable *drawable,
- GdkGC *gc,
- GdkSegment *segs,
- gint nsegs)
+/**
+ * gdk_drawable_get_visible_region:
+ * @drawable: a #GdkDrawable
+ *
+ * Computes the region of a drawable that is potentially visible.
+ * This does not necessarily take into account if the window is
+ * obscured by other windows, but no area outside of this region
+ * is visible.
+ *
+ * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy()
+ * when you are done.
+ **/
+cairo_region_t *
+gdk_drawable_get_visible_region (GdkDrawable *drawable)
{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-
- if (nsegs == 0)
- return;
-
- g_return_if_fail (segs != NULL);
- g_return_if_fail (GDK_IS_GC (gc));
- g_return_if_fail (nsegs >= 0);
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_segments (drawable, gc, segs, nsegs);
+ return GDK_DRAWABLE_GET_CLASS (drawable)->get_visible_region (drawable);
}
-void
-gdk_draw_lines (GdkDrawable *drawable,
- GdkGC *gc,
- GdkPoint *points,
- gint npoints)
+static cairo_region_t *
+gdk_drawable_real_get_visible_region (GdkDrawable *drawable)
{
+ GdkRectangle rect;
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (points != NULL);
- g_return_if_fail (GDK_IS_GC (gc));
- g_return_if_fail (npoints >= 0);
+ rect.x = 0;
+ rect.y = 0;
- if (npoints == 0)
- return;
+ gdk_drawable_get_size (drawable, &rect.width, &rect.height);
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_lines (drawable, gc, points, npoints);
+ return cairo_region_create_rectangle (&rect);
}
-void
-gdk_draw_glyphs (GdkDrawable *drawable,
- GdkGC *gc,
- PangoFont *font,
- gint x,
- gint y,
- PangoGlyphString *glyphs)
+/**
+ * _gdk_drawable_ref_cairo_surface:
+ * @drawable: a #GdkDrawable
+ *
+ * Obtains a #cairo_surface_t for the given drawable. If a
+ * #cairo_surface_t for the drawable already exists, it will be
+ * referenced, otherwise a new surface will be created.
+ *
+ * Return value: a newly referenced #cairo_surface_t that points
+ * to @drawable. Unref with cairo_surface_destroy()
+ **/
+cairo_surface_t *
+_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable)
{
- g_return_if_fail (GDK_IS_DRAWABLE (drawable));
- g_return_if_fail (GDK_IS_GC (gc));
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+ return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable);
+}
- GDK_DRAWABLE_GET_CLASS (drawable)->draw_glyphs (drawable, gc, font, x, y, glyphs);
+/* Implementation of the old vfunc in terms of the new one
+ in case someone calls it directly (which they shouldn't!) */
+static void
+gdk_drawable_real_draw_drawable (GdkDrawable *drawable,
+ GdkGC *gc,
+ GdkDrawable *src,
+ gint xsrc,
+ gint ysrc,
+ gint xdest,
+ gint ydest,
+ gint width,
+ gint height)
+{
+ GDK_DRAWABLE_GET_CLASS (drawable)->draw_drawable_with_src (drawable,
+ gc,
+ src,
+ xsrc,
+ ysrc,
+ xdest,
+ ydest,
+ width,
+ height,
+ src);
}
+/************************************************************************/
-GdkImage*
-gdk_drawable_get_image (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height)
+/**
+ * _gdk_drawable_get_scratch_gc:
+ * @drawable: A #GdkDrawable
+ * @graphics_exposures: Whether the returned #GdkGC should generate graphics exposures
+ *
+ * Returns a #GdkGC suitable for drawing on @drawable. The #GdkGC has
+ * the standard values for @drawable, except for the graphics_exposures
+ * field which is determined by the @graphics_exposures parameter.
+ *
+ * The foreground color of the returned #GdkGC is undefined. The #GdkGC
+ * must not be altered in any way, except to change its foreground color.
+ *
+ * Return value: A #GdkGC suitable for drawing on @drawable
+ *
+ * Since: 2.4
+ **/
+GdkGC *
+_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
+ gboolean graphics_exposures)
{
- GdkDrawable *composite;
- gint composite_x_offset = 0;
- gint composite_y_offset = 0;
- GdkImage *retval;
-
+ GdkScreen *screen;
+ gint depth;
+
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- g_return_val_if_fail (x >= 0, NULL);
- g_return_val_if_fail (y >= 0, NULL);
- g_return_val_if_fail (width >= 0, NULL);
- g_return_val_if_fail (height >= 0, NULL);
- composite =
- GDK_DRAWABLE_GET_CLASS (drawable)->get_composite_drawable (drawable,
- x, y,
- width, height,
- &composite_x_offset,
- &composite_y_offset);
-
- retval = GDK_DRAWABLE_GET_CLASS (composite)->get_image (composite,
- x - composite_x_offset,
- y - composite_y_offset,
- width, height);
+ screen = gdk_drawable_get_screen (drawable);
+
+ g_return_val_if_fail (!screen->closed, NULL);
+
+ depth = gdk_drawable_get_depth (drawable) - 1;
- g_object_unref (G_OBJECT (composite));
+ if (graphics_exposures)
+ {
+ if (!screen->exposure_gcs[depth])
+ {
+ GdkGCValues values;
+ GdkGCValuesMask mask;
+
+ values.graphics_exposures = TRUE;
+ mask = GDK_GC_EXPOSURES;
- return retval;
+ screen->exposure_gcs[depth] =
+ gdk_gc_new_with_values (drawable, &values, mask);
+ }
+
+ return screen->exposure_gcs[depth];
+ }
+ else
+ {
+ if (!screen->normal_gcs[depth])
+ {
+ screen->normal_gcs[depth] =
+ gdk_gc_new (drawable);
+ }
+
+ return screen->normal_gcs[depth];
+ }
}
-static GdkDrawable*
-gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
- gint x,
- gint y,
- gint width,
- gint height,
- gint *composite_x_offset,
- gint *composite_y_offset)
+/**
+ * _gdk_drawable_get_subwindow_scratch_gc:
+ * @drawable: A #GdkDrawable
+ *
+ * Returns a #GdkGC suitable for drawing on @drawable. The #GdkGC has
+ * the standard values for @drawable, except for the graphics_exposures
+ * field which is %TRUE and the subwindow mode which is %GDK_INCLUDE_INFERIORS.
+ *
+ * The foreground color of the returned #GdkGC is undefined. The #GdkGC
+ * must not be altered in any way, except to change its foreground color.
+ *
+ * Return value: A #GdkGC suitable for drawing on @drawable
+ *
+ * Since: 2.18
+ **/
+GdkGC *
+_gdk_drawable_get_subwindow_scratch_gc (GdkDrawable *drawable)
{
+ GdkScreen *screen;
+ gint depth;
+
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
- *composite_x_offset = 0;
- *composite_y_offset = 0;
+ screen = gdk_drawable_get_screen (drawable);
+
+ g_return_val_if_fail (!screen->closed, NULL);
+
+ depth = gdk_drawable_get_depth (drawable) - 1;
+
+ if (!screen->subwindow_gcs[depth])
+ {
+ GdkGCValues values;
+ GdkGCValuesMask mask;
+
+ values.graphics_exposures = TRUE;
+ values.subwindow_mode = GDK_INCLUDE_INFERIORS;
+ mask = GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW;
+
+ screen->subwindow_gcs[depth] =
+ gdk_gc_new_with_values (drawable, &values, mask);
+ }
- return GDK_DRAWABLE (g_object_ref (G_OBJECT (drawable)));
+ return screen->subwindow_gcs[depth];
+}
+
+
+/*
+ * _gdk_drawable_get_source_drawable:
+ * @drawable: a #GdkDrawable
+ *
+ * Returns a drawable for the passed @drawable that is guaranteed to be
+ * usable to create a pixmap (e.g.: not an offscreen window).
+ *
+ * Since: 2.16
+ */
+GdkDrawable *
+_gdk_drawable_get_source_drawable (GdkDrawable *drawable)
+{
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+
+ if (GDK_DRAWABLE_GET_CLASS (drawable)->get_source_drawable)
+ return GDK_DRAWABLE_GET_CLASS (drawable)->get_source_drawable (drawable);
+
+ return drawable;
+}
+
+cairo_surface_t *
+_gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
+ int width,
+ int height)
+{
+ return GDK_DRAWABLE_GET_CLASS (drawable)->create_cairo_surface (drawable,
+ width, height);
}