[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Thu Nov 4 13:08:24 CET 2010
SVN commit 1193057 by beschow:
make the TextureColorizer an object member of MarbleModel rather than a class member
* The TextureColorizer depends on the current map theme (land file, sea file). Thus, it should be an object member.
M +3 -17 MarbleModel.cpp
M +27 -16 TextureColorizer.cpp
M +3 -22 TextureColorizer.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1193056:1193057
@@ -141,7 +141,7 @@
// View and paint stuff
GeoSceneDocument *m_mapTheme;
LayerManager *m_layerManager;
- static TextureColorizer *m_texcolorizer; //left as null if unused
+ TextureColorizer m_texcolorizer;
HttpDownloadManager *m_downloadManager;
StackedTileLoader *m_tileLoader;
@@ -183,7 +183,6 @@
};
VectorComposer *MarbleModelPrivate::m_veccomposer = 0;
-TextureColorizer *MarbleModelPrivate::m_texcolorizer = 0;
QAtomicInt MarbleModelPrivate::refCounter(0);
GeoSceneGroup * MarbleModelPrivate::textureLayerProperties() const
@@ -208,11 +207,6 @@
MarbleModelPrivate::refCounter.ref();
if( MarbleModelPrivate::refCounter == 1 ) {
d->m_veccomposer = new VectorComposer();
- d->m_texcolorizer = 0;
- /* d->m_texcolorizer is not initialized here since it takes a long time
- to create the palette and it might not even be used. Instead it's created
- in setMapTheme if the theme being loaded does need it. If the theme
- doesn't need it, it's left as is. */
}
connect( d->m_veccomposer, SIGNAL( datasetLoaded() ), SIGNAL( modelChanged() ) );
@@ -317,7 +311,6 @@
if( MarbleModelPrivate::refCounter == 1 ) {
delete d->m_veccomposer;
- delete d->m_texcolorizer;
}
delete d->m_popSortModel;
delete d->m_placemarkmanager;
@@ -558,16 +551,9 @@
if(landfile.isEmpty())
landfile = MarbleDirs::path( "landcolors.leg" );
- if( !d->m_texcolorizer ) {
- /* This is where the TextureColorizer is created if it's needed
- by the new map theme. */
- d->m_texcolorizer = new TextureColorizer( seafile, landfile );
- } else if( d->m_texcolorizer->seafile() != seafile ||
- d->m_texcolorizer->landfile() != landfile ) {
- d->m_texcolorizer->generatePalette( seafile, landfile );
+ d->m_texcolorizer.setSeaFileLandFile( seafile, landfile );
}
}
- }
mDebug() << "THEME CHANGED: ***" << mapTheme->head()->mapThemeId();
emit themeChanged( mapTheme->head()->mapThemeId() );
@@ -669,7 +655,7 @@
// Colorize using settings from when the map was loaded
// there's no need to check the palette because it's set with the map theme
if( filter->type() == "colorize" ) {
- d->m_texcolorizer->colorize( viewParams );
+ d->m_texcolorizer.colorize( viewParams );
}
} //else { mDebug() << "No filters to act on..."; }
}
--- trunk/KDE/kdeedu/marble/src/lib/TextureColorizer.cpp #1193056:1193057
@@ -30,27 +30,27 @@
#include "AbstractProjection.h"
#include "MathHelper.h"
-using namespace Marble;
+namespace Marble
+{
-uint TextureColorizer::texturepalette[16][512];
-
-TextureColorizer::TextureColorizer( const QString& seafile,
- const QString& landfile )
+typedef struct
{
- QTime t;
- t.start();
- generatePalette(seafile, landfile);
- qDebug("TextureColorizer: Time elapsed: %d ms", t.elapsed());
-}
+ uchar x1;
+ uchar x2;
+ uchar x3;
+ uchar x4;
+} GpUint;
-QString TextureColorizer::seafile() const
+
+typedef union
{
- return m_seafile;
-}
+ uint buffer;
+ GpUint gpuint;
+} GpFifo;
-QString TextureColorizer::landfile() const
+
+TextureColorizer::TextureColorizer()
{
- return m_landfile;
}
// This function takes two images, both in viewParams:
@@ -291,9 +291,16 @@
}
}
-void TextureColorizer::generatePalette(const QString& seafile,
+void TextureColorizer::setSeaFileLandFile(const QString& seafile,
const QString& landfile)
{
+ if( m_seafile == seafile && m_landfile == landfile ) {
+ return;
+ }
+
+ QTime t;
+ t.start();
+
QImage gradientImage ( 256, 1, QImage::Format_RGB32 );
QPainter gradientPainter;
gradientPainter.begin( &gradientImage );
@@ -364,4 +371,8 @@
m_seafile = seafile;
m_landfile = landfile;
+
+ qDebug("TextureColorizer::setSeaFileLandFile: Time elapsed: %d ms", t.elapsed());
}
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/TextureColorizer.h #1193056:1193057
@@ -23,39 +23,20 @@
class ViewParams;
-typedef struct
-{
- uchar x1;
- uchar x2;
- uchar x3;
- uchar x4;
-} GpUint;
-
-
-typedef union
-{
- uint buffer;
- GpUint gpuint;
-} GpFifo;
-
-
class TextureColorizer
{
public:
- TextureColorizer(const QString&, const QString&);
+ TextureColorizer();
virtual ~TextureColorizer(){}
void colorize(ViewParams *viewParams);
- QString seafile() const;
- QString landfile() const;
-
- void generatePalette( const QString& seafile,
+ void setSeaFileLandFile( const QString& seafile,
const QString& landfile );
private:
QString m_seafile;
QString m_landfile;
- static uint texturepalette[16][512];
+ uint texturepalette[16][512];
};
}
More information about the Marble-commits
mailing list