diff options
author | Johannes Schickel | 2006-04-11 15:34:07 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-04-11 15:34:07 +0000 |
commit | a7a5f40cfc4f89ac934d84636fed80222eb6fbc4 (patch) | |
tree | 8ab5309422a6e0f83d0484a227dd51bc38a103c3 | |
parent | c3733105cc2eda7bc0993a7030d898998b5c45f6 (diff) | |
download | scummvm-rg350-a7a5f40cfc4f89ac934d84636fed80222eb6fbc4.tar.gz scummvm-rg350-a7a5f40cfc4f89ac934d84636fed80222eb6fbc4.tar.bz2 scummvm-rg350-a7a5f40cfc4f89ac934d84636fed80222eb6fbc4.zip |
- cleans up drawSurfaceMasked a little bit
- get rid of getColorAlpha in drawSurfaceMasked if no alpha blending is used
svn-id: r21792
-rw-r--r-- | gui/ThemeNew.cpp | 114 |
1 files changed, 44 insertions, 70 deletions
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp index 84ce4d1dad..f7410a6429 100644 --- a/gui/ThemeNew.cpp +++ b/gui/ThemeNew.cpp @@ -1141,7 +1141,6 @@ void ThemeNew::drawShadowRect(const Common::Rect &r, const Common::Rect &area, c upDown = true; for (int i = 0; i < partsW; ++i) { - // calculate the correct drawing width int usedWidth = drawWidth; if (specialWidth && i == 1) { @@ -1187,90 +1186,65 @@ void ThemeNew::drawSurfaceMasked(const Common::Rect &r, const Graphics::Surface const OverlayColor *src = 0; const OverlayColor transparency = _colors[kColorTransparency]; + int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; - if (upDown && !leftRight) { // upsidedown + int srcAdd = 0; + if (upDown) { src = (const OverlayColor*)surf->pixels + (surf->h - 1) * surf->w; - int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; + srcAdd = -surf->w; + } else { + src = (const OverlayColor*)surf->pixels; + srcAdd = surf->w; + } - for (int i = 0; i < r.height(); ++i) { - if (dst < _screen.pixels) { - dst += _screen.w; - src -= surf->w; - continue; - } + while (dst < _screen.pixels) { + dst += _screen.w; + src += srcAdd; + } - OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); - for (int x = 0; x < drawWidth; ++x) { - if (src[x] != transparency) { - dst[x] = getColorAlpha(src[x] & rowColor, dst[x], alpha); + if (alpha >= 256) { + if (leftRight) { + for (int i = 0; i < r.height(); ++i) { + OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); + for (int x = 0; x < drawWidth; ++x) { + if (src[drawWidth-x-1] != transparency) + dst[x] = src[drawWidth-x-1] & rowColor; } - } - - dst += _screen.w; - src -= surf->w; - } - } else if (upDown && leftRight) { // upsidedown + left right inverse - src = (const OverlayColor*)surf->pixels + (surf->h - 1) * surf->w; - int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; - - for (int i = 0; i < r.height(); ++i) { - if (dst < _screen.pixels) { dst += _screen.w; - src -= surf->w; - continue; + src += srcAdd; } - - OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); - for (int x = 0; x < drawWidth; ++x) { - if (src[drawWidth-x-1] != transparency) { - dst[x] = getColorAlpha(src[drawWidth-x-1] & rowColor, dst[x], alpha); + } else { + for (int i = 0; i < r.height(); ++i) { + OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); + for (int x = 0; x < drawWidth; ++x) { + if (src[x] != transparency) + dst[x] = src[x] & rowColor; } - } - - dst += _screen.w; - src -= surf->w; - } - } else if (!upDown && leftRight) { // left right inverse - src = (const OverlayColor*)surf->pixels; - int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; - - for (int i = 0; i < r.height(); ++i) { - if (dst < _screen.pixels) { dst += _screen.w; - src += surf->w; - continue; + src += srcAdd; } - - OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); - for (int x = 0; x < drawWidth; ++x) { - if (src[drawWidth-x-1] != transparency) { - dst[x] = getColorAlpha(src[drawWidth-x-1] & rowColor, dst[x], alpha); - } - } - - dst += _screen.w; - src += surf->w; } - } else { // normal - src = (const OverlayColor*)surf->pixels; - int drawWidth = (r.width() < surf->w) ? r.width() : surf->w; - - for (int i = 0; i < r.height(); ++i) { - if (dst < _screen.pixels) { + } else { + if (leftRight) { + for (int i = 0; i < r.height(); ++i) { + OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); + for (int x = 0; x < drawWidth; ++x) { + if (src[drawWidth-x-1] != transparency) + dst[x] = getColorAlpha(src[drawWidth-x-1] & rowColor, dst[x], alpha); + } dst += _screen.w; - src += surf->w; - continue; + src += srcAdd; } - - OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); - for (int x = 0; x < drawWidth; ++x) { - if (src[x] != transparency) { - dst[x] = getColorAlpha(src[x] & rowColor, dst[x], alpha); + } else { + for (int i = 0; i < r.height(); ++i) { + OverlayColor rowColor = calcGradient(start, end, i, r.height(), factor); + for (int x = 0; x < drawWidth; ++x) { + if (src[x] != transparency) + dst[x] = getColorAlpha(src[x] & rowColor, dst[x], alpha); } + dst += _screen.w; + src += srcAdd; } - - dst += _screen.w; - src += surf->w; } } } |