File: tile-private.h

package info (click to toggle)
gimp 2.2.13-1etch4
  • links: PTS
  • area: main
  • in suites: etch
  • size: 94,832 kB
  • ctags: 47,113
  • sloc: ansic: 524,858; xml: 36,798; lisp: 9,870; sh: 9,409; makefile: 7,923; python: 2,674; perl: 2,589; yacc: 520; lex: 334
file content (114 lines) | stat: -rw-r--r-- 3,742 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef __TILE_PRIVATE_H__
#define __TILE_PRIVATE_H__

#include "config.h"

#ifdef USE_PTHREADS
#include <pthread.h>
#endif

#include <sys/types.h>

#include <glib.h>


typedef struct _TileLink TileLink;

struct _TileLink
{
  TileLink    *next;
  gint         tile_num; /* the number of this tile within the drawable */
  TileManager *tm;       /* A pointer to the tile manager for this tile.
			  *  We need this in order to call the tile managers
			  *  validate proc whenever the tile is referenced
			  *  yet invalid.
			  */
};

struct _Tile
{
  gshort  ref_count;    /* reference count. when the reference count is
 		         *  non-zero then the "data" for this tile must
		         *  be valid. when the reference count for a tile
		         *  is 0 then the "data" for this tile must be
		         *  NULL.
		         */
  gshort  write_count;  /* write count: number of references that are
                           for write access */
  gshort  share_count;  /* share count: number of tile managers that
                           hold this tile */
  guint   dirty : 1;    /* is the tile dirty? has it been modified? */
  guint   valid : 1;    /* is the tile valid? */

  guchar  bpp;          /* the bytes per pixel (1, 2, 3 or 4) */
  gushort ewidth;       /* the effective width of the tile */
  gushort eheight;      /* the effective height of the tile
		         *  a tile's effective width and height may be smaller
		         *  (but not larger) than TILE_WIDTH and TILE_HEIGHT.
		         *  this is to handle edge tiles of a drawable.
		         */

  TileRowHint *rowhint; /* An array of hints for rendering purposes */

  guchar *data;         /* the data for the tile. this may be NULL in which
                         *  case the tile data is on disk.
                         */

  gint    swap_num;     /* the index into the file table of the file to be used
                         * for swapping. swap_num 1 is always the global
                         * swap file.
                         */
  off_t   swap_offset;  /* the offset within the swap file of the tile data.
		         * if the tile data is in memory this will be set
                         * to -1.
                         */

  TileLink *tlink;

  Tile     *next;
  Tile     *prev;       /* List pointers for the tile cache lists */
  gpointer  listhead;   /* Pointer to the head of the list this tile is on */

#ifdef USE_PTHREADS
  pthread_mutex_t mutex;
#endif
};


#ifdef USE_PTHREADS
#define TILE_MUTEX_LOCK(tile)   pthread_mutex_lock(&((tile)->mutex))
#define TILE_MUTEX_UNLOCK(tile) pthread_mutex_unlock(&((tile)->mutex))
#else
#define TILE_MUTEX_LOCK(tile)   /* nothing */
#define TILE_MUTEX_UNLOCK(tile) /* nothing */
#endif


/*  an inlined version of tile_size()  */
static inline gint
tile_size_inline (Tile *tile)
{
  return tile->ewidth * tile->eheight * tile->bpp;
}



#endif /* __TILE_PRIVATE_H__ */