Subversion Repositories Kolibri OS

Rev

Rev 1892 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1892 serge 1
/* cairo - a vector graphics library with display and print output
2
 *
3
 * Copyright © 2002 University of Southern California
4
 * Copyright © 2005 Red Hat, Inc.
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it either under the terms of the GNU Lesser General Public
8
 * License version 2.1 as published by the Free Software Foundation
9
 * (the "LGPL") or, at your option, under the terms of the Mozilla
10
 * Public License Version 1.1 (the "MPL"). If you do not alter this
11
 * notice, a recipient may use your version of this file under either
12
 * the MPL or the LGPL.
13
 *
14
 * You should have received a copy of the LGPL along with this library
15
 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
17
 * You should have received a copy of the MPL along with this library
18
 * in the file COPYING-MPL-1.1
19
 *
20
 * The contents of this file are subject to the Mozilla Public License
21
 * Version 1.1 (the "License"); you may not use this file except in
22
 * compliance with the License. You may obtain a copy of the License at
23
 * http://www.mozilla.org/MPL/
24
 *
25
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26
 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27
 * the specific language governing rights and limitations.
28
 *
29
 * The Original Code is the cairo graphics library.
30
 *
31
 * The Initial Developer of the Original Code is University of Southern
32
 * California.
33
 *
34
 * Contributor(s):
35
 *	Carl D. Worth 
36
 */
37
 
38
#ifndef CAIRO_SCALED_FONT_PRIVATE_H
39
#define CAIRO_SCALED_FONT_PRIVATE_H
40
 
41
#include "cairo.h"
42
 
43
#include "cairo-types-private.h"
44
#include "cairo-list-private.h"
45
#include "cairo-mutex-type-private.h"
46
#include "cairo-reference-count-private.h"
47
 
3959 Serge 48
CAIRO_BEGIN_DECLS
49
 
1892 serge 50
typedef struct _cairo_scaled_glyph_page cairo_scaled_glyph_page_t;
51
 
52
struct _cairo_scaled_font {
53
    /* For most cairo objects, the rule for multiple threads is that
54
     * the user is responsible for any locking if the same object is
55
     * manipulated from multiple threads simultaneously.
56
     *
57
     * However, with the caching that cairo does for scaled fonts, a
58
     * user can easily end up with the same cairo_scaled_font object
59
     * being manipulated from multiple threads without the user ever
60
     * being aware of this, (and in fact, unable to control it).
61
     *
62
     * So, as a special exception, the cairo implementation takes care
63
     * of all locking needed for cairo_scaled_font_t. Most of what is
64
     * in the scaled font is immutable, (which is what allows for the
65
     * sharing in the first place). The things that are modified and
66
     * the locks protecting them are as follows:
67
     *
68
     * 1. The reference count (scaled_font->ref_count)
69
     *
70
     *    Modifications to the reference count are protected by the
71
     *    _cairo_scaled_font_map_mutex. This is because the reference
72
     *    count of a scaled font is intimately related with the font
73
     *    map itself, (and the magic holdovers array).
74
     *
75
     * 2. The cache of glyphs (scaled_font->glyphs)
76
     * 3. The backend private data (scaled_font->surface_backend,
77
     *				    scaled_font->surface_private)
78
     *
79
     *    Modifications to these fields are protected with locks on
80
     *    scaled_font->mutex in the generic scaled_font code.
81
     */
82
 
83
    cairo_hash_entry_t hash_entry;
84
 
85
    /* useful bits for _cairo_scaled_font_nil */
86
    cairo_status_t status;
87
    cairo_reference_count_t ref_count;
88
    cairo_user_data_array_t user_data;
89
 
90
    cairo_font_face_t *original_font_face; /* may be NULL */
91
 
92
    /* hash key members */
93
    cairo_font_face_t *font_face; /* may be NULL */
94
    cairo_matrix_t font_matrix;	  /* font space => user space */
95
    cairo_matrix_t ctm;	          /* user space => device space */
96
    cairo_font_options_t options;
97
 
98
    unsigned int placeholder : 1; /*  protected by fontmap mutex */
99
    unsigned int holdover : 1;
100
    unsigned int finished : 1;
101
 
102
    /* "live" scaled_font members */
103
    cairo_matrix_t scale;	     /* font space => device space */
104
    cairo_matrix_t scale_inverse;    /* device space => font space */
105
    double max_scale;		     /* maximum x/y expansion of scale */
106
    cairo_font_extents_t extents;    /* user space */
107
    cairo_font_extents_t fs_extents; /* font space */
108
 
109
    /* The mutex protects modification to all subsequent fields. */
110
    cairo_mutex_t mutex;
111
 
112
    cairo_hash_table_t *glyphs;
113
    cairo_list_t glyph_pages;
114
    cairo_bool_t cache_frozen;
115
    cairo_bool_t global_cache_frozen;
116
 
3959 Serge 117
    cairo_list_t dev_privates;
1892 serge 118
 
119
    /* font backend managing this scaled font */
120
    const cairo_scaled_font_backend_t *backend;
121
    cairo_list_t link;
122
};
123
 
