[gimp/goat-invasion: 521/526] app: pass a format, not bpp, to gimp_viewable_get_dummy_pixbuf()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 521/526] app: pass a format, not bpp, to gimp_viewable_get_dummy_pixbuf()
- Date: Sun, 22 Apr 2012 13:43:04 +0000 (UTC)
commit 7c7110bc294ba7b87a5fd618b863825eb0dcb5f2
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 21 21:41:36 2012 +0200
app: pass a format, not bpp, to gimp_viewable_get_dummy_pixbuf()
and add tons of <gegl.h> includes.
app/actions/text-tool-commands.c | 1 +
app/core/gimp-templates.c | 2 +-
app/core/gimpcurve-load.c | 2 +-
app/core/gimpcurve-map.c | 2 +-
app/core/gimpcurve-save.c | 2 +-
app/core/gimpcurve.c | 2 +-
app/core/gimpdocumentlist.c | 2 +-
app/core/gimpdynamics-load.c | 2 +-
app/core/gimpdynamics-save.c | 2 +-
app/core/gimpgradient-save.c | 2 +-
app/core/gimpimagemapconfig.c | 2 +-
app/core/gimptoolpreset-save.c | 2 +-
app/core/gimpviewable.c | 37 ++++++++++-----------
app/core/gimpviewable.h | 4 +-
app/dialogs/preferences-dialog.c | 1 +
app/display/gimpdisplayshell-scale-dialog.c | 1 +
app/display/gimptooldialog.c | 1 +
app/menus/file-menu.c | 1 +
app/pdb/drawable-cmds.c | 47 +++++++++++++++++++--------
app/text/gimpfontlist.c | 2 +-
app/tools/gimpforegroundselecttoolundo.c | 1 +
app/widgets/gimpactiongroup.c | 1 +
app/widgets/gimpcellrendererviewable.c | 1 +
app/widgets/gimpcontainertreestore.c | 1 +
app/widgets/gimpcontainertreeview-dnd.c | 1 +
app/widgets/gimpcontrollerinfo.c | 1 +
app/widgets/gimpcontrollerlist.c | 1 +
app/widgets/gimpcontrollers.c | 1 +
app/widgets/gimpoverlaydialog.c | 1 +
app/widgets/gimpsettingseditor.c | 1 +
app/widgets/gimptemplateeditor.c | 1 +
app/widgets/gimpviewrenderer-frame.c | 1 +
app/widgets/gimpviewrendererimagefile.c | 1 +
tools/pdbgen/pdb/drawable.pdb | 47 +++++++++++++++++++--------
34 files changed, 115 insertions(+), 62 deletions(-)
---
diff --git a/app/actions/text-tool-commands.c b/app/actions/text-tool-commands.c
index 88e813b..04e364c 100644
--- a/app/actions/text-tool-commands.c
+++ b/app/actions/text-tool-commands.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/core/gimp-templates.c b/app/core/gimp-templates.c
index 9925e0e..8da3e4e 100644
--- a/app/core/gimp-templates.c
+++ b/app/core/gimp-templates.c
@@ -19,7 +19,7 @@
#include <string.h>
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimpcurve-load.c b/app/core/gimpcurve-load.c
index 24c4977..4c2f32a 100644
--- a/app/core/gimpcurve-load.c
+++ b/app/core/gimpcurve-load.c
@@ -19,7 +19,7 @@
#include <errno.h>
-#include <glib-object.h>
+#include <gegl.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/core/gimpcurve-map.c b/app/core/gimpcurve-map.c
index 3d02c49..81a1c9d 100644
--- a/app/core/gimpcurve-map.c
+++ b/app/core/gimpcurve-map.c
@@ -19,7 +19,7 @@
#include <string.h>
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpmath/gimpmath.h"
diff --git a/app/core/gimpcurve-save.c b/app/core/gimpcurve-save.c
index b7925f3..0390f37 100644
--- a/app/core/gimpcurve-save.c
+++ b/app/core/gimpcurve-save.c
@@ -19,7 +19,7 @@
#include <errno.h>
-#include <glib-object.h>
+#include <gegl.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/core/gimpcurve.c b/app/core/gimpcurve.c
index 667c702..e6df335 100644
--- a/app/core/gimpcurve.c
+++ b/app/core/gimpcurve.c
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <string.h> /* memcmp */
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimpdocumentlist.c b/app/core/gimpdocumentlist.c
index 0930009..c1da5e0 100644
--- a/app/core/gimpdocumentlist.c
+++ b/app/core/gimpdocumentlist.c
@@ -17,7 +17,7 @@
#include "config.h"
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimpdynamics-load.c b/app/core/gimpdynamics-load.c
index 19b5597..4639ad9 100644
--- a/app/core/gimpdynamics-load.c
+++ b/app/core/gimpdynamics-load.c
@@ -17,7 +17,7 @@
#include "config.h"
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimpdynamics-save.c b/app/core/gimpdynamics-save.c
index e1c222d..c316bab 100644
--- a/app/core/gimpdynamics-save.c
+++ b/app/core/gimpdynamics-save.c
@@ -17,7 +17,7 @@
#include "config.h"
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimpgradient-save.c b/app/core/gimpgradient-save.c
index 64d3f4a..5d07651 100644
--- a/app/core/gimpgradient-save.c
+++ b/app/core/gimpgradient-save.c
@@ -20,7 +20,7 @@
#include <string.h>
#include <errno.h>
-#include <glib-object.h>
+#include <gegl.h>
#include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/core/gimpimagemapconfig.c b/app/core/gimpimagemapconfig.c
index ed64607..da2ae71 100644
--- a/app/core/gimpimagemapconfig.c
+++ b/app/core/gimpimagemapconfig.c
@@ -22,7 +22,7 @@
#include <string.h>
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimptoolpreset-save.c b/app/core/gimptoolpreset-save.c
index b2d88ba..8826ead 100644
--- a/app/core/gimptoolpreset-save.c
+++ b/app/core/gimptoolpreset-save.c
@@ -17,7 +17,7 @@
#include "config.h"
-#include <glib-object.h>
+#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c
index 3b81bc7..dfeaba7 100644
--- a/app/core/gimpviewable.c
+++ b/app/core/gimpviewable.c
@@ -794,35 +794,33 @@ gimp_viewable_get_new_preview (GimpViewable *viewable,
* Returns: a #GimpTempBuf containing the preview image.
**/
GimpTempBuf *
-gimp_viewable_get_dummy_preview (GimpViewable *viewable,
- gint width,
- gint height,
- gint bpp)
+gimp_viewable_get_dummy_preview (GimpViewable *viewable,
+ gint width,
+ gint height,
+ const Babl *format)
{
GdkPixbuf *pixbuf;
GimpTempBuf *buf;
- guchar *src;
- guchar *dest;
+ GeglBuffer *src_buffer;
+ GeglBuffer *dest_buffer;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
- g_return_val_if_fail (bpp == 3 || bpp == 4, NULL);
+ g_return_val_if_fail (format != NULL, NULL);
- pixbuf = gimp_viewable_get_dummy_pixbuf (viewable, width, height, bpp);
+ pixbuf = gimp_viewable_get_dummy_pixbuf (viewable, width, height,
+ babl_format_has_alpha (format));
- buf = gimp_temp_buf_new (width, height, gimp_bpp_to_babl_format (bpp));
+ buf = gimp_temp_buf_new (width, height, format);
- src = gdk_pixbuf_get_pixels (pixbuf);
- dest = gimp_temp_buf_get_data (buf);
+ src_buffer = gimp_pixbuf_create_buffer (pixbuf);
+ dest_buffer = gimp_temp_buf_create_buffer (buf);
- while (height--)
- {
- memcpy (dest, src, width * bpp);
+ gegl_buffer_copy (src_buffer, NULL, dest_buffer, NULL);
- src += gdk_pixbuf_get_rowstride (pixbuf);
- dest += width * bpp;
- }
+ g_object_unref (src_buffer);
+ g_object_unref (dest_buffer);
g_object_unref (pixbuf);
@@ -968,7 +966,7 @@ GdkPixbuf *
gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
gint width,
gint height,
- gint bpp)
+ gboolean with_alpha)
{
GdkPixbuf *icon;
GdkPixbuf *pixbuf;
@@ -978,7 +976,6 @@ gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
- g_return_val_if_fail (bpp == 3 || bpp == 4, NULL);
icon = gdk_pixbuf_new_from_inline (-1, stock_question_64, FALSE, NULL);
@@ -993,7 +990,7 @@ gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
w = RINT (ratio * (gdouble) w);
h = RINT (ratio * (gdouble) h);
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, (bpp == 4), 8, width, height);
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, with_alpha, 8, width, height);
gdk_pixbuf_fill (pixbuf, 0xffffffff);
if (w && h)
diff --git a/app/core/gimpviewable.h b/app/core/gimpviewable.h
index 9af188f..49e2922 100644
--- a/app/core/gimpviewable.h
+++ b/app/core/gimpviewable.h
@@ -148,7 +148,7 @@ GimpTempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable,
GimpTempBuf * gimp_viewable_get_dummy_preview (GimpViewable *viewable,
gint width,
gint height,
- gint bpp);
+ const Babl *format);
GdkPixbuf * gimp_viewable_get_pixbuf (GimpViewable *viewable,
GimpContext *context,
@@ -162,7 +162,7 @@ GdkPixbuf * gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
GdkPixbuf * gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
gint width,
gint height,
- gint bpp);
+ gboolean with_alpha);
gchar * gimp_viewable_get_description (GimpViewable *viewable,
gchar **tooltip);
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index a8e6d5b..5a6e444 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -19,6 +19,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
diff --git a/app/display/gimpdisplayshell-scale-dialog.c b/app/display/gimpdisplayshell-scale-dialog.c
index f4c269e..7ec5f21 100644
--- a/app/display/gimpdisplayshell-scale-dialog.c
+++ b/app/display/gimpdisplayshell-scale-dialog.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
diff --git a/app/display/gimptooldialog.c b/app/display/gimptooldialog.c
index 71181ea..f31b301 100644
--- a/app/display/gimptooldialog.c
+++ b/app/display/gimptooldialog.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/menus/file-menu.c b/app/menus/file-menu.c
index b949850..9b0b6e4 100644
--- a/app/menus/file-menu.c
+++ b/app/menus/file-menu.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpthumb/gimpthumb.h"
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 8206bd8..3a5a1a6 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -735,13 +735,22 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews)
- buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
- width, height);
+ {
+ buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
+ width, height);
+ }
else
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- width, height,
- gimp_drawable_has_alpha (drawable) ?
- 4 : 3);
+ {
+ const Babl *format;
+
+ if (gimp_drawable_has_alpha (drawable))
+ format = babl_format ("R'G'B'A u8");
+ else
+ format = babl_format ("R'G'B' u8");
+
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ width, height, format);
+ }
if (buf)
{
@@ -813,15 +822,25 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
GimpTempBuf *buf;
if (image->gimp->config->layer_previews)
- buf = gimp_drawable_get_sub_preview (drawable,
- src_x, src_y,
- src_width, src_height,
- dest_width, dest_height);
+ {
+ buf = gimp_drawable_get_sub_preview (drawable,
+ src_x, src_y,
+ src_width, src_height,
+ dest_width, dest_height);
+ }
else
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- dest_width, dest_height,
- gimp_drawable_has_alpha (drawable) ?
- 4 : 3);
+ {
+ const Babl *format;
+
+ if (gimp_drawable_has_alpha (drawable))
+ format = babl_format ("R'G'B'A u8");
+ else
+ format = babl_format ("R'G'B' u8");
+
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ dest_width, dest_height,
+ format);
+ }
if (buf)
{
diff --git a/app/text/gimpfontlist.c b/app/text/gimpfontlist.c
index a89adde..b812a31 100644
--- a/app/text/gimpfontlist.c
+++ b/app/text/gimpfontlist.c
@@ -24,7 +24,7 @@
#include <string.h>
-#include <glib-object.h>
+#include <gegl.h>
#include <pango/pangocairo.h>
#include <pango/pangofc-fontmap.h>
diff --git a/app/tools/gimpforegroundselecttoolundo.c b/app/tools/gimpforegroundselecttoolundo.c
index d91fb70..a735f7d 100644
--- a/app/tools/gimpforegroundselecttoolundo.c
+++ b/app/tools/gimpforegroundselecttoolundo.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "tools-types.h"
diff --git a/app/widgets/gimpactiongroup.c b/app/widgets/gimpactiongroup.c
index a399c4b..85b1900 100644
--- a/app/widgets/gimpactiongroup.c
+++ b/app/widgets/gimpactiongroup.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/widgets/gimpcellrendererviewable.c b/app/widgets/gimpcellrendererviewable.c
index c490b19..2115f08 100644
--- a/app/widgets/gimpcellrendererviewable.c
+++ b/app/widgets/gimpcellrendererviewable.c
@@ -20,6 +20,7 @@
#include <config.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
diff --git a/app/widgets/gimpcontainertreestore.c b/app/widgets/gimpcontainertreestore.c
index 16b43b8..05ae500 100644
--- a/app/widgets/gimpcontainertreestore.c
+++ b/app/widgets/gimpcontainertreestore.c
@@ -22,6 +22,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
diff --git a/app/widgets/gimpcontainertreeview-dnd.c b/app/widgets/gimpcontainertreeview-dnd.c
index 91367e6..85fa472 100644
--- a/app/widgets/gimpcontainertreeview-dnd.c
+++ b/app/widgets/gimpcontainertreeview-dnd.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
diff --git a/app/widgets/gimpcontrollerinfo.c b/app/widgets/gimpcontrollerinfo.c
index 90e70c9..057ba09 100644
--- a/app/widgets/gimpcontrollerinfo.c
+++ b/app/widgets/gimpcontrollerinfo.c
@@ -22,6 +22,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
diff --git a/app/widgets/gimpcontrollerlist.c b/app/widgets/gimpcontrollerlist.c
index d4896ac..f87d798 100644
--- a/app/widgets/gimpcontrollerlist.c
+++ b/app/widgets/gimpcontrollerlist.c
@@ -22,6 +22,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/widgets/gimpcontrollers.c b/app/widgets/gimpcontrollers.c
index 4d43cb2..8c5877f 100644
--- a/app/widgets/gimpcontrollers.c
+++ b/app/widgets/gimpcontrollers.c
@@ -17,6 +17,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/widgets/gimpoverlaydialog.c b/app/widgets/gimpoverlaydialog.c
index 063426b..8031dcc 100644
--- a/app/widgets/gimpoverlaydialog.c
+++ b/app/widgets/gimpoverlaydialog.c
@@ -20,6 +20,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
diff --git a/app/widgets/gimpsettingseditor.c b/app/widgets/gimpsettingseditor.c
index a554e86..3710917 100644
--- a/app/widgets/gimpsettingseditor.c
+++ b/app/widgets/gimpsettingseditor.c
@@ -22,6 +22,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 53166c0..075deb2 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -19,6 +19,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
diff --git a/app/widgets/gimpviewrenderer-frame.c b/app/widgets/gimpviewrenderer-frame.c
index 0eb1547..9e7b335 100644
--- a/app/widgets/gimpviewrenderer-frame.c
+++ b/app/widgets/gimpviewrenderer-frame.c
@@ -22,6 +22,7 @@
#include "config.h"
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
diff --git a/app/widgets/gimpviewrendererimagefile.c b/app/widgets/gimpviewrendererimagefile.c
index 60bcbf1..2a9c7d2 100644
--- a/app/widgets/gimpviewrendererimagefile.c
+++ b/app/widgets/gimpviewrendererimagefile.c
@@ -22,6 +22,7 @@
#include <string.h>
+#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpthumb/gimpthumb.h"
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index 7cc6946..ced571a 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -719,13 +719,22 @@ HELP
width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews)
- buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
- width, height);
+ {
+ buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
+ width, height);
+ }
else
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- width, height,
- gimp_drawable_has_alpha (drawable) ?
- 4 : 3);
+ {
+ const Babl *format;
+
+ if (gimp_drawable_has_alpha (drawable))
+ format = babl_format ("R'G'B'A u8");
+ else
+ format = babl_format ("R'G'B' u8");
+
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ width, height, format);
+ }
if (buf)
{
@@ -798,15 +807,25 @@ HELP
GimpTempBuf *buf;
if (image->gimp->config->layer_previews)
- buf = gimp_drawable_get_sub_preview (drawable,
- src_x, src_y,
- src_width, src_height,
- dest_width, dest_height);
+ {
+ buf = gimp_drawable_get_sub_preview (drawable,
+ src_x, src_y,
+ src_width, src_height,
+ dest_width, dest_height);
+ }
else
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- dest_width, dest_height,
- gimp_drawable_has_alpha (drawable) ?
- 4 : 3);
+ {
+ const Babl *format;
+
+ if (gimp_drawable_has_alpha (drawable))
+ format = babl_format ("R'G'B'A u8");
+ else
+ format = babl_format ("R'G'B' u8");
+
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ dest_width, dest_height,
+ format);
+ }
if (buf)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]