[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Tue Jul 27 23:59:02 CEST 2010
SVN commit 1155696 by beschow:
realize that StackedTiles are never empty => remove StackedTile::hasTiles()
StackedTiles can now be assigned tiles via the constructor only.
The constructor asserts that more than zero tiles are passed.
M +0 -2 MergedLayerDecorator.cpp
M +6 -19 StackedTile.cpp
M +1 -6 StackedTile.h
M +14 -16 StackedTileLoader.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MergedLayerDecorator.cpp #1155695:1155696
@@ -131,8 +131,6 @@
if ( m_sunLocator->getCitylights() && m_sunLocator->planet()->id() == "earth" ) {
StackedTile * tile = loadDataset( m_cityLightsTextureLayer );
- if ( !tile->hasTiles() )
- return;
QImage * nighttile = tile->resultTile();
--- trunk/KDE/kdeedu/marble/src/lib/StackedTile.cpp #1155695:1155696
@@ -227,20 +227,17 @@
}
-StackedTile::StackedTile( TileId const& id, QObject * parent )
- : AbstractTile( *new StackedTilePrivate( id ), parent ), d(0)
+StackedTile::StackedTile( TileId const& id, QVector<QSharedPointer<TextureTile> > const &tiles )
+ : AbstractTile( *new StackedTilePrivate( id ), 0 ), d(0)
{
+ Q_ASSERT( !tiles.isEmpty() );
+
// The d-ptr is cached as a member to avoid having to use d_func()
// or the Q_D macro in the pixel() function. Otherwise it leads
// to measurable runtime overhead because pixel() is called frequently.
d = d_func();
-}
-StackedTile::StackedTile( StackedTilePrivate &dd, QObject * parent )
- : AbstractTile( dd, parent ), d(0)
-{
- // See comment above
- d = d_func();
+ d->m_tiles = tiles;
}
StackedTile::~StackedTile()
@@ -267,11 +264,6 @@
d->m_forMergedLayerDecorator = true;
}
-void StackedTile::addTile( QSharedPointer<TextureTile> const & tile )
-{
- d->m_tiles.append( tile );
-}
-
void StackedTile::initJumpTables()
{
// mDebug() << "Entered initJumpTables( bool ) of Tile" << d->m_id;
@@ -344,14 +336,9 @@
return &d->m_resultTile;
}
-bool StackedTile::hasTiles() const
-{
- return !d->m_tiles.isEmpty();
-}
-
void StackedTile::initResultTile()
{
- Q_ASSERT( hasTiles() );
+ Q_ASSERT( !d->m_tiles.isEmpty() );
// if there are more than one active texture layers, we have to convert the
// result tile into QImage::Format_ARGB32_Premultiplied to make blending possible
const bool withConversion = d->m_tiles.count() > 1;
--- trunk/KDE/kdeedu/marble/src/lib/StackedTile.h #1155695:1155696
@@ -39,13 +39,12 @@
friend class StackedTileLoader;
public:
- explicit StackedTile( TileId const& tid, QObject * parent = 0 );
+ explicit StackedTile( TileId const& tid, QVector<QSharedPointer<TextureTile> > const &tiles );
virtual ~StackedTile();
int depth() const;
int numBytes() const;
bool isExpired() const;
- bool hasTiles() const;
bool forMergedLayerDecorator() const;
void setForMergedLayerDecorator();
@@ -68,14 +67,10 @@
uint pixelF( qreal x, qreal y ) const;
uint pixelF( qreal x, qreal y, const QRgb& pixel ) const;
- protected:
- StackedTile( StackedTilePrivate &dd, QObject *parent );
-
private:
Q_DECLARE_PRIVATE( StackedTile )
Q_DISABLE_COPY( StackedTile )
- void addTile( QSharedPointer<TextureTile> const & );
void initJumpTables();
void initResultTile();
--- trunk/KDE/kdeedu/marble/src/lib/StackedTileLoader.cpp #1155695:1155696
@@ -200,11 +200,8 @@
// and place it in the hash from where it will get transferred to the cache
// mDebug() << "load Tile from Disk: " << stackedTileId.toString();
- stackedTile = new StackedTile( stackedTileId );
- if ( forMergedLayerDecorator )
- stackedTile->setForMergedLayerDecorator();
- d->m_tilesOnDisplay[ stackedTileId ] = stackedTile;
+ QVector<QSharedPointer<TextureTile> > tiles;
QVector<GeoSceneTexture const *> const textureLayers = findRelevantTextureLayers( stackedTileId );
QVector<GeoSceneTexture const *>::const_iterator pos = textureLayers.constBegin();
QVector<GeoSceneTexture const *>::const_iterator const end = textureLayers.constEnd();
@@ -218,15 +215,18 @@
usage );
if ( tile ) {
tile->setBlending( textureLayer->blending() );
- stackedTile->addTile( tile );
+ tiles.append( tile );
}
}
- Q_ASSERT( stackedTile->hasTiles() );
+ Q_ASSERT( !tiles.isEmpty() );
- if ( stackedTile->hasTiles() ) {
+ stackedTile = new StackedTile( stackedTileId, tiles );
+ if ( forMergedLayerDecorator )
+ stackedTile->setForMergedLayerDecorator();
+ d->m_tilesOnDisplay[ stackedTileId ] = stackedTile;
stackedTile->initResultTile();
mergeDecorations( stackedTile );
- }
+
return stackedTile;
}
@@ -255,9 +255,7 @@
return cachedTile;
}
- StackedTile * const stackedTile = new StackedTile( stackedTileId );
- d->m_tilesOnDisplay[ stackedTileId ] = stackedTile;
-
+ QVector<QSharedPointer<TextureTile> > tiles;
QVector<GeoSceneTexture const *> const textureLayers = findRelevantTextureLayers( stackedTileId );
QVector<GeoSceneTexture const *>::const_iterator pos = textureLayers.constBegin();
QVector<GeoSceneTexture const *>::const_iterator const end = textureLayers.constEnd();
@@ -269,14 +267,15 @@
usage );
if ( tile ) {
tile->setBlending( textureLayer->blending() );
- stackedTile->addTile( tile );
+ tiles.append( tile );
}
}
- Q_ASSERT( stackedTile->hasTiles() );
+ Q_ASSERT( !tiles.isEmpty() );
- if ( stackedTile->hasTiles() ) {
+ StackedTile * const stackedTile = new StackedTile( stackedTileId, tiles );
+ d->m_tilesOnDisplay[ stackedTileId ] = stackedTile;
stackedTile->initResultTile();
- }
+
return stackedTile;
}
@@ -498,7 +497,6 @@
void StackedTileLoader::mergeDecorations( StackedTile * const tile ) const
{
- Q_ASSERT( tile->hasTiles() );
Q_ASSERT( !tile->resultTile()->isNull() );
if ( !tile->forMergedLayerDecorator() )
m_parent->paintTile( tile, findTextureLayer( tile->id() ) );
More information about the Marble-commits
mailing list