Compare commits
1 Commits
main
...
coverage-c
Author | SHA1 | Date |
---|---|---|
Behdad Esfahbod | 1ec0f58297 |
|
@ -30,6 +30,8 @@
|
|||
#ifndef OT_LAYOUT_COMMON_COVERAGEFORMAT1_HH
|
||||
#define OT_LAYOUT_COMMON_COVERAGEFORMAT1_HH
|
||||
|
||||
#include "../../../hb-cache.hh"
|
||||
|
||||
namespace OT {
|
||||
namespace Layout {
|
||||
namespace Common {
|
||||
|
@ -57,8 +59,18 @@ struct CoverageFormat1_3
|
|||
|
||||
unsigned int get_coverage (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
static hb_cache_t<16, 8, 9, true> cache;
|
||||
|
||||
unsigned v;
|
||||
if (cache.get ((glyph_id + (uintptr_t) this) & 0xFFFF, &v))
|
||||
{
|
||||
if (glyphArray[v] == glyph_id)
|
||||
return v;
|
||||
}
|
||||
|
||||
unsigned int i;
|
||||
glyphArray.bfind (glyph_id, &i, HB_NOT_FOUND_STORE, NOT_COVERED);
|
||||
cache.set ((glyph_id + (uintptr_t) this) & 0xFFFF, i);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "RangeRecord.hh"
|
||||
|
||||
#include "../../../hb-cache.hh"
|
||||
|
||||
namespace OT {
|
||||
namespace Layout {
|
||||
namespace Common {
|
||||
|
@ -59,7 +61,18 @@ struct CoverageFormat2_4
|
|||
|
||||
unsigned int get_coverage (hb_codepoint_t glyph_id) const
|
||||
{
|
||||
static hb_cache_t<16, 8, 9, true> cache;
|
||||
|
||||
unsigned v;
|
||||
if (cache.get ((glyph_id + (uintptr_t) this) & 0xFFFF, &v))
|
||||
{
|
||||
const RangeRecord<Types> &range = rangeRecord[v];
|
||||
if (range.first <= glyph_id && glyph_id <= range.last)
|
||||
return (unsigned int) range.value + (glyph_id - range.first);
|
||||
}
|
||||
|
||||
const RangeRecord<Types> &range = rangeRecord.bsearch (glyph_id);
|
||||
cache.set ((glyph_id + (uintptr_t) this) & 0xFFFF, &range - &rangeRecord[0]);
|
||||
return likely (range.first <= range.last)
|
||||
? (unsigned int) range.value + (glyph_id - range.first)
|
||||
: NOT_COVERED;
|
||||
|
|
Loading…
Reference in New Issue