From b70bbf075a20524e6c1859fb18db0865c65182ca Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Aug 2013 15:31:36 +0300 Subject: move surface combination into sdlimagehelper. --- src/gui/sdlfont.cpp | 11 ++++++----- src/resources/sdl2imagehelper.cpp | 10 ++++++++++ src/resources/sdl2imagehelper.h | 5 +++++ src/resources/sdlimagehelper.cpp | 10 ++++++++++ src/resources/sdlimagehelper.h | 5 +++++ src/sdl2graphics.cpp | 8 -------- src/sdl2graphics.h | 3 --- src/sdlgraphics.cpp | 6 ------ src/sdlgraphics.h | 3 --- src/test/testlauncher.cpp | 5 +++-- src/utils/sdlhelper.cpp | 2 +- 11 files changed, 40 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index e1a0cf832..653e7f69f 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -32,6 +32,7 @@ #include "resources/image.h" #include "resources/imagehelper.h" #include "resources/resourcemanager.h" +#include "resources/sdlimagehelper.h" #include @@ -195,17 +196,17 @@ void SDLTextChunk::generate(TTF_Font *const font, const float alpha) static_cast(surface->w), static_cast(surface->h) }; - MSDL_gfxBlitRGBA(surface2, nullptr, background, &rect); + SDLImageHelper::combineSurface(surface2, nullptr, background, &rect); rect.x = -OUTLINE_SIZE; - MSDL_gfxBlitRGBA(surface2, nullptr, background, &rect); + SDLImageHelper::combineSurface(surface2, nullptr, background, &rect); rect.x = 0; rect.y = -OUTLINE_SIZE; - MSDL_gfxBlitRGBA(surface2, nullptr, background, &rect); + SDLImageHelper::combineSurface(surface2, nullptr, background, &rect); rect.y = OUTLINE_SIZE; - MSDL_gfxBlitRGBA(surface2, nullptr, background, &rect); + SDLImageHelper::combineSurface(surface2, nullptr, background, &rect); rect.x = 0; rect.y = 0; - MSDL_gfxBlitRGBA(surface, nullptr, background, &rect); + SDLImageHelper::combineSurface(surface, nullptr, background, &rect); SDL_FreeSurface(surface); SDL_FreeSurface(surface2); surface = background; diff --git a/src/resources/sdl2imagehelper.cpp b/src/resources/sdl2imagehelper.cpp index a015080d4..acc72ce00 100644 --- a/src/resources/sdl2imagehelper.cpp +++ b/src/resources/sdl2imagehelper.cpp @@ -163,4 +163,14 @@ SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const width, height, 32, rmask, gmask, bmask, amask); } +int SDLImageHelper::combineSurface(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect) +{ + SDL_SetSurfaceBlendMode (src, SDL_BLENDMODE_BLEND); + SDL_BlitSurface(src, srcrect, dst, dstrect); + return 1; +} + #endif // USE_SDL2 diff --git a/src/resources/sdl2imagehelper.h b/src/resources/sdl2imagehelper.h index e0629aea3..9edd48ebe 100644 --- a/src/resources/sdl2imagehelper.h +++ b/src/resources/sdl2imagehelper.h @@ -89,6 +89,11 @@ class SDLImageHelper final : public ImageHelper SDL_Surface *create32BitSurface(int width, int height) const override; + static int combineSurface(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect); + protected: /** SDL_Surface to SDL_Surface Image loader */ Image *_SDLload(SDL_Surface *tmpImage) const A_WARN_UNUSED; diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index 7a1953444..7a7de1906 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -33,6 +33,7 @@ #include "resources/image.h" +#include #include #include "debug.h" @@ -295,4 +296,13 @@ SDL_Surface *SDLImageHelper::create32BitSurface(int width, int height) const return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); } + +int SDLImageHelper::combineSurface(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect) +{ + return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect); +} + #endif // USE_SDL2 diff --git a/src/resources/sdlimagehelper.h b/src/resources/sdlimagehelper.h index 0aa3001b0..6f53c75ef 100644 --- a/src/resources/sdlimagehelper.h +++ b/src/resources/sdlimagehelper.h @@ -92,6 +92,11 @@ class SDLImageHelper final : public ImageHelper SDL_Surface *create32BitSurface(int width, int height) const override; + static int combineSurface(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect); + protected: /** SDL_Surface to SDL_Surface Image loader */ Image *_SDLload(SDL_Surface *tmpImage) const A_WARN_UNUSED; diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp index 6d6a745ec..71a3ebbae 100644 --- a/src/sdl2graphics.cpp +++ b/src/sdl2graphics.cpp @@ -41,14 +41,6 @@ #include "debug.h" -int MSDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect) -{ - SDL_SetSurfaceBlendMode (src, SDL_BLENDMODE_BLEND); - SDL_BlitSurface(src, srcrect, dst, dstrect); - return 1; -} - #if SDL_BYTEORDER == SDL_LIL_ENDIAN static unsigned int *cR = nullptr; static unsigned int *cG = nullptr; diff --git a/src/sdl2graphics.h b/src/sdl2graphics.h index 09ca411e2..583be5e8a 100644 --- a/src/sdl2graphics.h +++ b/src/sdl2graphics.h @@ -36,9 +36,6 @@ class MapLayer; struct SDL_Surface; -int MSDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - /** * A central point of control for graphics. */ diff --git a/src/sdlgraphics.cpp b/src/sdlgraphics.cpp index 38984593c..a77076c26 100644 --- a/src/sdlgraphics.cpp +++ b/src/sdlgraphics.cpp @@ -39,12 +39,6 @@ #include "debug.h" -int MSDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect) -{ - return SDL_gfxBlitRGBA(src, srcrect, dst, dstrect); -} - #if SDL_BYTEORDER == SDL_LIL_ENDIAN static unsigned int *cR = nullptr; static unsigned int *cG = nullptr; diff --git a/src/sdlgraphics.h b/src/sdlgraphics.h index 9f80f6acb..b0a076b26 100644 --- a/src/sdlgraphics.h +++ b/src/sdlgraphics.h @@ -39,9 +39,6 @@ class MapLayer; struct SDL_Surface; -int MSDL_gfxBlitRGBA(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - /** * A central point of control for graphics. */ diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 1752e4380..09a505e85 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -38,6 +38,7 @@ #include "resources/image.h" #include "resources/imagehelper.h" #include "resources/imagewriter.h" +#include "resources/sdlimagehelper.h" #include "resources/wallpaper.h" #include @@ -249,7 +250,7 @@ int TestLauncher::testDye() rect.w, rect.h); if (surface) { - MSDL_gfxBlitRGBA(image->mSDLSurface, nullptr, + SDLImageHelper::combineSurface(image->mSDLSurface, nullptr, surface, nullptr); ImageWriter::writePNG(image->mSDLSurface, client->getTempDirectory() + "/testimage1.png"); @@ -268,7 +269,7 @@ int TestLauncher::testDye() rect.w, rect.h); if (surface) { - MSDL_gfxBlitRGBA(image->mSDLSurface, nullptr, + SDLImageHelper::combineSurface(image->mSDLSurface, nullptr, surface, nullptr); ImageWriter::writePNG(image->mSDLSurface, client->getTempDirectory() + "/testimage3.png"); diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp index 204dd921d..ed2187172 100644 --- a/src/utils/sdlhelper.cpp +++ b/src/utils/sdlhelper.cpp @@ -81,7 +81,7 @@ void SDL::grabInput(SDL_Surface *const window A_UNUSED, const bool grab) void SDL::setGamma(SDL_Surface *const window A_UNUSED, const float gamma) { - SDL_SetGamma(gamma, gamma, gamma) + SDL_SetGamma(gamma, gamma, gamma); } void SDL::setVsync(const int val) -- cgit v1.2.3-60-g2f50