1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2025-11-05 10:40:17 +01:00

gdrv: blit no more, present render:vScreen directly.

Improved split bitmap handling.
This commit is contained in:
Muzychenko Andrey 2021-09-25 16:52:19 +03:00
parent 625a6e7498
commit 22ce8ac538
16 changed files with 290 additions and 467 deletions

View file

@ -18,16 +18,6 @@ EntryData::~EntryData()
zdrv::destroy_zmap(reinterpret_cast<zmap_header_type*>(Buffer));
memory::free(Buffer);
}
if (DerivedBmp)
{
gdrv::destroy_bitmap(DerivedBmp);
memory::free(DerivedBmp);
}
if (DerivedZMap)
{
zdrv::destroy_zmap(DerivedZMap);
memory::free(DerivedZMap);
}
}
@ -38,8 +28,7 @@ GroupData::GroupData(int groupId)
void GroupData::AddEntry(EntryData* entry)
{
Entries.push_back(entry);
auto addEntry = true;
switch (entry->EntryType)
{
case FieldTypes::GroupName:
@ -47,21 +36,23 @@ void GroupData::AddEntry(EntryData* entry)
break;
case FieldTypes::Bitmap8bit:
{
auto bmp = reinterpret_cast<gdrv_bitmap8*>(entry->Buffer);
if (bmp->BitmapType == BitmapTypes::Spliced)
auto srcBmp = reinterpret_cast<gdrv_bitmap8*>(entry->Buffer);
if (srcBmp->BitmapType == BitmapTypes::Spliced)
{
// Get rid of spliced bitmap early on, to simplify render pipeline
auto splitBmp = memory::allocate<gdrv_bitmap8>();
auto splitZMap = memory::allocate<zmap_header_type>();
SplitSplicedBitmap(*bmp, *splitBmp, *splitZMap);
entry->DerivedBmp = splitBmp;
entry->DerivedZMap = splitZMap;
SetBitmap(splitBmp);
SetZMap(splitZMap);
auto bmp = memory::allocate<gdrv_bitmap8>();
auto zMap = memory::allocate<zmap_header_type>();
SplitSplicedBitmap(*srcBmp, *bmp, *zMap);
NeedsSort = true;
addEntry = false;
AddEntry(new EntryData(FieldTypes::Bitmap8bit, reinterpret_cast<char*>(bmp)));
AddEntry(new EntryData(FieldTypes::Bitmap16bit, reinterpret_cast<char*>(zMap)));
delete entry;
}
else
{
SetBitmap(bmp);
SetBitmap(srcBmp);
}
break;
}
@ -72,6 +63,24 @@ void GroupData::AddEntry(EntryData* entry)
}
default: break;
}
if (addEntry)
Entries.push_back(entry);
}
void GroupData::FinalizeGroup()
{
if (NeedsSort)
{
// Entries within a group are sorted by EntryType, in ascending order.
// Dat files follow this rule, zMaps inserted in the middle break it.
NeedsSort = false;
std::sort(Entries.begin(), Entries.end(), [](const EntryData* lhs, const EntryData* rhs)
{
return lhs->EntryType < rhs->EntryType;
});
Entries.shrink_to_fit();
}
}
gdrv_bitmap8* GroupData::GetBitmap(int resolution) const