[Marble-commits] branches/KDE/4.6/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Mon Jan 3 12:53:01 CET 2011
SVN commit 1211244 by beschow:
move QImage caching of the canvas into texture mappers
* this is another step to allow the texture mappers to paint to the QPaintDevice directly
M +8 -1 AbstractScanlineTextureMapper.h
M +20 -0 EquirectScanlineTextureMapper.cpp
M +11 -1 EquirectScanlineTextureMapper.h
M +20 -0 MercatorScanlineTextureMapper.cpp
M +11 -1 MercatorScanlineTextureMapper.h
M +26 -0 SphericalScanlineTextureMapper.cpp
M +13 -2 SphericalScanlineTextureMapper.h
M +9 -28 TextureLayer.cpp
M +20 -0 TileScalingTextureMapper.cpp
M +11 -1 TileScalingTextureMapper.h
--- branches/KDE/4.6/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.h #1211243:1211244
@@ -22,10 +22,12 @@
#include "MarbleMath.h"
#include "MathHelper.h"
+class QRect;
namespace Marble
{
+class GeoPainter;
class StackedTile;
class StackedTileLoader;
class TextureColorizer;
@@ -40,8 +42,13 @@
QObject * const parent = 0 );
~AbstractScanlineTextureMapper();
- virtual void mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer ) = 0;
+ virtual void mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer ) = 0;
+ virtual void setRepaintNeeded() = 0;
+
bool interlaced() const;
void setInterlaced( const bool enabled );
int tileZoomLevel() const;
--- branches/KDE/4.6/kdeedu/marble/src/lib/EquirectScanlineTextureMapper.cpp #1211243:1211244
@@ -19,6 +19,7 @@
#include <QtGui/QImage>
// Marble
+#include "GeoPainter.h"
#include "MarbleDirs.h"
#include "MarbleDebug.h"
#include "StackedTileLoader.h"
@@ -32,12 +33,31 @@
EquirectScanlineTextureMapper::EquirectScanlineTextureMapper( StackedTileLoader *tileLoader,
QObject *parent )
: AbstractScanlineTextureMapper( tileLoader, parent ),
+ m_repaintNeeded( true ),
m_oldCenterLon( 0.0 ),
m_oldYPaintedTop( 0 )
{
}
+void EquirectScanlineTextureMapper::mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer )
+{
+ if ( m_repaintNeeded ) {
+ mapTexture( viewParams, texColorizer );
+ m_repaintNeeded = false;
+ }
+
+ painter->drawImage( dirtyRect, *viewParams->canvasImage(), dirtyRect );
+}
+
+void EquirectScanlineTextureMapper::setRepaintNeeded()
+{
+ m_repaintNeeded = true;
+}
+
void EquirectScanlineTextureMapper::mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer )
{
QImage *canvasImage = viewParams->canvasImage();
--- branches/KDE/4.6/kdeedu/marble/src/lib/EquirectScanlineTextureMapper.h #1211243:1211244
@@ -25,9 +25,19 @@
public:
EquirectScanlineTextureMapper( StackedTileLoader *tileLoader, QObject *parent = 0 );
- void mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer );
+ virtual void mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer );
+ virtual void setRepaintNeeded();
+
private:
+ void mapTexture( ViewParams *viewParams,
+ TextureColorizer *texColorizer );
+
+ private:
+ bool m_repaintNeeded;
float m_oldCenterLon;
int m_oldYPaintedTop;
};
--- branches/KDE/4.6/kdeedu/marble/src/lib/MercatorScanlineTextureMapper.cpp #1211243:1211244
@@ -20,6 +20,7 @@
#include <QtGui/QImage>
// Marble
+#include "GeoPainter.h"
#include "MarbleDirs.h"
#include "MarbleDebug.h"
#include "StackedTileLoader.h"
@@ -34,12 +35,31 @@
MercatorScanlineTextureMapper::MercatorScanlineTextureMapper( StackedTileLoader *tileLoader,
QObject *parent )
: AbstractScanlineTextureMapper( tileLoader, parent ),
+ m_repaintNeeded( true ),
m_oldCenterLon( 0.0 ),
m_oldYPaintedTop( 0 )
{
}
+void MercatorScanlineTextureMapper::mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer )
+{
+ if ( m_repaintNeeded ) {
+ mapTexture( viewParams, texColorizer );
+ m_repaintNeeded = false;
+ }
+
+ painter->drawImage( dirtyRect, *viewParams->canvasImage(), dirtyRect );
+}
+
+void MercatorScanlineTextureMapper::setRepaintNeeded()
+{
+ m_repaintNeeded = true;
+}
+
void MercatorScanlineTextureMapper::mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer )
{
QImage *canvasImage = viewParams->canvasImage();
--- branches/KDE/4.6/kdeedu/marble/src/lib/MercatorScanlineTextureMapper.h #1211243:1211244
@@ -25,9 +25,19 @@
public:
MercatorScanlineTextureMapper( StackedTileLoader *tileLoader, QObject *parent = 0 );
- void mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer );
+ virtual void mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer );
+ virtual void setRepaintNeeded();
+
private:
+ void mapTexture( ViewParams *viewParams,
+ TextureColorizer *texColorizer );
+
+ private:
+ bool m_repaintNeeded;
float m_oldCenterLon;
int m_oldYPaintedTop;
};
--- branches/KDE/4.6/kdeedu/marble/src/lib/SphericalScanlineTextureMapper.cpp #1211243:1211244
@@ -16,6 +16,7 @@
#include <QtGui/QImage>
#include "global.h"
+#include "GeoPainter.h"
#include "MarbleDebug.h"
#include "MarbleDirs.h"
#include "Quaternion.h"
@@ -31,10 +32,35 @@
SphericalScanlineTextureMapper::SphericalScanlineTextureMapper( StackedTileLoader *tileLoader,
QObject *parent )
: AbstractScanlineTextureMapper( tileLoader, parent )
+ , m_repaintNeeded( true )
{
m_interlaced = false;
}
+void SphericalScanlineTextureMapper::mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer )
+{
+ if ( m_repaintNeeded ) {
+ mapTexture( viewParams, texColorizer );
+
+ m_repaintNeeded = false;
+ }
+
+ const int radius = (int)(1.05 * (qreal)(viewParams->radius()));
+
+ QRect rect( viewParams->width() / 2 - radius, viewParams->height() / 2 - radius,
+ 2 * radius, 2 * radius);
+ rect = rect.intersect( dirtyRect );
+ painter->drawImage( rect, *viewParams->canvasImage(), rect );
+}
+
+void SphericalScanlineTextureMapper::setRepaintNeeded()
+{
+ m_repaintNeeded = true;
+}
+
void SphericalScanlineTextureMapper::mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer )
{
QImage *canvasImage = viewParams->canvasImage();
--- branches/KDE/4.6/kdeedu/marble/src/lib/SphericalScanlineTextureMapper.h #1211243:1211244
@@ -37,10 +37,21 @@
public:
SphericalScanlineTextureMapper( StackedTileLoader *tileLoader, QObject *parent = 0 );
- void mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer );
+ virtual void mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer );
- protected:
+ virtual void setRepaintNeeded();
+
+ private:
+ void mapTexture( ViewParams *viewParams,
+ TextureColorizer *texColorizer );
+
inline bool needsFilter( const QRgb& rgb, int& oldR, int& oldB, int &oldG );
+
+ private:
+ bool m_repaintNeeded;
};
}
--- branches/KDE/4.6/kdeedu/marble/src/lib/TextureLayer.cpp #1211243:1211244
@@ -56,7 +56,6 @@
AbstractScanlineTextureMapper *m_texmapper;
TextureColorizer *m_texcolorizer;
GeoSceneDocument *m_mapTheme;
- bool m_justModified;
};
TextureLayer::Private::Private( MapThemeManager *mapThemeManager, HttpDownloadManager *downloadManager, SunLocator *sunLocator, TextureLayer *parent )
@@ -66,13 +65,14 @@
, m_texmapper( 0 )
, m_texcolorizer( 0 )
, m_mapTheme( 0 )
- , m_justModified( true )
{
}
void TextureLayer::Private::mapChanged()
{
- m_justModified = true;
+ if ( m_texmapper ) {
+ m_texmapper->setRepaintNeeded();
+ }
emit m_parent->repaintNeeded( QRegion() );
}
@@ -152,31 +152,12 @@
if ( !d->m_mapTheme->map()->hasTextureLayers() )
return;
- if ( d->m_justModified ) {
- // Create the height map image a.k.a viewParams->d->m_canvasImage.
- d->m_texmapper->mapTexture( viewParams, d->m_texcolorizer );
+ if ( !d->m_texmapper )
+ return;
- d->m_justModified = false;
+ d->m_texmapper->mapTexture( painter, viewParams, dirtyRect, d->m_texcolorizer );
}
- // Paint the map on the Widget
-// QTime t;
-// t.start();
- if ( viewParams->projection() == Spherical ) {
- const int radius = (int)(1.05 * (qreal)(viewParams->radius()));
-
- QRect rect( viewParams->width() / 2 - radius, viewParams->height() / 2 - radius,
- 2 * radius, 2 * radius);
- rect = rect.intersect( dirtyRect );
- painter->drawImage( rect, *viewParams->canvasImage(), rect );
- }
- else {
- painter->drawImage( dirtyRect, *viewParams->canvasImage(), dirtyRect );
- }
-
-// qDebug( "Painted in %ims", t.elapsed() );
-}
-
void TextureLayer::setShowTileId( bool show )
{
d->m_tileLoader.setShowTileId( show );
@@ -208,14 +189,14 @@
}
Q_ASSERT( d->m_texmapper );
connect( d->m_texmapper, SIGNAL( tileLevelChanged( int )), SIGNAL( tileLevelChanged( int )));
-
- d->m_justModified = true;
}
void TextureLayer::setNeedsUpdate()
{
- d->m_justModified = true;
+ if ( d->m_texmapper ) {
+ d->m_texmapper->setRepaintNeeded();
}
+}
void TextureLayer::setVolatileCacheLimit( quint64 kilobytes )
{
--- branches/KDE/4.6/kdeedu/marble/src/lib/TileScalingTextureMapper.cpp #1211243:1211244
@@ -21,6 +21,7 @@
#include <QtGui/QPainter>
// Marble
+#include "GeoPainter.h"
#include "StackedTileLoader.h"
#include "ViewParams.h"
#include "TextureColorizer.h"
@@ -33,11 +34,30 @@
TileScalingTextureMapper::TileScalingTextureMapper( StackedTileLoader *tileLoader,
QObject *parent )
: AbstractScanlineTextureMapper( tileLoader, parent ),
+ m_repaintNeeded( true ),
m_oldYPaintedTop( 0 )
{
}
+void TileScalingTextureMapper::mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer )
+{
+ if ( m_repaintNeeded ) {
+ mapTexture( viewParams, texColorizer );
+ m_repaintNeeded = false;
+ }
+
+ painter->drawImage( dirtyRect, *viewParams->canvasImage(), dirtyRect );
+}
+
+void TileScalingTextureMapper::setRepaintNeeded()
+{
+ m_repaintNeeded = true;
+}
+
void TileScalingTextureMapper::mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer )
{
if ( viewParams->radius() <= 0 )
--- branches/KDE/4.6/kdeedu/marble/src/lib/TileScalingTextureMapper.h #1211243:1211244
@@ -24,9 +24,19 @@
public:
TileScalingTextureMapper( StackedTileLoader *tileLoader, QObject *parent = 0 );
- void mapTexture( ViewParams *viewParams, TextureColorizer *texColorizer );
+ virtual void mapTexture( GeoPainter *painter,
+ ViewParams *viewParams,
+ const QRect &dirtyRect,
+ TextureColorizer *texColorizer );
+ virtual void setRepaintNeeded();
+
private:
+ void mapTexture( ViewParams *viewParams,
+ TextureColorizer *texColorizer );
+
+ private:
+ bool m_repaintNeeded;
int m_oldYPaintedTop;
};
More information about the Marble-commits
mailing list