From d0e6d477d245610288ab622ecf47426a9dcbc400 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 12 Jul 2011 03:55:01 +0300 Subject: Add tiles caching for software mode. --- src/graphics.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/graphics.cpp') 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(x); + rect->dst.y = static_cast(y); + rect->src.x = static_cast(image->mBounds.x); + rect->src.y = static_cast(image->mBounds.y); + rect->src.w = static_cast(image->mBounds.w); + rect->src.h = static_cast(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) +{ + +} -- cgit v1.2.3-60-g2f50