mirror of https://github.com/AxioDL/metaforce.git
CTextRenderBuffer: Forward declare structs where applicable
These are only used internally, so we can completely hide these structs from external view. This allows their implementation to be changed without needing to recompile all the headers that include it.
This commit is contained in:
parent
fda08db9b1
commit
20b74c4818
|
@ -12,31 +12,60 @@
|
|||
|
||||
namespace urde {
|
||||
|
||||
struct CTextRenderBuffer::BooFontCharacters {
|
||||
TLockedToken<CRasterFont> m_font;
|
||||
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance>::Token m_instBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBinding;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBinding2;
|
||||
std::vector<CTextSupportShader::CharacterInstance> m_charData;
|
||||
u32 m_charCount = 0;
|
||||
bool m_dirty = true;
|
||||
|
||||
BooFontCharacters(const CToken& token) : m_font(token) {}
|
||||
};
|
||||
|
||||
struct CTextRenderBuffer::BooImage {
|
||||
CFontImageDef m_imageDef;
|
||||
hecl::VertexBufferPool<CTextSupportShader::ImageInstance>::Token m_instBuf;
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding;
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding2;
|
||||
CTextSupportShader::ImageInstance m_imageData;
|
||||
bool m_dirty = true;
|
||||
|
||||
BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset) : m_imageDef(imgDef) {
|
||||
m_imageData.SetMetrics(imgDef, offset);
|
||||
}
|
||||
};
|
||||
|
||||
struct CTextRenderBuffer::BooPrimitiveMark {
|
||||
Command m_cmd;
|
||||
u32 m_bindIdx;
|
||||
u32 m_instIdx;
|
||||
|
||||
void SetOpacity(CTextRenderBuffer& rb, float opacity) {
|
||||
switch (m_cmd) {
|
||||
case Command::CharacterRender: {
|
||||
BooFontCharacters& fc = rb.m_fontCharacters[m_bindIdx];
|
||||
CTextSupportShader::CharacterInstance& inst = fc.m_charData[m_instIdx];
|
||||
inst.m_mulColor.a() = opacity;
|
||||
fc.m_dirty = true;
|
||||
break;
|
||||
}
|
||||
case Command::ImageRender: {
|
||||
BooImage& img = rb.m_images[m_bindIdx];
|
||||
img.m_imageData.m_color.a() = opacity;
|
||||
img.m_dirty = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CTextRenderBuffer::CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df) : x0_mode(mode), m_drawFlags(df) {}
|
||||
|
||||
CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset) : m_imageDef(imgDef) {
|
||||
m_imageData.SetMetrics(imgDef, offset);
|
||||
}
|
||||
|
||||
void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, float opacity) {
|
||||
switch (m_cmd) {
|
||||
case Command::CharacterRender: {
|
||||
BooFontCharacters& fc = rb.m_fontCharacters[m_bindIdx];
|
||||
CTextSupportShader::CharacterInstance& inst = fc.m_charData[m_instIdx];
|
||||
inst.m_mulColor.a() = opacity;
|
||||
fc.m_dirty = true;
|
||||
break;
|
||||
}
|
||||
case Command::ImageRender: {
|
||||
BooImage& img = rb.m_images[m_bindIdx];
|
||||
img.m_imageData.m_color.a() = opacity;
|
||||
img.m_dirty = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
CTextRenderBuffer::~CTextRenderBuffer() = default;
|
||||
|
||||
void CTextRenderBuffer::CommitResources() {
|
||||
if (m_committed)
|
||||
|
@ -125,6 +154,8 @@ void CTextRenderBuffer::SetPrimitiveOpacity(int idx, float opacity) {
|
|||
m_primitiveMarks[idx].SetOpacity(*this, opacity);
|
||||
}
|
||||
|
||||
u32 CTextRenderBuffer::GetPrimitiveCount() const { return m_primitiveMarks.size(); }
|
||||
|
||||
void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const {
|
||||
const_cast<CTextRenderBuffer*>(this)->CommitResources();
|
||||
|
||||
|
|
|
@ -65,35 +65,13 @@ private:
|
|||
hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf;
|
||||
hecl::UniformBufferPool<CTextSupportShader::Uniform>::Token m_uniBuf2;
|
||||
|
||||
struct BooFontCharacters {
|
||||
TLockedToken<CRasterFont> m_font;
|
||||
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance>::Token m_instBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBinding;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBinding2;
|
||||
std::vector<CTextSupportShader::CharacterInstance> m_charData;
|
||||
u32 m_charCount = 0;
|
||||
bool m_dirty = true;
|
||||
BooFontCharacters(const CToken& token) : m_font(token) {}
|
||||
};
|
||||
struct BooFontCharacters;
|
||||
std::vector<BooFontCharacters> m_fontCharacters;
|
||||
|
||||
struct BooImage {
|
||||
CFontImageDef m_imageDef;
|
||||
hecl::VertexBufferPool<CTextSupportShader::ImageInstance>::Token m_instBuf;
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding;
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>> m_dataBinding2;
|
||||
CTextSupportShader::ImageInstance m_imageData;
|
||||
bool m_dirty = true;
|
||||
BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
|
||||
};
|
||||
struct BooImage;
|
||||
std::vector<BooImage> m_images;
|
||||
|
||||
struct BooPrimitiveMark {
|
||||
Command m_cmd;
|
||||
u32 m_bindIdx;
|
||||
u32 m_instIdx;
|
||||
void SetOpacity(CTextRenderBuffer& rb, float opacity);
|
||||
};
|
||||
struct BooPrimitiveMark;
|
||||
std::vector<BooPrimitiveMark> m_primitiveMarks;
|
||||
u32 m_imagesCount = 0;
|
||||
u32 m_activeFontCh = UINT32_MAX;
|
||||
|
@ -109,6 +87,8 @@ private:
|
|||
|
||||
public:
|
||||
CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df);
|
||||
~CTextRenderBuffer();
|
||||
|
||||
#if 0
|
||||
void SetPrimitive(const Primitive&, int);
|
||||
Primitive GetPrimitive(int) const;
|
||||
|
@ -119,7 +99,7 @@ public:
|
|||
void AddPaletteChange(const CGraphicsPalette& palette);
|
||||
#else
|
||||
void SetPrimitiveOpacity(int idx, float opacity);
|
||||
u32 GetPrimitiveCount() const { return m_primitiveMarks.size(); }
|
||||
u32 GetPrimitiveCount() const;
|
||||
#endif
|
||||
void SetMode(EMode mode);
|
||||
void Render(const zeus::CColor& col, float) const;
|
||||
|
|
Loading…
Reference in New Issue