You.i Engine
YiAbstractTextAtlas.h
Go to the documentation of this file.
1 // © You i Labs Inc. All rights reserved.
2 #ifndef _YI_ABSTRACT_TEXT_ATLAS_H_
3 #define _YI_ABSTRACT_TEXT_ATLAS_H_
4 
6 
16 {
18 
19  int32_t fontSize;
20 
21  uint32_t glyphID;
22 
23  size_t textureIndex;
24 };
25 
30 {
31 public:
35  struct GlyphData
36  {
37  GlyphData();
38 
39  const uint8_t *pData;
40  int32_t stride;
42  };
43 
45  virtual ~CYIAbstractTextAtlas();
46 
51  virtual bool CreateNewFontAtlas(uint32_t width, uint32_t height) = 0;
52 
63  virtual void SetRegion(ssize_t id, void *pReference, YI_REGION region, const uint8_t *pData, const int32_t stride) override final;
64 
74  virtual void SetRegion(ssize_t id, void *pReference, YI_REGION region, GlyphData glyphData) = 0;
75 
79  virtual YI_TEXTURE_DETAILS *GetTexture(ssize_t id, void *pReference) override;
80 
85  int32_t GetGlyphPadding() const;
86 
90  bool AddGlyph(const uint32_t glyphWidth, const uint32_t glyphHeight, YI_GLYPH_DETAILS *pGlyphDetails, GlyphData glyphData);
91 
92 protected:
96  void SetGlyphPadding(int32_t glyphPadding);
97 
98  /*
99  \details This function is called in GetTexture to determine whether the requested glyph matches
100  a glyph which already exists in the atlas. Implementations should use this to compare whether the
101  requested glyph matches the existing candidate glyph based on their own criteria.
102 
103  The default implementation compares font size, glyph ID, and font ID.
104  */
105  virtual bool CompareGlyphDetails(YI_GLYPH_DETAILS *pLeft, YI_GLYPH_DETAILS *pRight) const;
106 
107 private:
108  int32_t m_glyphPadding;
109 };
110 
113 #endif
ssize_t fontID
Definition: YiAbstractTextAtlas.h:17
Class for a texture atlas.
Definition: YiTextureAtlas.h:53
Definition: YiAbstractTextAtlas.h:15
long long ssize_t
Definition: YiPredefWindows.h:21
Definition: YiAbstractTextAtlas.h:35
Definition: YiTextureAtlas.h:42
uint32_t glyphID
Definition: YiAbstractTextAtlas.h:21
const uint8_t * pData
Definition: YiAbstractTextAtlas.h:39
Abstract class for a text atlas.
Definition: YiAbstractTextAtlas.h:29
bool isPreprocessed
Definition: YiAbstractTextAtlas.h:41
int32_t stride
Definition: YiAbstractTextAtlas.h:40
int32_t fontSize
Definition: YiAbstractTextAtlas.h:19
Definition: YiTextureAtlas.h:20
size_t textureIndex
Definition: YiAbstractTextAtlas.h:23