diff options
author | Alex Larsson <alexl@redhat.com> | 2002-01-25 17:10:03 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2002-01-25 17:10:03 +0000 |
commit | 588e9d1dc060442a86f809598f3ad9aee2609b4b (patch) | |
tree | 2d37a5f9ea8fcca7a8fe84ca02047ab0f9b2b756 /gdk | |
parent | 54b6e6f76b0ff6c8752cddec0516497867baca43 (diff) | |
download | gtk+-588e9d1dc060442a86f809598f3ad9aee2609b4b.tar.gz |
Implement copy_to_image instead of get_image
2002-01-25 Alex Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkdrawable-fb2.c (gdk_drawable_impl_fb_class_init):
Implement copy_to_image instead of get_image
* gdk/linux-fb/gdkimage-fb.c:
Implement _gdk_image_new_for_depth, _gdk_windowing_get_bits_for_depth and
_gdk_fb_copy_to_image.
Based in part on patch from Mathieu Lacage <mathieu_lacage@realmagic.fr>
* gdk/linux-fb/gdkmain-fb.c:
Make ENABLE_FB_MANAGER region larger.
* gdk/linux-fb/gdkprivate-fb.h:
Change _gdk_fb_get_image to _gdk_fb_copy_to_image.
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/linux-fb/gdkdrawable-fb2.c | 2 | ||||
-rw-r--r-- | gdk/linux-fb/gdkimage-fb.c | 138 | ||||
-rw-r--r-- | gdk/linux-fb/gdkmain-fb.c | 2 | ||||
-rw-r--r-- | gdk/linux-fb/gdkprivate-fb.h | 13 |
4 files changed, 100 insertions, 55 deletions
diff --git a/gdk/linux-fb/gdkdrawable-fb2.c b/gdk/linux-fb/gdkdrawable-fb2.c index 4c5cfd2f7c..c44279e7c5 100644 --- a/gdk/linux-fb/gdkdrawable-fb2.c +++ b/gdk/linux-fb/gdkdrawable-fb2.c @@ -221,7 +221,7 @@ gdk_drawable_impl_fb_class_init (GdkDrawableFBClass *klass) drawable_class->get_depth = gdk_fb_get_depth; drawable_class->get_visual = gdk_fb_get_visual; - drawable_class->get_image = _gdk_fb_get_image; + drawable_class->_copy_to_image = _gdk_fb_copy_to_image; } static void diff --git a/gdk/linux-fb/gdkimage-fb.c b/gdk/linux-fb/gdkimage-fb.c index dff16fbb52..7c803fa560 100644 --- a/gdk/linux-fb/gdkimage-fb.c +++ b/gdk/linux-fb/gdkimage-fb.c @@ -103,6 +103,41 @@ gdk_image_get_type (void) return object_type; } + +GdkImage* +_gdk_image_new_for_depth (GdkImageType type, + GdkVisual *visual, + gint width, + gint height, + gint depth) +{ + GdkImage *image; + GdkImagePrivateFB *private; + + g_return_val_if_fail (!visual || GDK_IS_VISUAL (visual), NULL); + g_return_val_if_fail (visual || depth != -1, NULL); + + if (visual) + depth = visual->depth; + + image = g_object_new (gdk_image_get_type (), NULL); + private = GDK_IMAGE_PRIVATE_DATA (image); + + image->type = 0; + image->visual = visual; + image->width = width; + image->height = height; + image->depth = depth; + + image->byte_order = 0; + image->bits_per_pixel = image->depth; + image->bpp = image->depth/8; + image->bpl = (width * image->depth + 7) / 8; + image->mem = g_malloc (image->bpl * height); + + return image; +} + GdkImage * gdk_image_new_bitmap(GdkVisual *visual, gpointer data, @@ -141,35 +176,19 @@ gdk_image_new (GdkImageType type, gint width, gint height) { - GdkImage *image; - GdkImagePrivateFB *private; - - image = g_object_new (gdk_image_get_type (), NULL); - private = GDK_IMAGE_PRIVATE_DATA (image); - - image->type = 0; - image->visual = visual; - image->width = width; - image->height = height; - image->depth = visual->depth; - - image->byte_order = 0; - image->bits_per_pixel = image->depth; - image->bpp = image->depth/8; - image->bpl = (width * image->depth + 7) / 8; - image->mem = g_malloc (image->bpl * height); - - return image; + return _gdk_image_new_for_depth (type, visual, width, height, -1); } GdkImage* -_gdk_fb_get_image (GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height) +_gdk_fb_copy_to_image (GdkDrawable *drawable, + GdkImage *image, + gint src_x, + gint src_y, + gint dest_x, + gint dest_y, + gint width, + gint height) { - GdkImage *image; GdkImagePrivateFB *private; GdkPixmapFBData fbd; GdkRegion *region = NULL; @@ -177,28 +196,35 @@ _gdk_fb_get_image (GdkDrawable *drawable, g_return_val_if_fail (drawable != NULL, NULL); - image = g_object_new (gdk_image_get_type (), NULL); + if (image == NULL) + { + image = g_object_new (gdk_image_get_type (), NULL); + + image->type = GDK_IMAGE_NORMAL; + image->visual = gdk_drawable_get_visual (drawable); + image->width = width; + image->height = height; + image->bits_per_pixel = GDK_DRAWABLE_FBDATA (drawable)->depth; + image->depth = image->bits_per_pixel; + + if (image->bits_per_pixel <= 8) + image->bpp = 1; + else if (image->bits_per_pixel <= 16) + image->bpp = 2; + else if (image->bits_per_pixel <= 24) + image->bpp = 3; + else + image->bpp = 4; + image->byte_order = 1; + + image->bpl = (image->width * image->depth + 7) / 8; /* Packed pixels */ + image->mem = g_malloc (image->bpl * image->height); + + dest_x = 0; + dest_y = 0; + } + private = GDK_IMAGE_PRIVATE_DATA (image); - - image->type = GDK_IMAGE_NORMAL; - image->visual = gdk_drawable_get_visual (drawable); - image->width = width; - image->height = height; - image->bits_per_pixel = GDK_DRAWABLE_FBDATA (drawable)->depth; - image->depth = image->bits_per_pixel; - - if (image->bits_per_pixel <= 8) - image->bpp = 1; - else if (image->bits_per_pixel <= 16) - image->bpp = 2; - else if (image->bits_per_pixel <= 24) - image->bpp = 3; - else - image->bpp = 4; - image->byte_order = 1; - - image->bpl = (image->width * image->depth + 7) / 8; /* Packed pixels */ - image->mem = g_malloc (image->bpl * image->height); /* Fake its existence as a pixmap */ memset (&fbd, 0, sizeof(fbd)); @@ -224,8 +250,8 @@ _gdk_fb_get_image (GdkDrawable *drawable, gdk_fb_draw_drawable_2 ((GdkPixmap *)&fbd, _gdk_fb_screen_gc, drawable, - x, y, - 0, 0, + src_x, src_y, + dest_x, dest_y, width, height, TRUE, TRUE); @@ -314,3 +340,19 @@ void _gdk_image_exit(void) { } + +/* copy/pasted from gdkimage-win32.c */ +gint +_gdk_windowing_get_bits_for_depth (gint depth) +{ + if ((1 == depth) || (8 == depth) || (16 == depth) || + (24 == depth) || (32 == depth)) + return depth; + else if (15 == depth) + return 16; + else + g_assert_not_reached (); + + return 0; +} + diff --git a/gdk/linux-fb/gdkmain-fb.c b/gdk/linux-fb/gdkmain-fb.c index e20fa369e3..372f80c76b 100644 --- a/gdk/linux-fb/gdkmain-fb.c +++ b/gdk/linux-fb/gdkmain-fb.c @@ -567,6 +567,7 @@ gdk_fb_manager_callback (GIOChannel *gioc, static void gdk_fb_manager_connect (GdkFBDisplay *display) { +#ifdef ENABLE_FB_MANAGER int fd; struct sockaddr_un addr; struct msghdr msg = {0}; @@ -581,7 +582,6 @@ gdk_fb_manager_connect (GdkFBDisplay *display) display->manager_blocked = FALSE; display->manager_fd = -1; -#ifdef ENABLE_FB_MANAGER fd = socket (PF_UNIX, SOCK_STREAM, 0); g_print ("socket: %d\n", fd); diff --git a/gdk/linux-fb/gdkprivate-fb.h b/gdk/linux-fb/gdkprivate-fb.h index 40cfabc8a3..e8741f4aab 100644 --- a/gdk/linux-fb/gdkprivate-fb.h +++ b/gdk/linux-fb/gdkprivate-fb.h @@ -308,11 +308,14 @@ GdkGC * _gdk_fb_gc_new (GdkDrawable *drawable, void _gdk_fb_gc_calc_state (GdkGC *gc, GdkGCValuesMask changed); -GdkImage *_gdk_fb_get_image (GdkDrawable *drawable, - gint x, - gint y, - gint width, - gint height); +GdkImage *_gdk_fb_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_fb_drawable_clear (GdkDrawable *drawable); void gdk_fb_draw_drawable (GdkDrawable *drawable, GdkGC *gc, |