File indexing completed on 2024-04-28 11:31:24

0001 /*
0002     SPDX-FileCopyrightText: 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
0003     SPDX-FileCopyrightText: 2012 Ander Pijoan <ander.pijoan@deusto.es>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef MARBLE_TEXTURETILE_H
0009 #define MARBLE_TEXTURETILE_H
0010 
0011 #include <QImage>
0012 
0013 #include "Tile.h"
0014 
0015 namespace Marble
0016 {
0017 class Blending;
0018 class TileId;
0019 
0020 /*!
0021     \class TextureTile
0022     \brief A class that resembles an image tile (extends Tile).
0023 
0024     This tile provides a bitmap image for a certain (geographic) area and
0025     for a given zoom level. Each Tile can be identified via a unique
0026     TileId.
0027 
0028     A stack of Tiles that cover the same area and the same
0029     zoom level can be stored (and painted) layer by layer in a StackedTile object.
0030     For this purpose each Tile specifies a blending type.
0031 
0032     Usually the tiles are organized in so called quad tiles: This means that
0033     with increasing zoom level four other tiles cover the same area as a
0034     single "parent" tile in the previous zoom level. These four tiles have
0035     the same pixel size as the "parent" tile.
0036 
0037     The process of "filling the tile with data is done in stages: The
0038     State describes the current progress of loading the data (Empty, Scaled,
0039     Expired, StateUptodate).
0040 
0041     The life time cycle of a Tile can also be influenced by its
0042     expiration time which will trigger a reload of the tile data.
0043 */
0044 
0045 class TextureTile : public Tile
0046 {
0047  public:
0048     TextureTile(TileId const & tileId, QImage const & image, const Blending * blending );
0049     ~TextureTile() override;
0050 
0051 /*!
0052     \brief Returns the QImage that describes the look of the Tile
0053     \return A non-zero pointer to a QImage associated with the tile.
0054 */
0055     QImage const * image() const;
0056 
0057 /*!
0058     \brief Returns the kind of blending used for the texture tile.
0059     \return A pointer to the blending object used for painting/merging the Tile.
0060 
0061     If no blending is set the pointer returned will be zero.
0062 */
0063     Blending const * blending() const;
0064 
0065     int byteCount() const;
0066 
0067  private:
0068     Q_DISABLE_COPY( TextureTile )
0069 
0070     QImage const m_image;
0071     Blending const * const m_blending;
0072 
0073 };
0074 
0075 inline QImage const * TextureTile::image() const
0076 {
0077     return &m_image;
0078 }
0079 
0080 inline Blending const * TextureTile::blending() const
0081 {
0082     return m_blending;
0083 }
0084 
0085 inline int TextureTile::byteCount() const
0086 {
0087 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
0088     return m_image.sizeInBytes();
0089 #else
0090     return m_image.byteCount();
0091 #endif
0092 }
0093 
0094 }
0095 
0096 #endif // MARBLE_TEXTURETILE_H