mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r18709) -Fix (r10227,FS#3464): Animation buffer for 32bpp-anim blitter was only validated during sprite blitting, other drawing operations didn't check it. Initial startup and window resize could therefore lead to crash.
This commit is contained in:
parent
5ab64809fe
commit
abb147d974
@ -202,14 +202,6 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
|
|
||||||
/* The size of the screen changed; we can assume we can wipe all data from our buffer */
|
|
||||||
free(this->anim_buf);
|
|
||||||
this->anim_buf = CallocT<uint8>(_screen.width * _screen.height);
|
|
||||||
this->anim_buf_width = _screen.width;
|
|
||||||
this->anim_buf_height = _screen.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
|
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
|
||||||
@ -448,3 +440,14 @@ Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
|
|||||||
{
|
{
|
||||||
return Blitter::PALETTE_ANIMATION_BLITTER;
|
return Blitter::PALETTE_ANIMATION_BLITTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Blitter_32bppAnim::PostResize()
|
||||||
|
{
|
||||||
|
if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
|
||||||
|
/* The size of the screen changed; we can assume we can wipe all data from our buffer */
|
||||||
|
free(this->anim_buf);
|
||||||
|
this->anim_buf = CallocT<uint8>(_screen.width * _screen.height);
|
||||||
|
this->anim_buf_width = _screen.width;
|
||||||
|
this->anim_buf_height = _screen.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
|
|
||||||
/* virtual */ const char *GetName() { return "32bpp-anim"; }
|
/* virtual */ const char *GetName() { return "32bpp-anim"; }
|
||||||
/* virtual */ int GetBytesPerPixel() { return 5; }
|
/* virtual */ int GetBytesPerPixel() { return 5; }
|
||||||
|
/* virtual */ void PostResize();
|
||||||
|
|
||||||
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
|
||||||
};
|
};
|
||||||
|
@ -200,6 +200,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual int GetBytesPerPixel() = 0;
|
virtual int GetBytesPerPixel() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post resize event
|
||||||
|
*/
|
||||||
|
virtual void PostResize() { };
|
||||||
|
|
||||||
virtual ~Blitter() { }
|
virtual ~Blitter() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -221,6 +221,8 @@ static bool CreateMainSurface(uint w, uint h)
|
|||||||
_cursor.pos.x = mouse_x;
|
_cursor.pos.x = mouse_x;
|
||||||
_cursor.pos.y = mouse_y;
|
_cursor.pos.y = mouse_y;
|
||||||
|
|
||||||
|
BlitterFactoryBase::GetCurrentBlitter()->PostResize();
|
||||||
|
|
||||||
InitPalette();
|
InitPalette();
|
||||||
|
|
||||||
char caption[32];
|
char caption[32];
|
||||||
|
@ -197,6 +197,8 @@ void QZ_GameSizeChanged()
|
|||||||
_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
|
_screen.dst_ptr = _cocoa_subdriver->GetPixelBuffer();
|
||||||
_fullscreen = _cocoa_subdriver->IsFullscreen();
|
_fullscreen = _cocoa_subdriver->IsFullscreen();
|
||||||
|
|
||||||
|
BlitterFactoryBase::GetCurrentBlitter()->PostResize();
|
||||||
|
|
||||||
GameSizeChanged();
|
GameSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +251,9 @@ static bool CreateMainSurface(uint w, uint h)
|
|||||||
_screen.pitch = newscreen->pitch / (bpp / 8);
|
_screen.pitch = newscreen->pitch / (bpp / 8);
|
||||||
_screen.dst_ptr = newscreen->pixels;
|
_screen.dst_ptr = newscreen->pixels;
|
||||||
_sdl_screen = newscreen;
|
_sdl_screen = newscreen;
|
||||||
|
|
||||||
|
BlitterFactoryBase::GetCurrentBlitter()->PostResize();
|
||||||
|
|
||||||
InitPalette();
|
InitPalette();
|
||||||
|
|
||||||
snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
|
snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
|
||||||
|
@ -160,6 +160,9 @@ static void ClientSizeChanged(int w, int h)
|
|||||||
/* mark all palette colors dirty */
|
/* mark all palette colors dirty */
|
||||||
_pal_first_dirty = 0;
|
_pal_first_dirty = 0;
|
||||||
_pal_count_dirty = 256;
|
_pal_count_dirty = 256;
|
||||||
|
|
||||||
|
BlitterFactoryBase::GetCurrentBlitter()->PostResize();
|
||||||
|
|
||||||
GameSizeChanged();
|
GameSizeChanged();
|
||||||
|
|
||||||
/* redraw screen */
|
/* redraw screen */
|
||||||
@ -302,6 +305,9 @@ static bool MakeWindow(bool full_screen)
|
|||||||
ShowWindow(_wnd.main_wnd, showstyle);
|
ShowWindow(_wnd.main_wnd, showstyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlitterFactoryBase::GetCurrentBlitter()->PostResize();
|
||||||
|
|
||||||
GameSizeChanged(); // invalidate all windows, force redraw
|
GameSizeChanged(); // invalidate all windows, force redraw
|
||||||
return true; // the request succedded
|
return true; // the request succedded
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user