diff options
author | Eugene Sandulenko | 2014-06-03 19:00:47 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2014-06-15 15:43:25 +0300 |
commit | 5c706dde274753b62c9fc72d5d33b4f42100c11a (patch) | |
tree | eb4a0f8b58ed7e479de8da0b9a70c76fed6e9daf /engines/sword25/gfx | |
parent | 385f8358ab2ea138a39eb6fc76d246b3c5f48e45 (diff) | |
download | scummvm-rg350-5c706dde274753b62c9fc72d5d33b4f42100c11a.tar.gz scummvm-rg350-5c706dde274753b62c9fc72d5d33b4f42100c11a.tar.bz2 scummvm-rg350-5c706dde274753b62c9fc72d5d33b4f42100c11a.zip |
SWORD25: Switch to common TransparentSurface
Diffstat (limited to 'engines/sword25/gfx')
-rw-r--r-- | engines/sword25/gfx/animation.cpp | 8 | ||||
-rw-r--r-- | engines/sword25/gfx/bitmapresource.h | 18 | ||||
-rw-r--r-- | engines/sword25/gfx/dynamicbitmap.cpp | 8 | ||||
-rw-r--r-- | engines/sword25/gfx/graphicengine.cpp | 10 | ||||
-rw-r--r-- | engines/sword25/gfx/image/image.h | 22 | ||||
-rw-r--r-- | engines/sword25/gfx/image/imgloader.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/gfx/image/renderedimage.cpp | 292 | ||||
-rw-r--r-- | engines/sword25/gfx/image/renderedimage.h | 11 | ||||
-rw-r--r-- | engines/sword25/gfx/image/swimage.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/image/vectorimage.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/image/vectorimagerenderer.cpp | 10 | ||||
-rw-r--r-- | engines/sword25/gfx/staticbitmap.cpp | 8 | ||||
-rw-r--r-- | engines/sword25/gfx/text.cpp | 6 |
13 files changed, 73 insertions, 328 deletions
diff --git a/engines/sword25/gfx/animation.cpp b/engines/sword25/gfx/animation.cpp index eeb78857ea..e2662fb2b3 100644 --- a/engines/sword25/gfx/animation.cpp +++ b/engines/sword25/gfx/animation.cpp @@ -189,14 +189,14 @@ bool Animation::doRender(RectangleList *updateRects) { bool result; if (isScalingAllowed() && (_width != pBitmapResource->getWidth() || _height != pBitmapResource->getHeight())) { result = pBitmapResource->blit(_absoluteX, _absoluteY, - (animationDescriptionPtr->getFrame(_currentFrame).flipV ? BitmapResource::FLIP_V : 0) | - (animationDescriptionPtr->getFrame(_currentFrame).flipH ? BitmapResource::FLIP_H : 0), + (animationDescriptionPtr->getFrame(_currentFrame).flipV ? Graphics::FLIP_V : 0) | + (animationDescriptionPtr->getFrame(_currentFrame).flipH ? Graphics::FLIP_H : 0), 0, _modulationColor, _width, _height, updateRects); } else { result = pBitmapResource->blit(_absoluteX, _absoluteY, - (animationDescriptionPtr->getFrame(_currentFrame).flipV ? BitmapResource::FLIP_V : 0) | - (animationDescriptionPtr->getFrame(_currentFrame).flipH ? BitmapResource::FLIP_H : 0), + (animationDescriptionPtr->getFrame(_currentFrame).flipV ? Graphics::FLIP_V : 0) | + (animationDescriptionPtr->getFrame(_currentFrame).flipH ? Graphics::FLIP_H : 0), 0, _modulationColor, -1, -1, updateRects); } diff --git a/engines/sword25/gfx/bitmapresource.h b/engines/sword25/gfx/bitmapresource.h index 7a4daedd84..2ae891f5cd 100644 --- a/engines/sword25/gfx/bitmapresource.h +++ b/engines/sword25/gfx/bitmapresource.h @@ -40,22 +40,6 @@ namespace Sword25 { class BitmapResource : public Resource { public: - /** - @brief Die möglichen Flippingparameter für die Blit-Methode. - */ - enum FLIP_FLAGS { - /// Das Bild wird nicht gespiegelt. - FLIP_NONE = 0, - /// Das Bild wird an der horizontalen Achse gespiegelt. - FLIP_H = 1, - /// Das Bild wird an der vertikalen Achse gespiegelt. - FLIP_V = 2, - /// Das Bild wird an der horizontalen und vertikalen Achse gespiegelt. - FLIP_HV = FLIP_H | FLIP_V, - /// Das Bild wird an der horizontalen und vertikalen Achse gespiegelt. - FLIP_VH = FLIP_H | FLIP_V - }; - BitmapResource(const Common::String &filename, Image *pImage) : _pImage(pImage), Resource(filename, Resource::TYPE_BITMAP) {} virtual ~BitmapResource() { delete _pImage; } @@ -120,7 +104,7 @@ public: - IsColorModulationAllowed() */ bool blit(int posX = 0, int posY = 0, - int flipping = FLIP_NONE, + int flipping = Graphics::FLIP_NONE, Common::Rect *pSrcPartRect = NULL, uint color = BS_ARGB(255, 255, 255, 255), int width = -1, int height = -1, diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp index ce9c056d08..a335f87fa5 100644 --- a/engines/sword25/gfx/dynamicbitmap.cpp +++ b/engines/sword25/gfx/dynamicbitmap.cpp @@ -86,8 +86,8 @@ bool DynamicBitmap::doRender(RectangleList *updateRects) { // a bit slow when drawing videos, but it's not the main // bottleneck. result = _image->blit(_absoluteX, _absoluteY, - (_flipV ? BitmapResource::FLIP_V : 0) | - (_flipH ? BitmapResource::FLIP_H : 0), + (_flipV ? Graphics::FLIP_V : 0) | + (_flipH ? Graphics::FLIP_H : 0), 0, _modulationColor, -1, -1, updateRects); #else @@ -105,8 +105,8 @@ bool DynamicBitmap::doRender(RectangleList *updateRects) { return true; } else { result = _image->blit(_absoluteX, _absoluteY, - (_flipV ? BitmapResource::FLIP_V : 0) | - (_flipH ? BitmapResource::FLIP_H : 0), + (_flipV ? Graphics::FLIP_V : 0) | + (_flipH ? Graphics::FLIP_H : 0), 0, _modulationColor, _width, _height, updateRects); } diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp index 2a870c021d..f887c3cd51 100644 --- a/engines/sword25/gfx/graphicengine.cpp +++ b/engines/sword25/gfx/graphicengine.cpp @@ -183,7 +183,7 @@ bool GraphicEngine::fill(const Common::Rect *fillRectPtr, uint color) { if (rect.width() > 0 && rect.height() > 0) { if (ca == 0xff) { - _backSurface.fillRect(rect, color); + _backSurface.fillRect(rect, BS_ARGB(cr, cg, cb, ca)); } else { byte *outo = (byte *)_backSurface.getBasePtr(rect.left, rect.top); byte *out; @@ -192,23 +192,23 @@ bool GraphicEngine::fill(const Common::Rect *fillRectPtr, uint color) { out = outo; for (int j = rect.left; j < rect.right; j++) { #if defined(SCUMM_LITTLE_ENDIAN) + *out = 255; + out++; *out += (byte)(((cb - *out) * ca) >> 8); out++; *out += (byte)(((cg - *out) * ca) >> 8); out++; *out += (byte)(((cr - *out) * ca) >> 8); out++; - *out = 255; - out++; #else - *out = 255; - out++; *out += (byte)(((cr - *out) * ca) >> 8); out++; *out += (byte)(((cg - *out) * ca) >> 8); out++; *out += (byte)(((cb - *out) * ca) >> 8); out++; + *out = 255; + out++; #endif } diff --git a/engines/sword25/gfx/image/image.h b/engines/sword25/gfx/image/image.h index 8fbf802501..f8cb0dfec0 100644 --- a/engines/sword25/gfx/image/image.h +++ b/engines/sword25/gfx/image/image.h @@ -43,6 +43,7 @@ #include "sword25/kernel/common.h" #include "common/rect.h" #include "sword25/gfx/graphicengine.h" +#include "graphics/transparent_surface.h" namespace Sword25 { @@ -52,23 +53,6 @@ class Image { public: virtual ~Image() {} - // Enums - /** - @brief The possible flipping parameters for the blit methode. - */ - enum FLIP_FLAGS { - /// The image will not be flipped. - FLIP_NONE = 0, - /// The image will be flipped at the horizontal axis. - FLIP_H = 1, - /// The image will be flipped at the vertical axis. - FLIP_V = 2, - /// The image will be flipped at the horizontal and vertical axis. - FLIP_HV = FLIP_H | FLIP_V, - /// The image will be flipped at the horizontal and vertical axis. - FLIP_VH = FLIP_H | FLIP_V - }; - //@{ /** @name Accessor methods */ @@ -100,7 +84,7 @@ public: @param PosY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.<br> The default value is 0. @param Flipping how the the image should be flipped.<br> - The default value is BS_Image::FLIP_NONE (no flipping) + The default value is Graphics::FLIP_NONE (no flipping) @param pSrcPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.<br> This referes to the unflipped and unscaled image.<br> The default value is NULL. @@ -128,7 +112,7 @@ public: - IsSetContentAllowed() */ virtual bool blit(int posX = 0, int posY = 0, - int flipping = FLIP_NONE, + int flipping = Graphics::FLIP_NONE, Common::Rect *pPartRect = NULL, uint color = BS_ARGB(255, 255, 255, 255), int width = -1, int height = -1, diff --git a/engines/sword25/gfx/image/imgloader.cpp b/engines/sword25/gfx/image/imgloader.cpp index b4b3030de8..f299cee9d1 100644 --- a/engines/sword25/gfx/image/imgloader.cpp +++ b/engines/sword25/gfx/image/imgloader.cpp @@ -45,7 +45,7 @@ bool ImgLoader::decodePNGImage(const byte *fileDataPtr, uint fileSize, byte *&un error("Error while reading PNG image"); const Graphics::Surface *sourceSurface = png.getSurface(); - Graphics::Surface *pngSurface = sourceSurface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24), png.getPalette()); + Graphics::Surface *pngSurface = sourceSurface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0), png.getPalette()); width = pngSurface->w; height = pngSurface->h; @@ -70,7 +70,7 @@ bool ImgLoader::decodeThumbnailImage(const byte *pFileData, uint fileSize, byte uint32 totalSize = pitch * height; pUncompressedData = new byte[totalSize]; uint32 *dst = (uint32 *)pUncompressedData; // treat as uint32, for pixelformat output - const Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24); + const Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0); byte r, g, b; for (uint32 i = 0; i < totalSize / 4; i++) { diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index 107b4cd402..de79630376 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -100,9 +100,6 @@ static byte *readSavegameThumbnail(const Common::String &filename, uint &fileSiz } RenderedImage::RenderedImage(const Common::String &filename, bool &result) : - _data(0), - _width(0), - _height(0), _isTransparent(true) { result = false; @@ -130,10 +127,18 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) : // Uncompress the image int pitch; + byte *dst; + int w, h; if (isPNG) - result = ImgLoader::decodePNGImage(pFileData, fileSize, _data, _width, _height, pitch); + result = ImgLoader::decodePNGImage(pFileData, fileSize, dst, w, h, pitch); else - result = ImgLoader::decodeThumbnailImage(pFileData, fileSize, _data, _width, _height, pitch); + result = ImgLoader::decodeThumbnailImage(pFileData, fileSize, dst, w, h, pitch); + + _surface.w = w; + _surface.h = h; + _surface.pitch = w * 4; + _surface.setPixels(dst); + _surface.format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0); if (!result) { error("Could not decode image."); @@ -157,12 +162,9 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) : // ----------------------------------------------------------------------------- RenderedImage::RenderedImage(uint width, uint height, bool &result) : - _width(width), - _height(height), _isTransparent(true) { - _data = new byte[width * height * 4]; - Common::fill(_data, &_data[width * height * 4], 0); + _surface.create(width, height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); _backSurface = Kernel::getInstance()->getGfx()->getSurface(); @@ -172,9 +174,11 @@ RenderedImage::RenderedImage(uint width, uint height, bool &result) : return; } -RenderedImage::RenderedImage() : _width(0), _height(0), _data(0), _isTransparent(true) { +RenderedImage::RenderedImage() : _isTransparent(true) { _backSurface = Kernel::getInstance()->getGfx()->getSurface(); + _surface.format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0); + _doCleanup = false; return; @@ -183,8 +187,6 @@ RenderedImage::RenderedImage() : _width(0), _height(0), _data(0), _isTransparent // ----------------------------------------------------------------------------- RenderedImage::~RenderedImage() { - if (_doCleanup) - delete[] _data; } // ----------------------------------------------------------------------------- @@ -198,17 +200,17 @@ bool RenderedImage::fill(const Common::Rect *pFillRect, uint color) { bool RenderedImage::setContent(const byte *pixeldata, uint size, uint offset, uint stride) { // Check if PixelData contains enough pixel to create an image with image size equals width * height - if (size < static_cast<uint>(_width * _height * 4)) { - error("PixelData vector is too small to define a 32 bit %dx%d image.", _width, _height); + if (size < static_cast<uint>(_surface.w * _surface.h * 4)) { + error("PixelData vector is too small to define a 32 bit %dx%d image.", _surface.w, _surface.h); return false; } const byte *in = &pixeldata[offset]; - byte *out = _data; + byte *out = (byte *)_surface.getPixels(); - for (int i = 0; i < _height; i++) { - memcpy(out, in, _width * 4); - out += _width * 4; + for (int i = 0; i < _surface.h; i++) { + memcpy(out, in, _surface.w * 4); + out += _surface.w * 4; in += stride; } @@ -216,9 +218,10 @@ bool RenderedImage::setContent(const byte *pixeldata, uint size, uint offset, ui } void RenderedImage::replaceContent(byte *pixeldata, int width, int height) { - _width = width; - _height = height; - _data = pixeldata; + _surface.w = width; + _surface.h = height; + _surface.pitch = width * 4; + _surface.setPixels(pixeldata); } // ----------------------------------------------------------------------------- @@ -230,251 +233,26 @@ uint RenderedImage::getPixel(int x, int y) { // ----------------------------------------------------------------------------- bool RenderedImage::blit(int posX, int posY, int flipping, Common::Rect *pPartRect, uint color, int width, int height, RectangleList *updateRects) { - int ca = (color >> 24) & 0xff; - - // Check if we need to draw anything at all - if (ca == 0) - return true; - - int cr = (color >> 16) & 0xff; - int cg = (color >> 8) & 0xff; - int cb = (color >> 0) & 0xff; - - // Create an encapsulating surface for the data - Graphics::Surface srcImage; - // TODO: Is the data really in the screen format? - srcImage.init(_width, _height, _width * 4, _data, g_system->getScreenFormat()); - - if (pPartRect) { - srcImage.setPixels(&_data[pPartRect->top * srcImage.pitch + pPartRect->left * 4]); - srcImage.w = pPartRect->right - pPartRect->left; - srcImage.h = pPartRect->bottom - pPartRect->top; - - debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, - pPartRect->left, pPartRect->top, pPartRect->width(), pPartRect->height(), color, width, height); - } else { - - debug(6, "Blit(%d, %d, %d, [%d, %d, %d, %d], %08x, %d, %d)", posX, posY, flipping, 0, 0, - srcImage.w, srcImage.h, color, width, height); - } - - if (width == -1) - width = srcImage.w; - if (height == -1) - height = srcImage.h; - -#ifdef SCALING_TESTING - // Hardcode scaling to 66% to test scaling - width = width * 2 / 3; - height = height * 2 / 3; -#endif - - Graphics::Surface *img; - Graphics::Surface *imgScaled = NULL; - byte *savedPixels = NULL; - if ((width != srcImage.w) || (height != srcImage.h)) { - // Scale the image - img = imgScaled = scale(srcImage, width, height); - savedPixels = (byte *)img->getPixels(); - } else { - img = &srcImage; - } - - for (RectangleList::iterator it = updateRects->begin(); it != updateRects->end(); ++it) { - const Common::Rect &clipRect = *it; - - int skipLeft = 0, skipTop = 0; - int drawX = posX, drawY = posY; - int drawWidth = img->w; - int drawHeight = img->h; - - // Handle clipping - if (drawX < clipRect.left) { - skipLeft = clipRect.left - drawX; - drawWidth -= skipLeft; - drawX = clipRect.left; - } - - if (drawY < clipRect.top) { - skipTop = clipRect.top - drawY; - drawHeight -= skipTop; - drawY = clipRect.top; - } - - if (drawX + drawWidth >= clipRect.right) - drawWidth = clipRect.right - drawX; - - if (drawY + drawHeight >= clipRect.bottom) - drawHeight = clipRect.bottom - drawY; - - if ((drawWidth > 0) && (drawHeight > 0)) { - int xp = 0, yp = 0; - - int inStep = 4; - int inoStep = img->pitch; - if (flipping & Image::FLIP_V) { - inStep = -inStep; - xp = img->w - 1 - skipLeft; - } else { - xp = skipLeft; - } - - if (flipping & Image::FLIP_H) { - inoStep = -inoStep; - yp = img->h - 1 - skipTop; - } else { - yp = skipTop; - } - - byte *ino = (byte *)img->getBasePtr(xp, yp); - byte *outo = (byte *)_backSurface->getBasePtr(drawX, drawY); - -#if defined(SCUMM_LITTLE_ENDIAN) - // Simple memcpy if the source bitmap doesn't have transparent pixels and the drawing transparency is 255 - // NOTE Only possible with LE-machines at the moment, maybe it would be feasible to convert the bitmap pixels at loading time? - if (!_isTransparent && ca == 255) { - for (int i = 0; i < drawHeight; i++) { - memcpy(outo, ino, drawWidth * 4); - outo += _backSurface->pitch; - ino += inoStep; - } - } else -#endif - { - byte *in, *out; - for (int i = 0; i < drawHeight; i++) { - out = outo; - in = ino; - for (int j = 0; j < drawWidth; j++) { - uint32 pix = *(uint32 *)in; - int a = (pix >> 24) & 0xff; - in += inStep; - - if (ca != 255) { - a = a * ca >> 8; - } - - if (a == 0) { - // Full transparency - out += 4; - continue; - } - - int b = (pix >> 0) & 0xff; - int g = (pix >> 8) & 0xff; - int r = (pix >> 16) & 0xff; - - if (a == 255) { -#if defined(SCUMM_LITTLE_ENDIAN) - if (cb != 255) - b = (b * cb) >> 8; - if (cg != 255) - g = (g * cg) >> 8; - if (cr != 255) - r = (r * cr) >> 8; - *(uint32 *)out = (255 << 24) | (r << 16) | (g << 8) | b; - out += 4; -#else - *out++ = a; - if (cr != 255) - *out++ = (r * cr) >> 8; - else - *out++ = r; - if (cg != 255) - *out++ = (g * cg) >> 8; - else - *out++ = g; - if (cb != 255) - *out++ = (b * cb) >> 8; - else - *out++ = b; -#endif - } else { -#if defined(SCUMM_LITTLE_ENDIAN) - pix = *(uint32 *)out; - int outb = ((pix >> 0) & 0xff) * (255 - a); - int outg = ((pix >> 8) & 0xff) * (255 - a); - int outr = ((pix >> 16) & 0xff) * (255 - a); - if (cb == 0) - outb = outb >> 8; - else if (cb != 255) - outb = ((outb << 8) + b * a * cb) >> 16; - else - outb = (outb + b * a) >> 8; - if (cg == 0) - outg = outg >> 8; - else if (cg != 255) - outg = ((outg << 8) + g * a * cg) >> 16; - else - outg = (outg + g * a) >> 8; - if (cr == 0) - outr = outr >> 8; - else if (cr != 255) - outr = ((outr << 8) + r * a * cr) >> 16; - else - outr = (outr + r * a) >> 8; - *(uint32 *)out = (255 << 24) | (outr << 16) | (outg << 8) | outb; - out += 4; -#else - *out = 255; - out++; - if (cr == 0) - *out = (*out * (255-a)) >> 8; - else if (cr != 255) - *out = (((*out * (255-a)) << 8) + r * a * cr) >> 16; - else - *out = ((*out * (255-a)) + r * a) >> 8; - out++; - if (cg == 0) - *out = (*out * (255-a)) >> 8; - else if (cg != 255) - *out = (((*out * (255-a)) << 8) + g * a * cg) >> 16; - else - *out = ((*out * (255-a)) + g * a) >> 8; - out++; - if (cb == 0) - *out = (*out * (255-a)) >> 8; - else if (cb != 255) - *out = (((*out * (255-a)) << 8) + b * a * cb) >> 16; - else - *out = ((*out * (255-a)) + b * a) >> 8; - out++; -#endif - } - } - outo += _backSurface->pitch; - ino += inoStep; - } - } - - } - - } - - if (imgScaled) { - imgScaled->setPixels(savedPixels); - imgScaled->free(); - delete imgScaled; - } + _surface.blit(*_backSurface, posX, posY, flipping, pPartRect, color, width, height); return true; } void RenderedImage::copyDirectly(int posX, int posY) { - byte *data = _data; - int w = _width; - int h = _height; + byte *data = (byte *)_surface.getPixels(); + int w = _surface.w; + int h = _surface.h; // Handle off-screen clipping if (posY < 0) { - h = MAX(0, (int)_height - -posY); - data = (byte *)_data + _width * -posY; + h = MAX(0, (int)_surface.h - -posY); + data = (byte *)_surface.getPixels() + _surface.w * -posY; posY = 0; } if (posX < 0) { - w = MAX(0, (int)_width - -posX); - data = (byte *)_data + (-posX * 4); + w = MAX(0, (int)_surface.h - -posX); + data = (byte *)_surface.getPixels() + (-posX * 4); posX = 0; } @@ -487,9 +265,9 @@ void RenderedImage::copyDirectly(int posX, int posY) { void RenderedImage::checkForTransparency() { // Check if the source bitmap has any transparent pixels at all _isTransparent = false; - byte *data = _data; - for (int i = 0; i < _height; i++) { - for (int j = 0; j < _width; j++) { + byte *data = (byte *)_surface.getPixels(); + for (int i = 0; i < _surface.h; i++) { + for (int j = 0; j < _surface.w; j++) { _isTransparent = data[3] != 0xff; if (_isTransparent) return; diff --git a/engines/sword25/gfx/image/renderedimage.h b/engines/sword25/gfx/image/renderedimage.h index 3cc9725b12..5b65a27355 100644 --- a/engines/sword25/gfx/image/renderedimage.h +++ b/engines/sword25/gfx/image/renderedimage.h @@ -39,6 +39,7 @@ #include "sword25/kernel/common.h" #include "sword25/gfx/image/image.h" #include "sword25/gfx/graphicengine.h" +#include "graphics/transparent_surface.h" namespace Sword25 { @@ -60,10 +61,10 @@ public: virtual ~RenderedImage(); virtual int getWidth() const { - return _width; + return _surface.w; } virtual int getHeight() const { - return _height; + return _surface.h; } virtual GraphicEngine::COLOR_FORMATS getColorFormat() const { return GraphicEngine::CF_ARGB32; @@ -72,7 +73,7 @@ public: void copyDirectly(int posX, int posY); virtual bool blit(int posX = 0, int posY = 0, - int flipping = Image::FLIP_NONE, + int flipping = Graphics::FLIP_NONE, Common::Rect *pPartRect = NULL, uint color = BS_ARGB(255, 255, 255, 255), int width = -1, int height = -1, @@ -108,9 +109,7 @@ public: virtual bool isSolid() const { return !_isTransparent; } private: - byte *_data; - int _width; - int _height; + Graphics::TransparentSurface _surface; bool _doCleanup; bool _isTransparent; diff --git a/engines/sword25/gfx/image/swimage.h b/engines/sword25/gfx/image/swimage.h index b31c2318ec..60978eb6cc 100644 --- a/engines/sword25/gfx/image/swimage.h +++ b/engines/sword25/gfx/image/swimage.h @@ -55,7 +55,7 @@ public: } virtual bool blit(int posX = 0, int posY = 0, - int flipping = Image::FLIP_NONE, + int flipping = Graphics::FLIP_NONE, Common::Rect *pPartRect = NULL, uint color = BS_ARGB(255, 255, 255, 255), int width = -1, int height = -1, diff --git a/engines/sword25/gfx/image/vectorimage.h b/engines/sword25/gfx/image/vectorimage.h index a99d532e75..057064fc6a 100644 --- a/engines/sword25/gfx/image/vectorimage.h +++ b/engines/sword25/gfx/image/vectorimage.h @@ -209,7 +209,7 @@ public: } virtual bool setContent(const byte *pixeldata, uint size, uint offset, uint stride); virtual bool blit(int posX = 0, int posY = 0, - int flipping = FLIP_NONE, + int flipping = Graphics::FLIP_NONE, Common::Rect *pPartRect = NULL, uint color = BS_ARGB(255, 255, 255, 255), int width = -1, int height = -1, diff --git a/engines/sword25/gfx/image/vectorimagerenderer.cpp b/engines/sword25/gfx/image/vectorimagerenderer.cpp index c7a79fd3c4..c69cb497c1 100644 --- a/engines/sword25/gfx/image/vectorimagerenderer.cpp +++ b/engines/sword25/gfx/image/vectorimagerenderer.cpp @@ -52,7 +52,7 @@ void art_rgb_fill_run1(byte *buf, byte r, byte g, byte b, int n) { memset(buf, g, n + n + n + n); } else { uint32 *alt = (uint32 *)buf; - uint32 color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(0xff, r, g, b); + uint32 color = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(r, g, b, 0xff); for (i = 0; i < n; i++) *alt++ = color; @@ -66,22 +66,22 @@ void art_rgb_run_alpha1(byte *buf, byte r, byte g, byte b, int alpha, int n) { for (i = 0; i < n; i++) { #if defined(SCUMM_LITTLE_ENDIAN) v = *buf; + *buf++ = MIN(v + alpha, 0xff); + v = *buf; *buf++ = v + (((b - v) * alpha + 0x80) >> 8); v = *buf; *buf++ = v + (((g - v) * alpha + 0x80) >> 8); v = *buf; *buf++ = v + (((r - v) * alpha + 0x80) >> 8); - v = *buf; - *buf++ = MIN(v + alpha, 0xff); #else v = *buf; - *buf++ = MIN(v + alpha, 0xff); - v = *buf; *buf++ = v + (((r - v) * alpha + 0x80) >> 8); v = *buf; *buf++ = v + (((g - v) * alpha + 0x80) >> 8); v = *buf; *buf++ = v + (((b - v) * alpha + 0x80) >> 8); + v = *buf; + *buf++ = MIN(v + alpha, 0xff); #endif } } diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp index 14e2012d80..1a6c812508 100644 --- a/engines/sword25/gfx/staticbitmap.cpp +++ b/engines/sword25/gfx/staticbitmap.cpp @@ -98,14 +98,14 @@ bool StaticBitmap::doRender(RectangleList *updateRects) { bool result; if (_scaleFactorX == 1.0f && _scaleFactorY == 1.0f) { result = bitmapResourcePtr->blit(_absoluteX, _absoluteY, - (_flipV ? BitmapResource::FLIP_V : 0) | - (_flipH ? BitmapResource::FLIP_H : 0), + (_flipV ? Graphics::FLIP_V : 0) | + (_flipH ? Graphics::FLIP_H : 0), 0, _modulationColor, -1, -1, updateRects); } else { result = bitmapResourcePtr->blit(_absoluteX, _absoluteY, - (_flipV ? BitmapResource::FLIP_V : 0) | - (_flipH ? BitmapResource::FLIP_H : 0), + (_flipV ? Graphics::FLIP_V : 0) | + (_flipH ? Graphics::FLIP_H : 0), 0, _modulationColor, _width, _height, updateRects); } diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp index b0a9e4ed3f..904435fcb0 100644 --- a/engines/sword25/gfx/text.cpp +++ b/engines/sword25/gfx/text.cpp @@ -99,7 +99,7 @@ void Text::setText(const Common::String &text) { } void Text::setColor(uint32 modulationColor) { - uint32 newModulationColor = (modulationColor & 0x00ffffff) | (_modulationColor & 0xff000000); + uint32 newModulationColor = (modulationColor & 0xffffff00) | (_modulationColor & 0x000000ff); if (newModulationColor != _modulationColor) { _modulationColor = newModulationColor; forceRefresh(); @@ -108,7 +108,7 @@ void Text::setColor(uint32 modulationColor) { void Text::setAlpha(int alpha) { assert(alpha >= 0 && alpha < 256); - uint32 newModulationColor = (_modulationColor & 0x00ffffff) | alpha << 24; + uint32 newModulationColor = (_modulationColor & 0xffffff00) | alpha; if (newModulationColor != _modulationColor) { _modulationColor = newModulationColor; forceRefresh(); @@ -173,7 +173,7 @@ bool Text::doRender(RectangleList *updateRects) { Common::Rect renderRect(curX, curY, curX + curRect.width(), curY + curRect.height()); renderRect.translate(curRect.left - curX, curRect.top - curY); - result = charMapPtr->blit(curX, curY, Image::FLIP_NONE, &renderRect, _modulationColor, -1, -1, updateRects); + result = charMapPtr->blit(curX, curY, Graphics::FLIP_NONE, &renderRect, _modulationColor, -1, -1, updateRects); if (!result) break; |