port(EterLib): TextBar/DibBar/BlockTexture for uiTip TipBoard/BigBoard
TextBar and DibBar verbatim over the FreeType GDI shim (+GetTextExtentPoint32A); BlockTexture verbatim except Render, which records the clipped quad as a UI image of the device CPU texture (UIRenderAddImageNamed). Notices now render; port.text_bar covers block split, pixels, colour, ClearBar and TipBoard clip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c7bcb9bbbe
commit
6d2d262de8
+156
-54
@@ -1,64 +1,166 @@
|
||||
// Platform skeleton for EterLib/DibBar.h (40250 EterLib/DibBar.cpp), generated by platform_stub.py.
|
||||
// Every MT_PLATFORM_STUB() body is unimplemented: replace it with the platform implementation.
|
||||
// 40250 EterLib/DibBar.cpp, verbatim (RECT initialisers cast to LONG).
|
||||
#include "EterLib/StdAfx.h"
|
||||
#include "EterLib/DibBar.h"
|
||||
#include "EterLib/BlockTexture.h"
|
||||
|
||||
#include "../PlatformStub.h"
|
||||
void CDibBar::Invalidate()
|
||||
{
|
||||
// PORT: RECT holds the 32-bit Win32 LONG, so static_cast<long> would narrow here.
|
||||
RECT rect = { static_cast<LONG>(0), static_cast<LONG>(0), static_cast<LONG>(m_dwWidth), static_cast<LONG>(m_dwHeight)};
|
||||
|
||||
std::vector<CBlockTexture *>::iterator itor = m_kVec_pkBlockTexture.begin();
|
||||
for (; itor != m_kVec_pkBlockTexture.end(); ++itor)
|
||||
{
|
||||
CBlockTexture * pTexture = *itor;
|
||||
pTexture->InvalidateRect(rect);
|
||||
}
|
||||
}
|
||||
|
||||
void CDibBar::SetClipRect(const RECT & c_rRect)
|
||||
{
|
||||
std::vector<CBlockTexture *>::iterator itor = m_kVec_pkBlockTexture.begin();
|
||||
for (; itor != m_kVec_pkBlockTexture.end(); ++itor)
|
||||
{
|
||||
CBlockTexture * pTexture = *itor;
|
||||
assert(pTexture);
|
||||
if (!pTexture)
|
||||
continue;
|
||||
pTexture->SetClipRect(c_rRect);
|
||||
}
|
||||
}
|
||||
|
||||
void CDibBar::ClearBar()
|
||||
{
|
||||
DWORD * pdwBuf = (DWORD *)m_dib.GetPointer();
|
||||
memset(pdwBuf, 0, m_dib.GetWidth()*m_dib.GetHeight()*4);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void CDibBar::Render(int ix, int iy)
|
||||
{
|
||||
std::vector<CBlockTexture *>::iterator itor = m_kVec_pkBlockTexture.begin();
|
||||
for (; itor != m_kVec_pkBlockTexture.end(); ++itor)
|
||||
{
|
||||
CBlockTexture * pTexture = *itor;
|
||||
pTexture->Render(ix, iy);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CDibBar::__NearTextureSize(DWORD dwSize)
|
||||
{
|
||||
if ((dwSize & (dwSize-1)) == 0)
|
||||
return dwSize;
|
||||
|
||||
DWORD dwRet = 2;
|
||||
while (dwRet < dwSize)
|
||||
{
|
||||
dwRet <<= 1;
|
||||
}
|
||||
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
void CDibBar::__DivideTextureSize(DWORD dwSize, DWORD dwMax, DWORD * pdwxStep, DWORD * pdwxCount, DWORD * pdwxRest)
|
||||
{
|
||||
if (dwSize<dwMax)
|
||||
{
|
||||
*pdwxStep = dwMax;
|
||||
*pdwxCount = 0;
|
||||
*pdwxRest = dwSize%dwMax;
|
||||
return;
|
||||
}
|
||||
|
||||
*pdwxStep = dwMax;
|
||||
*pdwxCount = dwSize/dwMax;
|
||||
*pdwxRest = dwSize%dwMax;
|
||||
}
|
||||
|
||||
CBlockTexture * CDibBar::__BuildTextureBlock(DWORD dwxPos, DWORD dwyPos, DWORD dwImageWidth, DWORD dwImageHeight, DWORD dwTextureWidth, DWORD dwTextureHeight)
|
||||
{
|
||||
if (dwTextureWidth == 0 || dwTextureHeight == 0)
|
||||
return NULL;
|
||||
|
||||
// PORT: RECT holds the 32-bit Win32 LONG, so static_cast<long> would narrow here.
|
||||
RECT posRect = { static_cast<LONG>(dwxPos), static_cast<LONG>(dwyPos), static_cast<LONG>(dwxPos+dwImageWidth), static_cast<LONG>(dwyPos+dwImageHeight)};
|
||||
|
||||
CBlockTexture * pBlockTexture = new CBlockTexture;
|
||||
if (!pBlockTexture->Create(&m_dib, posRect, dwTextureWidth, dwTextureHeight))
|
||||
{
|
||||
delete pBlockTexture;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pBlockTexture;
|
||||
}
|
||||
|
||||
void CDibBar::__BuildTextureBlockList(DWORD dwWidth, DWORD dwHeight, DWORD dwMax)
|
||||
{
|
||||
DWORD dwxStep, dwyStep;
|
||||
DWORD dwxCount, dwyCount;
|
||||
DWORD dwxRest, dwyRest;
|
||||
__DivideTextureSize(dwWidth, dwMax, &dwxStep, &dwxCount, &dwxRest);
|
||||
__DivideTextureSize(dwHeight, dwMax, &dwyStep, &dwyCount, &dwyRest);
|
||||
DWORD dwxTexRest = __NearTextureSize(dwxRest);
|
||||
DWORD dwyTexRest = __NearTextureSize(dwyRest);
|
||||
|
||||
for (DWORD y = 0; y < dwyCount; ++y)
|
||||
{
|
||||
for (DWORD x = 0; x < dwxCount; ++x)
|
||||
{
|
||||
CBlockTexture * pTexture = __BuildTextureBlock(x*dwxStep, y*dwyStep,
|
||||
dwxStep, dwyStep,
|
||||
dwMax, dwMax);
|
||||
if (pTexture)
|
||||
m_kVec_pkBlockTexture.push_back(pTexture);
|
||||
}
|
||||
|
||||
CBlockTexture * pTexture = __BuildTextureBlock(dwxCount*dwxStep, y*dwyStep,
|
||||
dwxRest, dwyStep,
|
||||
dwxTexRest, dwMax);
|
||||
|
||||
if (pTexture)
|
||||
m_kVec_pkBlockTexture.push_back(pTexture);
|
||||
}
|
||||
|
||||
for (DWORD x = 0; x < dwxCount; ++x)
|
||||
{
|
||||
CBlockTexture * pTexture = __BuildTextureBlock(x*dwxStep, dwyCount*dwyStep,
|
||||
dwxStep, dwyRest,
|
||||
dwMax, dwyTexRest);
|
||||
if (pTexture)
|
||||
m_kVec_pkBlockTexture.push_back(pTexture);
|
||||
}
|
||||
|
||||
if (dwxRest > 0 && dwyRest > 0)
|
||||
{
|
||||
CBlockTexture * pTexture = __BuildTextureBlock(dwxCount*dwxStep, dwyCount*dwyStep,
|
||||
dwxRest, dwyRest,
|
||||
dwxTexRest, dwyTexRest);
|
||||
if (pTexture)
|
||||
m_kVec_pkBlockTexture.push_back(pTexture);
|
||||
}
|
||||
}
|
||||
|
||||
bool CDibBar::Create(HDC hdc, DWORD dwWidth, DWORD dwHeight)
|
||||
{
|
||||
if (!m_dib.Create(hdc, dwWidth, dwHeight))
|
||||
{
|
||||
Tracef(" Failed to create CDibBar\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dwWidth = dwWidth;
|
||||
m_dwHeight = dwHeight;
|
||||
|
||||
__BuildTextureBlockList(dwWidth, dwHeight);
|
||||
OnCreate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CDibBar::CDibBar()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
CDibBar::~CDibBar()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CDibBar::Create(HDC, DWORD, DWORD) -> bool
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<bool>();
|
||||
}
|
||||
|
||||
auto CDibBar::Invalidate() -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CDibBar::SetClipRect(const RECT &) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CDibBar::ClearBar() -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CDibBar::Render(int, int) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CDibBar::__NearTextureSize(DWORD) -> DWORD
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<DWORD>();
|
||||
}
|
||||
|
||||
auto CDibBar::__DivideTextureSize(DWORD, DWORD, DWORD *, DWORD *, DWORD *) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CDibBar::__BuildTextureBlock(DWORD, DWORD, DWORD, DWORD, DWORD, DWORD) -> CBlockTexture *
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<CBlockTexture *>();
|
||||
}
|
||||
|
||||
auto CDibBar::__BuildTextureBlockList(DWORD, DWORD, DWORD) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user