API: remove gdk_drawable_copy_to_image()
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user