diff options
author | Willem Jan Palenstijn | 2013-08-19 23:07:48 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-08-19 23:14:20 +0200 |
commit | 91c2f8fb097f65801f6f97340e0a4a8dbead6404 (patch) | |
tree | fa7a7cd81fee64cfebd81dcab010baf22ca7ebc6 /engines/wintermute | |
parent | efbf1ff5f999786675fdf28b53970af0eacfa759 (diff) | |
download | scummvm-rg350-91c2f8fb097f65801f6f97340e0a4a8dbead6404.tar.gz scummvm-rg350-91c2f8fb097f65801f6f97340e0a4a8dbead6404.tar.bz2 scummvm-rg350-91c2f8fb097f65801f6f97340e0a4a8dbead6404.zip |
WINTERMUTE: Don't use a lookup table for alpha
This gives a drawTickets() speed increase of about 10% in the JULIA demo
(on a core i7 920).
Diffstat (limited to 'engines/wintermute')
-rw-r--r-- | engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 1 | ||||
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.cpp | 30 | ||||
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.h | 3 |
3 files changed, 3 insertions, 31 deletions
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 668105457f..9738357dd1 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -84,7 +84,6 @@ BaseRenderOSystem::~BaseRenderOSystem() { delete _renderSurface; _blankSurface->free(); delete _blankSurface; - TransparentSurface::destroyLookup(); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index e375322ae9..d348015ed0 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -140,13 +140,6 @@ void TransparentSurface::copyPixelNearestNeighbor(float projX, float projY, int } #endif -byte *TransparentSurface::_lookup = nullptr; - -void TransparentSurface::destroyLookup() { - delete[] _lookup; - _lookup = nullptr; -} - TransparentSurface::TransparentSurface() : Surface(), _enableAlphaBlit(true) {} TransparentSurface::TransparentSurface(const Surface &surf, bool copyData) : Surface(), _enableAlphaBlit(true) { @@ -186,22 +179,9 @@ void doBlitOpaque(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pit } } -void TransparentSurface::generateLookup() { - _lookup = new byte[256 * 256]; - for (int i = 0; i < 256; i++) { - for (int j = 0; j < 256; j++) { - _lookup[(i << 8) + j] = (i * j) >> 8; - } - } -} - void TransparentSurface::doBlitAlpha(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep) { byte *in, *out; - if (!_lookup) { - generateLookup(); - } - #ifdef SCUMM_LITTLE_ENDIAN const int aIndex = 3; const int bIndex = 0; @@ -255,13 +235,9 @@ void TransparentSurface::doBlitAlpha(byte *ino, byte *outo, uint32 width, uint32 default: // alpha blending outa = 255; - - outb = _lookup[(((oPix >> bShiftTarget) & 0xff)) + ((255 - a) << 8)]; - outg = _lookup[(((oPix >> gShiftTarget) & 0xff)) + ((255 - a) << 8)]; - outr = _lookup[(((oPix >> rShiftTarget) & 0xff)) + ((255 - a) << 8)]; - outb += _lookup[b + (a << 8)]; - outg += _lookup[g + (a << 8)]; - outr += _lookup[r + (a << 8)]; + outb = ((b * a) + ((oPix >> bShiftTarget) & 0xff) * (255-a)) >> 8; + outg = ((g * a) + ((oPix >> gShiftTarget) & 0xff) * (255-a)) >> 8; + outr = ((r * a) + ((oPix >> rShiftTarget) & 0xff) * (255-a)) >> 8; out[aIndex] = outa; out[bIndex] = outb; diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 9d06f3e006..a486e97946 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -114,11 +114,8 @@ struct TransparentSurface : public Graphics::Surface { TransparentSurface *scale(uint16 newWidth, uint16 newHeight) const; TransparentSurface *rotoscale(const TransformStruct &transform) const; - static byte *_lookup; - static void destroyLookup(); private: static void doBlitAlpha(byte *ino, byte *outo, uint32 width, uint32 height, uint32 pitch, int32 inStep, int32 inoStep); - static void generateLookup(); }; /** |