aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/gfx/image/vectorimage.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2010-09-03 23:02:00 +0000
committerEugene Sandulenko2010-10-12 23:34:25 +0000
commit7032c209a7e8bbd77bc7638f1a173a992bdb5e81 (patch)
tree7657c701d1edd8e218f233546f8ed4cac950e079 /engines/sword25/gfx/image/vectorimage.cpp
parent5f83fd19540c3072f50edff0acddf1cb6a072b78 (diff)
downloadscummvm-rg350-7032c209a7e8bbd77bc7638f1a173a992bdb5e81.tar.gz
scummvm-rg350-7032c209a7e8bbd77bc7638f1a173a992bdb5e81.tar.bz2
scummvm-rg350-7032c209a7e8bbd77bc7638f1a173a992bdb5e81.zip
SWORD25: Initial code for vector image rendering. Crashes badly.
svn-id: r53314
Diffstat (limited to 'engines/sword25/gfx/image/vectorimage.cpp')
-rw-r--r--engines/sword25/gfx/image/vectorimage.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp
index 45e81b6f71..42cac1aaa1 100644
--- a/engines/sword25/gfx/image/vectorimage.cpp
+++ b/engines/sword25/gfx/image/vectorimage.cpp
@@ -43,6 +43,8 @@
#include <libart_lgpl/art_vpath_bpath.h>
+#include "sword25/gfx/opengl/glimage.h"
+
namespace Sword25 {
#define BS_LOG_PREFIX "VECTORIMAGE"
@@ -230,7 +232,7 @@ Common::Rect CalculateBoundingBox(const VectorImageElement &vectorImageElement)
// Konstruktion
// -----------------------------------------------------------------------------
-VectorImage::VectorImage(const byte *pFileData, uint fileSize, bool &success) {
+VectorImage::VectorImage(const byte *pFileData, uint fileSize, bool &success) : _pixelData(0) {
success = false;
// Bitstream-Objekt erzeugen
@@ -312,6 +314,9 @@ VectorImage::~VectorImage() {
for (int i = _elements[j].getPathCount() - 1; i >= 0; i--)
if (_elements[j].getPathInfo(i).getVec())
art_free(_elements[j].getPathInfo(i).getVec());
+
+ if (_pixelData)
+ free(_pixelData);
}
@@ -591,4 +596,42 @@ bool VectorImage::setContent(const byte *pixeldata, uint size, uint offset, uint
return 0;
}
+bool VectorImage::blit(int posX, int posY,
+ int flipping,
+ Common::Rect *pPartRect,
+ uint color,
+ int width, int height) {
+ static VectorImage *oldThis = 0;
+ static int oldWidth = -2;
+ static int oldHeight = -2;
+
+ // Falls Breite oder Höhe 0 sind, muss nichts dargestellt werden.
+ if (width == 0 || height == 0)
+ return true;
+
+ // Feststellen, ob das alte Bild im Cache nicht wiederbenutzt werden kann und neu Berechnet werden muss
+ if (!(oldThis == this && oldWidth == width && oldHeight == height)) {
+ float ScaleFactorX = (width == - 1) ? 1 : static_cast<float>(width) / static_cast<float>(getWidth());
+ float ScaleFactorY = (height == - 1) ? 1 : static_cast<float>(height) / static_cast<float>(getHeight());
+
+ uint RenderedWidth;
+ uint RenderedHeight;
+
+ render(ScaleFactorX, ScaleFactorY, RenderedWidth, RenderedHeight);
+
+ oldThis = this;
+ oldHeight = height;
+ oldWidth = width;
+ }
+
+ GLImage *rend = new GLImage();
+
+ rend->replaceContent(_pixelData, width, height);
+ rend->blit(posX, posY, flipping, pPartRect, color, width, height);
+
+ delete rend;
+
+ return true;
+}
+
} // End of namespace Sword25