2001-02-05 23:22:20 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-03-01 11:53:41 +08:00
|
|
|
* gimppreviewrenderer.c
|
|
|
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
2001-02-05 23:22:20 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-05-03 20:26:05 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-02-05 23:22:20 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 11:48:54 +08:00
|
|
|
#include "widgets-types.h"
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2002-09-07 06:25:19 +08:00
|
|
|
#ifdef __GNUC__
|
2002-05-08 00:23:14 +08:00
|
|
|
#warning FIXME #include "display/display-types.h"
|
2002-09-07 06:25:19 +08:00
|
|
|
#endif
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "display/display-types.h"
|
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2002-03-22 23:47:59 +08:00
|
|
|
#include "core/gimpviewable.h"
|
2001-02-23 11:29:53 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "display/gimpdisplayshell-render.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
#include "gimppreviewrenderer.h"
|
|
|
|
#include "gimppreviewrenderer-utils.h"
|
2003-03-13 21:08:37 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-05-08 11:48:54 +08:00
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-07 05:43:59 +08:00
|
|
|
enum
|
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
UPDATE,
|
2001-02-07 05:43:59 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
static void gimp_preview_renderer_class_init (GimpPreviewRendererClass *klass);
|
|
|
|
static void gimp_preview_renderer_init (GimpPreviewRenderer *renderer);
|
2002-01-31 01:39:56 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
static void gimp_preview_renderer_finalize (GObject *object);
|
2001-02-07 08:06:58 +08:00
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
static gboolean gimp_preview_renderer_idle_update (GimpPreviewRenderer *renderer);
|
2003-09-29 21:35:59 +08:00
|
|
|
static void gimp_preview_renderer_real_draw (GimpPreviewRenderer *renderer,
|
|
|
|
GdkWindow *window,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const GdkRectangle *draw_area,
|
|
|
|
const GdkRectangle *expose_area);
|
2003-03-01 11:53:41 +08:00
|
|
|
static void gimp_preview_renderer_real_render (GimpPreviewRenderer *renderer,
|
|
|
|
GtkWidget *widget);
|
2002-02-01 00:47:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
static void gimp_preview_renderer_size_changed (GimpPreviewRenderer *renderer,
|
|
|
|
GimpViewable *viewable);
|
2003-04-11 19:18:12 +08:00
|
|
|
static GdkGC * gimp_preview_renderer_create_gc (GimpPreviewRenderer *renderer,
|
|
|
|
GdkWindow *window,
|
|
|
|
GtkWidget *widget);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
static guint renderer_signals[LAST_SIGNAL] = { 0 };
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
static GObjectClass *parent_class = NULL;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
|
|
|
|
2001-08-07 08:06:06 +08:00
|
|
|
GType
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_get_type (void)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
static GType renderer_type = 0;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (! renderer_type)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
static const GTypeInfo renderer_info =
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
sizeof (GimpPreviewRendererClass),
|
2001-10-17 19:33:43 +08:00
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
2003-03-01 11:53:41 +08:00
|
|
|
(GClassInitFunc) gimp_preview_renderer_class_init,
|
2001-10-17 19:33:43 +08:00
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
2003-03-01 11:53:41 +08:00
|
|
|
sizeof (GimpPreviewRenderer),
|
2001-10-17 19:33:43 +08:00
|
|
|
0, /* n_preallocs */
|
2003-03-01 11:53:41 +08:00
|
|
|
(GInstanceInitFunc) gimp_preview_renderer_init,
|
2001-02-05 23:22:20 +08:00
|
|
|
};
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer_type = g_type_register_static (G_TYPE_OBJECT,
|
|
|
|
"GimpPreviewRenderer",
|
|
|
|
&renderer_info, 0);
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
2003-02-27 21:59:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
return renderer_type;
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_class_init (GimpPreviewRendererClass *klass)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
GObjectClass *object_class;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-09-29 21:35:59 +08:00
|
|
|
renderer_signals[UPDATE] =
|
2003-03-01 11:53:41 +08:00
|
|
|
g_signal_new ("update",
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2003-03-01 11:53:41 +08:00
|
|
|
G_STRUCT_OFFSET (GimpPreviewRendererClass, update),
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
NULL, NULL,
|
2001-11-23 07:46:13 +08:00
|
|
|
gimp_marshal_VOID__VOID,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_TYPE_NONE, 0);
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
object_class->finalize = gimp_preview_renderer_finalize;
|
2001-02-08 02:01:54 +08:00
|
|
|
|
2003-09-29 21:35:59 +08:00
|
|
|
klass->draw = gimp_preview_renderer_real_draw;
|
2003-03-01 11:53:41 +08:00
|
|
|
klass->render = gimp_preview_renderer_real_render;
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_init (GimpPreviewRenderer *renderer)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->viewable = NULL;
|
2002-11-10 04:01:19 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->width = 8;
|
|
|
|
renderer->height = 8;
|
|
|
|
renderer->border_width = 0;
|
|
|
|
renderer->dot_for_dot = TRUE;
|
|
|
|
renderer->is_popup = FALSE;
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_rgba_set (&renderer->border_color, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
2003-04-11 19:18:12 +08:00
|
|
|
renderer->gc = NULL;
|
2002-03-22 23:21:18 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->buffer = NULL;
|
|
|
|
renderer->rowstride = 0;
|
2003-03-01 20:55:43 +08:00
|
|
|
renderer->bytes = 3;
|
2003-02-27 00:17:10 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->no_preview_pixbuf = NULL;
|
2003-04-11 19:18:12 +08:00
|
|
|
renderer->bg_stock_id = NULL;
|
2003-02-27 00:17:10 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->size = -1;
|
|
|
|
renderer->needs_render = TRUE;
|
|
|
|
renderer->idle_id = 0;
|
2001-02-05 23:22:20 +08:00
|
|
|
}
|
|
|
|
|
2002-02-01 00:47:20 +08:00
|
|
|
static void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_finalize (GObject *object)
|
2002-02-01 00:47:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
GimpPreviewRenderer *renderer;
|
2002-02-01 00:47:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer = GIMP_PREVIEW_RENDERER (object);
|
2003-02-27 21:59:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->idle_id)
|
2003-02-27 00:17:10 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_source_remove (renderer->idle_id);
|
|
|
|
renderer->idle_id = 0;
|
2003-02-27 00:17:10 +08:00
|
|
|
}
|
2003-02-27 21:59:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->viewable)
|
|
|
|
gimp_preview_renderer_set_viewable (renderer, NULL);
|
2002-02-01 00:47:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->buffer)
|
2003-02-27 00:17:10 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_free (renderer->buffer);
|
|
|
|
renderer->buffer = NULL;
|
2003-02-27 00:17:10 +08:00
|
|
|
}
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->no_preview_pixbuf)
|
2002-02-01 00:47:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_object_unref (renderer->no_preview_pixbuf);
|
|
|
|
renderer->no_preview_pixbuf = NULL;
|
2002-02-01 00:47:20 +08:00
|
|
|
}
|
|
|
|
|
2003-04-11 19:18:12 +08:00
|
|
|
if (renderer->bg_stock_id)
|
|
|
|
{
|
|
|
|
g_free (renderer->bg_stock_id);
|
|
|
|
renderer->bg_stock_id = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (renderer->gc)
|
2002-02-01 00:47:20 +08:00
|
|
|
{
|
2003-04-11 19:18:12 +08:00
|
|
|
g_object_unref (renderer->gc);
|
|
|
|
renderer->gc = NULL;
|
2002-02-01 00:47:20 +08:00
|
|
|
}
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-02-01 00:47:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
GimpPreviewRenderer *
|
2003-03-03 20:59:03 +08:00
|
|
|
gimp_preview_renderer_new (GType viewable_type,
|
|
|
|
gint size,
|
|
|
|
gint border_width,
|
|
|
|
gboolean is_popup)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
GimpPreviewRenderer *renderer;
|
2001-02-20 06:54:12 +08:00
|
|
|
|
2003-03-03 20:59:03 +08:00
|
|
|
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
|
2003-04-01 21:53:47 +08:00
|
|
|
g_return_val_if_fail (size > 0 &&
|
|
|
|
size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
2002-08-27 23:31:24 +08:00
|
|
|
g_return_val_if_fail (border_width >= 0 &&
|
|
|
|
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
|
|
|
|
NULL);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->is_popup = is_popup ? TRUE : FALSE;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_size (renderer, size, border_width);
|
2003-03-03 20:59:03 +08:00
|
|
|
gimp_preview_renderer_remove_idle (renderer);
|
2001-02-13 08:12:15 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
return renderer;
|
2001-02-09 23:12:01 +08:00
|
|
|
}
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
GimpPreviewRenderer *
|
2003-03-03 20:59:03 +08:00
|
|
|
gimp_preview_renderer_new_full (GType viewable_type,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint border_width,
|
|
|
|
gboolean is_popup)
|
2001-02-05 23:22:20 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
GimpPreviewRenderer *renderer;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-03-03 20:59:03 +08:00
|
|
|
g_return_val_if_fail (g_type_is_a (viewable_type, GIMP_TYPE_VIEWABLE), NULL);
|
2003-04-01 21:53:47 +08:00
|
|
|
g_return_val_if_fail (width > 0 &&
|
|
|
|
width <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
|
|
|
g_return_val_if_fail (height > 0 &&
|
|
|
|
height <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
|
2002-08-27 23:31:24 +08:00
|
|
|
g_return_val_if_fail (border_width >= 0 &&
|
|
|
|
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, NULL);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer = g_object_new (gimp_preview_renderer_type_from_viewable_type (viewable_type),
|
|
|
|
NULL);
|
2001-02-08 07:14:14 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->is_popup = is_popup ? TRUE : FALSE;
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_size_full (renderer, width, height, border_width);
|
2003-03-03 20:59:03 +08:00
|
|
|
gimp_preview_renderer_remove_idle (renderer);
|
2002-08-22 20:49:01 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
return renderer;
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
|
|
|
|
2001-02-08 12:16:41 +08:00
|
|
|
void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_viewable (GimpPreviewRenderer *renderer,
|
|
|
|
GimpViewable *viewable)
|
2001-02-08 12:16:41 +08:00
|
|
|
{
|
2002-08-27 23:31:24 +08:00
|
|
|
GType viewable_type = G_TYPE_NONE;
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
2001-02-08 12:16:41 +08:00
|
|
|
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
|
2002-08-22 20:49:01 +08:00
|
|
|
|
|
|
|
if (viewable)
|
|
|
|
{
|
|
|
|
viewable_type = G_TYPE_FROM_INSTANCE (viewable);
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (g_type_is_a (G_TYPE_FROM_INSTANCE (renderer),
|
|
|
|
gimp_preview_renderer_type_from_viewable_type (viewable_type)));
|
2002-08-22 20:49:01 +08:00
|
|
|
}
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (viewable == renderer->viewable)
|
2002-05-10 20:47:42 +08:00
|
|
|
return;
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->buffer)
|
2002-05-10 20:47:42 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_free (renderer->buffer);
|
|
|
|
renderer->buffer = NULL;
|
2002-05-10 20:47:42 +08:00
|
|
|
}
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->no_preview_pixbuf)
|
2001-02-08 12:16:41 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_object_unref (renderer->no_preview_pixbuf);
|
|
|
|
renderer->no_preview_pixbuf = NULL;
|
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->viewable)
|
|
|
|
{
|
|
|
|
g_object_remove_weak_pointer (G_OBJECT (renderer->viewable),
|
|
|
|
(gpointer *) &renderer->viewable);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (renderer->viewable,
|
2003-03-03 20:59:03 +08:00
|
|
|
G_CALLBACK (gimp_preview_renderer_invalidate),
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer);
|
2003-02-20 20:47:42 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (renderer->viewable,
|
|
|
|
G_CALLBACK (gimp_preview_renderer_size_changed),
|
|
|
|
renderer);
|
2002-03-22 23:47:59 +08:00
|
|
|
}
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->viewable = viewable;
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->viewable)
|
2001-02-08 12:16:41 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (renderer->viewable),
|
|
|
|
(gpointer *) &renderer->viewable);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_signal_connect_swapped (renderer->viewable,
|
2001-07-25 07:11:30 +08:00
|
|
|
"invalidate_preview",
|
2003-03-03 20:59:03 +08:00
|
|
|
G_CALLBACK (gimp_preview_renderer_invalidate),
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_signal_connect_swapped (renderer->viewable,
|
2001-07-25 07:11:30 +08:00
|
|
|
"size_changed",
|
2003-03-01 11:53:41 +08:00
|
|
|
G_CALLBACK (gimp_preview_renderer_size_changed),
|
|
|
|
renderer);
|
2001-02-08 12:16:41 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->size != -1)
|
|
|
|
gimp_preview_renderer_set_size (renderer, renderer->size,
|
|
|
|
renderer->border_width);
|
2003-03-22 01:22:04 +08:00
|
|
|
|
|
|
|
gimp_preview_renderer_invalidate (renderer);
|
2001-02-08 12:16:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_size (GimpPreviewRenderer *renderer,
|
|
|
|
gint preview_size,
|
|
|
|
gint border_width)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
gint width, height;
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
2003-04-01 21:53:47 +08:00
|
|
|
g_return_if_fail (preview_size > 0 &&
|
|
|
|
preview_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
|
2002-08-27 23:31:24 +08:00
|
|
|
g_return_if_fail (border_width >= 0 &&
|
|
|
|
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->size = preview_size;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->viewable)
|
2003-02-22 03:03:19 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_viewable_get_preview_size (renderer->viewable,
|
2003-02-22 03:03:19 +08:00
|
|
|
preview_size,
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->is_popup,
|
|
|
|
renderer->dot_for_dot,
|
2003-02-22 03:03:19 +08:00
|
|
|
&width, &height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = preview_size;
|
|
|
|
height = preview_size;
|
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_size_full (renderer, width, height, border_width);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_size_full (GimpPreviewRenderer *renderer,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint border_width)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
2003-04-01 21:53:47 +08:00
|
|
|
g_return_if_fail (width > 0 &&
|
|
|
|
width <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
|
|
|
|
g_return_if_fail (height > 0 &&
|
|
|
|
height <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE);
|
2002-08-27 23:31:24 +08:00
|
|
|
g_return_if_fail (border_width >= 0 &&
|
|
|
|
border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (width != renderer->width ||
|
|
|
|
height != renderer->height ||
|
|
|
|
border_width != renderer->border_width)
|
2002-01-31 01:39:56 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->width = width;
|
|
|
|
renderer->height = height;
|
|
|
|
renderer->border_width = border_width;
|
2002-01-31 01:39:56 +08:00
|
|
|
|
2003-03-01 20:55:43 +08:00
|
|
|
renderer->rowstride = (renderer->width * renderer->bytes + 3) & ~3;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->buffer)
|
2002-01-31 01:39:56 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_free (renderer->buffer);
|
|
|
|
renderer->buffer = NULL;
|
2002-01-31 01:39:56 +08:00
|
|
|
}
|
|
|
|
|
2003-03-03 20:59:03 +08:00
|
|
|
if (renderer->viewable)
|
|
|
|
gimp_preview_renderer_invalidate (renderer);
|
2002-01-31 01:39:56 +08:00
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_dot_for_dot (GimpPreviewRenderer *renderer,
|
|
|
|
gboolean dot_for_dot)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (dot_for_dot != renderer->dot_for_dot)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->dot_for_dot = dot_for_dot ? TRUE: FALSE;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->size != -1)
|
|
|
|
gimp_preview_renderer_set_size (renderer, renderer->size,
|
|
|
|
renderer->border_width);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-03-03 20:59:03 +08:00
|
|
|
gimp_preview_renderer_invalidate (renderer);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_set_border_color (GimpPreviewRenderer *renderer,
|
|
|
|
const GimpRGB *color)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
2001-03-12 01:24:47 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (gimp_rgb_distance (&renderer->border_color, color))
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->border_color = *color;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-04-11 19:18:12 +08:00
|
|
|
if (renderer->gc)
|
2003-02-27 00:17:10 +08:00
|
|
|
{
|
|
|
|
GdkColor gdk_color;
|
|
|
|
|
2003-06-11 00:44:44 +08:00
|
|
|
gimp_rgb_get_gdk_color (&renderer->border_color, &gdk_color);
|
2003-04-11 19:18:12 +08:00
|
|
|
gdk_gc_set_rgb_fg_color (renderer->gc, &gdk_color);
|
2003-02-27 00:17:10 +08:00
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
gimp_preview_renderer_update_idle (renderer);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-11 19:18:12 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_set_background (GimpPreviewRenderer *renderer,
|
|
|
|
const gchar *stock_id)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
|
|
|
|
if (renderer->bg_stock_id)
|
|
|
|
g_free (renderer->bg_stock_id);
|
|
|
|
|
|
|
|
renderer->bg_stock_id = g_strdup (stock_id);
|
|
|
|
|
|
|
|
if (renderer->gc)
|
|
|
|
{
|
|
|
|
g_object_unref (renderer->gc);
|
|
|
|
renderer->gc = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-13 23:04:13 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_unrealize (GimpPreviewRenderer *renderer)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
|
|
|
|
if (renderer->gc)
|
|
|
|
{
|
|
|
|
g_object_unref (renderer->gc);
|
|
|
|
renderer->gc = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-24 10:42:09 +08:00
|
|
|
void
|
2003-03-03 20:59:03 +08:00
|
|
|
gimp_preview_renderer_invalidate (GimpPreviewRenderer *renderer)
|
2001-02-24 10:42:09 +08:00
|
|
|
{
|
2003-03-01 11:53:41 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
2001-08-07 20:42:23 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->idle_id)
|
|
|
|
g_source_remove (renderer->idle_id);
|
2002-11-10 04:01:19 +08:00
|
|
|
|
2003-03-03 20:59:03 +08:00
|
|
|
renderer->needs_render = TRUE;
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
renderer->idle_id =
|
2002-11-10 04:01:19 +08:00
|
|
|
g_idle_add_full (G_PRIORITY_LOW,
|
2003-03-16 19:14:29 +08:00
|
|
|
(GSourceFunc) gimp_preview_renderer_idle_update,
|
2003-03-03 20:59:03 +08:00
|
|
|
renderer, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_preview_renderer_update (GimpPreviewRenderer *renderer)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
|
|
|
|
if (renderer->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (renderer->idle_id);
|
|
|
|
renderer->idle_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_emit (renderer, renderer_signals[UPDATE], 0);
|
|
|
|
}
|
|
|
|
|
2003-03-16 19:14:29 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_update_idle (GimpPreviewRenderer *renderer)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
|
|
|
|
if (renderer->idle_id)
|
|
|
|
g_source_remove (renderer->idle_id);
|
|
|
|
|
|
|
|
renderer->idle_id =
|
|
|
|
g_idle_add_full (G_PRIORITY_LOW,
|
|
|
|
(GSourceFunc) gimp_preview_renderer_idle_update,
|
|
|
|
renderer, NULL);
|
|
|
|
}
|
|
|
|
|
2003-03-03 20:59:03 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_remove_idle (GimpPreviewRenderer *renderer)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
|
|
|
|
if (renderer->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (renderer->idle_id);
|
|
|
|
renderer->idle_id = 0;
|
|
|
|
}
|
2001-02-24 10:42:09 +08:00
|
|
|
}
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_draw (GimpPreviewRenderer *renderer,
|
|
|
|
GdkWindow *window,
|
|
|
|
GtkWidget *widget,
|
2003-04-11 16:37:26 +08:00
|
|
|
const GdkRectangle *draw_area,
|
|
|
|
const GdkRectangle *expose_area)
|
2003-03-01 11:53:41 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
g_return_if_fail (draw_area != NULL);
|
|
|
|
g_return_if_fail (expose_area != NULL);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (! GTK_WIDGET_DRAWABLE (widget) || ! renderer->viewable)
|
|
|
|
return;
|
2001-02-07 05:43:59 +08:00
|
|
|
|
2003-09-29 21:35:59 +08:00
|
|
|
GIMP_PREVIEW_RENDERER_GET_CLASS (renderer)->draw (renderer,
|
|
|
|
window, widget,
|
|
|
|
draw_area, expose_area);
|
2002-11-10 04:01:19 +08:00
|
|
|
|
2003-09-29 21:35:59 +08:00
|
|
|
if (renderer->border_width > 0)
|
|
|
|
{
|
2003-09-30 20:06:58 +08:00
|
|
|
GdkRectangle rect;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
rect.width = renderer->width + 2 * renderer->border_width;
|
|
|
|
rect.height = renderer->height + 2 * renderer->border_width;
|
|
|
|
rect.x = draw_area->x + (draw_area->width - rect.width) / 2;
|
|
|
|
rect.y = draw_area->y + (draw_area->height - rect.height) / 2;
|
2003-09-29 21:35:59 +08:00
|
|
|
|
|
|
|
if (! renderer->gc)
|
|
|
|
renderer->gc = gimp_preview_renderer_create_gc (renderer,
|
|
|
|
window, widget);
|
|
|
|
|
|
|
|
for (i = 0; i < renderer->border_width; i++)
|
|
|
|
gdk_draw_rectangle (window,
|
|
|
|
renderer->gc,
|
|
|
|
FALSE,
|
2003-09-30 20:06:58 +08:00
|
|
|
rect.x + i,
|
|
|
|
rect.y + i,
|
|
|
|
rect.width - 2 * i - 1,
|
|
|
|
rect.height - 2 * i - 1);
|
2003-09-29 21:35:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_preview_renderer_idle_update (GimpPreviewRenderer *renderer)
|
|
|
|
{
|
|
|
|
renderer->idle_id = 0;
|
|
|
|
|
|
|
|
if (renderer->viewable)
|
|
|
|
gimp_preview_renderer_update (renderer);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_renderer_real_draw (GimpPreviewRenderer *renderer,
|
|
|
|
GdkWindow *window,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const GdkRectangle *draw_area,
|
|
|
|
const GdkRectangle *expose_area)
|
|
|
|
{
|
2003-09-30 20:06:58 +08:00
|
|
|
GdkRectangle rect;
|
2003-09-29 21:35:59 +08:00
|
|
|
GdkRectangle render_rect;
|
|
|
|
|
|
|
|
if (renderer->needs_render)
|
|
|
|
GIMP_PREVIEW_RENDERER_GET_CLASS (renderer)->render (renderer, widget);
|
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (renderer->no_preview_pixbuf)
|
2003-02-27 21:59:41 +08:00
|
|
|
{
|
2003-04-11 19:18:12 +08:00
|
|
|
if (renderer->bg_stock_id)
|
|
|
|
{
|
|
|
|
if (!renderer->gc)
|
|
|
|
renderer->gc = gimp_preview_renderer_create_gc (renderer,
|
|
|
|
window, widget);
|
|
|
|
|
2003-09-29 21:35:59 +08:00
|
|
|
if (gdk_rectangle_intersect ((GdkRectangle *) draw_area,
|
|
|
|
(GdkRectangle *) expose_area,
|
|
|
|
&render_rect))
|
|
|
|
{
|
|
|
|
gdk_draw_rectangle (GDK_DRAWABLE (window), renderer->gc,
|
|
|
|
TRUE,
|
|
|
|
render_rect.x, render_rect.y,
|
|
|
|
render_rect.width, render_rect.height);
|
|
|
|
}
|
2003-04-11 19:18:12 +08:00
|
|
|
}
|
|
|
|
|
2003-09-30 20:06:58 +08:00
|
|
|
rect.width = gdk_pixbuf_get_width (renderer->no_preview_pixbuf);
|
|
|
|
rect.height = gdk_pixbuf_get_height (renderer->no_preview_pixbuf);
|
|
|
|
rect.x = draw_area->x + (draw_area->width - rect.width) / 2;
|
|
|
|
rect.y = draw_area->y + (draw_area->height - rect.height) / 2;
|
2003-03-01 11:53:41 +08:00
|
|
|
|
2003-09-30 20:06:58 +08:00
|
|
|
if (gdk_rectangle_intersect (&rect, (GdkRectangle *) expose_area,
|
2003-04-11 16:37:26 +08:00
|
|
|
&render_rect))
|
2003-03-01 11:53:41 +08:00
|
|
|
{
|
|
|
|
gdk_draw_pixbuf (GDK_DRAWABLE (window),
|
|
|
|
widget->style->bg_gc[widget->state],
|
|
|
|
renderer->no_preview_pixbuf,
|
2003-09-30 20:06:58 +08:00
|
|
|
render_rect.x - rect.x,
|
|
|
|
render_rect.y - rect.y,
|
2003-03-01 11:53:41 +08:00
|
|
|
render_rect.x,
|
|
|
|
render_rect.y,
|
|
|
|
render_rect.width,
|
|
|
|
render_rect.height,
|
|
|
|
GDK_RGB_DITHER_NORMAL,
|
2003-03-14 00:49:37 +08:00
|
|
|
0, 0);
|
2003-03-01 11:53:41 +08:00
|
|
|
}
|
2003-02-27 21:59:41 +08:00
|
|
|
}
|
2003-03-01 11:53:41 +08:00
|
|
|
else if (renderer->buffer)
|
|
|
|
{
|
2003-09-30 20:06:58 +08:00
|
|
|
rect.width = renderer->width;
|
|
|
|
rect.height = renderer->height;
|
|
|
|
rect.x = draw_area->x + (draw_area->width - rect.width) / 2;
|
|
|
|
rect.y = draw_area->y + (draw_area->height - rect.height) / 2;
|
2002-11-10 04:01:19 +08:00
|
|
|
|
2003-09-30 20:06:58 +08:00
|
|
|
if (gdk_rectangle_intersect (&rect, (GdkRectangle *) expose_area,
|
2003-04-11 16:37:26 +08:00
|
|
|
&render_rect))
|
2003-03-01 11:53:41 +08:00
|
|
|
{
|
|
|
|
guchar *buf;
|
|
|
|
|
|
|
|
buf = (renderer->buffer +
|
2003-09-30 20:06:58 +08:00
|
|
|
(render_rect.y - rect.y) * renderer->rowstride +
|
|
|
|
(render_rect.x - rect.x) * renderer->bytes);
|
2003-03-01 11:53:41 +08:00
|
|
|
|
|
|
|
gdk_draw_rgb_image_dithalign (window,
|
|
|
|
widget->style->black_gc,
|
|
|
|
render_rect.x,
|
|
|
|
render_rect.y,
|
|
|
|
render_rect.width,
|
|
|
|
render_rect.height,
|
|
|
|
GDK_RGB_DITHER_NORMAL,
|
|
|
|
buf,
|
|
|
|
renderer->rowstride,
|
|
|
|
expose_area->x - draw_area->x,
|
|
|
|
expose_area->y - draw_area->y);
|
|
|
|
}
|
|
|
|
}
|
2002-11-04 20:15:29 +08:00
|
|
|
}
|
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
static void
|
2003-03-01 11:53:41 +08:00
|
|
|
gimp_preview_renderer_real_render (GimpPreviewRenderer *renderer,
|
|
|
|
GtkWidget *widget)
|
2001-02-07 08:06:58 +08:00
|
|
|
{
|
2001-02-08 04:35:18 +08:00
|
|
|
TempBuf *temp_buf;
|
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
temp_buf = gimp_viewable_get_preview (renderer->viewable,
|
|
|
|
renderer->width,
|
|
|
|
renderer->height);
|
|
|
|
|
|
|
|
if (temp_buf)
|
|
|
|
{
|
|
|
|
gimp_preview_renderer_default_render_buffer (renderer, widget, temp_buf);
|
|
|
|
}
|
|
|
|
else /* no preview available */
|
|
|
|
{
|
|
|
|
const gchar *stock_id;
|
|
|
|
|
|
|
|
stock_id = gimp_viewable_get_stock_id (renderer->viewable);
|
|
|
|
|
|
|
|
gimp_preview_renderer_default_render_stock (renderer, widget, stock_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_preview_renderer_size_changed (GimpPreviewRenderer *renderer,
|
|
|
|
GimpViewable *viewable)
|
|
|
|
{
|
|
|
|
if (renderer->size != -1)
|
|
|
|
gimp_preview_renderer_set_size (renderer, renderer->size,
|
|
|
|
renderer->border_width);
|
2003-03-22 01:22:04 +08:00
|
|
|
|
|
|
|
gimp_preview_renderer_invalidate (renderer);
|
2003-03-04 01:19:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* protected functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_preview_renderer_default_render_buffer (GimpPreviewRenderer *renderer,
|
|
|
|
GtkWidget *widget,
|
|
|
|
TempBuf *temp_buf)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
g_return_if_fail (temp_buf != NULL);
|
|
|
|
|
|
|
|
if (temp_buf->width < renderer->width)
|
|
|
|
temp_buf->x = (renderer->width - temp_buf->width) / 2;
|
2001-02-08 04:35:18 +08:00
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
if (temp_buf->height < renderer->height)
|
|
|
|
temp_buf->y = (renderer->height - temp_buf->height) / 2;
|
2003-02-27 00:17:10 +08:00
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
gimp_preview_renderer_render_buffer (renderer, temp_buf, -1,
|
|
|
|
GIMP_PREVIEW_BG_CHECKS,
|
|
|
|
GIMP_PREVIEW_BG_WHITE);
|
|
|
|
}
|
2003-02-27 00:17:10 +08:00
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_default_render_stock (GimpPreviewRenderer *renderer,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const gchar *stock_id)
|
|
|
|
{
|
2003-04-12 05:23:34 +08:00
|
|
|
GdkPixbuf *pixbuf = NULL;
|
2003-03-13 21:08:37 +08:00
|
|
|
GtkIconSize icon_size;
|
2003-03-04 01:19:30 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PREVIEW_RENDERER (renderer));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
g_return_if_fail (stock_id != NULL);
|
|
|
|
|
|
|
|
if (renderer->no_preview_pixbuf)
|
|
|
|
{
|
|
|
|
g_object_unref (renderer->no_preview_pixbuf);
|
|
|
|
renderer->no_preview_pixbuf = NULL;
|
2003-02-27 00:17:10 +08:00
|
|
|
}
|
2003-03-04 01:19:30 +08:00
|
|
|
|
|
|
|
if (renderer->buffer)
|
2003-02-27 00:17:10 +08:00
|
|
|
{
|
2003-03-04 01:19:30 +08:00
|
|
|
g_free (renderer->buffer);
|
|
|
|
renderer->buffer = NULL;
|
|
|
|
}
|
2003-03-01 11:53:41 +08:00
|
|
|
|
2003-03-13 21:08:37 +08:00
|
|
|
icon_size = gimp_get_icon_size (widget, stock_id, GTK_ICON_SIZE_INVALID,
|
2003-04-12 05:23:34 +08:00
|
|
|
renderer->width, renderer->height);
|
2003-03-01 11:53:41 +08:00
|
|
|
|
2003-04-12 05:23:34 +08:00
|
|
|
if (icon_size)
|
|
|
|
pixbuf = gtk_widget_render_icon (widget, stock_id, icon_size, NULL);
|
2003-09-29 21:35:59 +08:00
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
if (pixbuf)
|
|
|
|
{
|
|
|
|
if (gdk_pixbuf_get_width (pixbuf) > renderer->width ||
|
|
|
|
gdk_pixbuf_get_height (pixbuf) > renderer->height)
|
2003-02-27 00:17:10 +08:00
|
|
|
{
|
2003-03-04 01:19:30 +08:00
|
|
|
GdkPixbuf *scaled_pixbuf;
|
|
|
|
gint pixbuf_width;
|
|
|
|
gint pixbuf_height;
|
|
|
|
|
|
|
|
gimp_viewable_calc_preview_size (renderer->viewable,
|
|
|
|
gdk_pixbuf_get_width (pixbuf),
|
|
|
|
gdk_pixbuf_get_height (pixbuf),
|
|
|
|
renderer->width,
|
|
|
|
renderer->height,
|
|
|
|
TRUE, 1.0, 1.0,
|
|
|
|
&pixbuf_width,
|
|
|
|
&pixbuf_height,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
|
|
|
|
pixbuf_width,
|
|
|
|
pixbuf_height,
|
|
|
|
GDK_INTERP_BILINEAR);
|
|
|
|
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
pixbuf = scaled_pixbuf;
|
2003-02-27 00:17:10 +08:00
|
|
|
}
|
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
renderer->no_preview_pixbuf = pixbuf;
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
2003-03-04 01:19:30 +08:00
|
|
|
|
|
|
|
renderer->needs_render = FALSE;
|
2001-02-07 08:06:58 +08:00
|
|
|
}
|
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
void
|
|
|
|
gimp_preview_renderer_render_buffer (GimpPreviewRenderer *renderer,
|
|
|
|
TempBuf *temp_buf,
|
|
|
|
gint channel,
|
|
|
|
GimpPreviewBG inside_bg,
|
|
|
|
GimpPreviewBG outside_bg)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2003-03-04 01:19:30 +08:00
|
|
|
if (! renderer->buffer)
|
|
|
|
renderer->buffer = g_new0 (guchar, renderer->height * renderer->rowstride);
|
2002-02-01 00:47:20 +08:00
|
|
|
|
2003-03-07 00:47:34 +08:00
|
|
|
if (renderer->no_preview_pixbuf)
|
|
|
|
{
|
|
|
|
g_object_unref (renderer->no_preview_pixbuf);
|
|
|
|
renderer->no_preview_pixbuf = NULL;
|
|
|
|
}
|
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
gimp_preview_render_to_buffer (temp_buf,
|
|
|
|
channel,
|
|
|
|
inside_bg,
|
|
|
|
outside_bg,
|
|
|
|
renderer->buffer,
|
|
|
|
renderer->width,
|
|
|
|
renderer->height,
|
|
|
|
renderer->rowstride,
|
|
|
|
renderer->bytes);
|
2002-02-01 00:47:20 +08:00
|
|
|
|
2003-03-04 01:19:30 +08:00
|
|
|
renderer->needs_render = FALSE;
|
|
|
|
}
|
2002-02-01 00:47:20 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
void
|
2003-02-27 00:17:10 +08:00
|
|
|
gimp_preview_render_to_buffer (TempBuf *temp_buf,
|
|
|
|
gint channel,
|
|
|
|
GimpPreviewBG inside_bg,
|
|
|
|
GimpPreviewBG outside_bg,
|
|
|
|
guchar *dest_buffer,
|
|
|
|
gint dest_width,
|
|
|
|
gint dest_height,
|
2003-03-01 20:55:43 +08:00
|
|
|
gint dest_rowstride,
|
|
|
|
gint dest_bytes)
|
2001-02-08 04:35:18 +08:00
|
|
|
{
|
|
|
|
guchar *src, *s;
|
|
|
|
guchar *cb;
|
2003-02-27 00:17:10 +08:00
|
|
|
guchar *pad_buf;
|
2001-02-08 04:35:18 +08:00
|
|
|
gint a;
|
|
|
|
gint i, j, b;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint rowstride;
|
|
|
|
gboolean color;
|
|
|
|
gboolean has_alpha;
|
2001-08-11 15:47:35 +08:00
|
|
|
gboolean render_composite;
|
2002-02-01 00:47:20 +08:00
|
|
|
gint red_component;
|
|
|
|
gint green_component;
|
|
|
|
gint blue_component;
|
|
|
|
gint alpha_component;
|
2001-02-08 04:35:18 +08:00
|
|
|
gint offset;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
/* Here are the different cases this functions handles correctly:
|
|
|
|
* 1) Offset temp_buf which does not necessarily cover full image area
|
|
|
|
* 2) Color conversion of temp_buf if it is gray and image is color
|
|
|
|
* 3) Background check buffer for transparent temp_bufs
|
|
|
|
* 4) Using the optional "channel" argument, one channel can be extracted
|
|
|
|
* from a multi-channel temp_buf and composited as a grayscale
|
|
|
|
* Prereqs:
|
|
|
|
* 1) Grayscale temp_bufs have bytes == {1, 2}
|
|
|
|
* 2) Color temp_bufs have bytes == {3, 4}
|
|
|
|
* 3) If image is gray, then temp_buf should have bytes == {1, 2}
|
|
|
|
*/
|
2002-02-01 00:47:20 +08:00
|
|
|
|
|
|
|
color = (temp_buf->bytes == 3 || temp_buf->bytes == 4);
|
|
|
|
has_alpha = (temp_buf->bytes == 2 || temp_buf->bytes == 4);
|
|
|
|
render_composite = (channel == -1);
|
|
|
|
rowstride = temp_buf->width * temp_buf->bytes;
|
2001-02-08 04:35:18 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
/* render the checkerboard only if the temp_buf has alpha *and*
|
2002-02-01 00:47:20 +08:00
|
|
|
* we render a composite preview
|
2001-08-10 22:41:39 +08:00
|
|
|
*/
|
2003-02-27 00:17:10 +08:00
|
|
|
if (has_alpha && render_composite && outside_bg == GIMP_PREVIEW_BG_CHECKS)
|
|
|
|
pad_buf = render_check_buf;
|
|
|
|
else if (outside_bg == GIMP_PREVIEW_BG_WHITE)
|
|
|
|
pad_buf = render_white_buf;
|
2002-02-01 00:47:20 +08:00
|
|
|
else
|
2003-02-27 00:17:10 +08:00
|
|
|
pad_buf = render_empty_buf;
|
2002-02-01 00:47:20 +08:00
|
|
|
|
|
|
|
if (render_composite)
|
2001-02-08 04:35:18 +08:00
|
|
|
{
|
2002-02-01 00:47:20 +08:00
|
|
|
if (color)
|
|
|
|
{
|
|
|
|
red_component = RED_PIX;
|
|
|
|
green_component = GREEN_PIX;
|
|
|
|
blue_component = BLUE_PIX;
|
|
|
|
alpha_component = ALPHA_PIX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
red_component = GRAY_PIX;
|
|
|
|
green_component = GRAY_PIX;
|
|
|
|
blue_component = GRAY_PIX;
|
|
|
|
alpha_component = ALPHA_G_PIX;
|
|
|
|
}
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-02-01 00:47:20 +08:00
|
|
|
red_component = channel;
|
|
|
|
green_component = channel;
|
|
|
|
blue_component = channel;
|
|
|
|
alpha_component = 0;
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-02-27 00:17:10 +08:00
|
|
|
x1 = CLAMP (temp_buf->x, 0, dest_width);
|
|
|
|
y1 = CLAMP (temp_buf->y, 0, dest_height);
|
|
|
|
x2 = CLAMP (temp_buf->x + temp_buf->width, 0, dest_width);
|
|
|
|
y2 = CLAMP (temp_buf->y + temp_buf->height, 0, dest_height);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2001-02-08 04:35:18 +08:00
|
|
|
src = temp_buf_data (temp_buf) + ((y1 - temp_buf->y) * rowstride +
|
|
|
|
(x1 - temp_buf->x) * temp_buf->bytes);
|
2001-02-05 23:22:20 +08:00
|
|
|
|
2003-02-27 00:17:10 +08:00
|
|
|
for (i = 0; i < dest_height; i++)
|
2001-02-08 04:35:18 +08:00
|
|
|
{
|
|
|
|
if (i & 0x4)
|
|
|
|
{
|
|
|
|
offset = 4;
|
2003-02-27 00:17:10 +08:00
|
|
|
cb = pad_buf + offset * 3;
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset = 0;
|
2003-02-27 00:17:10 +08:00
|
|
|
cb = pad_buf;
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
|
2003-09-29 21:35:59 +08:00
|
|
|
/* The interesting stuff between leading & trailing
|
2001-02-08 04:35:18 +08:00
|
|
|
* vertical transparency
|
|
|
|
*/
|
|
|
|
if (i >= y1 && i < y2)
|
|
|
|
{
|
|
|
|
/* Handle the leading transparency */
|
|
|
|
for (j = 0; j < x1; j++)
|
2003-03-01 20:55:43 +08:00
|
|
|
for (b = 0; b < dest_bytes; b++)
|
|
|
|
render_temp_buf[j * dest_bytes + b] = cb[j * 3 + b];
|
2001-02-08 04:35:18 +08:00
|
|
|
|
|
|
|
/* The stuff in the middle */
|
|
|
|
s = src;
|
|
|
|
for (j = x1; j < x2; j++)
|
|
|
|
{
|
2002-02-01 00:47:20 +08:00
|
|
|
if (has_alpha && render_composite)
|
|
|
|
{
|
|
|
|
a = s[alpha_component] << 8;
|
|
|
|
|
2003-02-27 00:17:10 +08:00
|
|
|
if (inside_bg == GIMP_PREVIEW_BG_CHECKS)
|
2002-02-01 00:47:20 +08:00
|
|
|
{
|
2003-02-27 00:17:10 +08:00
|
|
|
if ((j + offset) & 0x4)
|
|
|
|
{
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 0] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_dark_check [(a | s[red_component])];
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 1] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_dark_check [(a | s[green_component])];
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 2] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_dark_check [(a | s[blue_component])];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 0] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_light_check [(a | s[red_component])];
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 1] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_light_check [(a | s[green_component])];
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 2] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_light_check [(a | s[blue_component])];
|
|
|
|
}
|
2002-02-01 00:47:20 +08:00
|
|
|
}
|
2003-02-27 00:17:10 +08:00
|
|
|
else /* GIMP_PREVIEW_BG_WHITE */
|
2002-02-01 00:47:20 +08:00
|
|
|
{
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 0] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_white [(a | s[red_component])];
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 1] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_white [(a | s[green_component])];
|
2003-09-29 21:35:59 +08:00
|
|
|
render_temp_buf[j * 3 + 2] =
|
2003-02-27 00:17:10 +08:00
|
|
|
render_blend_white [(a | s[blue_component])];
|
2002-02-01 00:47:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-27 00:17:10 +08:00
|
|
|
render_temp_buf[j * 3 + 0] = s[red_component];
|
|
|
|
render_temp_buf[j * 3 + 1] = s[green_component];
|
|
|
|
render_temp_buf[j * 3 + 2] = s[blue_component];
|
2002-02-01 00:47:20 +08:00
|
|
|
}
|
2001-02-08 04:35:18 +08:00
|
|
|
|
|
|
|
s += temp_buf->bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the trailing transparency */
|
2003-02-27 00:17:10 +08:00
|
|
|
for (j = x2; j < dest_width; j++)
|
2003-03-01 20:55:43 +08:00
|
|
|
for (b = 0; b < dest_bytes; b++)
|
|
|
|
render_temp_buf[j * dest_bytes + b] = cb[j * 3 + b];
|
2001-02-08 04:35:18 +08:00
|
|
|
|
|
|
|
src += rowstride;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-27 00:17:10 +08:00
|
|
|
for (j = 0; j < dest_width; j++)
|
2003-03-01 20:55:43 +08:00
|
|
|
for (b = 0; b < dest_bytes; b++)
|
|
|
|
render_temp_buf[j * dest_bytes + b] = cb[j * 3 + b];
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
|
|
|
|
2003-02-27 00:17:10 +08:00
|
|
|
memcpy (dest_buffer + i * dest_rowstride,
|
2002-01-31 01:39:56 +08:00
|
|
|
render_temp_buf,
|
2003-03-01 20:55:43 +08:00
|
|
|
dest_width * dest_bytes);
|
2001-02-08 04:35:18 +08:00
|
|
|
}
|
2003-02-27 00:17:10 +08:00
|
|
|
}
|
2003-04-11 19:18:12 +08:00
|
|
|
|
|
|
|
static GdkGC *
|
|
|
|
gimp_preview_renderer_create_gc (GimpPreviewRenderer *renderer,
|
|
|
|
GdkWindow *window,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GdkGC *gc;
|
|
|
|
GdkPixmap *pixmap = NULL;
|
2003-04-11 20:48:54 +08:00
|
|
|
GdkColormap *colormap;
|
2003-04-11 19:18:12 +08:00
|
|
|
GdkGCValues values;
|
|
|
|
GdkGCValuesMask mask;
|
|
|
|
|
2003-06-11 00:44:44 +08:00
|
|
|
gimp_rgb_get_gdk_color (&renderer->border_color, &values.foreground);
|
2003-04-11 19:18:12 +08:00
|
|
|
|
2003-04-11 20:48:54 +08:00
|
|
|
colormap = gdk_drawable_get_colormap (window);
|
|
|
|
gdk_rgb_find_color (colormap, &values.foreground);
|
|
|
|
|
2003-04-11 19:18:12 +08:00
|
|
|
mask = GDK_GC_FOREGROUND;
|
|
|
|
|
|
|
|
if (renderer->bg_stock_id)
|
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
pixbuf = gtk_widget_render_icon (widget,
|
|
|
|
renderer->bg_stock_id,
|
|
|
|
GTK_ICON_SIZE_DIALOG, NULL);
|
|
|
|
|
|
|
|
if (pixbuf)
|
|
|
|
{
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
|
|
|
|
|
|
|
pixmap = gdk_pixmap_new (window, width, height,
|
|
|
|
gdk_colormap_get_visual (colormap)->depth);
|
|
|
|
gdk_drawable_set_colormap (pixmap, colormap);
|
|
|
|
|
|
|
|
gdk_draw_rectangle (pixmap, widget->style->white_gc,
|
|
|
|
TRUE,
|
|
|
|
0, 0, width, height);
|
|
|
|
|
|
|
|
gdk_draw_pixbuf (pixmap, widget->style->white_gc,
|
|
|
|
pixbuf, 0, 0,
|
|
|
|
0, 0, width, height,
|
|
|
|
GDK_RGB_DITHER_NORMAL, 0, 0);
|
|
|
|
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pixmap)
|
|
|
|
{
|
|
|
|
values.fill = GDK_TILED;
|
|
|
|
values.tile = pixmap;
|
|
|
|
values.ts_x_origin = 0;
|
|
|
|
values.ts_y_origin = 0;
|
|
|
|
|
|
|
|
mask |= (GDK_GC_FILL |
|
|
|
|
GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gc = gdk_gc_new_with_values (GDK_DRAWABLE (window), &values, mask);
|
|
|
|
|
|
|
|
if (pixmap)
|
|
|
|
g_object_unref (pixmap);
|
|
|
|
|
|
|
|
return gc;
|
|
|
|
}
|