3959 Serge 124
struct _cairo_scaled_font_private {
125
    cairo_list_t link;
126
    const void *key;
127
    void (*destroy) (cairo_scaled_font_private_t *,
128
		     cairo_scaled_font_t *);
129
};
130
 
131
struct _cairo_scaled_glyph {
132
    cairo_hash_entry_t hash_entry;
133
 
134
    cairo_text_extents_t    metrics;		/* user-space metrics */
135
    cairo_text_extents_t    fs_metrics;		/* font-space metrics */
136
    cairo_box_t		    bbox;		/* device-space bounds */
137
    int16_t                 x_advance;		/* device-space rounded X advance */
138
    int16_t                 y_advance;		/* device-space rounded Y advance */
139
 
140
    unsigned int	    has_info;
141
    cairo_image_surface_t   *surface;		/* device-space image */
142
    cairo_path_fixed_t	    *path;		/* device-space outline */
143
    cairo_surface_t         *recording_surface;	/* device-space recording-surface */
144
 
145
    const void		   *dev_private_key;
146
    void		   *dev_private;
147
    cairo_list_t            dev_privates;
148
};
149
 
150
struct _cairo_scaled_glyph_private {
151
    cairo_list_t link;
152
    const void *key;
153
    void (*destroy) (cairo_scaled_glyph_private_t *,
154
		     cairo_scaled_glyph_t *,
155
		     cairo_scaled_font_t *);
156
};
157
 
158
cairo_private cairo_scaled_font_private_t *
159
_cairo_scaled_font_find_private (cairo_scaled_font_t *scaled_font,
160
				 const void *key);
161
 
1892 serge 162
cairo_private void
3959 Serge 163
_cairo_scaled_font_attach_private (cairo_scaled_font_t *scaled_font,
164
				   cairo_scaled_font_private_t *priv,
165
				   const void *key,
166
				   void (*destroy) (cairo_scaled_font_private_t *,
167
						    cairo_scaled_font_t *));
1892 serge 168
 
3959 Serge 169
cairo_private cairo_scaled_glyph_private_t *
170
_cairo_scaled_glyph_find_private (cairo_scaled_glyph_t *scaled_glyph,
171
				 const void *key);
172
 
173
cairo_private void
174
_cairo_scaled_glyph_attach_private (cairo_scaled_glyph_t *scaled_glyph,
175
				   cairo_scaled_glyph_private_t *priv,
176
				   const void *key,
177
				   void (*destroy) (cairo_scaled_glyph_private_t *,
178
						    cairo_scaled_glyph_t *,
179
						    cairo_scaled_font_t *));
180
 
181
CAIRO_END_DECLS
182
 
1892 serge 183
#endif /* CAIRO_SCALED_FONT_PRIVATE_H */