From 16745f3a7b17c483a03900eb527b844603ae5473 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 29 Mar 2020 16:35:02 -0700 Subject: [PATCH] Revert "CTextRenderBuffer: Forward declare structs where applicable" --- Runtime/GuiSys/CTextRenderBuffer.cpp | 77 +++++++++------------------- Runtime/GuiSys/CTextRenderBuffer.hpp | 32 +++++++++--- 2 files changed, 49 insertions(+), 60 deletions(-) diff --git a/Runtime/GuiSys/CTextRenderBuffer.cpp b/Runtime/GuiSys/CTextRenderBuffer.cpp index ffebd3aa8..2888b5867 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.cpp +++ b/Runtime/GuiSys/CTextRenderBuffer.cpp @@ -12,60 +12,31 @@ namespace urde { -struct CTextRenderBuffer::BooFontCharacters { - TLockedToken m_font; - hecl::VertexBufferPool::Token m_instBuf; - boo::ObjToken m_dataBinding; - boo::ObjToken m_dataBinding2; - std::vector 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::Token m_instBuf; - std::vector> m_dataBinding; - std::vector> 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::~CTextRenderBuffer() = default; +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; + } +} void CTextRenderBuffer::CommitResources() { if (m_committed) @@ -154,8 +125,6 @@ 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(this)->CommitResources(); diff --git a/Runtime/GuiSys/CTextRenderBuffer.hpp b/Runtime/GuiSys/CTextRenderBuffer.hpp index 947bccef3..b3ad6806b 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.hpp +++ b/Runtime/GuiSys/CTextRenderBuffer.hpp @@ -65,13 +65,35 @@ private: hecl::UniformBufferPool::Token m_uniBuf; hecl::UniformBufferPool::Token m_uniBuf2; - struct BooFontCharacters; + struct BooFontCharacters { + TLockedToken m_font; + hecl::VertexBufferPool::Token m_instBuf; + boo::ObjToken m_dataBinding; + boo::ObjToken m_dataBinding2; + std::vector m_charData; + u32 m_charCount = 0; + bool m_dirty = true; + BooFontCharacters(const CToken& token) : m_font(token) {} + }; std::vector m_fontCharacters; - struct BooImage; + struct BooImage { + CFontImageDef m_imageDef; + hecl::VertexBufferPool::Token m_instBuf; + std::vector> m_dataBinding; + std::vector> m_dataBinding2; + CTextSupportShader::ImageInstance m_imageData; + bool m_dirty = true; + BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset); + }; std::vector m_images; - struct BooPrimitiveMark; + struct BooPrimitiveMark { + Command m_cmd; + u32 m_bindIdx; + u32 m_instIdx; + void SetOpacity(CTextRenderBuffer& rb, float opacity); + }; std::vector m_primitiveMarks; u32 m_imagesCount = 0; u32 m_activeFontCh = UINT32_MAX; @@ -87,8 +109,6 @@ private: public: CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df); - ~CTextRenderBuffer(); - #if 0 void SetPrimitive(const Primitive&, int); Primitive GetPrimitive(int) const; @@ -99,7 +119,7 @@ public: void AddPaletteChange(const CGraphicsPalette& palette); #else void SetPrimitiveOpacity(int idx, float opacity); - u32 GetPrimitiveCount() const; + u32 GetPrimitiveCount() const { return m_primitiveMarks.size(); } #endif void SetMode(EMode mode); void Render(const zeus::CColor& col, float) const;