--------------------------------------------------------------------
| 83 | |
| 84 | //-------------------------------------------------------------------- |
| 85 | glyph_cache* cache_glyph(unsigned glyph_code, |
| 86 | unsigned glyph_index, |
| 87 | unsigned data_size, |
| 88 | glyph_data_type data_type, |
| 89 | const rect_i& bounds, |
| 90 | double advance_x, |
| 91 | double advance_y) |
| 92 | { |
| 93 | unsigned msb = (glyph_code >> 8) & 0xFF; |
| 94 | if (m_glyphs[msb] == 0) |
| 95 | { |
| 96 | m_glyphs[msb] = (glyph_cache**)m_allocator.allocate( |
| 97 | sizeof(glyph_cache*) * 256, sizeof(glyph_cache*)); |
| 98 | std::memset(m_glyphs[msb], 0, sizeof(glyph_cache*) * 256); |
| 99 | } |
| 100 | |
| 101 | unsigned lsb = glyph_code & 0xFF; |
| 102 | if (m_glyphs[msb][lsb]) |
| 103 | return 0; // Already exists, do not overwrite |
| 104 | |
| 105 | glyph_cache* glyph = (glyph_cache*)m_allocator.allocate( |
| 106 | sizeof(glyph_cache), sizeof(double)); |
| 107 | |
| 108 | glyph->glyph_index = glyph_index; |
| 109 | glyph->data = m_allocator.allocate(data_size); |
| 110 | glyph->data_size = data_size; |
| 111 | glyph->data_type = data_type; |
| 112 | glyph->bounds = bounds; |
| 113 | glyph->advance_x = advance_x; |
| 114 | glyph->advance_y = advance_y; |
| 115 | return m_glyphs[msb][lsb] = glyph; |
| 116 | } |
| 117 | |
| 118 | private: |
| 119 | block_allocator m_allocator; |
no test coverage detected