# HG changeset patch # User MJP # Date 1390490230 -3600 # Thu Jan 23 16:17:10 2014 +0100 # Node ID 976ddba7d5810dad0de6272dbaf66426698bd111 # Parent 356c943c705a8d1f9a94e076d6dc92bcdf526442 Add blitter methods to backup/restore the animation buffer diff -r 356c943c705a -r 976ddba7d581 src/blitter/32bpp_anim.cpp --- a/src/blitter/32bpp_anim.cpp Sun Jan 19 09:27:44 2014 +0000 +++ b/src/blitter/32bpp_anim.cpp Thu Jan 23 16:17:10 2014 +0100 @@ -457,3 +457,22 @@ this->anim_buf_height = _screen.height; } } + +bool Blitter_32bppAnim::BackupAnimationBuffer() +{ + assert(this->anim_bkp == NULL); + /* C/MallocT halt on error. Not something interesting for a screenshot. */ + uint16 *buffer = (uint16*) malloc(_screen.width * _screen.height * sizeof(uint16)); + if (!buffer) return false; + this->anim_bkp = this->anim_buf; + this->anim_buf = buffer; + return true; +} + +void Blitter_32bppAnim::RestoreAnimationBuffer() +{ + assert(this->anim_bkp != NULL); + free(this->anim_buf); + this->anim_buf = this->anim_bkp; + this->anim_bkp = NULL; +} diff -r 356c943c705a -r 976ddba7d581 src/blitter/32bpp_anim.hpp --- a/src/blitter/32bpp_anim.hpp Sun Jan 19 09:27:44 2014 +0000 +++ b/src/blitter/32bpp_anim.hpp Thu Jan 23 16:17:10 2014 +0100 @@ -18,6 +18,7 @@ class Blitter_32bppAnim : public Blitter_32bppOptimized { protected: uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation + uint16 *anim_bkp; ///< Backup of anim_buf (used during giant screenshot). int anim_buf_width; ///< The width of the animation buffer. int anim_buf_height; ///< The height of the animation buffer. Palette palette; ///< The current palette. @@ -25,6 +26,7 @@ public: Blitter_32bppAnim() : anim_buf(NULL), + anim_bkp(NULL), anim_buf_width(0), anim_buf_height(0) {} @@ -43,6 +45,8 @@ /* virtual */ const char *GetName() { return "32bpp-anim"; } /* virtual */ int GetBytesPerPixel() { return 6; } /* virtual */ void PostResize(); + /* virtual */ bool BackupAnimationBuffer(); + /* virtual */ void RestoreAnimationBuffer(); /** * Look up the colour in the current palette. diff -r 356c943c705a -r 976ddba7d581 src/blitter/base.hpp --- a/src/blitter/base.hpp Sun Jan 19 09:27:44 2014 +0000 +++ b/src/blitter/base.hpp Thu Jan 23 16:17:10 2014 +0100 @@ -186,6 +186,17 @@ virtual Blitter::PaletteAnimation UsePaletteAnimation() = 0; /** + * Backup the animation buffer (important for 32bpp-anim blitter before giant screenshot). + * @return True on success. + */ + virtual bool BackupAnimationBuffer() { return true; }; + + /** + * Restore the animation buffer (important for 32bpp-anim blitter after giant screenshot). + */ + virtual void RestoreAnimationBuffer() { }; + + /** * Get the name of the blitter, the same as the Factory-instance returns. */ virtual const char *GetName() = 0;