コード例 #1
0
ファイル: gimpprojection.c プロジェクト: DevMaggio/gimp
static void
gimp_projection_paint_area (GimpProjection *proj,
                            gboolean        now,
                            gint            x,
                            gint            y,
                            gint            w,
                            gint            h)
{
  gint off_x, off_y;
  gint width, height;
  gint x1, y1, x2, y2;

  gimp_projectable_get_offset (proj->projectable, &off_x, &off_y);
  gimp_projectable_get_size   (proj->projectable, &width, &height);

  /*  Bounds check  */
  x1 = CLAMP (x,     0, width);
  y1 = CLAMP (y,     0, height);
  x2 = CLAMP (x + w, 0, width);
  y2 = CLAMP (y + h, 0, height);

  gimp_projection_invalidate (proj, x1, y1, x2 - x1, y2 - y1);

  /*  add the projectable's offsets because the list of update areas
   *  is in tile-pyramid coordinates, but our external API is always
   *  in terms of image coordinates.
   */
  g_signal_emit (proj, projection_signals[UPDATE], 0,
                 now,
                 x1 + off_x,
                 y1 + off_y,
                 x2 - x1,
                 y2 - y1);
}
コード例 #2
0
ファイル: gimpprojection.c プロジェクト: DevMaggio/gimp
static void
gimp_projection_projectable_changed (GimpProjectable *projectable,
                                     GimpProjection  *proj)
{
  gint off_x, off_y;
  gint width, height;

  if (proj->idle_render.idle_id)
    {
      g_source_remove (proj->idle_render.idle_id);
      proj->idle_render.idle_id = 0;
    }

  gimp_area_list_free (proj->update_areas);
  proj->update_areas = NULL;

  if (proj->pyramid)
    {
      tile_pyramid_destroy (proj->pyramid);
      proj->pyramid = NULL;
    }

  if (proj->buffer)
    {
      g_object_unref (proj->buffer);
      proj->buffer = NULL;
    }

  gimp_projectable_get_offset (proj->projectable, &off_x, &off_y);
  gimp_projectable_get_size (projectable, &width, &height);

  gimp_projection_add_update_area (proj, off_x, off_y, width, height);
}
コード例 #3
0
ファイル: gimpprojection.c プロジェクト: DevMaggio/gimp
static void
gimp_projection_add_update_area (GimpProjection *proj,
                                 gint            x,
                                 gint            y,
                                 gint            w,
                                 gint            h)
{
  GimpArea *area;
  gint      off_x, off_y;
  gint      width, height;

  gimp_projectable_get_offset (proj->projectable, &off_x, &off_y);
  gimp_projectable_get_size   (proj->projectable, &width, &height);

  /*  subtract the projectable's offsets because the list of update
   *  areas is in tile-pyramid coordinates, but our external API is
   *  always in terms of image coordinates.
   */
  x -= off_x;
  y -= off_y;

  area = gimp_area_new (CLAMP (x,     0, width),
                        CLAMP (y,     0, height),
                        CLAMP (x + w, 0, width),
                        CLAMP (y + h, 0, height));

  proj->update_areas = gimp_area_list_process (proj->update_areas, area);
}
コード例 #4
0
ファイル: gimpprojection.c プロジェクト: DevMaggio/gimp
TileManager *
gimp_projection_get_tiles_at_level (GimpProjection *proj,
                                    gint            level,
                                    gboolean       *is_premult)
{
  g_return_val_if_fail (GIMP_IS_PROJECTION (proj), NULL);

  if (! proj->pyramid)
    {
      const Babl *format;
      gint        bytes;
      gint        width;
      gint        height;

      format = gimp_projection_get_format (GIMP_PICKABLE (proj));

      bytes = babl_format_get_bytes_per_pixel (format);
      gimp_projectable_get_size (proj->projectable, &width, &height);

      proj->pyramid = tile_pyramid_new (bytes, width, height);

      tile_pyramid_set_validate_proc (proj->pyramid,
                                      (TileValidateProc) gimp_projection_validate_tile,
                                      proj);
    }

  return tile_pyramid_get_tiles (proj->pyramid, level, is_premult);
}
コード例 #5
0
ファイル: gimpprojection.c プロジェクト: DevMaggio/gimp
/**
 * gimp_projection_get_level:
 * @proj:    pointer to a GimpProjection
 * @scale_x: horizontal scale factor
 * @scale_y: vertical scale factor
 *
 * This function returns the optimal pyramid level for a given scale factor.
 *
 * Return value: the pyramid level to use for a given display scale factor.
 **/
