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