Ejemplo n.º 1
0
GeglNode *
gimp_projection_get_sink_node (GimpProjection *proj)
{
  GeglNode   *graph;
  GeglBuffer *buffer;

  g_return_val_if_fail (GIMP_IS_PROJECTION (proj), NULL);

  if (proj->sink_node)
    return proj->sink_node;

  proj->graph = gegl_node_new ();

  g_object_set (proj->graph,
                "dont-cache", TRUE,
                NULL);

  graph = gimp_projectable_get_graph (proj->projectable);
  gegl_node_add_child (proj->graph, graph);

  buffer = gimp_projection_get_buffer (GIMP_PICKABLE (proj));

  proj->sink_node =
    gegl_node_new_child (proj->graph,
                         "operation", "gegl:write-buffer",
                         "buffer",    buffer,
                         NULL);

  gegl_node_connect_to (graph,           "output",
                        proj->sink_node, "input");

  return proj->sink_node;
}
Ejemplo n.º 2
0
static gboolean
gimp_projection_get_pixel_at (GimpPickable *pickable,
                              gint          x,
                              gint          y,
                              const Babl   *format,
                              gpointer      pixel)
{
  GeglBuffer *buffer = gimp_projection_get_buffer (pickable);

  if (x <  0                               ||
      y <  0                               ||
      x >= gegl_buffer_get_width  (buffer) ||
      y >= gegl_buffer_get_height (buffer))
    return FALSE;

  gegl_buffer_sample (buffer, x, y, NULL, pixel, format,
                      GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);

  return TRUE;
}
Ejemplo n.º 3
0
static void
gimp_projection_pickable_flush (GimpPickable *pickable)
{
  GimpProjection *proj = GIMP_PROJECTION (pickable);

  /* create the buffer if it doesn't exist */
  gimp_projection_get_buffer (pickable);

  gimp_projection_finish_draw (proj);
  gimp_projection_flush_now (proj);

  if (proj->invalidate_preview)
    {
      /* invalidate the preview here since it is constructed from
       * the projection
       */
      proj->invalidate_preview = FALSE;

      gimp_projectable_invalidate_preview (proj->projectable);
    }
}
Ejemplo n.º 4
0
static void
gimp_projection_invalidate (GimpProjection *proj,
                            guint           x,
                            guint           y,
                            guint           w,
                            guint           h)
{
  if (proj->pyramid)
    {
      if (proj->sink_node)
        {
          GeglBuffer *buffer;

          buffer = gimp_projection_get_buffer (GIMP_PICKABLE (proj));

          /* makes the buffer drop all GimpTiles */
          gimp_gegl_buffer_refetch_tiles (buffer);
        }

      tile_pyramid_invalidate_area (proj->pyramid, x, y, w, h);
    }
}