diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-01 22:00:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-01 22:00:53 +0300 |
commit | dbf1544dc6dd7e31ad884afaffb192944f8bb22f (patch) | |
tree | 9e6d4e4e857577ffc562152bdb70bcd224f7a3a5 /src/resources/atlasmanager.cpp | |
parent | 62e2ccbb158f146e2c3ceab14ff5581d3f3975ef (diff) | |
download | manaplus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.tar.gz manaplus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.tar.bz2 manaplus-dbf1544dc6dd7e31ad884afaffb192944f8bb22f.tar.xz manaplus-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/atlasmanager.cpp')
-rw-r--r-- | src/resources/atlasmanager.cpp | 39 |
1 files changed, 16 insertions, 23 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; |