1997-11-24 22:37:52 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
1998-09-15 17:08:38 +00:00
|
|
|
#include <stdlib.h>
|
1997-11-24 22:37:52 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2002-01-04 05:58:01 +00:00
|
|
|
#include "gdk.h" /* For gdk_flush() */
|
1999-10-01 23:18:30 +00:00
|
|
|
#include "gdkimage.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gdkprivate.h"
|
2002-01-04 05:58:01 +00:00
|
|
|
#include "gdkinternals.h" /* For scratch_image code */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2001-10-03 18:19:48 +00:00
|
|
|
/**
|
|
|
|
* gdk_image_ref:
|
|
|
|
* @image: a #GdkImage
|
|
|
|
*
|
|
|
|
* Deprecated function; use g_object_ref() instead.
|
|
|
|
*
|
|
|
|
* Return value: the image
|
|
|
|
**/
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkImage *
|
1999-11-08 20:14:59 +00:00
|
|
|
gdk_image_ref (GdkImage *image)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
return (GdkImage *) g_object_ref (G_OBJECT (image));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2001-10-03 18:19:48 +00:00
|
|
|
/**
|
|
|
|
* gdk_image_unref:
|
|
|
|
* @image: a #GdkImage
|
|
|
|
*
|
|
|
|
* Deprecated function; use g_object_unref() instead.
|
|
|
|
*
|
|
|
|
**/
|
1997-11-24 22:37:52 +00:00
|
|
|
void
|
1999-11-08 20:14:59 +00:00
|
|
|
gdk_image_unref (GdkImage *image)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
g_return_if_fail (GDK_IS_IMAGE (image));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
Make this compile without framebuffer enabled
2000-06-20 Havoc Pennington <hp@redhat.com>
* modules/linux-fb/Makefile.am: Make this compile
without framebuffer enabled
* gdk/linux-fb/Makefile.am: Add conditional to not build
framebuffer unless specified in configure
* gdk/gdkdraw.c (gdk_draw_drawable): Fix bug where I was getting
the size of the target instead of source if -1 was passed for
width/height
* gdk/x11/gdkgeometry-x11.c (gdk_window_compute_position): Fix
width/height confusion.
2000-06-19 Havoc Pennington <hp@redhat.com>
* gdk/x11/gdkx.h (GDK_WINDOW_XWINDOW): change this to be
GDK_DRAWABLE_XID. In the future, we probably want to make it
faster with G_DISABLE_CHECKS turned on.
2000-06-14 Havoc Pennington <hp@redhat.com>
* gdk/Makefile.am: add gdkpixmap.c
* gdk/gdk.c: s/gdk_window_init/_gdk_windowing_window_init/
s/gdk_image_init/_gdk_windowing_image_init
* gdk/gdkcolor.c: make ref/unref compat wrappers for GObject
ref/unref
* gdk/gdkcolor.h: make GdkColormap a GObject subclass
* gdk/gdkcompat.h: remove GdkWindowType compat, since
GdkWindowType is now non-deprecated;
change gdk_window_get_type() compat to be
gdk_window_get_window_type().
* gdk/gdkdnd.h: make GdkDragContext a GObject.
* gdk/gdkdraw.c, gdk/gdkdraw.h: Convert GdkDrawable to a pure
virtual GObject. Make all functions call into the vtable.
Move gdk_image_put() guts in here. Remove GdkDrawableType
and gdk_drawable_get_type(), these are now GdkWindow-specific.
draw_image, get_depth, get_size, set_colormap, get_colormap,
get_visual added to the vtable.
* gdk/gdkgc.h, gdk/gdkgc.c: Convert GdkGC to a pure virtual
GObject. Virtualize everything.
(gdk_gc_new_with_values): remove check for destroyed window,
because now GdkWindow::create_gc will check this.
(gdk_gc_set_values): New function to set GC values, this
was already implemented but wasn't in the header
* gdk/gdkimage.h, gdk/gdkimage.c: Convert GdkImage to a GObject.
* gdk/gdkinternals.h: Remove _gdk_window_alloc(), remove
_gdk_window_draw_image(), remove _gdk_windowing_window_class,
remove _gdk_window_class; add _gdk_window_impl_get_type() and
_gdk_pixmap_impl_get_type(). Rename gdk_window_init to
_gdk_windowing_window_init, rename gdk_image_init to
_gdk_windowing_image_init.
* gdk/gdkpango.c: Reflect GObject-ification of PangoContext.
(gdk_draw_layout): Remove check for destroyed window,
because all the drawable methods already check it.
* gdk/gdkpixmap.h, gdk/gdkpixmap.c: Convert GdkPixmap to GObject.
Add gdkpixmap.c which contains implementation of GdkDrawable
virtual table (by chaining to a platform-specific implementation
object).
* gdk/gdkprivate.h: Remove GDK_IS_WINDOW, GDK_IS_PIXMAP,
GDK_DRAWABLE_DESTROYED. Add GDK_WINDOW_DESTROYED. Replace
GDK_DRAWABLE_TYPE with GDK_WINDOW_TYPE. Remove GdkDrawablePrivate,
GdkWindowPrivate, GdkImageClass, GdkImagePrivate, GdkGCPrivate,
GdkColormapPrivate.
* gdk/gdktypes.h: #include <glib-object.h>
* gdk/gdkwindow.h, gdk/gdkwindow.c: Convert GdkWindow to GObject.
Move most functionality to platform-specific implementation
object. GdkWindow itself now handles the backing store, then
chains to the platform-specific implementation.
(gdk_window_get_window_type): return GdkWindowType of the window.
(gdk_window_peek_children): New routine, returns the children of
a GdkWindow
(gdk_window_get_children): Was in X11-specific code and did
XQueryTree. Changed to simply return a copy of window->children;
so it can go in cross-platform code.
* gdk/x11/Makefile.am: fix broken MKINSTALLDIRS path
* gdk/x11/gdkcolor-x11.c: implement X-specific parts of
GdkColormap; just changed to use the new private data instead
of casting to GdkColormapPrivate.
* gdk/x11/gdkcursor-x11.c: added a couple typechecks to
gdk_cursor_new().
* gdk/x11/gdkdnd-x11.c: Change the way we access private fields
(private data member in the GObject).
(xdnd_manager_source_filter): Function had broken
error handling, fix it (use gdk_error_trap_push).
* gdk/x11/gdkdrawable-x11.c: This file now implements
a base class for GdkWindowImplX11/GdkPixmapImplX11. This
base class is purely for the convenience of the X port,
and not part of the interface to cross-platform GDK.
* gdk/x11/gdkevents-x11.c: Reflect various renamings.
* gdk/x11/gdkgc-x11.c: Implement a subclass of GdkGC that's
specific to X, and returned by the create_gc virtual method
of GdkDrawableImplX11.
(gdk_x11_gc_set_dashes): Change this to take an array of gint8
rather than gchar, this was also changed in the GdkGC vtable.
(gdk_x11_gc_values_to_xvalues): If GdkGCValues is NULL, or the
mask is 0, return immediately, instead of checking every flag.
This is faster, and keeps us from segfaulting if values is NULL
and the mask contains some nonzero flags.
* gdk/x11/gdkgeometry-x11.c: deal with all the rearranging of
GdkWindow.
* gdk/x11/gdkglobals-x11.c: change type of grab window, since
GdkWindowPrivate is gone.
* gdk/x11/gdkim-x11.c: rename things that got renamed.
* gdk/x11/gdkimage-x11.c: implement in terms of GObject, and
remove the image_put stuff that got transferred to GdkDrawable.
* gdk/x11/gdkinput.c: renamings
* gdk/x11/gdkmain-x11.c: #include <pango/pangox.h>
* gdk/x11/gdkpixmap-x11.c: GObject conversion
* gdk/x11/gdkprivate-x11.h: indentation fixes
* gdk/x11/gdkproperty-x11.c: renamings
* gdk/x11/gdkselection-x11.c: renamings
* gdk/x11/gdkwindow-x11.c: Restructuring and renaming; this now
implements the platform-specific "impl" object.
Moved gdk_window_get_children to gdk/gdkwindow.c
* gdk/x11/gdkx.h: Remove all the private structs and private datas
that no longer exist. Add declaration of GdkGCX11 object here.
Fix all the macros to still work.
* gtk/gtk-boxed.defs: Remove GtkStyle, GdkColormap, GdkWindow,
GdkDragContext from the boxed types since they are now GObjects.
* gtk/gtkstyle.h, gtk/gtkstyle.c: Converted GtkStyle to a GObject,
moved xthickness/ythickness into the instance. GtkStyleClass
functions are now in the standard vtable for GtkStyle, so you have
to create a GObject subclass to write a theme engine.
(gtk_style_copy): fixed a leaked PangoFontDescription
(gtk_style_init): renamed gtk_style_realize, so gtk_style_init
can be the standard GObject function.
* Throughout GTK:
s/style->klass->[xy]thickness/style->[xy]thickness
s/pango_layout_unref/g_object_unref/
* gtk/gtkrc.h, gtk/gtkrc.c: Converted GtkRcStyle to a GObject.
* gtk/gtksocket.c: Use gdk_window_get_user_data() instead of
accessing GDK internals.
* gtk/gtkwidget.c: Use gdk_window_peek_children() instead of
accessing GDK internals.
2000-06-20 21:04:44 +00:00
|
|
|
g_object_unref (G_OBJECT (image));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
2000-10-24 00:15:14 +00:00
|
|
|
|
Clip the retrieved image data to the screen, using a server grab to avoid
2001-06-28 Havoc Pennington <hp@pobox.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved
image data to the screen, using a server grab to avoid race
conditions.
* gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove
check for NULL return from gtk_image_new_from_stock(), it never
returns NULL.
(gtk_item_factory_create_item): fix bug where we parsed the stock
ID as an inline pixbuf
* gtk/gtktext.c (gtk_text_key_press): numeric keypad support
* gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad
support (should be using binding set here)
* gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad
support (should be using binding set here)
* gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad
support
* gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support
* gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad
* gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad
* gtk/gtkimcontextsimple.c
(gtk_im_context_simple_filter_keypress): keypad
* gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad
* gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes
* gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support
* gtk/gtkcolorsel.c (palette_activate): keypad support (of course,
should be binding-setted)
* gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes
* gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes
* gtk/gtkcalendar.c: numeric keypad fixes
* gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad
support
* gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop
screwup
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
clip the render area to the drawable's clip region in advance,
so we don't get data from the server that we don't need.
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
check return value of gdk_pixbuf_get_from_drawable(), fall back
to bilevel alpha if we can't get the pixbuf to composite against.
* gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap
* gdk/gdkimage.c (gdk_image_get_colormap): add
gdk_image_set_colormap, gdk_image_get_colormap
* gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to
take a region of the image, instead of converting the entire
image.
* gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help
keybinding signal. Add default bindings for it. Add default
handler for show_help that shows the tooltip for the widget.
* gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and
"close" keybinding signal, remove key press handler.
* gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this,
it's not our usual practice to leave a deprecated function around
with a runtime warning, plus we don't want it to appear in docs,
plus if we make them yellow no one will want to change them
anyhow.
2001-06-29 01:59:02 +00:00
|
|
|
/**
|
|
|
|
* gdk_image_get:
|
2001-11-21 21:44:08 +00:00
|
|
|
* @drawable: a #GdkDrawable
|
Clip the retrieved image data to the screen, using a server grab to avoid
2001-06-28 Havoc Pennington <hp@pobox.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved
image data to the screen, using a server grab to avoid race
conditions.
* gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove
check for NULL return from gtk_image_new_from_stock(), it never
returns NULL.
(gtk_item_factory_create_item): fix bug where we parsed the stock
ID as an inline pixbuf
* gtk/gtktext.c (gtk_text_key_press): numeric keypad support
* gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad
support (should be using binding set here)
* gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad
support (should be using binding set here)
* gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad
support
* gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support
* gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad
* gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad
* gtk/gtkimcontextsimple.c
(gtk_im_context_simple_filter_keypress): keypad
* gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad
* gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes
* gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support
* gtk/gtkcolorsel.c (palette_activate): keypad support (of course,
should be binding-setted)
* gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes
* gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes
* gtk/gtkcalendar.c: numeric keypad fixes
* gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad
support
* gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop
screwup
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
clip the render area to the drawable's clip region in advance,
so we don't get data from the server that we don't need.
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
check return value of gdk_pixbuf_get_from_drawable(), fall back
to bilevel alpha if we can't get the pixbuf to composite against.
* gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap
* gdk/gdkimage.c (gdk_image_get_colormap): add
gdk_image_set_colormap, gdk_image_get_colormap
* gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to
take a region of the image, instead of converting the entire
image.
* gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help
keybinding signal. Add default bindings for it. Add default
handler for show_help that shows the tooltip for the widget.
* gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and
"close" keybinding signal, remove key press handler.
* gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this,
it's not our usual practice to leave a deprecated function around
with a runtime warning, plus we don't want it to appear in docs,
plus if we make them yellow no one will want to change them
anyhow.
2001-06-29 01:59:02 +00:00
|
|
|
* @x: x coordinate in @window
|
|
|
|
* @y: y coordinate in @window
|
|
|
|
* @width: width of area in @window
|
|
|
|
* @height: height of area in @window
|
|
|
|
*
|
|
|
|
* This is a deprecated wrapper for gdk_drawable_get_image();
|
|
|
|
* gdk_drawable_get_image() should be used instead. Or even better: in
|
|
|
|
* most cases gdk_pixbuf_get_from_drawable() is the most convenient
|
|
|
|
* choice.
|
|
|
|
*
|
|
|
|
* Return value: a new #GdkImage or %NULL
|
|
|
|
**/
|
2000-10-24 00:15:14 +00:00
|
|
|
GdkImage*
|
2001-11-21 21:44:08 +00:00
|
|
|
gdk_image_get (GdkWindow *drawable,
|
2000-10-24 00:15:14 +00:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2001-11-21 21:44:08 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
|
2000-10-24 00:15:14 +00:00
|
|
|
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);
|
|
|
|
|
2001-11-21 22:42:50 +00:00
|
|
|
return gdk_drawable_get_image (drawable, x, y, width, height);
|
2000-10-24 00:15:14 +00:00
|
|
|
}
|
Clip the retrieved image data to the screen, using a server grab to avoid
2001-06-28 Havoc Pennington <hp@pobox.com>
* gdk/x11/gdkimage-x11.c (_gdk_x11_get_image): Clip the retrieved
image data to the screen, using a server grab to avoid race
conditions.
* gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove
check for NULL return from gtk_image_new_from_stock(), it never
returns NULL.
(gtk_item_factory_create_item): fix bug where we parsed the stock
ID as an inline pixbuf
* gtk/gtktext.c (gtk_text_key_press): numeric keypad support
* gtk/gtkspinbutton.c (gtk_spin_button_key_press): numeric keypad
support (should be using binding set here)
* gtk/gtkoptionmenu.c (gtk_option_menu_key_press): numeric keypad
support (should be using binding set here)
* gtk/gtkmenushell.c (gtk_menu_shell_class_init): numeric keypad
support
* gtk/gtkmenu.c (gtk_menu_class_init): numeric keypad support
* gtk/gtkmenubar.c (gtk_menu_bar_class_init): numeric keypad
* gtk/gtklistitem.c (gtk_list_item_class_init): numeric keypad
* gtk/gtkimcontextsimple.c
(gtk_im_context_simple_filter_keypress): keypad
* gtk/gtkfilesel.c (gtk_file_selection_key_press): keypad
* gtk/gtkentry.c (gtk_entry_class_init): numeric keypad fixes
* gtk/gtkctree.c (gtk_ctree_class_init): numeric keypad support
* gtk/gtkcolorsel.c (palette_activate): keypad support (of course,
should be binding-setted)
* gtk/gtkwindow.c (gtk_window_class_init): numeric keypad fixes
* gtk/gtkclist.c (gtk_clist_class_init): numeric keypad fixes
* gtk/gtkcalendar.c: numeric keypad fixes
* gtk/gtktextview.c (gtk_text_view_class_init): numeric keypad
support
* gdk/gdkwindow.c (gdk_window_get_clip_region): fix infinite loop
screwup
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
clip the render area to the drawable's clip region in advance,
so we don't get data from the server that we don't need.
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable_alpha):
check return value of gdk_pixbuf_get_from_drawable(), fall back
to bilevel alpha if we can't get the pixbuf to composite against.
* gdk/gdkdraw.c (gdk_drawable_get_image): set the image colormap
* gdk/gdkimage.c (gdk_image_get_colormap): add
gdk_image_set_colormap, gdk_image_get_colormap
* gdk/gdkpixbuf-drawable.c (rgbconvert): Change all converters to
take a region of the image, instead of converting the entire
image.
* gtk/gtkwidget.h (struct _GtkWidgetClass): add show_help
keybinding signal. Add default bindings for it. Add default
handler for show_help that shows the tooltip for the widget.
* gtk/gtkdialog.c (gtk_dialog_class_init): add binding set and
"close" keybinding signal, remove key press handler.
* gtk/gtktooltips.c (gtk_tooltips_set_colors): Just remove this,
it's not our usual practice to leave a deprecated function around
with a runtime warning, plus we don't want it to appear in docs,
plus if we make them yellow no one will want to change them
anyhow.
2001-06-29 01:59:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_image_set_colormap:
|
|
|
|
* @image: a #GdkImage
|
|
|
|
* @colormap: a #GdkColormap
|
|
|
|
*
|
|
|
|
* Sets the colormap for the image to the given colormap. Normally
|
|
|
|
* there's no need to use this function, images are created with the
|
|
|
|
* correct colormap if you get the image from a drawable. If you
|
|
|
|
* create the image from scratch, use the colormap of the drawable you
|
|
|
|
* intend to render the image to.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gdk_image_set_colormap (GdkImage *image,
|
|
|
|
GdkColormap *colormap)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GDK_IS_IMAGE (image));
|
|
|
|
g_return_if_fail (GDK_IS_COLORMAP (colormap));
|
|
|
|
|
|
|
|
if (image->colormap != colormap)
|
|
|
|
{
|
|
|
|
if (image->colormap)
|
|
|
|
g_object_unref (G_OBJECT (image->colormap));
|
|
|
|
|
|
|
|
image->colormap = colormap;
|
|
|
|
g_object_ref (G_OBJECT (image->colormap));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_image_get_colormap:
|
|
|
|
* @image: a #GdkImage
|
|
|
|
*
|
|
|
|
* Retrieves the colormap for a given image, if it exists. An image
|
|
|
|
* will have a colormap if the drawable from which it was created has
|
|
|
|
* a colormap, or if a colormap was set explicitely with
|
|
|
|
* gdk_image_set_colormap().
|
|
|
|
*
|
|
|
|
* Return value: colormap for the image
|
|
|
|
**/
|
|
|
|
GdkColormap *
|
|
|
|
gdk_image_get_colormap (GdkImage *image)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_IMAGE (image), NULL);
|
|
|
|
|
|
|
|
return image->colormap;
|
|
|
|
}
|
2002-01-04 05:58:01 +00:00
|
|
|
|
|
|
|
/* We have N_REGION GDK_SCRATCH_IMAGE_WIDTH x GDK_SCRATCH_IMAGE_HEIGHT regions divided
|
|
|
|
* up between n_images different images. possible_n_images gives
|
|
|
|
* various divisors of N_REGIONS. The reason for allowing this
|
|
|
|
* flexibility is that we want to create as few images as possible,
|
|
|
|
* but we want to deal with the abberant systems that have a SHMMAX
|
|
|
|
* limit less than
|
|
|
|
*
|
|
|
|
* GDK_SCRATCH_IMAGE_WIDTH * GDK_SCRATCH_IMAGE_HEIGHT * N_REGIONS * 4 (384k)
|
|
|
|
*
|
|
|
|
* (Are there any such?)
|
|
|
|
*/
|
|
|
|
#define N_REGIONS 6
|
|
|
|
static const int possible_n_images[] = { 1, 2, 3, 6 };
|
|
|
|
|
|
|
|
/* We allocate one GdkScratchImageInfo structure for each
|
|
|
|
* depth where we are allocating scratch images. (Future: one
|
|
|
|
* per depth, per display)
|
|
|
|
*/
|
|
|
|
typedef struct _GdkScratchImageInfo GdkScratchImageInfo;
|
|
|
|
|
|
|
|
struct _GdkScratchImageInfo {
|
|
|
|
gint depth;
|
|
|
|
|
|
|
|
gint n_images;
|
|
|
|
GdkImage *static_image[N_REGIONS];
|
|
|
|
gint static_image_idx;
|
|
|
|
|
|
|
|
/* In order to optimize filling fractions, we simultaneously fill in up
|
|
|
|
* to three regions of size GDK_SCRATCH_IMAGE_WIDTH * GDK_SCRATCH_IMAGE_HEIGHT: one
|
|
|
|
* for images that are taller than GDK_SCRATCH_IMAGE_HEIGHT / 2, and must
|
|
|
|
* be tiled horizontally. One for images that are wider than
|
|
|
|
* GDK_SCRATCH_IMAGE_WIDTH / 2 and must be tiled vertically, and a third
|
|
|
|
* for images smaller than GDK_SCRATCH_IMAGE_HEIGHT / 2 x GDK_SCRATCH_IMAGE_WIDTH x 2
|
|
|
|
* that we tile in horizontal rows.
|
|
|
|
*/
|
|
|
|
gint horiz_idx;
|
|
|
|
gint horiz_y;
|
|
|
|
gint vert_idx;
|
|
|
|
gint vert_x;
|
|
|
|
|
|
|
|
/* tile_y1 and tile_y2 define the horizontal band into
|
|
|
|
* which we are tiling images. tile_x is the x extent to
|
|
|
|
* which that is filled
|
|
|
|
*/
|
|
|
|
gint tile_idx;
|
|
|
|
gint tile_x;
|
|
|
|
gint tile_y1;
|
|
|
|
gint tile_y2;
|
|
|
|
};
|
|
|
|
|
|
|
|
static GSList *scratch_image_infos = NULL;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
allocate_scratch_images (GdkScratchImageInfo *info,
|
|
|
|
gint n_images,
|
|
|
|
gboolean shared)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < n_images; i++)
|
|
|
|
{
|
|
|
|
info->static_image[i] = _gdk_image_new_for_depth (shared ? GDK_IMAGE_SHARED : GDK_IMAGE_NORMAL,
|
|
|
|
NULL,
|
|
|
|
GDK_SCRATCH_IMAGE_WIDTH * (N_REGIONS / n_images), GDK_SCRATCH_IMAGE_HEIGHT,
|
|
|
|
info->depth);
|
|
|
|
|
|
|
|
if (!info->static_image[i])
|
|
|
|
{
|
|
|
|
gint j;
|
|
|
|
|
|
|
|
for (j = 0; j < i; j++)
|
|
|
|
gdk_image_unref (info->static_image[i]);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-01-31 15:48:58 +00:00
|
|
|
static GdkScratchImageInfo *
|
2002-01-04 05:58:01 +00:00
|
|
|
scratch_image_info_for_depth (gint depth)
|
|
|
|
{
|
|
|
|
GSList *tmp_list;
|
|
|
|
GdkScratchImageInfo *image_info;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
tmp_list = scratch_image_infos;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
image_info = tmp_list->data;
|
|
|
|
if (image_info->depth == depth)
|
|
|
|
return image_info;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
image_info = g_new (GdkScratchImageInfo, 1);
|
|
|
|
|
|
|
|
image_info->depth = depth;
|
|
|
|
|
|
|
|
/* Try to allocate as few possible shared images */
|
|
|
|
for (i=0; i < G_N_ELEMENTS (possible_n_images); i++)
|
|
|
|
{
|
|
|
|
if (allocate_scratch_images (image_info, possible_n_images[i], TRUE))
|
|
|
|
{
|
|
|
|
image_info->n_images = possible_n_images[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If that fails, just allocate N_REGIONS normal images */
|
|
|
|
if (i == G_N_ELEMENTS (possible_n_images))
|
|
|
|
{
|
|
|
|
allocate_scratch_images (image_info, N_REGIONS, FALSE);
|
|
|
|
image_info->n_images = N_REGIONS;
|
|
|
|
}
|
|
|
|
|
|
|
|
image_info->static_image_idx = 0;
|
|
|
|
|
|
|
|
image_info->horiz_y = GDK_SCRATCH_IMAGE_HEIGHT;
|
|
|
|
image_info->vert_x = GDK_SCRATCH_IMAGE_WIDTH;
|
|
|
|
image_info->tile_x = GDK_SCRATCH_IMAGE_WIDTH;
|
|
|
|
image_info->tile_y1 = image_info->tile_y2 = GDK_SCRATCH_IMAGE_HEIGHT;
|
|
|
|
|
|
|
|
scratch_image_infos = g_slist_prepend (scratch_image_infos, image_info);
|
|
|
|
|
|
|
|
return image_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Defining NO_FLUSH can cause inconsistent screen updates, but is useful
|
|
|
|
for performance evaluation. */
|
|
|
|
|
|
|
|
#undef NO_FLUSH
|
|
|
|
|
|
|
|
#ifdef VERBOSE
|
|
|
|
static gint sincelast;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static gint
|
|
|
|
alloc_scratch_image (GdkScratchImageInfo *image_info)
|
|
|
|
{
|
|
|
|
if (image_info->static_image_idx == N_REGIONS)
|
|
|
|
{
|
|
|
|
#ifndef NO_FLUSH
|
|
|
|
gdk_flush ();
|
|
|
|
#endif
|
|
|
|
#ifdef VERBOSE
|
|
|
|
g_print ("flush, %d puts since last flush\n", sincelast);
|
|
|
|
sincelast = 0;
|
|
|
|
#endif
|
|
|
|
image_info->static_image_idx = 0;
|
|
|
|
|
|
|
|
/* Mark all regions that we might be filling in as completely
|
|
|
|
* full, to force new tiles to be allocated for subsequent
|
|
|
|
* images
|
|
|
|
*/
|
|
|
|
image_info->horiz_y = GDK_SCRATCH_IMAGE_HEIGHT;
|
|
|
|
image_info->vert_x = GDK_SCRATCH_IMAGE_WIDTH;
|
|
|
|
image_info->tile_x = GDK_SCRATCH_IMAGE_WIDTH;
|
|
|
|
image_info->tile_y1 = image_info->tile_y2 = GDK_SCRATCH_IMAGE_HEIGHT;
|
|
|
|
}
|
|
|
|
return image_info->static_image_idx++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _gdk_image_get_scratch:
|
|
|
|
* @width: desired width
|
|
|
|
* @height: desired height
|
|
|
|
* @depth: depth of image
|
|
|
|
* @x: X location within returned image of scratch image
|
|
|
|
* @y: Y location within returned image of scratch image
|
|
|
|
*
|
|
|
|
* Allocates an image of size width/height, up to a maximum
|
|
|
|
* of GDK_SCRATCH_IMAGE_WIDTHxGDK_SCRATCH_IMAGE_HEIGHT
|
|
|
|
*
|
|
|
|
* Return value: a scratch image. This must be used by a
|
|
|
|
* call to gdk_image_put() before any other calls to
|
|
|
|
* _gdk_image_get_scratch()
|
|
|
|
**/
|
|
|
|
GdkImage *
|
|
|
|
_gdk_image_get_scratch (gint width,
|
|
|
|
gint height,
|
|
|
|
gint depth,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
|
|
|
{
|
|
|
|
GdkScratchImageInfo *image_info;
|
|
|
|
GdkImage *image;
|
|
|
|
gint idx;
|
|
|
|
|
|
|
|
image_info = scratch_image_info_for_depth (depth);
|
|
|
|
|
|
|
|
if (width >= (GDK_SCRATCH_IMAGE_WIDTH >> 1))
|
|
|
|
{
|
|
|
|
if (height >= (GDK_SCRATCH_IMAGE_HEIGHT >> 1))
|
|
|
|
{
|
|
|
|
idx = alloc_scratch_image (image_info);
|
|
|
|
*x = 0;
|
|
|
|
*y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (height + image_info->horiz_y > GDK_SCRATCH_IMAGE_HEIGHT)
|
|
|
|
{
|
|
|
|
image_info->horiz_idx = alloc_scratch_image (image_info);
|
|
|
|
image_info->horiz_y = 0;
|
|
|
|
}
|
|
|
|
idx = image_info->horiz_idx;
|
|
|
|
*x = 0;
|
|
|
|
*y = image_info->horiz_y;
|
|
|
|
image_info->horiz_y += height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (height >= (GDK_SCRATCH_IMAGE_HEIGHT >> 1))
|
|
|
|
{
|
|
|
|
if (width + image_info->vert_x > GDK_SCRATCH_IMAGE_WIDTH)
|
|
|
|
{
|
|
|
|
image_info->vert_idx = alloc_scratch_image (image_info);
|
|
|
|
image_info->vert_x = 0;
|
|
|
|
}
|
|
|
|
idx = image_info->vert_idx;
|
|
|
|
*x = image_info->vert_x;
|
|
|
|
*y = 0;
|
|
|
|
/* using 3 and -4 would be slightly more efficient on 32-bit machines
|
|
|
|
with > 1bpp displays */
|
|
|
|
image_info->vert_x += (width + 7) & -8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (width + image_info->tile_x > GDK_SCRATCH_IMAGE_WIDTH)
|
|
|
|
{
|
|
|
|
image_info->tile_y1 = image_info->tile_y2;
|
|
|
|
image_info->tile_x = 0;
|
|
|
|
}
|
|
|
|
if (height + image_info->tile_y1 > GDK_SCRATCH_IMAGE_HEIGHT)
|
|
|
|
{
|
|
|
|
image_info->tile_idx = alloc_scratch_image (image_info);
|
|
|
|
image_info->tile_x = 0;
|
|
|
|
image_info->tile_y1 = 0;
|
|
|
|
image_info->tile_y2 = 0;
|
|
|
|
}
|
|
|
|
if (height + image_info->tile_y1 > image_info->tile_y2)
|
|
|
|
image_info->tile_y2 = height + image_info->tile_y1;
|
|
|
|
idx = image_info->tile_idx;
|
|
|
|
*x = image_info->tile_x;
|
|
|
|
*y = image_info->tile_y1;
|
|
|
|
image_info->tile_x += (width + 7) & -8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
image = image_info->static_image[idx * image_info->n_images / N_REGIONS];
|
|
|
|
*x += GDK_SCRATCH_IMAGE_WIDTH * (idx % (N_REGIONS / image_info->n_images));
|
|
|
|
#ifdef VERBOSE
|
|
|
|
g_print ("index %d, x %d, y %d (%d x %d)\n", idx, *x, *y, width, height);
|
|
|
|
sincelast++;
|
|
|
|
#endif
|
|
|
|
return image;
|
|
|
|
}
|