From 7fc69ebdea10101d8d59eed400eff9da7c0b3b4c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Jul 2017 19:24:10 -0400 Subject: TITANIC: Inline CTransparencySurface methods at wjp's suggestion --- engines/titanic/support/transparency_surface.cpp | 35 ------------------------ engines/titanic/support/transparency_surface.h | 33 +++++++++++++++++----- 2 files changed, 26 insertions(+), 42 deletions(-) diff --git a/engines/titanic/support/transparency_surface.cpp b/engines/titanic/support/transparency_surface.cpp index 505cd1ff6c..a2efe12db7 100644 --- a/engines/titanic/support/transparency_surface.cpp +++ b/engines/titanic/support/transparency_surface.cpp @@ -57,39 +57,4 @@ CTransparencySurface::CTransparencySurface(const Graphics::Surface *surface, } } -int CTransparencySurface::moveX() { - if (++_pos.x >= _surface->w) { - _pos.x = 0; - ++_pos.y; - } - - return 1; -} - -uint CTransparencySurface::getPixel() const { - byte pixel = *(const byte *)_surface->getBasePtr(_pos.x, _pos.y); - return pixel; -} - -uint CTransparencySurface::getAlpha() const { - byte pixel = getPixel(); - return _opaqueColor ? 0xFF - pixel : pixel; -} - -bool CTransparencySurface::isPixelOpaque() const { - byte pixel = getPixel(); - if (_opaqueColor) - return pixel >= 0xf0; - else - return pixel < 0x10; -} - -bool CTransparencySurface::isPixelTransparent() const { - byte pixel = getPixel(); - if (_transparentColor) - return pixel >= 0xf0; - else - return pixel < 0x10; -} - } // End of namespace Titanic diff --git a/engines/titanic/support/transparency_surface.h b/engines/titanic/support/transparency_surface.h index 0970de46f5..6b726d6c4e 100644 --- a/engines/titanic/support/transparency_surface.h +++ b/engines/titanic/support/transparency_surface.h @@ -46,7 +46,10 @@ private: /** * Returns a a pixel from the transparency surface */ - uint getPixel() const; + inline uint getPixel() const { + byte pixel = *(const byte *)_surface->getBasePtr(_pos.x, _pos.y); + return pixel; + } public: /** * Constructor @@ -56,32 +59,48 @@ public: /** * Sets the row to get transparencies from */ - void setRow(int yp) { _pos.y = yp; } + inline void setRow(int yp) { _pos.y = yp; } /** * Sets the column to get transparencies from */ - void setCol(int xp) { _pos.x = xp; } + inline void setCol(int xp) { _pos.x = xp; } /** * Moves reading position horizontally by a single pixel */ - int moveX(); + inline int moveX() { + if (++_pos.x >= _surface->w) { + _pos.x = 0; + ++_pos.y; + } + + return 1; + } /** * Returns the alpha value for the pixel (0-31) */ - uint getAlpha() const; + inline uint getAlpha() const { + byte pixel = getPixel(); + return _opaqueColor ? 0xFF - pixel : pixel; + } /** * Returns true if the pixel is opaque */ - bool isPixelOpaque() const; + inline bool isPixelOpaque() const { + byte pixel = getPixel(); + return _opaqueColor ? pixel >= 0xf0 : pixel < 0x10; + } /** * Returns true if the pixel is completely transparent */ - bool isPixelTransparent() const; + inline bool isPixelTransparent() const { + byte pixel = getPixel(); + return _transparentColor ? pixel >= 0xf0 : pixel < 0x10; + } }; } // End of namespace Titanic -- cgit v1.2.3