[gimp/soc-2011-seamless-clone2] app: some GIMP-style cleanup to the last commit
- From: Clayton Walker <claytonw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2011-seamless-clone2] app: some GIMP-style cleanup to the last commit
- Date: Wed, 8 May 2013 14:59:43 +0000 (UTC)
commit a19fdfa955d1d47f0da666499b3c7539e027b46a
Author: Michael Natterer <mitch gimp org>
Date: Sat Feb 2 14:10:23 2013 +0100
app: some GIMP-style cleanup to the last commit
app/display/display-types.h | 1 +
app/display/gimpdisplay-transport.c | 96 ++++++++++++++++++++----------
app/display/gimpdisplay-transport.h | 15 ++---
app/display/gimpdisplayshell-callbacks.c | 1 +
app/display/gimpdisplayshell-draw.c | 1 +
app/display/gimpdisplayshell-render.c | 26 ++++----
app/display/gimpdisplayshell.h | 3 +-
7 files changed, 89 insertions(+), 54 deletions(-)
---
diff --git a/app/display/display-types.h b/app/display/display-types.h
index 77e5c59..d1323c0 100644
--- a/app/display/display-types.h
+++ b/app/display/display-types.h
@@ -43,6 +43,7 @@ typedef struct _GimpStatusbar GimpStatusbar;
typedef struct _GimpToolDialog GimpToolDialog;
+typedef struct _GimpDisplayXfer GimpDisplayXfer;
typedef struct _Selection Selection;
diff --git a/app/display/gimpdisplay-transport.c b/app/display/gimpdisplay-transport.c
index b2808a1..2e54f01 100644
--- a/app/display/gimpdisplay-transport.c
+++ b/app/display/gimpdisplay-transport.c
@@ -20,30 +20,50 @@
#include <gegl.h>
#include <gtk/gtk.h>
+#include "display-types.h"
+
#include "gimpdisplay-transport.h"
+
#define NUM_PAGES 2
-struct GimpDisplayXfer {
- struct rtree {
- struct rtree_node {
- struct rtree_node *children[2];
- struct rtree_node *next;
- int x, y, w, h;
- } root, *available;
- } rtree; /* track subregions of render_surface for efficient uploads */
+typedef struct _RTree RTree;
+typedef struct _RTreeNode RTreeNode;
+
+struct _RTreeNode
+{
+ RTreeNode *children[2];
+ RTreeNode *next;
+ gint x, y, w, h;
+};
+
+struct _RTree
+{
+ RTreeNode root;
+ RTreeNode *available;
+};
+
+struct _GimpDisplayXfer
+{
+ /* track subregions of render_surface for efficient uploads */
+ RTree rtree;
cairo_surface_t *render_surface[NUM_PAGES];
- int page;
+ gint page;
};
-static struct rtree_node *
-rtree_node_create (struct rtree *rtree, struct rtree_node **prev,
- int x, int y, int w, int h)
+
+static RTreeNode *
+rtree_node_create (RTree *rtree,
+ RTreeNode **prev,
+ gint x,
+ gint y,
+ gint w,
+ gint h)
{
- struct rtree_node *node;
+ RTreeNode *node;
- g_assert(x >= 0 && x+w <= rtree->root.w);
- g_assert(y >= 0 && y+h <= rtree->root.h);
+ g_assert (x >= 0 && x+w <= rtree->root.w);
+ g_assert (y >= 0 && y+h <= rtree->root.h);
node = g_slice_alloc (sizeof (*node));
if (node == NULL)
@@ -63,9 +83,10 @@ rtree_node_create (struct rtree *rtree, struct rtree_node **prev,
}
static void
-rtree_node_destroy (struct rtree *rtree, struct rtree_node *node)
+rtree_node_destroy (RTree *rtree,
+ RTreeNode *node)
{
- int i;
+ gint i;
for (i = 0; i < 2; i++)
{
@@ -73,19 +94,22 @@ rtree_node_destroy (struct rtree *rtree, struct rtree_node *node)
rtree_node_destroy (rtree, node->children[i]);
}
- g_slice_free (struct rtree_node, node);
+ g_slice_free (RTreeNode, node);
}
-static struct rtree_node *
-rtree_node_insert (struct rtree *rtree, struct rtree_node **prev,
- struct rtree_node *node, int w, int h)
+static RTreeNode *
+rtree_node_insert (RTree *rtree,
+ RTreeNode **prev,
+ RTreeNode *node,
+ gint w,
+ gint h)
{
*prev = node->next;
if (((node->w - w) | (node->h - h)) > 1)
{
- int ww = node->w - w;
- int hh = node->h - h;
+ gint ww = node->w - w;
+ gint hh = node->h - h;
if (ww >= hh)
{
@@ -110,10 +134,12 @@ rtree_node_insert (struct rtree *rtree, struct rtree_node **prev,
return node;
}
-static struct rtree_node *
-rtree_insert (struct rtree *rtree, int w, int h)
+static RTreeNode *
+rtree_insert (RTree *rtree,
+ gint w,
+ gint h)
{
- struct rtree_node *node, **prev;
+ RTreeNode *node, **prev;
for (prev = &rtree->available; (node = *prev); prev = &node->next)
if (node->w >= w && w < 2 * node->w && node->h >= h && h < 2 * node->h)
@@ -127,7 +153,9 @@ rtree_insert (struct rtree *rtree, int w, int h)
}
static void
-rtree_init (struct rtree *rtree, int w, int h)
+rtree_init (RTree *rtree,
+ gint w,
+ gint h)
{
rtree->root.x = 0;
rtree->root.y = 0;
@@ -140,9 +168,9 @@ rtree_init (struct rtree *rtree, int w, int h)
}
static void
-rtree_reset (struct rtree *rtree)
+rtree_reset (RTree *rtree)
{
- int i;
+ gint i;
for (i = 0; i < 2; i++)
{
@@ -178,6 +206,7 @@ gimp_display_xfer_realize (GtkWidget *widget)
screen = gtk_widget_get_screen (widget);
xfer = g_object_get_data (G_OBJECT (screen), "gimpdisplay-transport");
+
if (xfer == NULL)
{
cairo_t *cr;
@@ -209,10 +238,12 @@ gimp_display_xfer_realize (GtkWidget *widget)
cairo_surface_t *
gimp_display_xfer_get_surface (GimpDisplayXfer *xfer,
- gint w, gint h,
- gint *src_x, gint *src_y)
+ gint w,
+ gint h,
+ gint *src_x,
+ gint *src_y)
{
- struct rtree_node *node;
+ RTreeNode *node;
g_assert (w <= GIMP_DISPLAY_RENDER_BUF_WIDTH * GIMP_DISPLAY_RENDER_MAX_SCALE &&
h <= GIMP_DISPLAY_RENDER_BUF_HEIGHT * GIMP_DISPLAY_RENDER_MAX_SCALE);
@@ -230,5 +261,6 @@ gimp_display_xfer_get_surface (GimpDisplayXfer *xfer,
*src_x = node->x;
*src_y = node->y;
+
return xfer->render_surface[xfer->page];
}
diff --git a/app/display/gimpdisplay-transport.h b/app/display/gimpdisplay-transport.h
index 6c7b21f..c4062e2 100644
--- a/app/display/gimpdisplay-transport.h
+++ b/app/display/gimpdisplay-transport.h
@@ -18,7 +18,6 @@
#ifndef __GIMP_DISPLAY_TRANSPORT_H__
#define __GIMP_DISPLAY_TRANSPORT_H__
-#include <cairo.h>
/* #define GIMP_DISPLAY_RENDER_ENABLE_SCALING 1 */
@@ -31,14 +30,14 @@
#define GIMP_DISPLAY_RENDER_MAX_SCALE 1.0
#endif
-typedef struct GimpDisplayXfer GimpDisplayXfer;
-GimpDisplayXfer *
-gimp_display_xfer_realize (GtkWidget *widget);
+GimpDisplayXfer * gimp_display_xfer_realize (GtkWidget *widget);
+
+cairo_surface_t * gimp_display_xfer_get_surface (GimpDisplayXfer *xfer,
+ gint w,
+ gint h,
+ gint *src_x,
+ gint *src_y);
-cairo_surface_t *
-gimp_display_xfer_get_surface (GimpDisplayXfer *xfer,
- gint w, gint h,
- gint *src_x, gint *src_y);
#endif /* __GIMP_DISPLAY_TRANSPORT_H__ */
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 8a55932..30858de 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -34,6 +34,7 @@
#include "gimpcanvasitem.h"
#include "gimpdisplay.h"
+#include "gimpdisplay-transport.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-appearance.h"
#include "gimpdisplayshell-callbacks.h"
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index b0a56de..7f5f1e3 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -36,6 +36,7 @@
#include "gimpcanvas.h"
#include "gimpcanvaspath.h"
#include "gimpdisplay.h"
+#include "gimpdisplay-transport.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-draw.h"
#include "gimpdisplayshell-render.h"
diff --git a/app/display/gimpdisplayshell-render.c b/app/display/gimpdisplayshell-render.c
index ed4024b..b2abec9 100644
--- a/app/display/gimpdisplayshell-render.c
+++ b/app/display/gimpdisplayshell-render.c
@@ -36,12 +36,14 @@
#include "core/gimpprojection.h"
#include "gimpdisplay.h"
+#include "gimpdisplay-transport.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-transform.h"
#include "gimpdisplayshell-filter.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-scroll.h"
+
void
gimp_display_shell_render (GimpDisplayShell *shell,
cairo_t *cr,
@@ -50,18 +52,18 @@ gimp_display_shell_render (GimpDisplayShell *shell,
gint w,
gint h)
{
- GimpImage *image;
- GimpProjection *projection;
- GeglBuffer *buffer;
- gdouble window_scale = 1.0;
- gint viewport_offset_x;
- gint viewport_offset_y;
- gint viewport_width;
- gint viewport_height;
+ GimpImage *image;
+ GimpProjection *projection;
+ GeglBuffer *buffer;
+ gdouble window_scale = 1.0;
+ gint viewport_offset_x;
+ gint viewport_offset_y;
+ gint viewport_width;
+ gint viewport_height;
cairo_surface_t *xfer;
- gint src_x, src_y;
- gint stride;
- unsigned char *data;
+ gint src_x, src_y;
+ gint stride;
+ guchar *data;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (cr != NULL);
@@ -88,7 +90,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
h * window_scale,
&src_x, &src_y);
- stride =cairo_image_surface_get_stride (xfer);
+ stride = cairo_image_surface_get_stride (xfer);
data = cairo_image_surface_get_data (xfer);
data += src_y * stride + src_x * 4;
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index f3d68a5..d0ca7eb 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -18,7 +18,6 @@
#ifndef __GIMP_DISPLAY_SHELL_H__
#define __GIMP_DISPLAY_SHELL_H__
-#include "gimpdisplay-transport.h"
/* Apply to a float the same rounding mode used in the renderer */
#define PROJ_ROUND(coord) ((gint) RINT (coord))
@@ -115,7 +114,7 @@ struct _GimpDisplayShell
GtkWidget *statusbar; /* statusbar */
- GimpDisplayXfer *xfer;
+ GimpDisplayXfer *xfer; /* managers image buffer transfers */
cairo_surface_t *mask_surface; /* buffer for rendering the mask */
cairo_pattern_t *checkerboard; /* checkerboard pattern */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]