Codechange: Move spritelayout preprocessing to a separate class, which owns the heap allocations involved.

This commit is contained in:
frosch
2025-05-05 18:36:44 +02:00
committed by frosch
parent d9c43e7fda
commit 8bbfbd0347
11 changed files with 90 additions and 68 deletions

View File

@@ -287,19 +287,19 @@ static bool RangeHighComparator(const DeterministicSpriteGroupRange &range, uint
* @param[in,out] stage Construction stage (0-3), or nullptr if not applicable.
* @return sprite layout to draw.
*/
DrawTileSpriteSpan TileLayoutSpriteGroup::ProcessRegisters(uint8_t *stage) const
SpriteLayoutProcessor TileLayoutSpriteGroup::ProcessRegisters(uint8_t *stage) const
{
if (!this->dts.NeedsPreprocessing()) {
if (stage != nullptr && this->dts.consistent_max_offset > 0) *stage = GetConstructionStageOffset(*stage, this->dts.consistent_max_offset);
return {this->dts.ground, this->dts.seq};
return SpriteLayoutProcessor(this->dts);
}
uint8_t actual_stage = stage != nullptr ? *stage : 0;
this->dts.PrepareLayout(0, 0, 0, actual_stage, false);
this->dts.ProcessRegisters(0, 0, false);
SpriteLayoutProcessor result(this->dts, 0, 0, 0, actual_stage, false);
result.ProcessRegisters(0, 0);
/* Stage has been processed by PrepareLayout(), set it to zero. */
if (stage != nullptr) *stage = 0;
return this->dts.GetLayout();
return result;
}