4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_RASTERTILE_HPP
25 #define XCSOAR_RASTERTILE_HPP
27 #include "Terrain/RasterBuffer.hpp"
28 #include "Util/NonCopyable.hpp"
32 class RasterTile
: private NonCopyable
{
34 unsigned int xstart
, ystart
, xend
, yend
;
38 unsigned int xstart
, ystart
, xend
, yend
;
39 unsigned int width
, height
;
42 * The distance of this tile to the center of the screen. This
43 * attribute is used to determine which tiles should be loaded.
53 :xstart(0), ystart(0), xend(0), yend(0),
54 width(0), height(0) {}
56 void Set(unsigned _xstart
, unsigned _ystart
,
57 unsigned _xend
, unsigned _yend
) {
62 width
= xend
- xstart
;
63 height
= yend
- ystart
;
67 * Permanently disable this tile after a failure.
74 bool IsDefined() const {
75 return width
> 0 && height
> 0;
78 int GetDistance() const {
82 bool IsRequested() const {
94 bool SaveCache(FILE *file
) const;
95 bool LoadCache(FILE *file
);
97 bool CheckTileVisibility(int view_x
, int view_y
, unsigned view_radius
);
104 bool IsEnabled() const {
105 return buffer
.IsDefined();
107 bool IsDisabled() const {
108 return !buffer
.IsDefined();
112 * Determine the non-interpolated height at the specified pixel
115 * @param x the pixel column within the tile; may be out of range
116 * @param y the pixel row within the tile; may be out of range
119 short GetHeight(unsigned x
, unsigned y
) const;
122 * Determine the interpolated height at the specified sub-pixel
125 * @param x the pixel column within the tile; may be out of range
126 * @param y the pixel row within the tile; may be out of range
127 * @param ix the sub-pixel column for interpolation (0..255)
128 * @param iy the sub-pixel row for interpolation (0..255)
131 short GetInterpolatedHeight(unsigned x
, unsigned y
,
132 unsigned ix
, unsigned iy
) const;
134 inline short* GetImageBuffer() {
135 return buffer
.GetData();
138 bool VisibilityChanged(int view_x
, int view_y
, unsigned view_radius
);
140 void ScanLine(unsigned ax
, unsigned ay
, unsigned bx
, unsigned by
,
141 short *dest
, unsigned size
, bool interpolate
) const {
142 buffer
.ScanLine(ax
- (xstart
<< 8), ay
- (ystart
<< 8),
143 bx
- (xstart
<< 8), by
- (ystart
<< 8),
144 dest
, size
, interpolate
);