Commit 6f508455 authored by Benjamin Otte's avatar Benjamin Otte
Browse files

API: remove gdk_drawable_copy_to_image()

parent 2a72ffd4
......@@ -392,7 +392,6 @@ gdk_draw_layout_with_colors
<SUBSECTION>
gdk_draw_drawable
gdk_drawable_copy_to_image
<SUBSECTION Standard>
GDK_DRAWABLE
......
......@@ -354,19 +354,3 @@ bottom edges.
@height:
<!-- ##### FUNCTION gdk_drawable_copy_to_image ##### -->
<para>
</para>
@drawable:
@image:
@src_x:
@src_y:
@dest_x:
@dest_y:
@width:
@height:
@Returns:
......@@ -1003,7 +1003,6 @@ gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass)
drawable_class->get_size = gdk_directfb_get_size;
drawable_class->_copy_to_image = _gdk_directfb_copy_to_image;
drawable_class->get_screen = gdk_directfb_get_screen;
......
......@@ -217,76 +217,6 @@ _gdk_image_new_for_depth (GdkScreen *screen,
return image;
}
GdkImage*
_gdk_directfb_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height)
{
GdkDrawableImplDirectFB *impl;
GdkImageDirectFB *private;
int pitch;
DFBRectangle rect = { src_x, src_y, width, height };
IDirectFBDisplayLayer *layer = _gdk_display->layer;
g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_DIRECTFB (drawable), NULL);
g_return_val_if_fail (image != NULL || (dest_x == 0 && dest_y == 0), NULL);
impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
if (impl->wrapper == _gdk_parent_root)
{
DFBResult ret;
ret = layer->SetCooperativeLevel (layer, DLSCL_ADMINISTRATIVE);
if (ret)
{
DirectFBError ("_gdk_directfb_copy_to_image - SetCooperativeLevel",
ret);
return NULL;
}
ret = layer->GetSurface (layer, &impl->surface);
if (ret)
{
layer->SetCooperativeLevel (layer, DLSCL_SHARED);
DirectFBError ("_gdk_directfb_copy_to_image - GetSurface", ret);
return NULL;
}
}
if (! impl->surface)
return NULL;
if (!image)
image = gdk_image_new (GDK_IMAGE_NORMAL,
gdk_drawable_get_visual (drawable), width, height);
private = image->windowing_data;
private->surface->Unlock( private->surface );
private->surface->Blit( private->surface,
impl->surface, &rect, dest_x, dest_y );
private->surface->Lock( private->surface, DSLF_READ | DSLF_WRITE, &image->mem, &pitch );
image->bpl = pitch;
if (impl->wrapper == _gdk_parent_root)
{
impl->surface->Release (impl->surface);
impl->surface = NULL;
layer->SetCooperativeLevel (layer, DLSCL_SHARED);
}
return image;
}
guint32
gdk_image_get_pixel (GdkImage *image,
gint x,
......
......@@ -229,15 +229,6 @@ GdkGC * _gdk_directfb_gc_new (GdkDrawable *drawable,
GdkGCValues *values,
GdkGCValuesMask values_mask);
GdkImage* _gdk_directfb_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
void gdk_directfb_event_windows_add (GdkWindow *window);
void gdk_directfb_event_windows_remove (GdkWindow *window);
......
......@@ -540,7 +540,6 @@ gdk_drag_get_protocol
#if IN_HEADER(__GDK_DRAWABLE_H__)
#if IN_FILE(__GDK_DRAW_C__)
gdk_drawable_copy_to_image
gdk_drawable_get_clip_region
gdk_drawable_get_colormap
gdk_drawable_get_depth
......
......@@ -731,82 +731,6 @@ gdk_draw_trapezoids (GdkDrawable *drawable,
cairo_destroy (cr);
}
/**
* gdk_drawable_copy_to_image:
* @drawable: a #GdkDrawable
* @image: (allow-none): a #GdkDrawable, or %NULL if a new @image should be created.
* @src_x: x coordinate on @drawable
* @src_y: y coordinate on @drawable
* @dest_x: x coordinate within @image. Must be 0 if @image is %NULL
* @dest_y: y coordinate within @image. Must be 0 if @image is %NULL
* @width: width of region to get
* @height: height or region to get
*
* Copies a portion of @drawable into the client side image structure
* @image. If @image is %NULL, creates a new image of size @width x @height
* and copies into that. See gdk_drawable_get_image() for further details.
*
* Return value: @image, or a new a #GdkImage containing the contents
* of @drawable
*
* Since: 2.4
**/
GdkImage*
gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height)
{
GdkDrawable *composite;
gint composite_x_offset = 0;
gint composite_y_offset = 0;
GdkImage *retval;
GdkColormap *cmap;
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (src_x >= 0, NULL);
g_return_val_if_fail (src_y >= 0, NULL);
/* FIXME? Note race condition since we get the size then
* get the image, and the size may have changed.
*/
if (width < 0 || height < 0)
gdk_drawable_get_size (drawable,
width < 0 ? &width : NULL,
height < 0 ? &height : NULL);
composite =
GDK_DRAWABLE_GET_CLASS (drawable)->get_composite_drawable (drawable,
src_x, src_y,
width, height,
&composite_x_offset,
&composite_y_offset);
retval = GDK_DRAWABLE_GET_CLASS (composite)->_copy_to_image (composite,
image,
src_x - composite_x_offset,
src_y - composite_y_offset,
dest_x, dest_y,
width, height);
g_object_unref (composite);
if (!image && retval)
{
cmap = gdk_drawable_get_colormap (drawable);
if (cmap)
gdk_image_set_colormap (retval, cmap);
}
return retval;
}
static GdkDrawable *
gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
gint x,
......
......@@ -134,15 +134,6 @@ struct _GdkDrawableClass
gint *composite_x_offset,
gint *composite_y_offset);
GdkImage* (*_copy_to_image) (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
void (*draw_glyphs_transformed) (GdkDrawable *drawable,
GdkGC *gc,
PangoMatrix *matrix,
......@@ -308,15 +299,6 @@ void gdk_draw_trapezoids (GdkDrawable *drawable,
gint n_trapezoids);
GdkImage *gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
cairo_region_t *gdk_drawable_get_clip_region (GdkDrawable *drawable);
cairo_region_t *gdk_drawable_get_visible_region (GdkDrawable *drawable);
......
......@@ -333,15 +333,6 @@ GdkImage *_gdk_image_get_scratch (GdkScreen *screen,
gint *x,
gint *y);
GdkImage *_gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable);
GdkDrawable *_gdk_drawable_get_source_drawable (GdkDrawable *drawable);
......
......@@ -151,26 +151,6 @@ gdk_offscreen_window_create_gc (GdkDrawable *drawable,
return gdk_gc_new_with_values (offscreen->pixmap, values, values_mask);
}
static GdkImage*
gdk_offscreen_window_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height)
{
GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
return gdk_drawable_copy_to_image (offscreen->pixmap,
image,
src_x,
src_y,
dest_x, dest_y,
width, height);
}
static cairo_surface_t *
gdk_offscreen_window_ref_cairo_surface (GdkDrawable *drawable)
{
......@@ -1119,7 +1099,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
object_class->finalize = gdk_offscreen_window_finalize;
drawable_class->create_gc = gdk_offscreen_window_create_gc;
drawable_class->_copy_to_image = gdk_offscreen_window_copy_to_image;
drawable_class->ref_cairo_surface = gdk_offscreen_window_ref_cairo_surface;
drawable_class->set_colormap = gdk_offscreen_window_set_colormap;
drawable_class->get_colormap = gdk_offscreen_window_get_colormap;
......
......@@ -101,15 +101,6 @@ static void gdk_pixmap_real_get_size (GdkDrawable *drawable,
gint *width,
gint *height);
static GdkImage* gdk_pixmap_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
static cairo_surface_t *gdk_pixmap_ref_cairo_surface (GdkDrawable *drawable);
static cairo_surface_t *gdk_pixmap_create_cairo_surface (GdkDrawable *drawable,
int width,
......@@ -179,7 +170,6 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
drawable_class->set_colormap = gdk_pixmap_real_set_colormap;
drawable_class->get_colormap = gdk_pixmap_real_get_colormap;
drawable_class->get_visual = gdk_pixmap_real_get_visual;
drawable_class->_copy_to_image = gdk_pixmap_copy_to_image;
drawable_class->ref_cairo_surface = gdk_pixmap_ref_cairo_surface;
drawable_class->create_cairo_surface = gdk_pixmap_create_cairo_surface;
}
......@@ -452,24 +442,6 @@ gdk_pixmap_real_get_colormap (GdkDrawable *drawable)
return gdk_drawable_get_colormap (((GdkPixmapObject*)drawable)->impl);
}
static GdkImage*
gdk_pixmap_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height)
{
g_return_val_if_fail (GDK_IS_PIXMAP (drawable), NULL);
return gdk_drawable_copy_to_image (((GdkPixmapObject*)drawable)->impl,
image,
src_x, src_y, dest_x, dest_y,
width, height);
}
static cairo_surface_t *
gdk_pixmap_ref_cairo_surface (GdkDrawable *drawable)
{
......
......@@ -292,15 +292,6 @@ static void gdk_window_draw_trapezoids (GdkDrawable *drawable,
GdkTrapezoid *trapezoids,
gint n_trapezoids);
static GdkImage* gdk_window_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
static cairo_surface_t *gdk_window_ref_cairo_surface (GdkDrawable *drawable);
static cairo_surface_t *gdk_window_create_cairo_surface (GdkDrawable *drawable,
int width,
......@@ -494,7 +485,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
drawable_class->set_colormap = gdk_window_real_set_colormap;
drawable_class->get_colormap = gdk_window_real_get_colormap;
drawable_class->get_visual = gdk_window_real_get_visual;
drawable_class->_copy_to_image = gdk_window_copy_to_image;
drawable_class->ref_cairo_surface = gdk_window_ref_cairo_surface;
drawable_class->create_cairo_surface = gdk_window_create_cairo_surface;
drawable_class->set_cairo_clip = gdk_window_set_cairo_clip;
......@@ -4911,40 +4901,6 @@ gdk_window_real_get_colormap (GdkDrawable *drawable)
return gdk_drawable_get_colormap (((GdkWindowObject*)drawable)->impl);
}
static GdkImage*
gdk_window_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height)
{
GdkWindowObject *private = (GdkWindowObject *) drawable;
gint x_offset, y_offset;
g_return_val_if_fail (GDK_IS_WINDOW (drawable), NULL);
if (GDK_WINDOW_DESTROYED (drawable))
return NULL;
/* If we're here, a composite image was not necessary, so
* we can ignore the paint stack.
*/
/* TODO: Is this right? */
x_offset = 0;
y_offset = 0;
return gdk_drawable_copy_to_image (private->impl,
image,
src_x - x_offset,
src_y - y_offset,
dest_x, dest_y,
width, height);
}
static void
gdk_window_drop_cairo_surface (GdkWindowObject *private)
{
......
......@@ -544,8 +544,6 @@ gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass)
drawable_class->get_depth = gdk_quartz_get_depth;
drawable_class->get_screen = gdk_quartz_get_screen;
drawable_class->get_visual = gdk_quartz_get_visual;
drawable_class->_copy_to_image = _gdk_quartz_image_copy_to_image;
}
GType
......
......@@ -26,155 +26,6 @@
static GObjectClass *parent_class;
GdkImage *
_gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height)
{
GdkScreen *screen;
g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_QUARTZ (drawable), NULL);
g_return_val_if_fail (image != NULL || (dest_x == 0 && dest_y == 0), NULL);
screen = gdk_drawable_get_screen (drawable);
if (!image)
image = _gdk_image_new_for_depth (screen, GDK_IMAGE_FASTEST, NULL,
width, height,
gdk_drawable_get_depth (drawable));
if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable))
{
GdkPixmapImplQuartz *pix_impl;
gint bytes_per_row;
guchar *data;
int x, y;
pix_impl = GDK_PIXMAP_IMPL_QUARTZ (drawable);
data = (guchar *)(pix_impl->data);
if (src_x + width > pix_impl->width || src_y + height > pix_impl->height)
{
g_warning ("Out of bounds copy-area for pixmap -> image conversion\n");
return image;
}
switch (gdk_drawable_get_depth (drawable))
{
case 24:
bytes_per_row = pix_impl->width * 4;
for (y = 0; y < height; y++)
{
guchar *src = data + ((y + src_y) * bytes_per_row) + (src_x * 4);
for (x = 0; x < width; x++)
{
gint32 pixel;
/* RGB24, 4 bytes per pixel, skip first. */
pixel = src[0] << 16 | src[1] << 8 | src[2];
src += 4;
gdk_image_put_pixel (image, dest_x + x, dest_y + y, pixel);
}
}
break;
case 32:
bytes_per_row = pix_impl->width * 4;
for (y = 0; y < height; y++)
{
guchar *src = data + ((y + src_y) * bytes_per_row) + (src_x * 4);
for (x = 0; x < width; x++)
{
gint32 pixel;
/* ARGB32, 4 bytes per pixel. */
pixel = src[0] << 24 | src[1] << 16 | src[2] << 8 | src[3];
src += 4;
gdk_image_put_pixel (image, dest_x + x, dest_y + y, pixel);
}
}
break;
case 1: /* TODO: optimize */
bytes_per_row = pix_impl->width;
for (y = 0; y < height; y++)
{
guchar *src = data + ((y + src_y) * bytes_per_row) + src_x;
for (x = 0; x < width; x++)
{
gint32 pixel;
/* 8 bits */
pixel = src[0];
src++;
gdk_image_put_pixel (image, dest_x + x, dest_y + y, pixel);
}
}
break;
default:
g_warning ("Unsupported bit depth %d\n", gdk_drawable_get_depth (drawable));
return image;
}
}
else if (GDK_IS_WINDOW_IMPL_QUARTZ (drawable))
{
GdkQuartzView *view;
NSBitmapImageRep *rep;
NSRect rect;
guchar *data;
int x, y;
NSSize size;
view = GDK_WINDOW_IMPL_QUARTZ (drawable)->view;
/* We return the image even if we can't copy to it. */
if (![view lockFocusIfCanDraw])
return image;
rect = NSMakeRect (src_x, src_y, width, height);
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: rect];
[view unlockFocus];
data = [rep bitmapData];
size = [rep size];
for (y = 0; y < size.height; y++)
{
guchar *src = data + y * [rep bytesPerRow];
for (x = 0; x < size.width; x++)
{
gint32 pixel;
if (image->byte_order == GDK_LSB_FIRST)
pixel = src[0] << 8 | src[1] << 16 |src[2] << 24;
else
pixel = src[0] << 16 | src[1] << 8 |src[2];
src += 3;
gdk_image_put_pixel (image, dest_x + x, dest_y + y, pixel);
}
}
[rep release];
}
return image;
}
static void
gdk_image_finalize (GObject *object)
{
......
......@@ -180,16 +180,6 @@ gboolean _gdk_quartz_event_loop_check_pending (void);
NSEvent * _gdk_quartz_event_loop_get_pending (void);
void _gdk_quartz_event_loop_release_event (NSEvent *event);
/* FIXME: image */
GdkImage *_gdk_quartz_image_copy_to_image (GdkDrawable *drawable,
GdkImage *image,
gint src_x,
gint src_y,
gint dest_x,
gint dest_y,
gint width,
gint height);
/* Keys */
GdkEventType _gdk_quartz_keys_event_type (NSEvent *event);
gboolean _gdk_quartz_keys_is_modifier (guint keycode);
......
......@@ -137,8 +137,6 @@ _gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
drawable_class->get_depth = gdk_win32_get_depth;
drawable_class->get_screen = gdk_win32_get_screen;
drawable_class->get_visual = gdk_win32_get_visual;
drawable_class->_copy_to_image = _gdk_win32_copy_to_image;
}