summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-06 15:26:12 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-06 15:26:12 +0300
commitfdbd1a4c521c537597b63cd4f2262517cab1f81a (patch)
treea873f6567942bfc8241703eb34a00abc671a2999
parent4fb8f9f0905038f3180f108ec56b2a326ceb3483 (diff)
downloadmanaplus-fdbd1a4c521c537597b63cd4f2262517cab1f81a.tar.gz
manaplus-fdbd1a4c521c537597b63cd4f2262517cab1f81a.tar.bz2
manaplus-fdbd1a4c521c537597b63cd4f2262517cab1f81a.tar.xz
manaplus-fdbd1a4c521c537597b63cd4f2262517cab1f81a.zip
Improve map draw speed in fast opengl.
-rw-r--r--src/graphics.cpp5
-rw-r--r--src/graphics.h3
-rw-r--r--src/maplayer.cpp7
-rw-r--r--src/normalopenglgraphics.cpp4
-rw-r--r--src/normalopenglgraphics.h3
-rw-r--r--src/resources/image.cpp10
-rw-r--r--src/resources/image.h5
-rw-r--r--src/safeopenglgraphics.cpp1
-rw-r--r--src/safeopenglgraphics.h3
9 files changed, 26 insertions, 15 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 19c53c83a..8b83880a7 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -785,6 +785,11 @@ void Graphics::calcImagePattern(GraphicsVertexes* const vert,
vert->incPtr(1);
}
+void Graphics::calcTile(ImageVertexes *const vert, const Image *const image,
+ int x, int y)
+{
+}
+
void Graphics::calcTile(ImageVertexes *const vert, int x, int y)
{
// Check that preconditions for blitting are met.
diff --git a/src/graphics.h b/src/graphics.h
index cdfc092fe..b95bb3779 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -206,6 +206,9 @@ class Graphics : public gcn::SDLGraphics
const int x, const int y,
const int w, const int h);
+ virtual void calcTile(ImageVertexes *const vert,
+ const Image *const image, int x, int y);
+
virtual void calcTile(ImageVertexes *const vert, int x, int y);
virtual void drawTile(const ImageVertexes *const vert);
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index cf40cfae7..f79c8c042 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -232,6 +232,7 @@ void MapLayer::updateOGL(Graphics *const graphics, int startX, int startY,
const int scrollX, const int scrollY,
const int debugFlags)
{
+#ifdef USE_OPENGL
delete_all(mTempRows);
mTempRows.clear();
@@ -276,7 +277,7 @@ void MapLayer::updateOGL(Graphics *const graphics, int startX, int startY,
const int py = py0 - img->mBounds.h;
if (flag || img->mBounds.h <= 32)
{
- if (lastImage != img)
+ if (!lastImage || lastImage->mGLImage != img->mGLImage)
{
if (img->mBounds.w > 32)
imgSet.clear();
@@ -294,11 +295,13 @@ void MapLayer::updateOGL(Graphics *const graphics, int startX, int startY,
}
lastImage = img;
}
- graphics->calcTile(imgVert, px, py);
+ lastImage = img;
+ graphics->calcTile(imgVert, lastImage, px, py);
}
}
}
}
+#endif
}
void MapLayer::drawOGL(Graphics *const graphics)
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index 4f3fd2aa2..b0e09b9eb 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -802,12 +802,12 @@ void NormalOpenGLGraphics::calcImagePattern(GraphicsVertexes *const vert,
}
void NormalOpenGLGraphics::calcTile(ImageVertexes *const vert,
+ const Image *const image,
int dstX, int dstY)
{
- if (!vert)
+ if (!vert || !image)
return;
- Image *image = vert->image;
const int srcX = image->mBounds.x;
const int srcY = image->mBounds.y;
diff --git a/src/normalopenglgraphics.h b/src/normalopenglgraphics.h
index b2cb90e67..64649f5c8 100644
--- a/src/normalopenglgraphics.h
+++ b/src/normalopenglgraphics.h
@@ -87,7 +87,8 @@ class NormalOpenGLGraphics final : public Graphics
const int x, const int y,
const int w, const int h) override;
- void calcTile(ImageVertexes *const vert, int x, int y) override;
+ void calcTile(ImageVertexes *const vert, const Image *const image,
+ int x, int y) override;
void drawTile(const ImageVertexes *const vert) override;
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 0e2423bf9..6fa0b5bf5 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -46,6 +46,9 @@
Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0,
uint8_t *const alphaChannel) :
Resource(),
+#ifdef USE_OPENGL
+ mGLImage(0),
+#endif
mLoaded(false),
mAlpha(1.0f),
mHasAlphaChannel(hasAlphaChannel0),
@@ -53,12 +56,7 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0,
mAlphaChannel(alphaChannel),
mUseAlphaCache(SDLImageHelper::mEnableAlphaCache),
mIsAlphaVisible(hasAlphaChannel0),
-#ifdef USE_OPENGL
- mIsAlphaCalculated(false),
- mGLImage(0)
-#else
mIsAlphaCalculated(false)
-#endif
{
mBounds.x = 0;
mBounds.y = 0;
@@ -83,6 +81,7 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0,
Image::Image(const GLuint glimage, const int width, const int height,
const int texWidth, const int texHeight) :
Resource(),
+ mGLImage(glimage),
mLoaded(false),
mAlpha(1.0f),
mHasAlphaChannel(true),
@@ -91,7 +90,6 @@ Image::Image(const GLuint glimage, const int width, const int height,
mUseAlphaCache(false),
mIsAlphaVisible(true),
mIsAlphaCalculated(false),
- mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight)
{
diff --git a/src/resources/image.h b/src/resources/image.h
index 8fafc87aa..26498e988 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -143,8 +143,6 @@ class Image : public Resource
void SDLTerminateAlphaCache();
#ifdef USE_OPENGL
- // OpenGL only public functions
-
int getTextureWidth() const
{ return mTexWidth; }
@@ -153,6 +151,8 @@ class Image : public Resource
GLuint getGLImage() const
{ return mGLImage; }
+
+ GLuint mGLImage;
#endif
bool isHasAlphaChannel() const
@@ -213,7 +213,6 @@ class Image : public Resource
Image(const GLuint glimage, const int width, const int height,
const int texWidth, const int texHeight);
- GLuint mGLImage;
int mTexWidth, mTexHeight;
#endif
};
diff --git a/src/safeopenglgraphics.cpp b/src/safeopenglgraphics.cpp
index 93cee86db..457ef6dfe 100644
--- a/src/safeopenglgraphics.cpp
+++ b/src/safeopenglgraphics.cpp
@@ -356,6 +356,7 @@ bool SafeOpenGLGraphics::calcImageRect(GraphicsVertexes *const vert,
}
void SafeOpenGLGraphics::calcTile(ImageVertexes *const vert A_UNUSED,
+ const Image *const image A_UNUSED,
int x A_UNUSED, int y A_UNUSED)
{
diff --git a/src/safeopenglgraphics.h b/src/safeopenglgraphics.h
index efa9da832..1a0d06f46 100644
--- a/src/safeopenglgraphics.h
+++ b/src/safeopenglgraphics.h
@@ -94,7 +94,8 @@ class SafeOpenGLGraphics final : public Graphics
void drawImageRect2(GraphicsVertexes *const vert,
const ImageRect &imgRect) override;
- void calcTile(ImageVertexes *const vert, int x, int y) override;
+ void calcTile(ImageVertexes *const vert, const Image *const image,
+ int x, int y) override;
void drawTile(const ImageVertexes *const vert) override;