summaryrefslogtreecommitdiff
path: root/src/blitter
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2010-01-04 02:32:36 +0000
committerpeter1138 <peter1138@openttd.org>2010-01-04 02:32:36 +0000
commitabb147d9742f349513d076a76b2957eb573d78e7 (patch)
tree57b0ff251d966e055785a8e289aacc6431540af4 /src/blitter
parent5ab64809fe72c38d373bdbed6ffa9b6660dd69d6 (diff)
downloadopenttd-abb147d9742f349513d076a76b2957eb573d78e7.tar.xz
(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.
Diffstat (limited to 'src/blitter')
-rw-r--r--src/blitter/32bpp_anim.cpp19
-rw-r--r--src/blitter/32bpp_anim.hpp1
-rw-r--r--src/blitter/base.hpp5
3 files changed, 17 insertions, 8 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index ef42ee0a3..42fbe3fe9 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -202,14 +202,6 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
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) {
default: NOT_REACHED();
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
@@ -448,3 +440,14 @@ Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
{
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;
+ }
+}
diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp
index 29f8a8d41..9063bf14c 100644
--- a/src/blitter/32bpp_anim.hpp
+++ b/src/blitter/32bpp_anim.hpp
@@ -42,6 +42,7 @@ public:
/* virtual */ const char *GetName() { return "32bpp-anim"; }
/* virtual */ int GetBytesPerPixel() { return 5; }
+ /* virtual */ void PostResize();
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
};
diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp
index 9046bca5e..278f3b7c8 100644
--- a/src/blitter/base.hpp
+++ b/src/blitter/base.hpp
@@ -200,6 +200,11 @@ public:
*/
virtual int GetBytesPerPixel() = 0;
+ /**
+ * Post resize event
+ */
+ virtual void PostResize() { };
+
virtual ~Blitter() { }
};