mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(gx): fully implement TEXTLINETEXTURE::NewTextLineTexture and TEXTLINETEXTURE::Recycle
This commit is contained in:
parent
84b16f2aeb
commit
32b5d6402b
@ -12,20 +12,37 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
TEXTLINETEXTURE* TEXTLINETEXTURE::NewTextLineTexture() {
|
STORM_LIST(TEXTLINETEXTURE) TEXTLINETEXTURE::s_freeTextLineTextures;
|
||||||
// TODO
|
uint32_t TEXTLINETEXTURE::s_recycledBytes;
|
||||||
// Allocate off of TEXTLINETEXTURE::s_freeTextLineTextures
|
|
||||||
|
|
||||||
auto m = SMemAlloc(sizeof(TEXTLINETEXTURE), __FILE__, __LINE__, 0x0);
|
TEXTLINETEXTURE* TEXTLINETEXTURE::NewTextLineTexture() {
|
||||||
return new (m) TEXTLINETEXTURE();
|
auto line = TEXTLINETEXTURE::s_freeTextLineTextures.Head();
|
||||||
|
|
||||||
|
if (!line) {
|
||||||
|
return STORM_NEW(TEXTLINETEXTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Likely TSBaseArray::Bytes()
|
||||||
|
TEXTLINETEXTURE::s_recycledBytes -= (sizeof(VERT) * line->m_vert.m_alloc) + (sizeof(CImVector) * line->m_colors.m_alloc);
|
||||||
|
|
||||||
|
line->Unlink();
|
||||||
|
|
||||||
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEXTLINETEXTURE::Recycle(TEXTLINETEXTURE* ptr) {
|
void TEXTLINETEXTURE::Recycle(TEXTLINETEXTURE* line) {
|
||||||
// TODO if (TEXTLINETEXTURE::s_recycledBytes <= 0x80000)
|
if (TEXTLINETEXTURE::s_recycledBytes > 0x80000) {
|
||||||
|
delete line;
|
||||||
if (ptr) {
|
return;
|
||||||
delete ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line->m_vert.SetCount(0);
|
||||||
|
line->m_colors.SetCount(0);
|
||||||
|
|
||||||
|
// TODO Likely TSBaseArray::Bytes()
|
||||||
|
TEXTLINETEXTURE::s_recycledBytes += (sizeof(VERT) * line->m_vert.m_alloc) + (sizeof(CImVector) * line->m_colors.m_alloc);
|
||||||
|
|
||||||
|
TEXTLINETEXTURE::s_freeTextLineTextures.LinkToTail(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEXTLINETEXTURE::WriteGeometry(CGxVertexPCT* buffer, const CImVector& fontColor, const C2Vector& shadowOffset, const CImVector& shadowColor, const C3Vector& viewTranslation, bool hasShadow, bool a8, int32_t vertexOffset, int32_t vertexCount) {
|
void TEXTLINETEXTURE::WriteGeometry(CGxVertexPCT* buffer, const CImVector& fontColor, const C2Vector& shadowOffset, const CImVector& shadowColor, const C3Vector& viewTranslation, bool hasShadow, bool a8, int32_t vertexOffset, int32_t vertexCount) {
|
||||||
|
|||||||
@ -16,8 +16,12 @@ struct VERT {
|
|||||||
C2Vector tc;
|
C2Vector tc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TEXTLINETEXTURE {
|
class TEXTLINETEXTURE : public TSLinkedNode<TEXTLINETEXTURE> {
|
||||||
public:
|
public:
|
||||||
|
// Static variables
|
||||||
|
static STORM_LIST(TEXTLINETEXTURE) s_freeTextLineTextures;
|
||||||
|
static uint32_t s_recycledBytes;
|
||||||
|
|
||||||
// Static functions
|
// Static functions
|
||||||
static TEXTLINETEXTURE* NewTextLineTexture();
|
static TEXTLINETEXTURE* NewTextLineTexture();
|
||||||
static void Recycle(TEXTLINETEXTURE* ptr);
|
static void Recycle(TEXTLINETEXTURE* ptr);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user