isle-portable/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp
Christian Semmler a3122cd209
Some checks are pending
CI / clang-format (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain /usr/local/vitasdk/share/vita.toolchain.cmake, false, false, Ninja, Vita, ubuntu-latest, true, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0, false, false, Visual Studio 17 2022, true, Xbox One, windows-latest, amd64, false, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake, false, devkitpro/devkitarm:latest, false, Ninja, true, Nintendo 3DS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake, false, devkitpro/devkita64:latest, false, Ninja, Nintendo Switch, true, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, emcmake, false, false, true, Ninja, Emscripten, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, false, Ninja, true, MSVC (arm64), windows-latest, amd64_arm64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, true, Ninja, true, MSVC (x86), windows-latest, amd64_x86, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, false, Ninja, true, MSVC (x64), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, true, false, Ninja, true, MSVC (x64 Debug), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, -DCMAKE_SYSTEM_NAME=iOS, false, false, Xcode, true, iOS, macos-15, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, Ninja, true, mingw-w64-i686, mingw32, msys2 mingw32, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, false, Ninja, Android, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, true, false, Ninja, macOS, macos-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, false, Ninja, true, mingw-w64-x86_64, mingw64, msys2 mingw64, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux (Debug), ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux, ubuntu-latest, true) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (aarch64, ubuntu-22.04-arm) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (x86_64, ubuntu-latest) (push) Waiting to run
CI / C++ (push) Waiting to run
CI / Release (push) Blocked by required conditions
Docker / Publish web port (push) Waiting to run
Merge remote-tracking branch 'isle/master'
2026-01-30 17:06:10 -08:00

151 lines
3.4 KiB
C++

#include "legotexturepresenter.h"
#include "legovideomanager.h"
#include "misc.h"
#include "misc/legocontainer.h"
#include "misc/legoimage.h"
#include "misc/legostorage.h"
#include "mxcompositepresenter.h"
#include "mxdirectx/mxdirect3d.h"
#include "mxdssubscriber.h"
#include <SDL3/SDL_stdinc.h>
DECOMP_SIZE_ASSERT(LegoTexturePresenter, 0x54)
DECOMP_SIZE_ASSERT(LegoNamedTexture, 0x14)
DECOMP_SIZE_ASSERT(LegoNamedTextureList, 0x18)
DECOMP_SIZE_ASSERT(LegoNamedTextureListCursor, 0x10)
// FUNCTION: LEGO1 0x1004eb40
LegoTexturePresenter::~LegoTexturePresenter()
{
VideoManager()->UnregisterPresenter(*this);
}
// FUNCTION: LEGO1 0x1004ebb0
MxResult LegoTexturePresenter::AddToManager()
{
VideoManager()->RegisterPresenter(*this);
return SUCCESS;
}
// FUNCTION: LEGO1 0x1004ebd0
MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk)
{
MxResult result = FAILURE;
LegoMemory storage(p_chunk.GetData(), p_chunk.GetLength());
LegoChar* textureName = NULL;
LegoS32 hardwareMode = VideoManager()->GetDirect3D()->AssignedDevice()->GetHardwareMode();
m_textures = new LegoNamedTextureList();
LegoU32 numTextures, i;
if (storage.Read(&numTextures, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
for (i = 0; i < numTextures; i++) {
LegoU32 textureNameLength;
LegoTexture* texture;
LegoNamedTexture* namedTexture;
if (storage.Read(&textureNameLength, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
textureName = new LegoChar[textureNameLength + 1];
if (storage.Read(textureName, textureNameLength) != SUCCESS) {
goto done;
}
textureName[textureNameLength] = '\0';
SDL_strlwr(textureName);
texture = new LegoTexture();
if (texture->Read(&storage, hardwareMode) != SUCCESS) {
goto done;
}
namedTexture = new LegoNamedTexture(textureName, texture);
m_textures->Append(namedTexture);
delete[] textureName;
textureName = NULL;
}
result = SUCCESS;
done:
if (textureName != NULL) {
delete[] textureName;
}
if (result != SUCCESS && m_textures != NULL) {
delete m_textures;
m_textures = NULL;
}
return result;
}
// FUNCTION: LEGO1 0x1004f290
MxResult LegoTexturePresenter::Store()
{
LegoNamedTextureListCursor cursor(m_textures);
LegoNamedTexture* namedTexture;
VideoManager();
while (cursor.Next(namedTexture)) {
LegoTexture* texture = namedTexture->GetTexture();
LegoTextureInfo* textureInfo = TextureContainer()->Get(namedTexture->GetName()->GetData());
if (textureInfo == NULL) {
textureInfo = LegoTextureInfo::Create(namedTexture->GetName()->GetData(), texture);
if (textureInfo != NULL) {
TextureContainer()->Add(namedTexture->GetName()->GetData(), textureInfo);
}
}
else {
textureInfo->LoadBits(texture->GetImage()->GetBits());
}
}
if (m_textures != NULL) {
delete m_textures;
}
m_textures = NULL;
return SUCCESS;
}
// FUNCTION: LEGO1 0x1004fc60
MxResult LegoTexturePresenter::PutData()
{
MxResult result = SUCCESS;
if (MxPresenter::IsEnabled() && m_currentChunk != NULL) {
result = Read(*m_currentChunk);
if (result == SUCCESS) {
Store();
}
if (m_currentTickleState == e_streaming) {
m_subscriber->FreeDataChunk(m_currentChunk);
}
m_currentChunk = NULL;
}
return result;
}
// FUNCTION: LEGO1 0x1004fcb0
void LegoTexturePresenter::DoneTickle()
{
if (this->m_compositePresenter && !this->m_compositePresenter->GetActionEnded(2)) {
SetTickleState(e_idle);
return;
}
MxMediaPresenter::DoneTickle();
}