From 896d41e4b073046c59933ea8829474bd82b9c506 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 31 Dec 2016 22:53:42 +0300 Subject: Improve special layers draw speed in same way like fringe layer. --- src/resources/map/maplayer.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/resources/map/maplayer.cpp') diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp index 5239403ed..249e67fdd 100644 --- a/src/resources/map/maplayer.cpp +++ b/src/resources/map/maplayer.cpp @@ -402,24 +402,39 @@ void MapLayer::drawSpecialLayer(Graphics *const graphics, endX1 = specialWidth; if (endX1 < 0) endX1 = 0; - - for (int x = startX; x < endX1; x++) + int x0 = startX; + const MapItem *item0 = mSpecialLayer->mTiles[ptr + startX]; + if (!item0 || item0->mType == MapItemType::EMPTY) + { + x0 += mSpecialLayer->mCache[ptr + startX]; + } + for (int x = x0; x < endX1; x++) { const int px1 = x * mapTileSize - scrollX; - - const MapItem *item = mSpecialLayer->mTiles[ptr + x]; + const MapItem *const item = mSpecialLayer->mTiles[ptr + x]; if (item) { item->draw(graphics, px1, py1, mapTileSize, mapTileSize); } + x += mSpecialLayer->mCache[ptr + x]; + } - item = mTempLayer->mTiles[ptr + x]; + item0 = mTempLayer->mTiles[ptr + startX]; + if (!item0 || item0->mType == MapItemType::EMPTY) + { + x0 += mTempLayer->mCache[ptr + startX]; + } + for (int x = x0; x < endX1; x++) + { + const int px1 = x * mapTileSize - scrollX; + const MapItem *const item = mTempLayer->mTiles[ptr + x]; if (item) { item->draw(graphics, px1, py1, mapTileSize, mapTileSize); } + x += mSpecialLayer->mCache[ptr + x]; } } -- cgit v1.2.3-60-g2f50