Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-shaper-private.hh

Issue 10915172: harfbuzz-ng roll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright © 2012 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Google Author(s): Behdad Esfahbod
25 */
26
27 #ifndef HB_SHAPER_PRIVATE_HH
28 #define HB_SHAPER_PRIVATE_HH
29
30 #include "hb-private.hh"
31
32 #include "hb-shape-plan.h" /* TODO remove */
33
34 typedef hb_bool_t hb_shape_func_t (hb_shape_plan_t *shape_plan,
35 hb_font_t *font,
36 hb_buffer_t *buffer,
37 const hb_feature_t *features,
38 unsigned int num_features);
39
40 #define HB_SHAPER_IMPLEMENT(name) \
41 extern "C" HB_INTERNAL hb_shape_func_t _hb_##name##_shape;
42 #include "hb-shaper-list.hh"
43 #undef HB_SHAPER_IMPLEMENT
44
45 struct hb_shaper_pair_t {
46 char name[16];
47 hb_shape_func_t *func;
48 };
49
50 HB_INTERNAL const hb_shaper_pair_t *
51 _hb_shapers_get (void);
52
53
54 /* For embedding in face / font / ... */
55 struct hb_shaper_data_t {
56 #define HB_SHAPER_IMPLEMENT(shaper) void *shaper;
57 #include "hb-shaper-list.hh"
58 #undef HB_SHAPER_IMPLEMENT
59 };
60
61 #define HB_SHAPERS_COUNT (sizeof (hb_shaper_data_t) / sizeof (void *))
62
63 /* Means: succeeded, but don't need to keep any data. */
64 #define HB_SHAPER_DATA_SUCCEEDED ((void *) +1)
65
66 /* Means: tried but failed to create. */
67 #define HB_SHAPER_DATA_INVALID ((void *) -1)
68 #define HB_SHAPER_DATA_IS_INVALID(data) ((void *) (data) == HB_SHAPER_DATA_INVAL ID)
69
70 #define HB_SHAPER_DATA_TYPE(shaper, object) struct hb_##shaper##_sha per_##object##_data_t
71 #define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* (HB_SHAPER_DA TA_TYPE(shaper, object) **) &(instance)->shaper_data.shaper)
72 #define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE (shaper, object, object)
73 #define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_## object##_data_create
74 #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_## object##_data_destroy
75
76 #define HB_SHAPER_DATA_PROTOTYPE(shaper, object) \
77 HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \
78 extern "C" HB_INTERNAL HB_SHAPER_DATA_TYPE (shaper, object) * \
79 HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object HB_ SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS); \
80 extern "C" HB_INTERNAL void \
81 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shape r, object) *data)
82
83 #define HB_SHAPER_DATA_DESTROY(shaper, object) \
84 if (object->shaper_data.shaper && \
85 object->shaper_data.shaper != HB_SHAPER_DATA_INVALID && \
86 object->shaper_data.shaper != HB_SHAPER_DATA_SUCCEEDED) \
87 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA (shaper, object));
88
89 #define HB_SHAPER_DATA_ENSURE_DECLARE(shaper, object) \
90 static inline bool \
91 hb_##shaper##_shaper_##object##_data_ensure (hb_##object##_t *object) \
92 {\
93 retry: \
94 HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, obj ect) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \
95 if (unlikely (!data)) { \
96 data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \
97 if (unlikely (!data)) \
98 data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \
99 if (!hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), NULL, data)) { \
100 HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \
101 goto retry; \
102 } \
103 } \
104 return data != NULL && !HB_SHAPER_DATA_IS_INVALID (data); \
105 }
106
107
108 #endif /* HB_SHAPER_PRIVATE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-shaper-list.hh ('k') | third_party/harfbuzz-ng/src/hb-tt-font.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698