diff options
| author | Alan Third | 2017-12-10 10:16:25 +0000 |
|---|---|---|
| committer | Alan Third | 2017-12-12 20:36:40 +0000 |
| commit | 45099bb90ff2107c3a30aef3047c893dbf5ef249 (patch) | |
| tree | e945651fd912dd952aae7b13e83717d6da0bb70c /src | |
| parent | b0369d0536cd510e8b7120ccf04ee98c4e323b59 (diff) | |
| download | emacs-45099bb90ff2107c3a30aef3047c893dbf5ef249.tar.gz emacs-45099bb90ff2107c3a30aef3047c893dbf5ef249.zip | |
Remove ObjC blocks (Bug#23753)
* src/macfont.m (macfont_get_glyph_for_character):
(mac_font_get_glyphs_for_variants): Inline Objective-C blocks.
(cherry picked from commit 4590f1d768adbb2120a2b02c614f7ed3b21a4a3e)
Diffstat (limited to 'src')
| -rw-r--r-- | src/macfont.m | 128 |
1 files changed, 55 insertions, 73 deletions
diff --git a/src/macfont.m b/src/macfont.m index 97879506ba4..6985364b34e 100644 --- a/src/macfont.m +++ b/src/macfont.m | |||
| @@ -1443,6 +1443,7 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c) | |||
| 1443 | int nrows; | 1443 | int nrows; |
| 1444 | dispatch_queue_t queue; | 1444 | dispatch_queue_t queue; |
| 1445 | dispatch_group_t group = NULL; | 1445 | dispatch_group_t group = NULL; |
| 1446 | int nkeys; | ||
| 1446 | 1447 | ||
| 1447 | if (row != 0) | 1448 | if (row != 0) |
| 1448 | { | 1449 | { |
| @@ -1479,23 +1480,16 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c) | |||
| 1479 | return glyph; | 1480 | return glyph; |
| 1480 | } | 1481 | } |
| 1481 | 1482 | ||
| 1482 | queue = | 1483 | nkeys = nkeys_or_perm; |
| 1483 | dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | 1484 | for (key = row * (256 / NGLYPHS_IN_VALUE); ; key++) |
| 1484 | group = dispatch_group_create (); | 1485 | if (CFDictionaryContainsKey (dictionary, |
| 1485 | dispatch_group_async (group, queue, ^{ | 1486 | (const void *) key)) |
| 1486 | int nkeys; | 1487 | { |
| 1487 | uintptr_t key; | 1488 | CFDictionaryRemoveValue (dictionary, |
| 1488 | nkeys = nkeys_or_perm; | 1489 | (const void *) key); |
| 1489 | for (key = row * (256 / NGLYPHS_IN_VALUE); ; key++) | 1490 | if (--nkeys == 0) |
| 1490 | if (CFDictionaryContainsKey (dictionary, | 1491 | break; |
| 1491 | (const void *) key)) | 1492 | } |
| 1492 | { | ||
| 1493 | CFDictionaryRemoveValue (dictionary, | ||
| 1494 | (const void *) key); | ||
| 1495 | if (--nkeys == 0) | ||
| 1496 | break; | ||
| 1497 | } | ||
| 1498 | }); | ||
| 1499 | } | 1493 | } |
| 1500 | 1494 | ||
| 1501 | len = 0; | 1495 | len = 0; |
| @@ -1535,12 +1529,6 @@ macfont_get_glyph_for_character (struct font *font, UTF32Char c) | |||
| 1535 | sizeof (CGGlyph *) * nrows); | 1529 | sizeof (CGGlyph *) * nrows); |
| 1536 | cache->glyph.matrix[nrows - 1] = glyphs; | 1530 | cache->glyph.matrix[nrows - 1] = glyphs; |
| 1537 | cache->glyph.nrows = nrows; | 1531 | cache->glyph.nrows = nrows; |
| 1538 | |||
| 1539 | if (group) | ||
| 1540 | { | ||
| 1541 | dispatch_group_wait (group, DISPATCH_TIME_FOREVER); | ||
| 1542 | dispatch_release (group); | ||
| 1543 | } | ||
| 1544 | } | 1532 | } |
| 1545 | 1533 | ||
| 1546 | return cache->glyph.matrix[nkeys_or_perm - ROW_PERM_OFFSET][c % 256]; | 1534 | return cache->glyph.matrix[nkeys_or_perm - ROW_PERM_OFFSET][c % 256]; |
| @@ -3267,9 +3255,6 @@ mac_font_get_glyphs_for_variants (CFDataRef uvs_table, UTF32Char c, | |||
| 3267 | struct variation_selector_record *records = uvs->variation_selector_records; | 3255 | struct variation_selector_record *records = uvs->variation_selector_records; |
| 3268 | CFIndex i; | 3256 | CFIndex i; |
| 3269 | UInt32 ir, nrecords; | 3257 | UInt32 ir, nrecords; |
| 3270 | dispatch_queue_t queue = | ||
| 3271 | dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | ||
| 3272 | dispatch_group_t group = dispatch_group_create (); | ||
| 3273 | 3258 | ||
| 3274 | nrecords = BUINT32_VALUE (uvs->num_var_selector_records); | 3259 | nrecords = BUINT32_VALUE (uvs->num_var_selector_records); |
| 3275 | i = 0; | 3260 | i = 0; |
| @@ -3293,66 +3278,63 @@ mac_font_get_glyphs_for_variants (CFDataRef uvs_table, UTF32Char c, | |||
| 3293 | default_uvs_offset = BUINT32_VALUE (records[ir].default_uvs_offset); | 3278 | default_uvs_offset = BUINT32_VALUE (records[ir].default_uvs_offset); |
| 3294 | non_default_uvs_offset = | 3279 | non_default_uvs_offset = |
| 3295 | BUINT32_VALUE (records[ir].non_default_uvs_offset); | 3280 | BUINT32_VALUE (records[ir].non_default_uvs_offset); |
| 3296 | dispatch_group_async (group, queue, ^{ | ||
| 3297 | glyphs[i] = kCGFontIndexInvalid; | ||
| 3298 | 3281 | ||
| 3299 | if (default_uvs_offset) | 3282 | glyphs[i] = kCGFontIndexInvalid; |
| 3283 | |||
| 3284 | if (default_uvs_offset) | ||
| 3285 | { | ||
| 3286 | struct default_uvs_table *default_uvs = | ||
| 3287 | (struct default_uvs_table *) ((UInt8 *) uvs | ||
| 3288 | + default_uvs_offset); | ||
| 3289 | struct unicode_value_range *ranges = | ||
| 3290 | default_uvs->unicode_value_ranges; | ||
| 3291 | UInt32 lo, hi; | ||
| 3292 | |||
| 3293 | lo = 0; | ||
| 3294 | hi = BUINT32_VALUE (default_uvs->num_unicode_value_ranges); | ||
| 3295 | while (lo < hi) | ||
| 3300 | { | 3296 | { |
| 3301 | struct default_uvs_table *default_uvs = | 3297 | UInt32 mid = (lo + hi) / 2; |
| 3302 | (struct default_uvs_table *) ((UInt8 *) uvs | ||
| 3303 | + default_uvs_offset); | ||
| 3304 | struct unicode_value_range *ranges = | ||
| 3305 | default_uvs->unicode_value_ranges; | ||
| 3306 | UInt32 lo, hi; | ||
| 3307 | |||
| 3308 | lo = 0; | ||
| 3309 | hi = BUINT32_VALUE (default_uvs->num_unicode_value_ranges); | ||
| 3310 | while (lo < hi) | ||
| 3311 | { | ||
| 3312 | UInt32 mid = (lo + hi) / 2; | ||
| 3313 | 3298 | ||
| 3314 | if (c < BUINT24_VALUE (ranges[mid].start_unicode_value)) | 3299 | if (c < BUINT24_VALUE (ranges[mid].start_unicode_value)) |
| 3315 | hi = mid; | 3300 | hi = mid; |
| 3316 | else | 3301 | else |
| 3317 | lo = mid + 1; | 3302 | lo = mid + 1; |
| 3318 | } | ||
| 3319 | if (hi > 0 | ||
| 3320 | && (c <= (BUINT24_VALUE (ranges[hi - 1].start_unicode_value) | ||
| 3321 | + BUINT8_VALUE (ranges[hi - 1].additional_count)))) | ||
| 3322 | glyphs[i] = 0; | ||
| 3323 | } | 3303 | } |
| 3304 | if (hi > 0 | ||
| 3305 | && (c <= (BUINT24_VALUE (ranges[hi - 1].start_unicode_value) | ||
| 3306 | + BUINT8_VALUE (ranges[hi - 1].additional_count)))) | ||
| 3307 | glyphs[i] = 0; | ||
| 3308 | } | ||
| 3324 | 3309 | ||
| 3325 | if (glyphs[i] == kCGFontIndexInvalid && non_default_uvs_offset) | 3310 | if (glyphs[i] == kCGFontIndexInvalid && non_default_uvs_offset) |
| 3311 | { | ||
| 3312 | struct non_default_uvs_table *non_default_uvs = | ||
| 3313 | (struct non_default_uvs_table *) ((UInt8 *) uvs | ||
| 3314 | + non_default_uvs_offset); | ||
| 3315 | struct uvs_mapping *mappings = non_default_uvs->uvs_mappings; | ||
| 3316 | UInt32 lo, hi; | ||
| 3317 | |||
| 3318 | lo = 0; | ||
| 3319 | hi = BUINT32_VALUE (non_default_uvs->num_uvs_mappings); | ||
| 3320 | while (lo < hi) | ||
| 3326 | { | 3321 | { |
| 3327 | struct non_default_uvs_table *non_default_uvs = | 3322 | UInt32 mid = (lo + hi) / 2; |
| 3328 | (struct non_default_uvs_table *) ((UInt8 *) uvs | ||
| 3329 | + non_default_uvs_offset); | ||
| 3330 | struct uvs_mapping *mappings = non_default_uvs->uvs_mappings; | ||
| 3331 | UInt32 lo, hi; | ||
| 3332 | |||
| 3333 | lo = 0; | ||
| 3334 | hi = BUINT32_VALUE (non_default_uvs->num_uvs_mappings); | ||
| 3335 | while (lo < hi) | ||
| 3336 | { | ||
| 3337 | UInt32 mid = (lo + hi) / 2; | ||
| 3338 | 3323 | ||
| 3339 | if (c < BUINT24_VALUE (mappings[mid].unicode_value)) | 3324 | if (c < BUINT24_VALUE (mappings[mid].unicode_value)) |
| 3340 | hi = mid; | 3325 | hi = mid; |
| 3341 | else | 3326 | else |
| 3342 | lo = mid + 1; | 3327 | lo = mid + 1; |
| 3343 | } | ||
| 3344 | if (hi > 0 && | ||
| 3345 | BUINT24_VALUE (mappings[hi - 1].unicode_value) == c) | ||
| 3346 | glyphs[i] = BUINT16_VALUE (mappings[hi - 1].glyph_id); | ||
| 3347 | } | 3328 | } |
| 3348 | }); | 3329 | if (hi > 0 && |
| 3330 | BUINT24_VALUE (mappings[hi - 1].unicode_value) == c) | ||
| 3331 | glyphs[i] = BUINT16_VALUE (mappings[hi - 1].glyph_id); | ||
| 3332 | } | ||
| 3349 | i++; | 3333 | i++; |
| 3350 | ir++; | 3334 | ir++; |
| 3351 | } | 3335 | } |
| 3352 | while (i < count) | 3336 | while (i < count) |
| 3353 | glyphs[i++] = kCGFontIndexInvalid; | 3337 | glyphs[i++] = kCGFontIndexInvalid; |
| 3354 | dispatch_group_wait (group, DISPATCH_TIME_FOREVER); | ||
| 3355 | dispatch_release (group); | ||
| 3356 | } | 3338 | } |
| 3357 | 3339 | ||
| 3358 | static int | 3340 | static int |