diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-06-29 22:31:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-06-29 22:31:02 +0300 |
commit | be877e12682b6f0e697b024f96a1dcaf4d0c8206 (patch) | |
tree | be1277cc745460055c98242a5b1223b4853f381a /src/render/surfacegraphics.cpp | |
parent | c23b922eecefd6cd6421139cf7ec2b59eb87d748 (diff) | |
download | manaverse-be877e12682b6f0e697b024f96a1dcaf4d0c8206.tar.gz manaverse-be877e12682b6f0e697b024f96a1dcaf4d0c8206.tar.bz2 manaverse-be877e12682b6f0e697b024f96a1dcaf4d0c8206.tar.xz manaverse-be877e12682b6f0e697b024f96a1dcaf4d0c8206.zip |
In renderers add copyImage function.
For now it same with drawImage.
Diffstat (limited to 'src/render/surfacegraphics.cpp')
-rw-r--r-- | src/render/surfacegraphics.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp index e6aee752f..8691274dd 100644 --- a/src/render/surfacegraphics.cpp +++ b/src/render/surfacegraphics.cpp @@ -77,6 +77,34 @@ bool SurfaceGraphics::drawImage(const Image *const image, #endif } +bool SurfaceGraphics::copyImage(const Image *const image, + int dstX, int dstY) +{ + FUNC_BLOCK("Graphics::drawImage", 1) + // Check that preconditions for blitting are met. + if (!mTarget || !image || !image->mSDLSurface) + return false; + + const SDL_Rect &imageRect = image->mBounds; + SDL_Rect dstRect; + SDL_Rect srcRect; + dstRect.x = static_cast<int16_t>(dstX); + dstRect.y = static_cast<int16_t>(dstY); + srcRect.x = static_cast<int16_t>(imageRect.x); + srcRect.y = static_cast<int16_t>(imageRect.y); + srcRect.w = static_cast<uint16_t>(imageRect.w); + srcRect.h = static_cast<uint16_t>(imageRect.h); + +#ifdef USE_SDL2 + // probably need change some flags + return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, + mTarget, &dstRect) < 0); +#else + return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, + mTarget, &dstRect) < 0); +#endif +} + void SurfaceGraphics::drawImageCached(const Image *const image, int x, int y) { |