diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-07-12 03:55:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-07-16 22:47:14 +0300 |
commit | d0e6d477d245610288ab622ecf47426a9dcbc400 (patch) | |
tree | e998d168d8eb4397602021b3b1411f80cc1466a9 /src/graphics.cpp | |
parent | 68b1e0ec82321757f2a29792d38d7eabb7d2cf98 (diff) | |
download | manaplus-d0e6d477d245610288ab622ecf47426a9dcbc400.tar.gz manaplus-d0e6d477d245610288ab622ecf47426a9dcbc400.tar.bz2 manaplus-d0e6d477d245610288ab622ecf47426a9dcbc400.tar.xz manaplus-d0e6d477d245610288ab622ecf47426a9dcbc400.zip |
Add tiles caching for software mode.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r-- | src/graphics.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp index d63c27324..88e88a905 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -26,6 +26,7 @@ #include "graphicsvertexes.h" #include "log.h" +#include "map.h" #include "resources/image.h" #include "resources/imageloader.h" @@ -569,6 +570,49 @@ void Graphics::calcImagePattern(GraphicsVertexes* vert, vert->incPtr(1); } +void Graphics::calcTile(ImageVertexes *vert, int x, int y) +{ + // Check that preconditions for blitting are met. + if (!vert || !vert->image || !vert->image->mSDLSurface) + return; + + const Image *image = vert->image; + + x += mClipStack.top().xOffset; + y += mClipStack.top().yOffset; + + DoubleRect *rect = new DoubleRect(); + + rect->dst.x = static_cast<short>(x); + rect->dst.y = static_cast<short>(y); + rect->src.x = static_cast<short>(image->mBounds.x); + rect->src.y = static_cast<short>(image->mBounds.y); + rect->src.w = static_cast<Uint16>(image->mBounds.w); + rect->src.h = static_cast<Uint16>(image->mBounds.h); + if (SDL_FakeUpperBlit(image->mSDLSurface, &rect->src, + mTarget, &rect->dst) == 1) + { + vert->sdl.push_back(rect); + } + else + { + delete rect; + } +} + +void Graphics::drawTile(ImageVertexes *vert) +{ + Image *img = vert->image; + DoubleRects *rects = &vert->sdl; + DoubleRects::iterator it = rects->begin(); + DoubleRects::iterator it_end = rects->end(); + while (it != it_end) + { + SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); + ++ it; + } +} + void Graphics::updateScreen() { if (mDoubleBuffer) @@ -845,3 +889,8 @@ void Graphics::fillRectangle(const gcn::Rectangle& rectangle) SDL_FillRect(mTarget, &rect, color); } } + +void Graphics::drawMapLayer(MapLayer *layer) +{ + +} |