summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-01 22:00:53 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-01 22:00:53 +0300
commitdbf1544dc6dd7e31ad884afaffb192944f8bb22f (patch)
tree9e6d4e4e857577ffc562152bdb70bcd224f7a3a5 /src/resources
parent62e2ccbb158f146e2c3ceab14ff5581d3f3975ef (diff)
downloadplus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.tar.gz
plus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.tar.bz2
plus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.tar.xz
plus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.zip
In atlasmanager use copy surface to image function.
This allow in OpenGL modes copy surface into video memory without software blitting.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/atlasmanager.cpp39
-rw-r--r--src/resources/textureatlas.h2
2 files changed, 16 insertions, 25 deletions
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index cadf917f9..cdbd26a65 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -26,7 +26,9 @@
#include "configuration.h"
-#include "render/surfacegraphics.h"
+#ifdef DEBUG_IMAGES
+#include "logger.h"
+#endif
#include "utils/mathutils.h"
#include "utils/physfscheckutils.h"
@@ -39,6 +41,7 @@
#include "resources/imagehelper.h"
#include "resources/openglimagehelper.h"
#include "resources/resourcemanager.h"
+#include "resources/sdlimagehelper.h"
#include "resources/textureatlas.h"
#include "debug.h"
@@ -255,36 +258,19 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
}
BLOCK_END("AtlasManager::createSDLAtlas create surface")
- SurfaceGraphics *const graphics = new SurfaceGraphics();
- graphics->setTarget(surface);
- graphics->beginDraw();
+ Image *image = imageHelper->load(surface);
// drawing SDL images to surface
FOR_EACH (std::vector<AtlasItem*>::iterator, it, atlas->items)
{
AtlasItem *const item = *it;
- Image *const image = item->image;
-
if (image)
{
- if (image->mSDLSurface)
- {
- BLOCK_START("AtlasManager::createSDLAtlas set surface attr")
-#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(image->mSDLSurface, SDL_ALPHA_OPAQUE);
- SDL_SetSurfaceBlendMode(image->mSDLSurface,
- SDL_BLENDMODE_NONE);
-#else
- SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE);
-#endif
- BLOCK_END("AtlasManager::createSDLAtlas set surface attr")
- graphics->drawImage(image, item->x, item->y);
- }
+ imageHelper->copySurfaceToImage(image, item->x, item->y,
+ item->image->mSDLSurface);
}
}
-
- delete graphics;
- atlas->surface = surface;
+ atlas->atlasImage = image;
BLOCK_END("AtlasManager::createSDLAtlas")
return surface;
}
@@ -293,7 +279,14 @@ void AtlasManager::convertAtlas(TextureAtlas *const atlas)
{
// no check for null pointer in atlas because it was in caller
// convert surface to OpemGL image
- atlas->atlasImage = imageHelper->load(atlas->surface);
+ Image *const oldImage = atlas->atlasImage;
+
+ if (oldImage->mSDLSurface)
+ {
+ atlas->atlasImage = imageHelper->load(atlas->atlasImage->mSDLSurface);
+ oldImage->decRef();
+ }
+
Image *const image = atlas->atlasImage;
if (!image)
return;
diff --git a/src/resources/textureatlas.h b/src/resources/textureatlas.h
index 11a45a5d3..be3d8abd8 100644
--- a/src/resources/textureatlas.h
+++ b/src/resources/textureatlas.h
@@ -42,7 +42,6 @@ struct TextureAtlas final
TextureAtlas() :
name(),
atlasImage(nullptr),
- surface(nullptr),
width(0),
height(0),
items()
@@ -53,7 +52,6 @@ struct TextureAtlas final
std::string name;
Image *atlasImage;
- SDL_Surface *surface;
int width;
int height;
std::vector <AtlasItem*> items;