diff options
Diffstat (limited to 'engines/sword25/gfx')
-rw-r--r-- | engines/sword25/gfx/animationtemplate.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/bitmap.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/dynamicbitmap.cpp | 6 | ||||
-rw-r--r-- | engines/sword25/gfx/dynamicbitmap.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/image/image.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/image/vectorimage.cpp | 31 | ||||
-rw-r--r-- | engines/sword25/gfx/image/vectorimage.h | 46 | ||||
-rw-r--r-- | engines/sword25/gfx/image/vectorimagerenderer.cpp | 28 | ||||
-rw-r--r-- | engines/sword25/gfx/image/vectorimagerenderer.h | 7 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/glimage.cpp | 5 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/glimage.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/glvectorimageblit.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/openglgfx.cpp | 66 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/openglgfx.h | 11 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/swimage.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/opengl/swimage.h | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/staticbitmap.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/gfx/staticbitmap.h | 2 |
18 files changed, 121 insertions, 101 deletions
diff --git a/engines/sword25/gfx/animationtemplate.h b/engines/sword25/gfx/animationtemplate.h index 48c20b9910..df94547411 100644 --- a/engines/sword25/gfx/animationtemplate.h +++ b/engines/sword25/gfx/animationtemplate.h @@ -123,7 +123,7 @@ public: virtual bool Unpersist(BS_InputPersistenceBlock &Reader); private: - Common::Array<const Frame> m_Frames; + Common::Array<Frame> m_Frames; BS_AnimationResource *m_SourceAnimationPtr; bool m_Valid; diff --git a/engines/sword25/gfx/bitmap.h b/engines/sword25/gfx/bitmap.h index 00d9308ec5..a6c451d674 100644 --- a/engines/sword25/gfx/bitmap.h +++ b/engines/sword25/gfx/bitmap.h @@ -172,7 +172,7 @@ public: @return Gibt false zurück, falls der Aufruf fehlgeschlagen ist. @remark Ein Aufruf dieser Methode ist nur erlaubt, wenn IsSetContentAllowed() true zurückgibt. */ - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0) = 0; + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset = 0, unsigned int Stride = 0) = 0; virtual bool IsScalingAllowed() const = 0; virtual bool IsAlphaAllowed() const = 0; diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp index 22a0d3d1dd..c042f5b88d 100644 --- a/engines/sword25/gfx/dynamicbitmap.cpp +++ b/engines/sword25/gfx/dynamicbitmap.cpp @@ -123,8 +123,8 @@ bool BS_DynamicBitmap::DoRender() { // ----------------------------------------------------------------------------- -bool BS_DynamicBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) { - return m_Image->SetContent(Pixeldata, Offset, Stride); +bool BS_DynamicBitmap::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) { + return m_Image->SetContent(Pixeldata, size, Offset, Stride); } // ----------------------------------------------------------------------------- @@ -184,7 +184,7 @@ bool BS_DynamicBitmap::Unpersist(BS_InputPersistenceBlock &Reader) { // Bild mit durchsichtigen Bilddaten initialisieren. byte *TransparentImageData = (byte *)calloc(m_Width * m_Height * 4, 1); - m_Image->SetContent(TransparentImageData); + m_Image->SetContent(TransparentImageData, m_Width * m_Height); free(TransparentImageData); Result &= BS_RenderObject::UnpersistChildren(Reader); diff --git a/engines/sword25/gfx/dynamicbitmap.h b/engines/sword25/gfx/dynamicbitmap.h index 04d1ce5c7a..4209c6e1a6 100644 --- a/engines/sword25/gfx/dynamicbitmap.h +++ b/engines/sword25/gfx/dynamicbitmap.h @@ -62,7 +62,7 @@ public: virtual unsigned int GetPixel(int X, int Y) const; - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride); + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride); virtual bool IsScalingAllowed() const; virtual bool IsAlphaAllowed() const; diff --git a/engines/sword25/gfx/image/image.h b/engines/sword25/gfx/image/image.h index 1489af97b3..805a4b80a5 100644 --- a/engines/sword25/gfx/image/image.h +++ b/engines/sword25/gfx/image/image.h @@ -165,7 +165,7 @@ public: @return Gibt false zurück, falls der Aufruf fehlgeschlagen ist. @remark Ein Aufruf dieser Methode ist nur erlaubt, wenn IsSetContentAllowed() true zurückgibt. */ - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) = 0; + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) = 0; /** @brief Liest einen Pixel des Bildes. diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp index 9e3e2fef71..549ef96d39 100644 --- a/engines/sword25/gfx/image/vectorimage.cpp +++ b/engines/sword25/gfx/image/vectorimage.cpp @@ -38,12 +38,8 @@ #include "sword25/kernel/bs_stdint.h" #include "sword25/gfx/image/vectorimage.h" -#include <vector> -#include <stdexcept> -#include "agg_bounding_rect.h" - -using namespace std; +#include "graphics/colormasks.h" namespace Sword25 { @@ -195,9 +191,9 @@ BS_Rect FlashRectToBSRect(BS_VectorImage::SWFBitStream &bs) { // Konvertiert SWF-Farben in AntiGrain Farben // ----------------------------------------------------------------------------- -agg::rgba8 FlashColorToAGGRGBA8(unsigned int FlashColor) { - agg::rgba8 ResultColor((FlashColor >> 16) & 0xff, (FlashColor >> 8) & 0xff, FlashColor & 0xff, FlashColor >> 24); - ResultColor.premultiply(); +uint32 FlashColorToAGGRGBA8(unsigned int FlashColor) { + uint32 ResultColor = Graphics::ARGBToColor<Graphics::ColorMasks<8888> >(FlashColor >> 24, (FlashColor >> 16) & 0xff, (FlashColor >> 8) & 0xff, FlashColor & 0xff); + return ResultColor; } @@ -215,12 +211,16 @@ struct CBBGetId { }; BS_Rect CalculateBoundingBox(const BS_VectorImageElement &VectorImageElement) { +#if 0 // TODO agg::path_storage Path = VectorImageElement.GetPaths(); CBBGetId IdSource(VectorImageElement); double x1, x2, y1, y2; agg::bounding_rect(Path, IdSource, 0, VectorImageElement.GetPathCount(), &x1, &y1, &x2, &y2); - +#else + double x1, x2, y1, y2; + x1 = x2 = y1 = y2 = 0; +#endif return BS_Rect(static_cast<int>(x1), static_cast<int>(y1), static_cast<int>(x2) + 1, static_cast<int>(y2) + 1); } } @@ -388,6 +388,7 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs) // Ein neuen Pfad erzeugen, es sei denn, es wurden nur neue Styles definiert if (StateLineStyle || StateFillStyle0 || StateFillStyle1 || StateMoveTo) { // Letzte Zeichenposition merken, beim Aufruf von start_new_path() wird die Zeichenpostionen auf 0, 0 zurückgesetzt +#if 0 // TODO double LastX = m_Elements.back().m_Paths.last_x(); double LastY = m_Elements.back().m_Paths.last_y(); @@ -400,6 +401,7 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs) m_Elements.back().m_Paths.move_to(MoveDeltaX, MoveDeltaY); else m_Elements.back().m_Paths.move_to(LastX, LastY); +#endif } } } else { @@ -414,11 +416,13 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs) s32 AnchorDeltaX = bs.GetSignedBits(NumBits); s32 AnchorDeltaY = bs.GetSignedBits(NumBits); +#if 0 // TODO double ControlX = m_Elements.back().m_Paths.last_x() + ControlDeltaX; double ControlY = m_Elements.back().m_Paths.last_y() + ControlDeltaY; double AnchorX = ControlX + AnchorDeltaX; double AnchorY = ControlY + AnchorDeltaY; m_Elements.back().m_Paths.curve3(ControlX, ControlY, AnchorX, AnchorY); +#endif } else { // Staight edge s32 DeltaX = 0; @@ -436,13 +440,15 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs) DeltaX = bs.GetSignedBits(NumBits); } +#if 0 // TODO m_Elements.back().m_Paths.line_rel(DeltaX, DeltaY); +#endif } } } // Bounding-Boxes der einzelnen Elemente berechnen - vector<BS_VectorImageElement>::iterator it = m_Elements.begin(); + Common::Array<BS_VectorImageElement>::iterator it = m_Elements.begin(); for (; it != m_Elements.end(); ++it) it->m_BoundingBox = CalculateBoundingBox(*it); return true; @@ -481,7 +487,8 @@ bool BS_VectorImage::ParseStyles(unsigned int ShapeType, SWFBitStream &bs, unsig // Anzahl an Linestyles bestimmen unsigned int LineStyleCount = bs.GetU8(); - if (LineStyleCount == 0xff) LineStyleCount = bs.GetU16(); + if (LineStyleCount == 0xff) + LineStyleCount = bs.GetU16(); // Alle Linestyles einlesen m_Elements.back().m_LineStyles.reserve(LineStyleCount); @@ -521,7 +528,7 @@ unsigned int BS_VectorImage::GetPixel(int X, int Y) { // ----------------------------------------------------------------------------- -bool BS_VectorImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) { +bool BS_VectorImage::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) { BS_LOG_ERRORLN("SetContent() is not supported."); return 0; } diff --git a/engines/sword25/gfx/image/vectorimage.h b/engines/sword25/gfx/image/vectorimage.h index f791a36f03..b17951bbdf 100644 --- a/engines/sword25/gfx/image/vectorimage.h +++ b/engines/sword25/gfx/image/vectorimage.h @@ -43,10 +43,10 @@ #include "sword25/gfx/image/image.h" #include "sword25/math/rect.h" +#if 0 #include <vector> #include "agg_path_storage.h" -#include "agg_color_rgba.h" - +#endif namespace Sword25 { @@ -62,7 +62,11 @@ class BS_VectorImage; class BS_VectorPathInfo { public: BS_VectorPathInfo(unsigned int ID, unsigned int LineStyle, unsigned int FillStyle0, unsigned int FillStyle1) : - m_ID(ID), m_LineStyle(LineStyle), m_FillStyle0(FillStyle0), m_FillStyle1(FillStyle1) {}; + m_ID(ID), m_LineStyle(LineStyle), m_FillStyle0(FillStyle0), m_FillStyle1(FillStyle1) {} + + BS_VectorPathInfo() { + m_ID = m_LineStyle = m_FillStyle0 = m_FillStyle1 = 0; + } unsigned int GetID() const { return m_ID; @@ -90,15 +94,18 @@ private: Werden alle Elemente eines Vektorbildes übereinandergelegt, ergibt sich das komplette Bild. */ class BS_VectorImageElement { - friend BS_VectorImage; + friend class BS_VectorImage; public: - const agg::path_storage &GetPaths() const { +#if 0 // TODO + const agg::path_storage &GetPaths() const { return m_Paths; } - unsigned int GetPathCount() const { +#endif + + unsigned int GetPathCount() const { return m_PathInfos.size(); } - const BS_VectorPathInfo &GetPathInfo(unsigned int PathNr) const { + const BS_VectorPathInfo &GetPathInfo(unsigned int PathNr) const { BS_ASSERT(PathNr < GetPathCount()); return m_PathInfos[PathNr]; } @@ -112,7 +119,7 @@ public: return m_LineStyles.size(); } - const agg::rgba8 &GetLineStyleColor(unsigned int LineStyle) const { + uint32 GetLineStyleColor(unsigned int LineStyle) const { BS_ASSERT(LineStyle < m_LineStyles.size()); return m_LineStyles[LineStyle].Color; } @@ -121,7 +128,7 @@ public: return m_FillStyles.size(); } - const agg::rgba8 &GetFillStyleColor(unsigned int FillStyle) const { + uint32 GetFillStyleColor(unsigned int FillStyle) const { BS_ASSERT(FillStyle < m_FillStyles.size()); return m_FillStyles[FillStyle]; } @@ -132,16 +139,19 @@ public: private: struct LineStyleType { - LineStyleType(double Width_, const agg::rgba8 &Color_) : Width(Width_), Color(Color_) {}; - double Width; - agg::rgba8 Color; + LineStyleType(double Width_, uint32 Color_) : Width(Width_), Color(Color_) {} + LineStyleType() { Width = 0; Color = 0; } + double Width; + uint32 Color; }; - agg::path_storage m_Paths; - Common::Array<BS_VectorPathInfo> m_PathInfos; - Common::Array<LineStyleType> m_LineStyles; - Common::Array<agg::rgba8> m_FillStyles; - BS_Rect m_BoundingBox; +#if 0 // TODO + agg::path_storage m_Paths; +#endif + Common::Array<BS_VectorPathInfo> m_PathInfos; + Common::Array<LineStyleType> m_LineStyles; + Common::Array<uint32> m_FillStyles; + BS_Rect m_BoundingBox; }; @@ -201,7 +211,7 @@ public: virtual bool IsSetContentAllowed() const { return false; } - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride); + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride); virtual bool Blit(int PosX = 0, int PosY = 0, int Flipping = FLIP_NONE, BS_Rect *pPartRect = NULL, diff --git a/engines/sword25/gfx/image/vectorimagerenderer.cpp b/engines/sword25/gfx/image/vectorimagerenderer.cpp index 0c7f93c130..1b7fe29cdf 100644 --- a/engines/sword25/gfx/image/vectorimagerenderer.cpp +++ b/engines/sword25/gfx/image/vectorimagerenderer.cpp @@ -38,13 +38,16 @@ #include "sword25/gfx/image/vectorimagerenderer.h" #include "sword25/gfx/image/vectorimage.h" + +#if 0 // TODO #include "agg_conv_curve.h" #include "agg_path_storage.h" #include "agg_conv_stroke.h" - +#endif namespace Sword25 { +#if 0 // TODO // ----------------------------------------------------------------------------- // CompoundShape // ----------------------------------------------------------------------------- @@ -109,23 +112,16 @@ private: const BS_VectorImageElement &m_ImageElement; }; - -// ----------------------------------------------------------------------------- -// Konstruktion -// ----------------------------------------------------------------------------- - BS_VectorImageRenderer::BS_VectorImageRenderer() : PixelFormat(rbuf) { } -// ----------------------------------------------------------------------------- - bool BS_VectorImageRenderer::Render(const BS_VectorImage &VectorImage, float ScaleFactorX, float ScaleFactorY, unsigned int &Width, unsigned int &Height, - Common::Array<char> & ImageData, + byte *ImageData, float LineScaleFactor, bool NoAlphaShapes) { Width = static_cast<unsigned int>(VectorImage.GetWidth() * ScaleFactorX); @@ -200,4 +196,18 @@ bool BS_VectorImageRenderer::Render(const BS_VectorImage &VectorImage, return true; } +#else + +BS_VectorImageRenderer::BS_VectorImageRenderer() {} + +bool BS_VectorImageRenderer::Render(const BS_VectorImage &VectorImage, + float ScaleFactorX, float ScaleFactorY, + unsigned int &Width, unsigned int &Height, + byte *ImageData, + float LineScaleFactor, + bool NoAlphaShapes) { + return true; +} +#endif + } // End of namespace Sword25 diff --git a/engines/sword25/gfx/image/vectorimagerenderer.h b/engines/sword25/gfx/image/vectorimagerenderer.h index ed073abb56..41e633ba76 100644 --- a/engines/sword25/gfx/image/vectorimagerenderer.h +++ b/engines/sword25/gfx/image/vectorimagerenderer.h @@ -40,8 +40,8 @@ // ----------------------------------------------------------------------------- #include "sword25/kernel/common.h" -#include <vector> +#if 0 // TODO #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" #include "agg_renderer_scanline.h" @@ -51,6 +51,7 @@ #include "agg_scanline_bin.h" #include "agg_trans_affine.h" #include "agg_span_allocator.h" +#endif namespace Sword25 { @@ -68,11 +69,12 @@ public: bool Render(const BS_VectorImage &VectorImage, float ScaleFactorX, float ScaleFactorY, unsigned int &Width, unsigned int &Height, - Common::Array<char> & ImageData, + byte *ImageData, float LineScaleFactor = 1.0f, bool NoAlphaShapes = false); private: +#if 0 typedef agg::pixfmt_rgba32_pre PixelFormatType; typedef agg::renderer_base<PixelFormatType> BaseRendererType; typedef agg::renderer_scanline_aa_solid<BaseRendererType> ScanlineRendererType; @@ -87,6 +89,7 @@ private: agg::scanline_bin ScanlineBin; agg::trans_affine Scale; agg::span_allocator<agg::rgba8> Alloc; +#endif }; } // End of namespace Sword25 diff --git a/engines/sword25/gfx/opengl/glimage.cpp b/engines/sword25/gfx/opengl/glimage.cpp index 1434a93e4e..d5e1376299 100644 --- a/engines/sword25/gfx/opengl/glimage.cpp +++ b/engines/sword25/gfx/opengl/glimage.cpp @@ -36,7 +36,6 @@ // INCLUDES // ----------------------------------------------------------------------------- -#include "sword25/util/glsprites/glsprites.h" #include "sword25/package/packagemanager.h" #include "sword25/gfx/image/imageloader.h" #include "sword25/gfx/opengl/openglgfx.h" @@ -139,9 +138,9 @@ bool BS_GLImage::Fill(const BS_Rect *pFillRect, unsigned int Color) { // ----------------------------------------------------------------------------- -bool BS_GLImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) { +bool BS_GLImage::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) { // Überprüfen, ob PixelData ausreichend viele Pixel enthält um ein Bild der Größe Width * Height zu erzeugen - if (Pixeldata.size() < static_cast<unsigned int>(m_Width * m_Height * 4)) { + if (size < static_cast<unsigned int>(m_Width * m_Height * 4)) { BS_LOG_ERRORLN("PixelData vector is too small to define a 32 bit %dx%d image.", m_Width, m_Height); return false; } diff --git a/engines/sword25/gfx/opengl/glimage.h b/engines/sword25/gfx/opengl/glimage.h index c5a7480874..9679089cee 100644 --- a/engines/sword25/gfx/opengl/glimage.h +++ b/engines/sword25/gfx/opengl/glimage.h @@ -88,7 +88,7 @@ public: unsigned int Color = BS_ARGB(255, 255, 255, 255), int Width = -1, int Height = -1); virtual bool Fill(const BS_Rect *pFillRect, unsigned int Color); - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset = 0, unsigned int Stride = 0); + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset = 0, unsigned int Stride = 0); virtual unsigned int GetPixel(int X, int Y); virtual bool IsBlitSource() const { diff --git a/engines/sword25/gfx/opengl/glvectorimageblit.cpp b/engines/sword25/gfx/opengl/glvectorimageblit.cpp index 9368e921e1..5689fdfcba 100644 --- a/engines/sword25/gfx/opengl/glvectorimageblit.cpp +++ b/engines/sword25/gfx/opengl/glvectorimageblit.cpp @@ -62,7 +62,7 @@ bool BS_VectorImage::Blit(int PosX, int PosY, unsigned int Color, int Width, int Height) { static BS_VectorImageRenderer VectorImageRenderer; - static vector<char> PixelData; + static byte *PixelData; static GLS_Sprite Sprite = 0; static BS_VectorImage *OldThis = 0; static int OldWidth; @@ -98,7 +98,7 @@ bool BS_VectorImage::Blit(int PosX, int PosY, return true; } - GLS_Result Result = GLS_SetSpriteData(Sprite, RenderedWidth, RenderedHeight, &PixelData[0], 0); + GLS_Result Result = GLS_SetSpriteData(Sprite, RenderedWidth, RenderedHeight, PixelData, 0); if (Result != GLS_OK) { BS_LOG_ERRORLN("Call to GLS_SetSpriteData() failed. Reason: %s", GLS_ResultString(Result)); return false; diff --git a/engines/sword25/gfx/opengl/openglgfx.cpp b/engines/sword25/gfx/opengl/openglgfx.cpp index 612e1c209e..6937efb813 100644 --- a/engines/sword25/gfx/opengl/openglgfx.cpp +++ b/engines/sword25/gfx/opengl/openglgfx.cpp @@ -55,12 +55,8 @@ #include "sword25/gfx/opengl/glimage.h" #include "sword25/gfx/opengl/swimage.h" -#include <algorithm> - namespace Sword25 { -using namespace std; - #define BS_LOG_PREFIX "OPENGLGFX" @@ -266,48 +262,50 @@ bool BS_OpenGLGfx::Fill(const BS_Rect *FillRectPtr, unsigned int Color) { // ----------------------------------------------------------------------------- -bool BS_OpenGLGfx::GetScreenshot(unsigned int &Width, unsigned int &Height, vector<unsigned int> & Data) { - if (!ReadFramebufferContents(m_Width, m_Height, Data)) return false; +bool BS_OpenGLGfx::GetScreenshot(unsigned int &Width, unsigned int &Height, byte **Data) { + if (!ReadFramebufferContents(m_Width, m_Height, Data)) + return false; // Die Größe des Framebuffers zurückgeben. Width = m_Width; Height = m_Height; // Bilddaten vom OpenGL-Format in unser eigenes Format umwandeln. - ReverseRGBAComponentOrder(Data); - FlipImagedataVertical(Width, Height, Data); + ReverseRGBAComponentOrder(*Data, Width * Height); + FlipImagedataVertical(Width, Height, *Data); return true; } // ----------------------------------------------------------------------------- -bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data) { - Data.resize(Width * Height); - glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &Data[0]); +bool BS_OpenGLGfx::ReadFramebufferContents(unsigned int Width, unsigned int Height, byte **Data) { + *Data = (byte *)malloc(Width * Height * 4); + glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, *Data); if (glGetError() == 0) return true; else { - Data.clear(); return false; } } // ----------------------------------------------------------------------------- -void BS_OpenGLGfx::ReverseRGBAComponentOrder(vector<unsigned int> & Data) { - vector<unsigned int>::iterator It = Data.begin(); - while (It != Data.end()) { - unsigned int Pixel = *It; - *It = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16); - ++It; +void BS_OpenGLGfx::ReverseRGBAComponentOrder(byte *Data, uint size) { + uint32 *ptr = (uint32 *)Data; + + for (uint i = 0; i < size; i++) { + unsigned int Pixel = *ptr; + *ptr = (Pixel & 0xff00ff00) | ((Pixel >> 16) & 0xff) | ((Pixel & 0xff) << 16); + ++ptr; } } // ----------------------------------------------------------------------------- -void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height, vector<unsigned int> & Data) { +void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height, byte *Data) { +#if 0 // TODO vector<unsigned int> LineBuffer(Width); for (unsigned int Y = 0; Y < Height / 2; ++Y) { @@ -317,26 +315,18 @@ void BS_OpenGLGfx::FlipImagedataVertical(unsigned int Width, unsigned int Height copy(Line2It, Line2It + Width, Line1It); copy(LineBuffer.begin(), LineBuffer.end(), Line2It); } +#endif } // ----------------------------------------------------------------------------- // RESOURCE MANAGING // ----------------------------------------------------------------------------- -static bool DoesStringEndWith(const Common::String &String, const std::string &OtherString) { - Common::String::size_type StringPos = String.rfind(OtherString); - if (StringPos == Common::String::npos) return false; - - return StringPos + OtherString.size() == String.size(); -} - -// ----------------------------------------------------------------------------- - BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) { BS_ASSERT(CanLoadResource(FileName)); // Bild für den Softwarebuffer laden - if (DoesStringEndWith(FileName, PNG_S_EXTENSION)) { + if (FileName.hasSuffix(PNG_S_EXTENSION)) { bool Result; BS_SWImage *pImage = new BS_SWImage(FileName, Result); if (!Result) { @@ -354,7 +344,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) { } // Sprite-Bild laden - if (DoesStringEndWith(FileName, PNG_EXTENSION) || DoesStringEndWith(FileName, B25S_EXTENSION)) { + if (FileName.hasSuffix(PNG_EXTENSION) || FileName.hasSuffix(B25S_EXTENSION)) { bool Result; BS_GLImage *pImage = new BS_GLImage(FileName, Result); if (!Result) { @@ -373,7 +363,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) { // Vectorgraphik laden - if (DoesStringEndWith(FileName, SWF_EXTENSION)) { + if (FileName.hasSuffix(SWF_EXTENSION)) { // Pointer auf Package-Manager holen BS_PackageManager *pPackage = BS_Kernel::GetInstance()->GetPackage(); BS_ASSERT(pPackage); @@ -406,7 +396,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) { } // Animation laden - if (DoesStringEndWith(FileName, ANI_EXTENSION)) { + if (FileName.hasSuffix(ANI_EXTENSION)) { BS_AnimationResource *pResource = new BS_AnimationResource(FileName); if (pResource->IsValid()) return pResource; @@ -417,7 +407,7 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) { } // Font laden - if (DoesStringEndWith(FileName, FNT_EXTENSION)) { + if (FileName.hasSuffix(FNT_EXTENSION)) { BS_FontResource *pResource = new BS_FontResource(BS_Kernel::GetInstance(), FileName); if (pResource->IsValid()) return pResource; @@ -434,11 +424,11 @@ BS_Resource *BS_OpenGLGfx::LoadResource(const Common::String &FileName) { // ----------------------------------------------------------------------------- bool BS_OpenGLGfx::CanLoadResource(const Common::String &FileName) { - return DoesStringEndWith(FileName, PNG_EXTENSION) || - DoesStringEndWith(FileName, ANI_EXTENSION) || - DoesStringEndWith(FileName, FNT_EXTENSION) || - DoesStringEndWith(FileName, SWF_EXTENSION) || - DoesStringEndWith(FileName, B25S_EXTENSION); + return FileName.hasSuffix(PNG_EXTENSION) || + FileName.hasSuffix(ANI_EXTENSION) || + FileName.hasSuffix(FNT_EXTENSION) || + FileName.hasSuffix(SWF_EXTENSION) || + FileName.hasSuffix(B25S_EXTENSION); } diff --git a/engines/sword25/gfx/opengl/openglgfx.h b/engines/sword25/gfx/opengl/openglgfx.h index 5a7ca8a85e..ae56ff7fe3 100644 --- a/engines/sword25/gfx/opengl/openglgfx.h +++ b/engines/sword25/gfx/opengl/openglgfx.h @@ -84,7 +84,7 @@ public: virtual bool GetVsync() const; virtual bool Fill(const BS_Rect *FillRectPtr = 0, unsigned int Color = BS_RGB(0, 0, 0)); - virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, Common::Array<unsigned int> & Data); + virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, byte **Data); // Resource-Managing Methoden // -------------------------- @@ -112,7 +112,8 @@ private: DebugLine(const BS_Vertex &_Start, const BS_Vertex &_End, unsigned int _Color) : Start(_Start), End(_End), - Color(_Color) {}; + Color(_Color) {} + DebugLine() {} BS_Vertex Start; BS_Vertex End; @@ -121,9 +122,9 @@ private: Common::Array<DebugLine> m_DebugLines; - static bool ReadFramebufferContents(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data); - static void ReverseRGBAComponentOrder(Common::Array<unsigned int> & Data); - static void FlipImagedataVertical(unsigned int Width, unsigned int Height, Common::Array<unsigned int> & Data); + static bool ReadFramebufferContents(unsigned int Width, unsigned int Height, byte **Data); + static void ReverseRGBAComponentOrder(byte *Data, uint size); + static void FlipImagedataVertical(unsigned int Width, unsigned int Height, byte *Data); }; } // End of namespace Sword25 diff --git a/engines/sword25/gfx/opengl/swimage.cpp b/engines/sword25/gfx/opengl/swimage.cpp index 5eebf44b10..f3aa9c1533 100644 --- a/engines/sword25/gfx/opengl/swimage.cpp +++ b/engines/sword25/gfx/opengl/swimage.cpp @@ -118,7 +118,7 @@ bool BS_SWImage::Fill(const BS_Rect *pFillRect, unsigned int Color) { // ----------------------------------------------------------------------------- -bool BS_SWImage::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) { + bool BS_SWImage::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) { BS_LOG_ERRORLN("SetContent() is not supported."); return false; } diff --git a/engines/sword25/gfx/opengl/swimage.h b/engines/sword25/gfx/opengl/swimage.h index 870cbeb830..d6e066661c 100644 --- a/engines/sword25/gfx/opengl/swimage.h +++ b/engines/sword25/gfx/opengl/swimage.h @@ -71,7 +71,7 @@ public: unsigned int Color = BS_ARGB(255, 255, 255, 255), int Width = -1, int Height = -1); virtual bool Fill(const BS_Rect *FillRectPtr, unsigned int Color); - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride); + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride); virtual unsigned int GetPixel(int X, int Y); virtual bool IsBlitSource() const { diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp index f4ad8151dc..00df44c83a 100644 --- a/engines/sword25/gfx/staticbitmap.cpp +++ b/engines/sword25/gfx/staticbitmap.cpp @@ -152,7 +152,7 @@ unsigned int BS_StaticBitmap::GetPixel(int X, int Y) const { // ----------------------------------------------------------------------------- -bool BS_StaticBitmap::SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride) { +bool BS_StaticBitmap::SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride) { BS_LOG_ERRORLN("SetContent() ist not supported with this object."); return false; } diff --git a/engines/sword25/gfx/staticbitmap.h b/engines/sword25/gfx/staticbitmap.h index 816f2a2b20..b5b2aac64a 100644 --- a/engines/sword25/gfx/staticbitmap.h +++ b/engines/sword25/gfx/staticbitmap.h @@ -63,7 +63,7 @@ public: virtual unsigned int GetPixel(int X, int Y) const; - virtual bool SetContent(const byte *Pixeldata, unsigned int Offset, unsigned int Stride); + virtual bool SetContent(const byte *Pixeldata, uint size, unsigned int Offset, unsigned int Stride); virtual bool IsScalingAllowed() const; virtual bool IsAlphaAllowed() const; |