~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/base/pixel-region.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
36
35
 
37
36
static gint                  get_portion_width       (PixelRegionIterator *PRI);
38
37
static gint                  get_portion_height      (PixelRegionIterator *PRI);
 
38
static void                  pixel_regions_free      (PixelRegionIterator *PRI);
39
39
static PixelRegionIterator * pixel_regions_configure (PixelRegionIterator *PRI);
40
40
static void                  pixel_region_configure  (PixelRegionHolder   *PRH,
41
41
                                                      PixelRegionIterator *PRI);
44
44
/**************************/
45
45
/*  Function definitions  */
46
46
 
 
47
/**
 
48
 * pixel_region_init:
 
49
 * @PR:    Pointer to PixelRegion struct, typically allocated on the
 
50
 *         stack
 
51
 * @tiles: Tiles
 
52
 * @x:     X of region
 
53
 * @y:     Y of region
 
54
 * @w:     Width of region
 
55
 * @h:     Height of region
 
56
 * @dirty: %TRUE if there will be changes to the pixel region that
 
57
 *         shall be written back to the tiles, %FALSE otherwise
 
58
 *
 
59
 * Initializes a pixel region over a set of tiles.
 
60
 **/
47
61
void
48
62
pixel_region_init (PixelRegion *PR,
49
63
                   TileManager *tiles,
76
90
                            gint         w,
77
91
                            gint         h)
78
92
{
79
 
  PR->data          = temp_buf_data (temp_buf);
 
93
  PR->data          = temp_buf_get_data (temp_buf);
80
94
  PR->tiles         = NULL;
81
95
  PR->curtile       = NULL;
82
96
  PR->offx          = 0;
154
168
  if (subsample == 1)
155
169
    {
156
170
      if (PR->tiles)
157
 
        read_pixel_data (PR->tiles, x, y, end - 1, y, data, PR->bytes);
 
171
        tile_manager_read_pixel_data (PR->tiles, x, y, end - 1, y, data,
 
172
                                      PR->bytes);
158
173
      else
159
174
        memcpy (data, PR->data + x * bpp + y * PR->rowstride, w * bpp);
160
175
    }
193
208
    {
194
209
      gint end = x + w;
195
210
 
196
 
      write_pixel_data (PR->tiles, x, y, end - 1, y, data, PR->bytes);
 
211
      tile_manager_write_pixel_data (PR->tiles, x, y, end - 1, y, data,
 
212
                                     PR->bytes);
197
213
    }
198
214
  else
199
215
    {
255
271
  gint end = y + h;
256
272
  gint bpp = PR->bytes;
257
273
 
258
 
  write_pixel_data (PR->tiles, x, y, x, end-1, data, bpp);
 
274
  tile_manager_write_pixel_data (PR->tiles, x, y, x, end-1, data, bpp);
259
275
}
260
276
 
261
277
gboolean
279
295
    return NULL;
280
296
 
281
297
  PRI = g_slice_new0 (PixelRegionIterator);
282
 
  PRI->dirty_tiles = 1;
283
298
 
284
299
  va_start (ap, num_regions);
285
300
 
349
364
              is a tile manager  */
350
365
          if (PRH->PR->tiles)
351
366
            {
352
 
              /* only set the dirty flag if PRH->dirty_tiles == TRUE */
353
 
              tile_release (PRH->PR->curtile,
354
 
                            PRH->PR->dirty && PRI->dirty_tiles);
 
367
              tile_release (PRH->PR->curtile, PRH->PR->dirty);
355
368
              PRH->PR->curtile = NULL;
356
369
            }
357
370
 
398
411
        }
399
412
    }
400
413
 
401
 
  if (PRI->pixel_regions)
402
 
    {
403
 
      for (list = PRI->pixel_regions; list; list = g_slist_next (list))
404
 
        g_slice_free (PixelRegionHolder, list->data);
405
 
 
406
 
      g_slist_free (PRI->pixel_regions);
407
 
 
408
 
      g_slice_free (PixelRegionIterator, PRI);
409
 
    }
 
414
  pixel_regions_free (PRI);
410
415
}
411
416
 
412
417
 
498
503
  return min_width;
499
504
}
500
505
 
 
506
static void
 
507
pixel_regions_free (PixelRegionIterator *PRI)
 
508
{
 
509
  if (PRI->pixel_regions)
 
510
    {
 
511
      GSList *list;
 
512
 
 
513
      for (list = PRI->pixel_regions; list; list = g_slist_next (list))
 
514
        g_slice_free (PixelRegionHolder, list->data);
 
515
 
 
516
      g_slist_free (PRI->pixel_regions);
 
517
 
 
518
      g_slice_free (PixelRegionIterator, PRI);
 
519
    }
 
520
}
501
521
 
502
522
static PixelRegionIterator *
503
523
pixel_regions_configure (PixelRegionIterator *PRI)
510
530
 
511
531
  if (PRI->portion_width  == 0 || PRI->portion_height == 0)
512
532
    {
513
 
      /*  free the pixel regions list  */
514
 
      if (PRI->pixel_regions)
515
 
        {
516
 
          for (list = PRI->pixel_regions; list; list = g_slist_next (list))
517
 
            g_slice_free (PixelRegionHolder, list->data);
518
 
 
519
 
          g_slist_free (PRI->pixel_regions);
520
 
          g_slice_free (PixelRegionIterator, PRI);
521
 
        }
 
533
      pixel_regions_free (PRI);
522
534
 
523
535
      return NULL;
524
536
    }