From dcf70dc6a66c054c6cb9398ff68a12c38cc4223c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 3 Sep 2010 21:49:28 +0000 Subject: SWORD25: Remove redundant colorspace defines and code. svn-id: r53312 --- engines/sword25/gfx/graphicengine.h | 43 --------- engines/sword25/gfx/image/imageloader.h | 151 -------------------------------- engines/sword25/gfx/image/pngloader.cpp | 53 +---------- engines/sword25/gfx/opengl/swimage.cpp | 2 +- 4 files changed, 2 insertions(+), 247 deletions(-) (limited to 'engines/sword25') diff --git a/engines/sword25/gfx/graphicengine.h b/engines/sword25/gfx/graphicengine.h index 07e15b83e3..084c2f1476 100644 --- a/engines/sword25/gfx/graphicengine.h +++ b/engines/sword25/gfx/graphicengine.h @@ -91,32 +91,6 @@ public: enum COLOR_FORMATS { /// Undefined/unknown colour format CF_UNKNOWN = 0, - /// 16-bit colour format (R5G5B5) - CF_RGB15, - /// 16-bit colour format (R5G6R5) - CF_RGB16, - /** - * Special alpha colour format of the engine, which supports very quick display using MMX instructions. - * The pixels are 16-bits wide and have the same format as #CF_RGB15. In addition, each pixel has an 8-bit - * alpha value. - * It summarises groupings of pixels pixels and four alpha values in a 12-byte data block. - * The data is stored in the following order: - * Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3 - * If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have - * arbitrary values. - */ - CF_RGB15_INTERLEAVED, - /** - * Special alpha colour format of the engine, which supports very quick display using MMX instructions. - * The pixels are 16-bits wide and have the same format as #CF_RGB16. In addition, each pixel has an 8-bit - * alpha value. - * It summarises groupings of pixels pixels and four alpha values in a 12-byte data block. - * The data is stored in the following order: - * Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3 - * If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have - * arbitrary values. - */ - CF_RGB16_INTERLEAVED, /** * 24-bit colour format (R8G8B8) */ @@ -314,14 +288,6 @@ public: */ static int GetPixelSize(GraphicEngine::COLOR_FORMATS ColorFormat) { switch (ColorFormat) { - case GraphicEngine::CF_RGB16: - case GraphicEngine::CF_RGB15: - return 2; - - case GraphicEngine::CF_RGB16_INTERLEAVED: - case GraphicEngine::CF_RGB15_INTERLEAVED: - return 3; - case GraphicEngine::CF_ARGB32: return 4; default: @@ -338,16 +304,7 @@ public: */ static int CalcPitch(GraphicEngine::COLOR_FORMATS ColorFormat, int Width) { switch (ColorFormat) { - case GraphicEngine::CF_RGB16: - case GraphicEngine::CF_RGB15: - return Width * 2; - - case GraphicEngine::CF_RGB16_INTERLEAVED: - case GraphicEngine::CF_RGB15_INTERLEAVED: - return (Width + 3) / 4 * 12; - case GraphicEngine::CF_ARGB32: - case GraphicEngine::CF_ABGR32: return Width * 4; default: diff --git a/engines/sword25/gfx/image/imageloader.h b/engines/sword25/gfx/image/imageloader.h index 4f6fb89305..aae48a083c 100644 --- a/engines/sword25/gfx/image/imageloader.h +++ b/engines/sword25/gfx/image/imageloader.h @@ -60,12 +60,7 @@ namespace Sword25 { - Die Klasse muss eine statische Methode haben, die eine Instanz von ihr erzeugt und einen Pointer darauf zurückgibt. - Diese Methode muss in der Liste in der Datei imageloader_ids.h eingetragen werden. - Die Klasse muss JEDES Eingabebild seines Bildformates in die folgenden Farbformate konvertieren können: - - BS_GraphicEngine::CF_RGB16 - - BS_GraphicEngine::CF_RGB15 - - BS_GraphicEngine::CF_RGB16_INTERLEAVED - - BS_GraphicEngine::CF_RGB15_INTERLEAVED - BS_GraphicEngine::CF_ARGB32 - - BS_GraphicEngine::CF_BGRA32 - Zum Konvertieren der Bilddaten können die Hilfsmethoden dieser Klasse benutzt werden, die ARGB Bilddaten in alle benötigten Farbformate konvertieren. */ @@ -86,10 +81,6 @@ public: @param FileSize die Größe der Bilddaten in Byte. @param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.
Folgende Farbformate werden unterstützt: - - BS_GraphicEngine::CF_RGB16 - - BS_GraphicEngine::CF_RGB15 - - BS_GraphicEngine::CF_RGB16_INTERLEAVED - - BS_GraphicEngine::CF_RGB15_INTERLEAVED - BS_GraphicEngine::CF_ARGB32 @param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten. @param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an. @@ -156,10 +147,6 @@ protected: @param FileSize die Größe der Bilddaten in Byte. @param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.
Folgende Farbformate werden unterstützt: - - BS_GraphicEngine::CF_RGB16 - - BS_GraphicEngine::CF_RGB15 - - BS_GraphicEngine::CF_RGB16_INTERLEAVED - - BS_GraphicEngine::CF_RGB15_INTERLEAVED - BS_GraphicEngine::CF_ARGB32 @param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten. @param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an. @@ -193,144 +180,6 @@ protected: //@} - //@{ - /** @name Konvertierungsmethoden */ - - /** - @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16 Farbformat. - @param pSrcData ein Pointer auf die Quelldaten. - @param pDestData ein Pointer auf den Zielpuffern. - @param Width die Anzahl der Pixel in der Bildzeile. - @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.
- Es sind mindestens Width * 2 Byte notwendig. - */ - static void RowARGB32ToRGB16(byte *pSrcData, byte *pDestData, uint Width) { - for (uint i = 0; i < Width; i++) { - ((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 11) | ((pSrcData[1] >> 2) << 5) | (pSrcData[0] >> 3); - pSrcData += 4; - } - } - - /** - @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15 Farbformat. - @param pSrcData ein Pointer auf die Quelldaten. - @param pDestData ein Pointer auf den Zielpuffern. - @param Width die Anzahl der Pixel in der Bildzeile. - @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.
- Es sind mindestens Width * 2 Byte notwendig. - */ - static void RowARGB32ToRGB15(byte *pSrcData, byte *pDestData, uint Width) { - for (uint i = 0; i < Width; i++) { - ((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 10) | ((pSrcData[1] >> 3) << 5) | (pSrcData[0] >> 3); - pSrcData += 4; - } - } - - /** - @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16_INTERLEAVED Farbformat. - @param pSrcData ein Pointer auf die Quelldaten. - @param pDestData ein Pointer auf den Zielpuffern. - @param Width die Anzahl der Pixel in der Bildzeile. - @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß sein muss.
- Es sind mindestens ((Width + 3) / 4) * 12 Byte notwendig. - */ - static void RowARGB32ToRGB16_INTERLEAVED(byte *pSrcData, byte *pDestData, uint Width) { - // Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst - uint BlockFillCount = 0; - uint AlphaBlock = 0; - for (uint i = 0; i < Width; i++) { - // Alphawert in den Alphablock schreiben - AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24); - - // Füllstand der Pixelblockes aktualisieren - BlockFillCount++; - - // Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben - if (BlockFillCount == 4 || i == (Width - 1)) { - // Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte - // "left aligned" sind. - AlphaBlock >>= (4 - BlockFillCount) * 8; - - // Alphablock schreiben - *((uint *)pDestData) = AlphaBlock; - pDestData += 4; - - // Pixel konvertieren und schreiben - RowARGB32ToRGB16(pSrcData, pDestData, BlockFillCount); - - // Pointer auf den nächsten Platz im Zielpuffer setzen - pDestData += 8; - - // Pointer auf die nächsten 4 Pixel im Quellpuffer setzen - pSrcData += 16; - - // Neuen Pixelblock beginnen - BlockFillCount = 0; - } - } - } - - /** - @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15_INTERLEAVED Farbformat. - @param pSrcData ein Pointer auf die Quelldaten. - @param pDestData ein Pointer auf den Zielpuffern. - @param Width die Anzahl der Pixel in der Bildzeile. - @remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.
- Es sind mindestens (Width / 4 + Width % 4) * 3 Byte notwendig. - */ - static void RowARGB32ToRGB15_INTERLEAVED(byte *pSrcData, byte *pDestData, uint Width) { - // Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst - uint BlockFillCount = 0; - uint AlphaBlock = 0; - for (uint i = 0; i < Width; i++) { - // Alphawert in den Alphablock schreiben - AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24); - - // Füllstand der Pixelblockes aktualisieren - BlockFillCount++; - - // Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben - if (BlockFillCount == 4 || i == (Width - 1)) { - // Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte - // "left aligned" sind. - AlphaBlock >>= (4 - BlockFillCount) * 8; - - // Alphablock schreiben - *((uint *)pDestData) = AlphaBlock; - pDestData += 4; - - // Pixel konvertieren und schreiben - RowARGB32ToRGB15(pSrcData, pDestData, BlockFillCount); - - // Pointer auf den nächsten Platz im Zielpuffer setzen - pDestData += 8; - - // Pointer auf die nächsten 4 Pixel im Quellpuffer setzen - pSrcData += 16; - - // Neuen Pixelblock beginnen - BlockFillCount = 0; - } - } - } - - /** - @brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_BGRA32 Farbformat. - @param pSrcData ein Pointer auf die Quelldaten. - @param pDestData ein Pointer auf den Zielpuffern. - @param Width die Anzahl der Pixel in der Bildzeile. - */ - static void RowARGB32ToABGR32(byte *pSrcData, byte *pDestData, uint Width) { - for (uint i = 0; i < Width; ++i) { - *pDestData++ = pSrcData[2]; - *pDestData++ = pSrcData[1]; - *pDestData++ = pSrcData[0]; - *pDestData++ = pSrcData[3]; - - pSrcData += 4; - } - } - private: /** diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp index c7a7b513c1..989eada8e9 100644 --- a/engines/sword25/gfx/image/pngloader.cpp +++ b/engines/sword25/gfx/image/pngloader.cpp @@ -75,12 +75,7 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn int i; // Zielfarbformat überprüfen - if (ColorFormat != GraphicEngine::CF_RGB16 && - ColorFormat != GraphicEngine::CF_RGB15 && - ColorFormat != GraphicEngine::CF_RGB16_INTERLEAVED && - ColorFormat != GraphicEngine::CF_RGB15_INTERLEAVED && - ColorFormat != GraphicEngine::CF_ARGB32 && - ColorFormat != GraphicEngine::CF_ABGR32) { + if (ColorFormat != GraphicEngine::CF_ARGB32) { BS_LOG_ERRORLN("Illegal or unsupported color format."); return false; } @@ -157,31 +152,9 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn // Zeile konvertieren switch (ColorFormat) { - case GraphicEngine::CF_RGB16: - RowARGB32ToRGB16((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - - case GraphicEngine::CF_RGB15: - RowARGB32ToRGB15((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - - case GraphicEngine::CF_RGB16_INTERLEAVED: - RowARGB32ToRGB16_INTERLEAVED((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - - case GraphicEngine::CF_RGB15_INTERLEAVED: - RowARGB32ToRGB15_INTERLEAVED((byte *)RawDataBuffer, - (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - case GraphicEngine::CF_ARGB32: memcpy(&UncompressedDataPtr[i * Pitch], RawDataBuffer, Pitch); break; - - case GraphicEngine::CF_ABGR32: - RowARGB32ToABGR32((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - default: assert(0); } @@ -209,30 +182,6 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn // Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren switch (ColorFormat) { - case GraphicEngine::CF_RGB16: - for (i = 0; i < Height; i++) - RowARGB32ToRGB16((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), - (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - - case GraphicEngine::CF_RGB15: - for (i = 0; i < Height; i++) - RowARGB32ToRGB15((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), - (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - - case GraphicEngine::CF_RGB16_INTERLEAVED: - for (i = 0; i < Height; i++) - RowARGB32ToRGB16_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), - (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - - case GraphicEngine::CF_RGB15_INTERLEAVED: - for (i = 0; i < Height; i++) - RowARGB32ToRGB15_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]), - (byte *)&UncompressedDataPtr[i * Pitch], Width); - break; - case GraphicEngine::CF_ARGB32: for (i = 0; i < Height; i++) memcpy(&UncompressedDataPtr[i * Pitch], &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)], Pitch); diff --git a/engines/sword25/gfx/opengl/swimage.cpp b/engines/sword25/gfx/opengl/swimage.cpp index 33d7435e02..a6a6468f65 100644 --- a/engines/sword25/gfx/opengl/swimage.cpp +++ b/engines/sword25/gfx/opengl/swimage.cpp @@ -77,7 +77,7 @@ SWImage::SWImage(const Common::String &filename, bool &result) : // Das Bild dekomprimieren byte *pUncompressedData; - if (!ImageLoader::LoadImage(pFileData, fileSize, GraphicEngine::CF_ABGR32, pUncompressedData, _width, _height, pitch)) { + if (!ImageLoader::LoadImage(pFileData, fileSize, GraphicEngine::CF_ARGB32, pUncompressedData, _width, _height, pitch)) { BS_LOG_ERRORLN("Could not decode image."); return; } -- cgit v1.2.3