diff options
author | Einar Johan Trøan Sømåen | 2012-12-13 21:08:12 +0100 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-12-13 21:08:12 +0100 |
commit | 7319ccd84f6facbaa3875d1adc31f26cea94d223 (patch) | |
tree | 72d47c3dc5861e01c291419e0fe07839aba3c1a5 /engines/wintermute | |
parent | 9f9b6e2af8342b88b45d858c979503f3df64f551 (diff) | |
download | scummvm-rg350-7319ccd84f6facbaa3875d1adc31f26cea94d223.tar.gz scummvm-rg350-7319ccd84f6facbaa3875d1adc31f26cea94d223.tar.bz2 scummvm-rg350-7319ccd84f6facbaa3875d1adc31f26cea94d223.zip |
WINTERMUTE: Implement simple sprite-batching to speed up tileImage-drawing.
Diffstat (limited to 'engines/wintermute')
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 21 | ||||
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.h | 5 |
2 files changed, 25 insertions, 1 deletions
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 7c0e9e76d9..c32054ac32 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -43,6 +43,7 @@ namespace Wintermute { RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { _colorMod = 0; + _batchNum = 0; _mirror = TransparentSurface::FLIP_NONE; if (mirrorX) { _mirror |= TransparentSurface::FLIP_V; @@ -80,6 +81,7 @@ RenderTicket::~RenderTicket() { bool RenderTicket::operator==(RenderTicket &t) { if ((t._owner != _owner) || + (t._batchNum != t._batchNum) || (t._hasAlpha != _hasAlpha) || (t._mirror != _mirror) || (t._colorMod != _colorMod) || @@ -100,6 +102,8 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _blankSurface = new Graphics::Surface(); _drawNum = 1; _needsFlip = true; + _spriteBatch = false; + _batchNum = 0; _borderLeft = _borderRight = _borderTop = _borderBottom = 0; _ratioX = _ratioY = 1.0f; @@ -310,6 +314,9 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (owner) { // Fade-tickets are owner-less RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); + compare._batchNum = _batchNum; + if (_spriteBatch) + _batchNum++; compare._colorMod = _colorMod; RenderQueueIterator it; // Avoid calling end() and operator* every time, when potentially going through @@ -318,7 +325,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S RenderTicket *compareTicket = NULL; for (it = _renderQueue.begin(); it != endIterator; ++it) { compareTicket = *it; - if (compareTicket->_owner == owner && *(compareTicket) == compare && compareTicket->_isValid) { + if (*(compareTicket) == compare && compareTicket->_isValid) { compareTicket->_colorMod = _colorMod; if (_disableDirtyRects) { drawFromSurface(compareTicket, NULL); @@ -647,4 +654,16 @@ void BaseRenderOSystem::endSaveLoad() { _drawNum = 1; } +bool BaseRenderOSystem::startSpriteBatch() { + _spriteBatch = true; + _batchNum = 1; + return STATUS_OK; +} + +bool BaseRenderOSystem::endSpriteBatch() { + _spriteBatch = false; + _batchNum = 0; + return STATUS_OK; +} + } // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 1e9b4ed2e2..1cef0038a1 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -46,6 +46,7 @@ public: Common::Rect _srcRect; Common::Rect _dstRect; uint32 _mirror; + uint32 _batchNum; bool _hasAlpha; bool _isValid; @@ -97,6 +98,8 @@ public: float getScaleRatioY() const { return _ratioY; } + virtual bool startSpriteBatch(); + virtual bool endSpriteBatch(); void endSaveLoad(); void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha = false); BaseSurface *createSurface(); @@ -120,6 +123,8 @@ private: int _borderBottom; bool _disableDirtyRects; + bool _spriteBatch; + uint32 _batchNum; float _ratioX; float _ratioY; uint32 _colorMod; |