gint
gimp_projection_get_level (GimpProjection *proj,
                           gdouble         scale_x,
                           gdouble         scale_y)
{
  gint width, height;

  gimp_projectable_get_size (proj->projectable, &width, &height);

  return tile_pyramid_get_level (width, height, MAX (scale_x, scale_y));
}
コード例 #6
0
ファイル: gimpprojection.c プロジェクト: Bootz/shiny-robot
static GeglBuffer *
gimp_projection_get_buffer (GimpPickable *pickable)
{
  GimpProjection *proj = GIMP_PROJECTION (pickable);

  if (! proj->buffer)
    {
      GeglNode   *graph;
      const Babl *format;
      gint        width;
      gint        height;

      graph = gimp_projectable_get_graph (proj->projectable);
      format = gimp_projection_get_format (GIMP_PICKABLE (proj));
      gimp_projectable_get_size (proj->projectable, &width, &height);

      proj->buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
                                      format);

      proj->validate_handler = gimp_tile_handler_projection_new (graph);
      gegl_buffer_add_handler (proj->buffer, proj->validate_handler);

      /*  This used to call gimp_tile_handler_projection_invalidate()
       *  which forced the entire projection to be constructed in one
       *  go for new images, causing a potentially huge delay. Now we
       *  initially validate stuff the normal way, which makes the
       *  image appear incrementally, but it keeps everything
       *  responsive.
       */
      gimp_projection_add_update_area (proj, 0, 0, width, height);
      proj->invalidate_preview = TRUE;
      gimp_projection_flush (proj);
    }

  return proj->buffer;
}
コード例 #7
0
void
gimp_projection_construct (GimpProjection *proj,
                           gint            x,
                           gint            y,
                           gint            w,
                           gint            h)
{
    g_return_if_fail (GIMP_IS_PROJECTION (proj));

#if 0
    GList *layers = gimp_projectable_get_layers (proj->projectable);

    if (layers && ! layers->next) /* a single layer */
    {
        GimpLayer    *layer    = layers->data;
        GimpDrawable *drawable = GIMP_DRAWABLE (layer);
        GimpItem     *item     = GIMP_ITEM (layer);
        gint          width, height;
        gint          off_x, off_y;

        gimp_projectable_get_offset (proj->projectable, &proj_off_x, &proj_off_y);
        gimp_projectable_get_size (proj->projectable, &width, &height);

        gimp_item_get_offset (item, &off_x, &off_y);

        if (gimp_drawable_has_alpha (drawable)                    &&
                gimp_item_get_visible (item)                          &&
                gimp_item_get_width  (item) == width                  &&
                gimp_item_get_height (item) == height                 &&
                ! gimp_drawable_is_indexed (layer)                    &&
                gimp_layer_get_opacity (layer) == GIMP_OPACITY_OPAQUE &&
                off_x == 0                                            &&
                off_y == 0                                            &&
                proj_offset_x == 0                                    &&
                proj_offset_y == 0)
        {
            PixelRegion srcPR, destPR;

            g_printerr ("cow-projection!");

            pixel_region_init (&srcPR,
                               gimp_drawable_get_tiles (layer),
                               x, y, w,h, FALSE);
            pixel_region_init (&destPR,
                               gimp_pickable_get_tiles (GIMP_PICKABLE (proj)),
                               x, y, w,h, TRUE);

            copy_region (&srcPR, &destPR);

            proj->construct_flag = TRUE;

            gimp_projection_construct_legacy (proj, FALSE, x, y, w, h);

            return;
        }
    }
#endif

    /*  First, determine if the projection image needs to be
     *  initialized--this is the case when there are no visible
     *  layers that cover the entire canvas--either because layers
     *  are offset or only a floating selection is visible
     */
    gimp_projection_initialize (proj, x, y, w, h);

    /*  call functions which process the list of layers and
     *  the list of channels
     */
    if (proj->use_gegl)
    {
        gimp_projection_construct_gegl (proj, x, y, w, h);
    }
    else
    {
        proj->construct_flag = FALSE;

        gimp_projection_construct_legacy (proj, TRUE, x, y, w, h);
    }
}