Load missile frames into a single buffer
Previously, the memory for each frame was allocated separately. Changes it to allocate a single buffer for all the frames. This has the following advantages: 1. Less bookkeeping overhead in the allocator. 2. Less alignment overhead (allocator results are max-aligned by default). We can follow this up with a similar treatment for other multi-file animations.
This commit is contained in:
parent
1519e995cf
commit
a5e1fa5bbe
8 changed files with 192 additions and 28 deletions
|
|
@ -310,8 +310,7 @@ void DrawMissilePrivate(const Surface &out, const Missile &missile, Point target
|
|||
return;
|
||||
}
|
||||
int nCel = missile._miAnimFrame;
|
||||
const auto *frameTable = reinterpret_cast<const uint32_t *>(missile._miAnimData);
|
||||
int frames = SDL_SwapLE32(frameTable[0]);
|
||||
const int frames = LoadLE32(missile._miAnimData);
|
||||
if (nCel < 1 || frames > 50 || nCel > frames) {
|
||||
Log("Draw Missile 2: frame {} of {}, missile type=={}", nCel, frames, missile._mitype);
|
||||
return;
|
||||
|
|
@ -458,7 +457,7 @@ void DrawPlayerIconHelper(const Surface &out, int pnum, missile_graphic_id missi
|
|||
position.x += CalculateWidth2(Players[pnum].AnimInfo.pCelSprite->Width()) - MissileSpriteData[missileGraphicId].animWidth2;
|
||||
|
||||
int width = MissileSpriteData[missileGraphicId].animWidth;
|
||||
byte *pCelBuff = MissileSpriteData[missileGraphicId].animData[0].get();
|
||||
const byte *pCelBuff = MissileSpriteData[missileGraphicId].GetFirstFrame();
|
||||
|
||||
CelSprite cel { pCelBuff, width };
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue