LazMapViewer: Minor refactoring of tile drawing.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9681 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
870c3252cb
commit
a49a182aa2
@ -1092,14 +1092,10 @@ procedure TMapViewerEngine.Redraw(const aWin: TMapWindow;
|
||||
const PaintOnly: Boolean);
|
||||
var
|
||||
TilesVis: TArea;
|
||||
x, y, px, py: Integer;
|
||||
x, y: Integer;
|
||||
iTile, numTiles, XShift: Integer;
|
||||
Tiles: TTileIdArray = nil;
|
||||
foundInCache: Boolean;
|
||||
tile: TTileID;
|
||||
previewDrawn: Boolean;
|
||||
previewImg: TPictureCacheItem;
|
||||
R: TRect;
|
||||
|
||||
procedure AddJob;
|
||||
var
|
||||
@ -1442,14 +1438,18 @@ var
|
||||
baseX: Integer;
|
||||
tile: TTileID;
|
||||
R: TRect;
|
||||
normalDraw: Boolean = true;
|
||||
stretchedDraw: Boolean = false; // normal or stretched image
|
||||
|
||||
procedure DrawTheTile(ATileID: TTileID; X, Y: Integer; AImg: TPictureCacheItem);
|
||||
// Draws the given tile, either directly from the image (Stretched=false) or
|
||||
// stretched (Stretched=true). Img=nil indicates a "missing" tile which
|
||||
// is painted as a uniformly colored rectangle.
|
||||
procedure DrawTheTile(ATileID: TTileID; X, Y: Integer; AImg: TPictureCacheItem;
|
||||
Stretched: Boolean);
|
||||
begin
|
||||
if normalDraw then
|
||||
DrawTile(ATileID, X, Y, AImg) // Covers the "missing tile" case when AImg = nil
|
||||
if Stretched then
|
||||
DrawStretchedTile(ATileID, X, Y, AImg, R)
|
||||
else
|
||||
DrawStretchedTile(ATileID, X, Y, AImg, R);
|
||||
DrawTile(ATileID, X, Y, AImg);
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -1465,6 +1465,7 @@ begin
|
||||
// Image is found in cache: Load it into "img". It can be drawn directly.
|
||||
Cache.GetFromCache(AWin.MapProvider, ATile, img);
|
||||
FoundInCache := true;
|
||||
stretchedDraw := false;
|
||||
end else
|
||||
if FDrawPreviewTiles then
|
||||
begin
|
||||
@ -1475,7 +1476,7 @@ begin
|
||||
begin
|
||||
// Load cache image into "img". It must be stretch-drawn.
|
||||
Cache.GetFromCache(AWin.MapProvider, tile, img);
|
||||
normalDraw := false;
|
||||
stretchedDraw := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1492,7 +1493,7 @@ begin
|
||||
X := baseX;
|
||||
while (X + TileSize.CX >= 0) do
|
||||
begin
|
||||
DrawTheTile(ATile, X, Y, img);
|
||||
DrawTheTile(ATile, X, Y, img, stretchedDraw);
|
||||
X := X - worldWidth;
|
||||
end;
|
||||
|
||||
@ -1500,12 +1501,12 @@ begin
|
||||
X := baseX + worldWidth;
|
||||
while (X <= AWin.Width) do
|
||||
begin
|
||||
DrawTheTile(ATile, X, Y, img);
|
||||
DrawTheTile(ATile, X, Y, img, stretchedDraw);
|
||||
X := X + worldWidth;
|
||||
end;
|
||||
end
|
||||
else
|
||||
DrawTheTile(ATile, X, Y, img);
|
||||
DrawTheTile(ATile, X, Y, img, stretchedDraw);
|
||||
end;
|
||||
|
||||
function TMapViewerEngine.ValidProvider(const AProvider: String): Boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user