-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcairoint.h
2042 lines (1658 loc) · 64.6 KB
/
cairoint.h
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2002 University of Southern California
* Copyright © 2005 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* The Original Code is the cairo graphics library.
*
* The Initial Developer of the Original Code is University of Southern
* California.
*
* Contributor(s):
* Carl D. Worth <[email protected]>
*/
/*
* These definitions are solely for use by the implementation of cairo
* and constitute no kind of standard. If you need any of these
* functions, please drop me a note. Either the library needs new
* functionality, or there's a way to do what you need using the
* existing published interfaces. [email protected]
*/
#ifndef _CAIROINT_H_
#define _CAIROINT_H_
#if HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef _MSC_VER
#define cairo_public __declspec(dllexport)
#endif
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include <limits.h>
#include <stdio.h>
#include "cairo.h"
#include <pixman.h>
#include "cairo-compiler-private.h"
#include "cairo-error-private.h"
#if CAIRO_HAS_PDF_SURFACE || \
CAIRO_HAS_PS_SURFACE || \
CAIRO_HAS_SCRIPT_SURFACE || \
CAIRO_HAS_XML_SURFACE
#define CAIRO_HAS_DEFLATE_STREAM 1
#endif
#if CAIRO_HAS_PS_SURFACE || \
CAIRO_HAS_PDF_SURFACE || \
CAIRO_HAS_SVG_SURFACE || \
CAIRO_HAS_WIN32_SURFACE
#define CAIRO_HAS_FONT_SUBSET 1
#endif
#if CAIRO_HAS_PS_SURFACE || \
CAIRO_HAS_PDF_SURFACE || \
CAIRO_HAS_FONT_SUBSET
#define CAIRO_HAS_PDF_OPERATORS 1
#endif
CAIRO_BEGIN_DECLS
#if _WIN32 && !_WIN32_WCE /* Permissions on WinCE? No worries! */
cairo_private FILE *
_cairo_win32_tmpfile (void);
#define tmpfile() _cairo_win32_tmpfile()
#endif
#undef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#undef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
#endif
#ifndef M_SQRT1_2
#define M_SQRT1_2 0.707106781186547524400844362104849039
#endif
#undef ARRAY_LENGTH
#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
#undef STRINGIFY
#undef STRINGIFY_ARG
#define STRINGIFY(macro_or_string) STRINGIFY_ARG (macro_or_string)
#define STRINGIFY_ARG(contents) #contents
#if defined (__GNUC__)
#define cairo_container_of(ptr, type, member) ({ \
const __typeof__ (((type *) 0)->member) *mptr__ = (ptr); \
(type *) ((char *) mptr__ - offsetof (type, member)); \
})
#else
#define cairo_container_of(ptr, type, member) \
((type *)((char *) (ptr) - (char *) &((type *)0)->member))
#endif
#define ASSERT_NOT_REACHED \
do { \
assert (!"reached"); \
} while (0)
#define COMPILE_TIME_ASSERT1(condition, line) \
typedef int compile_time_assertion_at_line_##line##_failed [(condition)?1:-1]
#define COMPILE_TIME_ASSERT0(condition, line) COMPILE_TIME_ASSERT1(condition, line)
#define COMPILE_TIME_ASSERT(condition) COMPILE_TIME_ASSERT0(condition, __LINE__)
#define CAIRO_ALPHA_IS_CLEAR(alpha) ((alpha) <= ((double)0x00ff / (double)0xffff))
#define CAIRO_ALPHA_SHORT_IS_CLEAR(alpha) ((alpha) <= 0x00ff)
#define CAIRO_ALPHA_IS_OPAQUE(alpha) ((alpha) >= ((double)0xff00 / (double)0xffff))
#define CAIRO_ALPHA_SHORT_IS_OPAQUE(alpha) ((alpha) >= 0xff00)
#define CAIRO_ALPHA_IS_ZERO(alpha) ((alpha) <= 0.0)
#define CAIRO_COLOR_IS_CLEAR(color) CAIRO_ALPHA_SHORT_IS_CLEAR ((color)->alpha_short)
#define CAIRO_COLOR_IS_OPAQUE(color) CAIRO_ALPHA_SHORT_IS_OPAQUE ((color)->alpha_short)
/* Reverse the bits in a byte with 7 operations (no 64-bit):
* Devised by Sean Anderson, July 13, 2001.
* Source: http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
*/
#define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
/* Return the number of 1 bits in mask.
*
* GCC 3.4 supports a "population count" builtin, which on many targets is
* implemented with a single instruction. There is a fallback definition
* in libgcc in case a target does not have one, which should be just as
* good as the open-coded solution below, (which is "HACKMEM 169").
*/
static inline int cairo_const
_cairo_popcount (uint32_t mask)
{
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
return __builtin_popcount (mask);
#else
register int y;
y = (mask >> 1) &033333333333;
y = mask - y - ((y >>1) & 033333333333);
return (((y + (y >> 3)) & 030707070707) % 077);
#endif
}
static cairo_always_inline cairo_bool_t
_cairo_is_little_endian (void)
{
static const int i = 1;
return *((char *) &i) == 0x01;
}
#ifdef WORDS_BIGENDIAN
#define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) (c)
#else
#define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c)
#endif
#ifdef WORDS_BIGENDIAN
#define cpu_to_be16(v) (v)
#define be16_to_cpu(v) (v)
#define cpu_to_be32(v) (v)
#define be32_to_cpu(v) (v)
#else
static inline uint16_t cairo_const
cpu_to_be16(uint16_t v)
{
return (v << 8) | (v >> 8);
}
static inline uint16_t cairo_const
be16_to_cpu(uint16_t v)
{
return cpu_to_be16 (v);
}
static inline uint32_t cairo_const
cpu_to_be32(uint32_t v)
{
return (cpu_to_be16 (v) << 16) | cpu_to_be16 (v >> 16);
}
static inline uint32_t cairo_const
be32_to_cpu(uint32_t v)
{
return cpu_to_be32 (v);
}
#endif
/* The glibc versions of ispace() and isdigit() are slow in UTF-8 locales.
*/
static inline int cairo_const
_cairo_isspace (int c)
{
return (c == 0x20 || (c >= 0x09 && c <= 0x0d));
}
static inline int cairo_const
_cairo_isdigit (int c)
{
return (c >= '0' && c <= '9');
}
#include "cairo-types-private.h"
#include "cairo-cache-private.h"
#include "cairo-reference-count-private.h"
#include "cairo-spans-private.h"
#include "cairo-surface-private.h"
cairo_private void
_cairo_box_from_doubles (cairo_box_t *box,
double *x1, double *y1,
double *x2, double *y2);
cairo_private void
_cairo_box_to_doubles (const cairo_box_t *box,
double *x1, double *y1,
double *x2, double *y2);
cairo_private void
_cairo_box_from_rectangle (cairo_box_t *box,
const cairo_rectangle_int_t *rectangle);
cairo_private void
_cairo_box_round_to_rectangle (const cairo_box_t *box,
cairo_rectangle_int_t *rectangle);
cairo_private void
_cairo_box_add_curve_to (cairo_box_t *extents,
const cairo_point_t *a,
const cairo_point_t *b,
const cairo_point_t *c,
const cairo_point_t *d);
cairo_private void
_cairo_boxes_get_extents (const cairo_box_t *boxes,
int num_boxes,
cairo_box_t *extents);
cairo_private extern const cairo_rectangle_int_t _cairo_empty_rectangle;
cairo_private extern const cairo_rectangle_int_t _cairo_unbounded_rectangle;
static inline void
_cairo_unbounded_rectangle_init (cairo_rectangle_int_t *rect)
{
*rect = _cairo_unbounded_rectangle;
}
cairo_private_no_warn cairo_bool_t
_cairo_rectangle_intersect (cairo_rectangle_int_t *dst,
const cairo_rectangle_int_t *src);
static inline cairo_bool_t
_cairo_rectangle_intersects (const cairo_rectangle_int_t *dst,
const cairo_rectangle_int_t *src)
{
return !(src->x >= dst->x + (int) dst->width ||
src->x + (int) src->width <= dst->x ||
src->y >= dst->y + (int) dst->height ||
src->y + (int) src->height <= dst->y);
}
static inline cairo_bool_t
_cairo_rectangle_contains_rectangle (const cairo_rectangle_int_t *a,
const cairo_rectangle_int_t *b)
{
return (a->x <= b->x &&
a->x + (int) a->width >= b->x + (int) b->width &&
a->y <= b->y &&
a->y + (int) a->height >= b->y + (int) b->height);
}
cairo_private void
_cairo_rectangle_int_from_double (cairo_rectangle_int_t *recti,
const cairo_rectangle_t *rectf);
/* Extends the dst rectangle to also contain src.
* If one of the rectangles is empty, the result is undefined
*/
cairo_private void
_cairo_rectangle_union (cairo_rectangle_int_t *dst,
const cairo_rectangle_int_t *src);
cairo_private cairo_bool_t
_cairo_box_intersects_line_segment (cairo_box_t *box,
cairo_line_t *line) cairo_pure;
cairo_private cairo_bool_t
_cairo_spline_intersects (const cairo_point_t *a,
const cairo_point_t *b,
const cairo_point_t *c,
const cairo_point_t *d,
const cairo_box_t *box) cairo_pure;
typedef struct {
const cairo_user_data_key_t *key;
void *user_data;
cairo_destroy_func_t destroy;
} cairo_user_data_slot_t;
cairo_private void
_cairo_user_data_array_init (cairo_user_data_array_t *array);
cairo_private void
_cairo_user_data_array_fini (cairo_user_data_array_t *array);
cairo_private void *
_cairo_user_data_array_get_data (cairo_user_data_array_t *array,
const cairo_user_data_key_t *key);
cairo_private cairo_status_t
_cairo_user_data_array_set_data (cairo_user_data_array_t *array,
const cairo_user_data_key_t *key,
void *user_data,
cairo_destroy_func_t destroy);
cairo_private cairo_status_t
_cairo_user_data_array_copy (cairo_user_data_array_t *dst,
const cairo_user_data_array_t *src);
cairo_private void
_cairo_user_data_array_foreach (cairo_user_data_array_t *array,
void (*func) (const void *key,
void *elt,
void *closure),
void *closure);
#define _CAIRO_HASH_INIT_VALUE 5381
cairo_private unsigned long
_cairo_hash_string (const char *c);
cairo_private unsigned long
_cairo_hash_bytes (unsigned long hash,
const void *bytes,
unsigned int length);
#define _cairo_scaled_glyph_index(g) ((g)->hash_entry.hash)
#define _cairo_scaled_glyph_set_index(g, i) ((g)->hash_entry.hash = (i))
#include "cairo-scaled-font-private.h"
struct _cairo_font_face {
/* hash_entry must be first */
cairo_hash_entry_t hash_entry;
cairo_status_t status;
cairo_reference_count_t ref_count;
cairo_user_data_array_t user_data;
const cairo_font_face_backend_t *backend;
};
cairo_private void
_cairo_default_context_reset_static_data (void);
cairo_private void
_cairo_toy_font_face_reset_static_data (void);
cairo_private void
_cairo_ft_font_reset_static_data (void);
cairo_private void
_cairo_win32_font_reset_static_data (void);
#if CAIRO_HAS_COGL_SURFACE
void
_cairo_cogl_context_reset_static_data (void);
#endif
/* the font backend interface */
struct _cairo_unscaled_font_backend {
void (*destroy) (void *unscaled_font);
};
/* #cairo_toy_font_face_t - simple family/slant/weight font faces used for
* the built-in font API
*/
typedef struct _cairo_toy_font_face {
cairo_font_face_t base;
const char *family;
cairo_bool_t owns_family;
cairo_font_slant_t slant;
cairo_font_weight_t weight;
cairo_font_face_t *impl_face; /* The non-toy font face this actually uses */
} cairo_toy_font_face_t;
typedef enum _cairo_scaled_glyph_info {
CAIRO_SCALED_GLYPH_INFO_METRICS = (1 << 0),
CAIRO_SCALED_GLYPH_INFO_SURFACE = (1 << 1),
CAIRO_SCALED_GLYPH_INFO_PATH = (1 << 2),
CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE = (1 << 3)
} cairo_scaled_glyph_info_t;
typedef struct _cairo_scaled_font_subset {
cairo_scaled_font_t *scaled_font;
unsigned int font_id;
unsigned int subset_id;
/* Index of glyphs array is subset_glyph_index.
* Value of glyphs array is scaled_font_glyph_index.
*/
unsigned long *glyphs;
char **utf8;
char **glyph_names;
int *to_latin_char;
unsigned long *latin_to_subset_glyph_index;
unsigned int num_glyphs;
cairo_bool_t is_composite;
cairo_bool_t is_scaled;
cairo_bool_t is_latin;
} cairo_scaled_font_subset_t;
struct _cairo_scaled_font_backend {
cairo_font_type_t type;
void
(*fini) (void *scaled_font);
cairo_warn cairo_int_status_t
(*scaled_glyph_init) (void *scaled_font,
cairo_scaled_glyph_t *scaled_glyph,
cairo_scaled_glyph_info_t info);
/* A backend only needs to implement this or ucs4_to_index(), not
* both. This allows the backend to do something more sophisticated
* then just converting characters one by one.
*/
cairo_warn cairo_int_status_t
(*text_to_glyphs) (void *scaled_font,
double x,
double y,
const char *utf8,
int utf8_len,
cairo_glyph_t **glyphs,
int *num_glyphs,
cairo_text_cluster_t **clusters,
int *num_clusters,
cairo_text_cluster_flags_t *cluster_flags);
unsigned long
(*ucs4_to_index) (void *scaled_font,
uint32_t ucs4);
/* Read data from a sfnt font table.
* @scaled_font: font
* @tag: 4 byte table name specifying the table to read.
* @offset: offset into the table
* @buffer: buffer to write data into. Caller must ensure there is sufficient space.
* If NULL, return the size of the table in @length.
* @length: If @buffer is NULL, the size of the table will be returned in @length.
* If @buffer is not null, @length specifies the number of bytes to read.
*
* If less than @length bytes are available to read this function
* returns CAIRO_INT_STATUS_UNSUPPORTED. Note that requesting more
* bytes than are available in the table may continue reading data
* from the following table and return success. If this is
* undesirable the caller should first query the table size. If an
* error occurs the output value of @length is undefined.
*
* Returns CAIRO_INT_STATUS_UNSUPPORTED if not a sfnt style font or table not found.
*/
cairo_warn cairo_int_status_t
(*load_truetype_table)(void *scaled_font,
unsigned long tag,
long offset,
unsigned char *buffer,
unsigned long *length);
/* ucs4 is set to -1 if the unicode character could not be found
* for the glyph */
cairo_warn cairo_int_status_t
(*index_to_ucs4)(void *scaled_font,
unsigned long index,
uint32_t *ucs4);
cairo_warn cairo_bool_t
(*is_synthetic)(void *scaled_font);
/* For type 1 fonts, return the glyph name for a given glyph index.
* A glyph index and list of glyph names in the Type 1 fonts is provided.
* The function returns the index of the glyph in the list of glyph names.
* @scaled_font: font
* @glyph_names: the names of each glyph in the Type 1 font in the
* order they appear in the CharStrings array
* @num_glyph_names: the number of names in the glyph_names array
* @glyph_index: the given glyph index
* @glyph_array_index: (index into glyph_names) the glyph name corresponding
* to the glyph_index
*/
cairo_warn cairo_int_status_t
(*index_to_glyph_name)(void *scaled_font,
char **glyph_names,
int num_glyph_names,
unsigned long glyph_index,
unsigned long *glyph_array_index);
/* Read data from a PostScript font.
* @scaled_font: font
* @offset: offset into the table
* @buffer: buffer to write data into. Caller must ensure there is sufficient space.
* If NULL, return the size of the table in @length.
* @length: If @buffer is NULL, the size of the table will be returned in @length.
* If @buffer is not null, @length specifies the number of bytes to read.
*
* If less than @length bytes are available to read this function
* returns CAIRO_INT_STATUS_UNSUPPORTED. If an error occurs the
* output value of @length is undefined.
*
* Returns CAIRO_INT_STATUS_UNSUPPORTED if not a Type 1 font.
*/
cairo_warn cairo_int_status_t
(*load_type1_data) (void *scaled_font,
long offset,
unsigned char *buffer,
unsigned long *length);
};
struct _cairo_font_face_backend {
cairo_font_type_t type;
cairo_warn cairo_status_t
(*create_for_toy) (cairo_toy_font_face_t *toy_face,
cairo_font_face_t **font_face);
/* The destroy() function is allowed to resurrect the font face
* by re-referencing. This is needed for the FreeType backend.
*/
void
(*destroy) (void *font_face);
cairo_warn cairo_status_t
(*scaled_font_create) (void *font_face,
const cairo_matrix_t *font_matrix,
const cairo_matrix_t *ctm,
const cairo_font_options_t *options,
cairo_scaled_font_t **scaled_font);
cairo_font_face_t *
(*get_implementation) (void *font_face,
const cairo_matrix_t *font_matrix,
const cairo_matrix_t *ctm,
const cairo_font_options_t *options);
};
extern const cairo_private struct _cairo_font_face_backend _cairo_user_font_face_backend;
/* concrete font backends */
#if CAIRO_HAS_FT_FONT
extern const cairo_private struct _cairo_font_face_backend _cairo_ft_font_face_backend;
#endif
#if CAIRO_HAS_WIN32_FONT
extern const cairo_private struct _cairo_font_face_backend _cairo_win32_font_face_backend;
#endif
#if CAIRO_HAS_QUARTZ_FONT
extern const cairo_private struct _cairo_font_face_backend _cairo_quartz_font_face_backend;
#endif
#define CAIRO_EXTEND_SURFACE_DEFAULT CAIRO_EXTEND_NONE
#define CAIRO_EXTEND_GRADIENT_DEFAULT CAIRO_EXTEND_PAD
#define CAIRO_FILTER_DEFAULT CAIRO_FILTER_GOOD
extern const cairo_private cairo_solid_pattern_t _cairo_pattern_clear;
extern const cairo_private cairo_solid_pattern_t _cairo_pattern_black;
extern const cairo_private cairo_solid_pattern_t _cairo_pattern_white;
struct _cairo_surface_attributes {
cairo_matrix_t matrix;
cairo_extend_t extend;
cairo_filter_t filter;
cairo_bool_t has_component_alpha;
int x_offset;
int y_offset;
void *extra;
};
#define CAIRO_FONT_SLANT_DEFAULT CAIRO_FONT_SLANT_NORMAL
#define CAIRO_FONT_WEIGHT_DEFAULT CAIRO_FONT_WEIGHT_NORMAL
#define CAIRO_WIN32_FONT_FAMILY_DEFAULT "Arial"
#define CAIRO_QUARTZ_FONT_FAMILY_DEFAULT "Helvetica"
#define CAIRO_FT_FONT_FAMILY_DEFAULT ""
#define CAIRO_USER_FONT_FAMILY_DEFAULT "@cairo:"
#if CAIRO_HAS_WIN32_FONT
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_win32_font_face_backend
#elif CAIRO_HAS_QUARTZ_FONT
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_QUARTZ_FONT_FAMILY_DEFAULT
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_quartz_font_face_backend
#elif CAIRO_HAS_FT_FONT
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_ft_font_face_backend
#else
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_user_font_face_backend
#endif
#define CAIRO_GSTATE_OPERATOR_DEFAULT CAIRO_OPERATOR_OVER
#define CAIRO_GSTATE_TOLERANCE_DEFAULT 0.1
#define CAIRO_GSTATE_FILL_RULE_DEFAULT CAIRO_FILL_RULE_WINDING
#define CAIRO_GSTATE_LINE_WIDTH_DEFAULT 2.0
#define CAIRO_GSTATE_LINE_CAP_DEFAULT CAIRO_LINE_CAP_BUTT
#define CAIRO_GSTATE_LINE_JOIN_DEFAULT CAIRO_LINE_JOIN_MITER
#define CAIRO_GSTATE_MITER_LIMIT_DEFAULT 10.0
#define CAIRO_GSTATE_DEFAULT_FONT_SIZE 10.0
#define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
#define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
typedef struct _cairo_stroke_face {
cairo_point_t ccw;
cairo_point_t point;
cairo_point_t cw;
cairo_slope_t dev_vector;
cairo_point_double_t dev_slope;
cairo_point_double_t usr_vector;
double length;
} cairo_stroke_face_t;
/* cairo.c */
static inline double cairo_const
_cairo_restrict_value (double value, double min, double max)
{
if (value < min)
return min;
else if (value > max)
return max;
else
return value;
}
/* C99 round() rounds to the nearest integral value with halfway cases rounded
* away from 0. _cairo_round rounds halfway cases toward positive infinity.
* This matches the rounding behaviour of _cairo_lround. */
static inline double cairo_const
_cairo_round (double r)
{
return floor (r + .5);
}
#if DISABLE_SOME_FLOATING_POINT
cairo_private int
_cairo_lround (double d) cairo_const;
#else
static inline int cairo_const
_cairo_lround (double r)
{
return _cairo_round (r);
}
#endif
cairo_private uint16_t
_cairo_half_from_float (float f) cairo_const;
cairo_private cairo_bool_t
_cairo_operator_bounded_by_mask (cairo_operator_t op) cairo_const;
cairo_private cairo_bool_t
_cairo_operator_bounded_by_source (cairo_operator_t op) cairo_const;
enum {
CAIRO_OPERATOR_BOUND_BY_MASK = 1 << 1,
CAIRO_OPERATOR_BOUND_BY_SOURCE = 1 << 2,
};
cairo_private uint32_t
_cairo_operator_bounded_by_either (cairo_operator_t op) cairo_const;
/* cairo-color.c */
cairo_private const cairo_color_t *
_cairo_stock_color (cairo_stock_t stock) cairo_pure;
#define CAIRO_COLOR_WHITE _cairo_stock_color (CAIRO_STOCK_WHITE)
#define CAIRO_COLOR_BLACK _cairo_stock_color (CAIRO_STOCK_BLACK)
#define CAIRO_COLOR_TRANSPARENT _cairo_stock_color (CAIRO_STOCK_TRANSPARENT)
cairo_private uint16_t
_cairo_color_double_to_short (double d) cairo_const;
cairo_private void
_cairo_color_init_rgba (cairo_color_t *color,
double red, double green, double blue,
double alpha);
cairo_private void
_cairo_color_multiply_alpha (cairo_color_t *color,
double alpha);
cairo_private void
_cairo_color_get_rgba (cairo_color_t *color,
double *red,
double *green,
double *blue,
double *alpha);
cairo_private void
_cairo_color_get_rgba_premultiplied (cairo_color_t *color,
double *red,
double *green,
double *blue,
double *alpha);
cairo_private cairo_bool_t
_cairo_color_equal (const cairo_color_t *color_a,
const cairo_color_t *color_b) cairo_pure;
cairo_private cairo_bool_t
_cairo_color_stop_equal (const cairo_color_stop_t *color_a,
const cairo_color_stop_t *color_b) cairo_pure;
cairo_private cairo_content_t
_cairo_color_get_content (const cairo_color_t *color) cairo_pure;
/* cairo-font-face.c */
extern const cairo_private cairo_font_face_t _cairo_font_face_nil;
cairo_private void
_cairo_font_face_init (cairo_font_face_t *font_face,
const cairo_font_face_backend_t *backend);
cairo_private cairo_status_t
_cairo_font_face_set_error (cairo_font_face_t *font_face,
cairo_status_t status);
cairo_private void
_cairo_unscaled_font_init (cairo_unscaled_font_t *font,
const cairo_unscaled_font_backend_t *backend);
cairo_private_no_warn cairo_unscaled_font_t *
_cairo_unscaled_font_reference (cairo_unscaled_font_t *font);
cairo_private void
_cairo_unscaled_font_destroy (cairo_unscaled_font_t *font);
/* cairo-font-face-twin.c */
cairo_private cairo_font_face_t *
_cairo_font_face_twin_create_fallback (void);
cairo_private cairo_status_t
_cairo_font_face_twin_create_for_toy (cairo_toy_font_face_t *toy_face,
cairo_font_face_t **font_face);
/* cairo-font-face-twin-data.c */
extern const cairo_private int8_t _cairo_twin_outlines[];
extern const cairo_private uint16_t _cairo_twin_charmap[128];
/* cairo-font-options.c */
cairo_private void
_cairo_font_options_init_default (cairo_font_options_t *options);
cairo_private void
_cairo_font_options_init_copy (cairo_font_options_t *options,
const cairo_font_options_t *other);
cairo_private void
_cairo_font_options_set_lcd_filter (cairo_font_options_t *options,
cairo_lcd_filter_t lcd_filter);
cairo_private cairo_lcd_filter_t
_cairo_font_options_get_lcd_filter (const cairo_font_options_t *options);
cairo_private void
_cairo_font_options_set_round_glyph_positions (cairo_font_options_t *options,
cairo_round_glyph_positions_t round);
cairo_private cairo_round_glyph_positions_t
_cairo_font_options_get_round_glyph_positions (const cairo_font_options_t *options);
/* cairo-hull.c */
cairo_private cairo_status_t
_cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices);
/* cairo-lzw.c */
cairo_private unsigned char *
_cairo_lzw_compress (unsigned char *data, unsigned long *size_in_out);
/* cairo-misc.c */
cairo_private cairo_status_t
_cairo_validate_text_clusters (const char *utf8,
int utf8_len,
const cairo_glyph_t *glyphs,
int num_glyphs,
const cairo_text_cluster_t *clusters,
int num_clusters,
cairo_text_cluster_flags_t cluster_flags);
cairo_private cairo_status_t
_cairo_intern_string (const char **str_inout, int len);
cairo_private void
_cairo_intern_string_reset_static_data (void);
/* cairo-path-fixed.c */
cairo_private cairo_path_fixed_t *
_cairo_path_fixed_create (void);
cairo_private void
_cairo_path_fixed_init (cairo_path_fixed_t *path);
cairo_private cairo_status_t
_cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
const cairo_path_fixed_t *other);
cairo_private void
_cairo_path_fixed_fini (cairo_path_fixed_t *path);
cairo_private void
_cairo_path_fixed_destroy (cairo_path_fixed_t *path);
cairo_private cairo_status_t
_cairo_path_fixed_move_to (cairo_path_fixed_t *path,
cairo_fixed_t x,
cairo_fixed_t y);
cairo_private void
_cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path);
cairo_private cairo_status_t
_cairo_path_fixed_rel_move_to (cairo_path_fixed_t *path,
cairo_fixed_t dx,
cairo_fixed_t dy);
cairo_private cairo_status_t
_cairo_path_fixed_line_to (cairo_path_fixed_t *path,
cairo_fixed_t x,
cairo_fixed_t y);
cairo_private cairo_status_t
_cairo_path_fixed_rel_line_to (cairo_path_fixed_t *path,
cairo_fixed_t dx,
cairo_fixed_t dy);
cairo_private cairo_status_t
_cairo_path_fixed_curve_to (cairo_path_fixed_t *path,
cairo_fixed_t x0, cairo_fixed_t y0,
cairo_fixed_t x1, cairo_fixed_t y1,
cairo_fixed_t x2, cairo_fixed_t y2);
cairo_private cairo_status_t
_cairo_path_fixed_rel_curve_to (cairo_path_fixed_t *path,
cairo_fixed_t dx0, cairo_fixed_t dy0,
cairo_fixed_t dx1, cairo_fixed_t dy1,
cairo_fixed_t dx2, cairo_fixed_t dy2);
cairo_private cairo_status_t
_cairo_path_fixed_close_path (cairo_path_fixed_t *path);
cairo_private cairo_bool_t
_cairo_path_fixed_get_current_point (cairo_path_fixed_t *path,
cairo_fixed_t *x,
cairo_fixed_t *y);
typedef cairo_status_t
(cairo_path_fixed_move_to_func_t) (void *closure,
const cairo_point_t *point);
typedef cairo_status_t
(cairo_path_fixed_line_to_func_t) (void *closure,
const cairo_point_t *point);
typedef cairo_status_t
(cairo_path_fixed_curve_to_func_t) (void *closure,
const cairo_point_t *p0,
const cairo_point_t *p1,
const cairo_point_t *p2);
typedef cairo_status_t
(cairo_path_fixed_close_path_func_t) (void *closure);
cairo_private cairo_status_t
_cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
cairo_path_fixed_move_to_func_t *move_to,
cairo_path_fixed_line_to_func_t *line_to,
cairo_path_fixed_curve_to_func_t *curve_to,
cairo_path_fixed_close_path_func_t *close_path,
void *closure);
cairo_private cairo_status_t
_cairo_path_fixed_interpret_flat (const cairo_path_fixed_t *path,
cairo_path_fixed_move_to_func_t *move_to,
cairo_path_fixed_line_to_func_t *line_to,
cairo_path_fixed_close_path_func_t *close_path,
void *closure,
double tolerance);
cairo_private cairo_bool_t
_cairo_path_bounder_extents (const cairo_path_fixed_t *path,
cairo_box_t *box);
cairo_private cairo_bool_t
_cairo_path_fixed_extents (const cairo_path_fixed_t *path,
cairo_box_t *box);
cairo_private void
_cairo_path_fixed_approximate_clip_extents (const cairo_path_fixed_t *path,
cairo_rectangle_int_t *extents);
cairo_private void
_cairo_path_fixed_approximate_fill_extents (const cairo_path_fixed_t *path,
cairo_rectangle_int_t *extents);
cairo_private void
_cairo_path_fixed_fill_extents (const cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
double tolerance,
cairo_rectangle_int_t *extents);
cairo_private void
_cairo_path_fixed_approximate_stroke_extents (const cairo_path_fixed_t *path,
const cairo_stroke_style_t *style,
const cairo_matrix_t *ctm,
cairo_rectangle_int_t *extents);
cairo_private cairo_status_t
_cairo_path_fixed_stroke_extents (const cairo_path_fixed_t *path,
const cairo_stroke_style_t *style,
const cairo_matrix_t *ctm,
const cairo_matrix_t *ctm_inverse,
double tolerance,
cairo_rectangle_int_t *extents);