| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2012 Google, Inc. | 2 * Copyright © 2012 Google, Inc. |
| 3 * | 3 * |
| 4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
| 5 * | 5 * |
| 6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
| 7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
| 8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
| 9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
| 10 * all copies of this software. | 10 * all copies of this software. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 static void | 39 static void |
| 40 hb_shape_plan_plan (hb_shape_plan_t *shape_plan, | 40 hb_shape_plan_plan (hb_shape_plan_t *shape_plan, |
| 41 const hb_feature_t *user_features, | 41 const hb_feature_t *user_features, |
| 42 unsigned int num_user_features, | 42 unsigned int num_user_features, |
| 43 const char * const *shaper_list) | 43 const char * const *shaper_list) |
| 44 { | 44 { |
| 45 const hb_shaper_pair_t *shapers = _hb_shapers_get (); | 45 const hb_shaper_pair_t *shapers = _hb_shapers_get (); |
| 46 | 46 |
| 47 #define HB_SHAPER_PLAN(shaper) \ | 47 #define HB_SHAPER_PLAN(shaper) \ |
| 48 HB_STMT_START { \ | 48 HB_STMT_START { \ |
| 49 » if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face)) { \ | 49 » if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) {
\ |
| 50 HB_SHAPER_DATA (shaper, shape_plan) = \ | 50 HB_SHAPER_DATA (shaper, shape_plan) = \ |
| 51 HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_
features, num_user_features); \ | 51 HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, user_
features, num_user_features); \ |
| 52 shape_plan->shaper_func = _hb_##shaper##_shape; \ | 52 shape_plan->shaper_func = _hb_##shaper##_shape; \ |
| 53 shape_plan->shaper_name = #shaper; \ | 53 shape_plan->shaper_name = #shaper; \ |
| 54 return; \ | 54 return; \ |
| 55 } \ | 55 } \ |
| 56 } HB_STMT_END | 56 } HB_STMT_END |
| 57 | 57 |
| 58 if (likely (!shaper_list)) { | 58 if (likely (!shaper_list)) { |
| 59 for (unsigned int i = 0; i < HB_SHAPERS_COUNT; i++) | 59 for (unsigned int i = 0; i < HB_SHAPERS_COUNT; i++) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 if (unlikely (!face)) | 111 if (unlikely (!face)) |
| 112 face = hb_face_get_empty (); | 112 face = hb_face_get_empty (); |
| 113 if (unlikely (!props || hb_object_is_inert (face))) | 113 if (unlikely (!props || hb_object_is_inert (face))) |
| 114 return hb_shape_plan_get_empty (); | 114 return hb_shape_plan_get_empty (); |
| 115 if (!(shape_plan = hb_object_create<hb_shape_plan_t> ())) | 115 if (!(shape_plan = hb_object_create<hb_shape_plan_t> ())) |
| 116 return hb_shape_plan_get_empty (); | 116 return hb_shape_plan_get_empty (); |
| 117 | 117 |
| 118 hb_face_make_immutable (face); | 118 hb_face_make_immutable (face); |
| 119 shape_plan->default_shaper_list = shaper_list == NULL; | 119 shape_plan->default_shaper_list = shaper_list == NULL; |
| 120 shape_plan->face = hb_face_reference (face); | 120 shape_plan->face_unsafe = face; |
| 121 shape_plan->props = *props; | 121 shape_plan->props = *props; |
| 122 | 122 |
| 123 hb_shape_plan_plan (shape_plan, user_features, num_user_features, shaper_list)
; | 123 hb_shape_plan_plan (shape_plan, user_features, num_user_features, shaper_list)
; |
| 124 | 124 |
| 125 return shape_plan; | 125 return shape_plan; |
| 126 } | 126 } |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * hb_shape_plan_get_empty: | 129 * hb_shape_plan_get_empty: |
| 130 * | 130 * |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 **/ | 183 **/ |
| 184 void | 184 void |
| 185 hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) | 185 hb_shape_plan_destroy (hb_shape_plan_t *shape_plan) |
| 186 { | 186 { |
| 187 if (!hb_object_destroy (shape_plan)) return; | 187 if (!hb_object_destroy (shape_plan)) return; |
| 188 | 188 |
| 189 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, shape_plan); | 189 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, shape_plan); |
| 190 #include "hb-shaper-list.hh" | 190 #include "hb-shaper-list.hh" |
| 191 #undef HB_SHAPER_IMPLEMENT | 191 #undef HB_SHAPER_IMPLEMENT |
| 192 | 192 |
| 193 hb_face_destroy (shape_plan->face); | |
| 194 | |
| 195 free (shape_plan); | 193 free (shape_plan); |
| 196 } | 194 } |
| 197 | 195 |
| 198 /** | 196 /** |
| 199 * hb_shape_plan_set_user_data: (skip) | 197 * hb_shape_plan_set_user_data: (skip) |
| 200 * @shape_plan: a shape plan. | 198 * @shape_plan: a shape plan. |
| 201 * @key: | 199 * @key: |
| 202 * @data: | 200 * @data: |
| 203 * @destroy: | 201 * @destroy: |
| 204 * @replace: | 202 * @replace: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 hb_font_t *font, | 255 hb_font_t *font, |
| 258 hb_buffer_t *buffer, | 256 hb_buffer_t *buffer, |
| 259 const hb_feature_t *features, | 257 const hb_feature_t *features, |
| 260 unsigned int num_features) | 258 unsigned int num_features) |
| 261 { | 259 { |
| 262 if (unlikely (hb_object_is_inert (shape_plan) || | 260 if (unlikely (hb_object_is_inert (shape_plan) || |
| 263 hb_object_is_inert (font) || | 261 hb_object_is_inert (font) || |
| 264 hb_object_is_inert (buffer))) | 262 hb_object_is_inert (buffer))) |
| 265 return false; | 263 return false; |
| 266 | 264 |
| 267 assert (shape_plan->face == font->face); | 265 assert (shape_plan->face_unsafe == font->face); |
| 268 assert (hb_segment_properties_equal (&shape_plan->props, &buffer->props)); | 266 assert (hb_segment_properties_equal (&shape_plan->props, &buffer->props)); |
| 269 | 267 |
| 270 #define HB_SHAPER_EXECUTE(shaper) \ | 268 #define HB_SHAPER_EXECUTE(shaper) \ |
| 271 HB_STMT_START { \ | 269 HB_STMT_START { \ |
| 272 return HB_SHAPER_DATA (shaper, shape_plan) && \ | 270 return HB_SHAPER_DATA (shaper, shape_plan) && \ |
| 273 hb_##shaper##_shaper_font_data_ensure (font) && \ | 271 hb_##shaper##_shaper_font_data_ensure (font) && \ |
| 274 _hb_##shaper##_shape (shape_plan, font, buffer, features, num_f
eatures); \ | 272 _hb_##shaper##_shape (shape_plan, font, buffer, features, num_f
eatures); \ |
| 275 } HB_STMT_END | 273 } HB_STMT_END |
| 276 | 274 |
| 277 if (0) | 275 if (0) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 386 |
| 389 node->shape_plan = shape_plan; | 387 node->shape_plan = shape_plan; |
| 390 node->next = cached_plan_nodes; | 388 node->next = cached_plan_nodes; |
| 391 | 389 |
| 392 if (!hb_atomic_ptr_cmpexch (&face->shape_plans, cached_plan_nodes, node)) { | 390 if (!hb_atomic_ptr_cmpexch (&face->shape_plans, cached_plan_nodes, node)) { |
| 393 hb_shape_plan_destroy (shape_plan); | 391 hb_shape_plan_destroy (shape_plan); |
| 394 free (node); | 392 free (node); |
| 395 goto retry; | 393 goto retry; |
| 396 } | 394 } |
| 397 | 395 |
| 398 /* Release our reference on face. */ | |
| 399 hb_face_destroy (face); | |
| 400 | |
| 401 return hb_shape_plan_reference (shape_plan); | 396 return hb_shape_plan_reference (shape_plan); |
| 402 } | 397 } |
| 403 | 398 |
| 404 /** | 399 /** |
| 405 * hb_shape_plan_get_shaper: | 400 * hb_shape_plan_get_shaper: |
| 406 * @shape_plan: a shape plan. | 401 * @shape_plan: a shape plan. |
| 407 * | 402 * |
| 408 * | 403 * |
| 409 * | 404 * |
| 410 * Return value: (transfer none): | 405 * Return value: (transfer none): |
| 411 * | 406 * |
| 412 * Since: 1.0 | 407 * Since: 1.0 |
| 413 **/ | 408 **/ |
| 414 const char * | 409 const char * |
| 415 hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan) | 410 hb_shape_plan_get_shaper (hb_shape_plan_t *shape_plan) |
| 416 { | 411 { |
| 417 return shape_plan->shaper_name; | 412 return shape_plan->shaper_name; |
| 418 } | 413 } |
| OLD | NEW |