ULRE/inc/hgl/graph/font/TextRender.h

89 lines
2.4 KiB
C
Raw Normal View History

2022-02-17 10:48:12 +08:00
#ifndef HGL_GRAPH_TEXT_RENDER_INCLUDE
2022-02-16 23:26:50 +08:00
#define HGL_GRAPH_TEXT_RENDER_INCLUDE
#include<hgl/graph/VK.h>
#include<hgl/type/Color4f.h>
namespace hgl
{
namespace graph
{
class FontSource;
class TileFont;
class TextLayout;
2022-06-24 17:51:05 +08:00
class TextPrimitive;
2022-02-16 23:26:50 +08:00
class TextRender
{
2022-02-17 11:02:55 +08:00
GPUDevice * device;
RenderResource * db;
2022-02-16 23:26:50 +08:00
2022-02-17 11:02:55 +08:00
Material * material;
MaterialInstance * material_instance;
2022-02-16 23:26:50 +08:00
2022-02-17 11:02:55 +08:00
Sampler * sampler;
2022-02-16 23:26:50 +08:00
2022-02-17 11:02:55 +08:00
Pipeline * pipeline;
2022-02-16 23:26:50 +08:00
2022-02-17 11:02:55 +08:00
FontSource * font_source;
2022-02-16 23:26:50 +08:00
2022-02-17 11:02:55 +08:00
TileFont * tile_font;
TextLayout * tl_engine;
2022-02-16 23:26:50 +08:00
Color4f color;
2022-02-17 11:02:55 +08:00
GPUBuffer * ubo_color;
2022-02-16 23:26:50 +08:00
2022-06-24 17:51:05 +08:00
SortedSets<TextPrimitive *> tr_sets;
2022-02-21 17:13:12 +08:00
2022-02-16 23:26:50 +08:00
private:
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,GPUBuffer *,int limit=-1);
2022-02-17 10:48:12 +08:00
TextRender(GPUDevice *dev,FontSource *);
2022-02-16 23:26:50 +08:00
bool InitTileFont(int limit);
2022-02-16 23:26:50 +08:00
bool InitTextLayoutEngine();
bool InitUBO();
bool InitMaterial(RenderPass *,GPUBuffer *);
public:
2022-02-17 10:48:12 +08:00
~TextRender();
bool Init(RenderPass *rp,GPUBuffer *ubo_camera_info,int limit);
2022-02-16 23:26:50 +08:00
2022-02-17 10:48:12 +08:00
public:
2022-06-24 17:51:05 +08:00
TextPrimitive *CreatePrimitive();
TextPrimitive *CreatePrimitive(const UTF16String &str);
2022-02-17 20:02:59 +08:00
2022-06-24 17:51:05 +08:00
bool Layout(TextPrimitive *tr,const UTF16String &str);
2022-02-17 20:02:59 +08:00
Renderable *CreateRenderable(TextPrimitive *text_render_obj);
2022-02-21 17:13:12 +08:00
2022-06-24 17:51:05 +08:00
void Release(TextPrimitive *);
2022-02-16 23:26:50 +08:00
};//class TextRender
2022-02-17 10:48:12 +08:00
/**
* CJK字体源
* @param cf CJK字体名称
* @param lf
* @param size
*/
FontSource *CreateCJKFontSource(const os_char *cf,const os_char *lf,const uint32_t size);
/**
*
* @param name
* @param size
*/
2022-02-17 20:02:59 +08:00
FontSource *AcquireFontSource(const os_char *name,const uint32_t size);
2022-02-17 10:48:12 +08:00
/**
*
* @param limit (-1)
2022-02-17 10:48:12 +08:00
*/
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,GPUBuffer *,int limit);
2022-02-16 23:26:50 +08:00
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_TEXT_RENDER_INCLUDE