summaryrefslogtreecommitdiffstats
path: root/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
blob: 4c48c46d91da31c9812b58597d8d8b120acac3d8 (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# HG changeset patch
# User Mats Palmgren <mats@mozilla.com>
# Parent  f3483af8ecf997453064201c49c48a682c7f3c29
Bug 1377257 part 1 - Add cairo_scaled_font_get_hint_metrics to avoid malloc/free that is required to use cairo_scaled_font_get_font_options.  r=jfkthame

diff --git a/gfx/cairo/add-cairo_scaled_font_get_hint_metrics b/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/add-cairo_scaled_font_get_hint_metrics
@@ -0,0 +1,82 @@
+# HG changeset patch
+# User Mats Palmgren <mats@mozilla.com>
+# Parent  f3483af8ecf997453064201c49c48a682c7f3c29
+Bug 1377257 part 1 - Add cairo_scaled_font_get_hint_metrics to avoid malloc/free that is required to use cairo_scaled_font_get_font_options.  r=jfkthame
+
+diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
+--- a/gfx/cairo/cairo/src/cairo-rename.h
++++ b/gfx/cairo/cairo/src/cairo-rename.h
+@@ -262,16 +262,17 @@
+ #define cairo_scale _moz_cairo_scale
+ #define cairo_scaled_font_create _moz_cairo_scaled_font_create
+ #define cairo_scaled_font_destroy _moz_cairo_scaled_font_destroy
+ #define cairo_scaled_font_extents _moz_cairo_scaled_font_extents
+ #define cairo_scaled_font_get_ctm _moz_cairo_scaled_font_get_ctm
+ #define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face
+ #define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix
+ #define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options
++#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics
+ #define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count
+ #define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix
+ #define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type
+ #define cairo_scaled_font_get_user_data _moz_cairo_scaled_font_get_user_data
+ #define cairo_scaled_font_glyph_extents _moz_cairo_scaled_font_glyph_extents
+ #define cairo_scaled_font_reference _moz_cairo_scaled_font_reference
+ #define cairo_scaled_font_set_user_data _moz_cairo_scaled_font_set_user_data
+ #define cairo_scaled_font_status _moz_cairo_scaled_font_status
+diff --git a/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c
+--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
++++ b/gfx/cairo/cairo/src/cairo-scaled-font.c
+@@ -2983,8 +2983,28 @@ cairo_scaled_font_get_font_options (cair
+     if (scaled_font->status) {
+ 	_cairo_font_options_init_default (options);
+ 	return;
+     }
+ 
+     _cairo_font_options_init_copy (options, &scaled_font->options);
+ }
+ slim_hidden_def (cairo_scaled_font_get_font_options);
++
++/**
++ * cairo_scaled_font_get_hint_metrics:
++ * @scaled_font: a #cairo_scaled_font_t
++ *
++ * Mozilla extension since the required malloc/free to use
++ * cairo_scaled_font_get_font_options() above is too slow.
++ **/
++cairo_public cairo_hint_metrics_t
++cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font)
++{
++    cairo_font_options_t options;
++    if (scaled_font->status) {
++	_cairo_font_options_init_default (&options);
++    } else {
++	_cairo_font_options_init_copy (&options, &scaled_font->options);
++    }
++    return options.hint_metrics;
++}
++slim_hidden_def (cairo_scaled_font_get_hint_metrics);
+diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
+--- a/gfx/cairo/cairo/src/cairo.h
++++ b/gfx/cairo/cairo/src/cairo.h
+@@ -1493,16 +1493,21 @@ cairo_scaled_font_get_ctm (cairo_scaled_
+ cairo_public void
+ cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t	*scaled_font,
+ 				    cairo_matrix_t	*scale_matrix);
+ 
+ cairo_public void
+ cairo_scaled_font_get_font_options (cairo_scaled_font_t		*scaled_font,
+ 				    cairo_font_options_t	*options);
+ 
++/* mozilla extension, see https://bugzilla.mozilla.org/show_bug.cgi?id=1377257 */
++cairo_public cairo_hint_metrics_t
++cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font);
++
++
+ 
+ /* Toy fonts */
+ 
+ cairo_public cairo_font_face_t *
+ cairo_toy_font_face_create (const char           *family,
+ 			    cairo_font_slant_t    slant,
+ 			    cairo_font_weight_t   weight);
+ 
diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h
--- a/gfx/cairo/cairo/src/cairo-rename.h
+++ b/gfx/cairo/cairo/src/cairo-rename.h
@@ -262,16 +262,17 @@
 #define cairo_scale _moz_cairo_scale
 #define cairo_scaled_font_create _moz_cairo_scaled_font_create
 #define cairo_scaled_font_destroy _moz_cairo_scaled_font_destroy
 #define cairo_scaled_font_extents _moz_cairo_scaled_font_extents
 #define cairo_scaled_font_get_ctm _moz_cairo_scaled_font_get_ctm
 #define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face
 #define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix
 #define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options
+#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics
 #define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count
 #define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix
 #define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type
 #define cairo_scaled_font_get_user_data _moz_cairo_scaled_font_get_user_data
 #define cairo_scaled_font_glyph_extents _moz_cairo_scaled_font_glyph_extents
 #define cairo_scaled_font_reference _moz_cairo_scaled_font_reference
 #define cairo_scaled_font_set_user_data _moz_cairo_scaled_font_set_user_data
 #define cairo_scaled_font_status _moz_cairo_scaled_font_status
diff --git a/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c
--- a/gfx/cairo/cairo/src/cairo-scaled-font.c
+++ b/gfx/cairo/cairo/src/cairo-scaled-font.c
@@ -2983,8 +2983,28 @@ cairo_scaled_font_get_font_options (cair
     if (scaled_font->status) {
 	_cairo_font_options_init_default (options);
 	return;
     }
 
     _cairo_font_options_init_copy (options, &scaled_font->options);
 }
 slim_hidden_def (cairo_scaled_font_get_font_options);
+
+/**
+ * cairo_scaled_font_get_hint_metrics:
+ * @scaled_font: a #cairo_scaled_font_t
+ *
+ * Mozilla extension since the required malloc/free to use
+ * cairo_scaled_font_get_font_options() above is too slow.
+ **/
+cairo_public cairo_hint_metrics_t
+cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font)
+{
+    cairo_font_options_t options;
+    if (scaled_font->status) {
+	_cairo_font_options_init_default (&options);
+    } else {
+	_cairo_font_options_init_copy (&options, &scaled_font->options);
+    }
+    return options.hint_metrics;
+}
+slim_hidden_def (cairo_scaled_font_get_hint_metrics);
diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h
--- a/gfx/cairo/cairo/src/cairo.h
+++ b/gfx/cairo/cairo/src/cairo.h
@@ -1493,16 +1493,19 @@ cairo_scaled_font_get_ctm (cairo_scaled_
 cairo_public void
 cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t	*scaled_font,
 				    cairo_matrix_t	*scale_matrix);
 
 cairo_public void
 cairo_scaled_font_get_font_options (cairo_scaled_font_t		*scaled_font,
 				    cairo_font_options_t	*options);
 
+cairo_public cairo_hint_metrics_t
+cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t		*scaled_font);
+
 
 /* Toy fonts */
 
 cairo_public cairo_font_face_t *
 cairo_toy_font_face_create (const char           *family,
 			    cairo_font_slant_t    slant,
 			    cairo_font_weight_t   weight);