1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2002 University of Southern California
4 * Copyright © 2005 Red Hat, Inc.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * You should have received a copy of the MPL along with this library
18 * in the file COPYING-MPL-1.1
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/
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.
29 * The Original Code is the cairo graphics library.
31 * The Initial Developer of the Original Code is University of Southern
35 * Carl D. Worth <cworth@cworth.org>
38 #ifndef CAIRO_SCALED_FONT_PRIVATE_H
39 #define CAIRO_SCALED_FONT_PRIVATE_H
43 #include "cairo-types-private.h"
44 #include "cairo-mutex-type-private.h"
45 #include "cairo-reference-count-private.h"
47 struct _cairo_scaled_font
{
48 /* For most cairo objects, the rule for multiple threads is that
49 * the user is responsible for any locking if the same object is
50 * manipulated from multiple threads simultaneously.
52 * However, with the caching that cairo does for scaled fonts, a
53 * user can easily end up with the same cairo_scaled_font object
54 * being manipulated from multiple threads without the user ever
55 * being aware of this, (and in fact, unable to control it).
57 * So, as a special exception, the cairo implementation takes care
58 * of all locking needed for cairo_scaled_font_t. Most of what is
59 * in the scaled font is immutable, (which is what allows for the
60 * sharing in the first place). The things that are modified and
61 * the locks protecting them are as follows:
63 * 1. The reference count (scaled_font->ref_count)
65 * Modifications to the reference count are protected by the
66 * _cairo_scaled_font_map_mutex. This is because the reference
67 * count of a scaled font is intimately related with the font
68 * map itself, (and the magic holdovers array).
70 * 2. The cache of glyphs (scaled_font->glyphs)
71 * 3. The backend private data (scaled_font->surface_backend,
72 * scaled_font->surface_private)
74 * Modifications to these fields are protected with locks on
75 * scaled_font->mutex in the generic scaled_font code.
78 /* must be first to be stored in a hash table */
79 cairo_hash_entry_t hash_entry
;
81 /* useful bits for _cairo_scaled_font_nil */
82 cairo_status_t status
;
83 cairo_reference_count_t ref_count
;
84 cairo_user_data_array_t user_data
;
86 /* hash key members */
87 cairo_font_face_t
*font_face
; /* may be NULL */
88 cairo_matrix_t font_matrix
; /* font space => user space */
89 cairo_matrix_t ctm
; /* user space => device space */
90 cairo_font_options_t options
;
92 cairo_bool_t placeholder
; /* protected by fontmap mutex */
94 cairo_bool_t finished
;
96 /* "live" scaled_font members */
97 cairo_matrix_t scale
; /* font space => device space */
98 cairo_matrix_t scale_inverse
; /* device space => font space */
99 double max_scale
; /* maximum x/y expansion of scale */
100 cairo_font_extents_t extents
; /* user space */
102 /* The mutex protects modification to all subsequent fields. */
105 cairo_cache_t
*glyphs
; /* glyph index -> cairo_scaled_glyph_t */
108 * One surface backend may store data in each glyph.
109 * Whichever surface manages to store its pointer here
110 * first gets to store data in each glyph
112 const cairo_surface_backend_t
*surface_backend
;
113 void *surface_private
;
115 /* font backend managing this scaled font */
116 const cairo_scaled_font_backend_t
*backend
;
119 #endif /* CAIRO_SCALED_FONT_PRIVATE_H */