[Marble-commits] KDE/kdeedu/marble/src/lib
Torsten Rahn
tackat at kde.org
Tue Jan 19 17:38:34 CET 2010
SVN commit 1077195 by rahn:
- Make Marble about 5-10% faster for full screen mode and allow for more
tuning in the future.
M +81 -29 AbstractScanlineTextureMapper.cpp
M +13 -1 AbstractScanlineTextureMapper.h
M +1 -1 TextureTile.cpp
--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.cpp #1077194:1077195
@@ -272,23 +272,27 @@
qreal oldPosX = -1;
qreal oldPosY = 0;
+ const bool alwaysCheckTileRange =
+ isOutOfTileRangeF( itLon, itLat, itStepLon, itStepLat,
+ tileWidth, tileHeight, n );
+
for ( int j=1; j < n; ++j ) {
qreal posX = itLon + itStepLon * j;
qreal posY = itLat + itStepLat * j;
+ if ( alwaysCheckTileRange )
+ if ( posX >= tileWidth
+ || posX < 0.0
+ || posY >= tileHeight
+ || posY < 0.0 )
+ {
+ nextTile( posX, posY );
+ itLon = m_prevLon + m_toTileCoordinatesLon;
+ itLat = m_prevLat + m_toTileCoordinatesLat;
+ posX = itLon + itStepLon * j;
+ posY = itLat + itStepLat * j;
+ oldPosX = -1;
+ }
- if ( posX >= tileWidth
- || posX < 0.0
- || posY >= tileHeight
- || posY < 0.0 )
- {
- nextTile( posX, posY );
- itLon = m_prevLon + m_toTileCoordinatesLon;
- itLat = m_prevLat + m_toTileCoordinatesLat;
- posX = itLon + itStepLon * j;
- posY = itLat + itStepLat * j;
- oldPosX = -1;
- }
-
*scanLine = m_tile->pixel( posX, posY );
// Just perform bilinear interpolation if there's a color change compared to the
@@ -355,6 +359,23 @@
}
}
+
+bool AbstractScanlineTextureMapper::isOutOfTileRangeF( qreal itLon, qreal itLat,
+ qreal itStepLon, qreal itStepLat,
+ int tileWidth, int tileHeight,
+ int n ) const
+{
+ qreal minIPosX = itLon + itStepLon;
+ qreal minIPosY = itLat + itStepLat;
+ qreal maxIPosX = itLon + itStepLon * ( n - 1 );
+ qreal maxIPosY = itLat + itStepLat * ( n - 1 );
+ return ( maxIPosX >= tileWidth || maxIPosX < 0
+ || maxIPosY >= tileHeight || maxIPosY < 0
+ || minIPosX >= tileWidth || minIPosX < 0
+ || minIPosY >= tileHeight || minIPosY < 0 );
+}
+
+
void AbstractScanlineTextureMapper::pixelValueApprox(const qreal& lon,
const qreal& lat, QRgb *scanLine,
int n )
@@ -386,24 +407,38 @@
const int tileWidth = m_tileLoader->tileWidth();
const int tileHeight = m_tileLoader->tileHeight();
- for ( int j = 1; j < n; ++j ) {
- int iPosX = ( itLon + itStepLon * j ) >> 7;
- int iPosY = ( itLat + itStepLat * j ) >> 7;
+ const bool alwaysCheckTileRange =
+ isOutOfTileRange( itLon, itLat, itStepLon, itStepLat,
+ tileWidth, tileHeight, n );
+
+ if ( !alwaysCheckTileRange ) {
+ for ( int j = 1; j < n; ++j ) {
+ int iPosX = ( itLon + itStepLon * j ) >> 7;
+ int iPosY = ( itLat + itStepLat * j ) >> 7;
+ *scanLine = m_tile->pixel( iPosX, iPosY );
+ ++scanLine;
+ }
+ }
+ else {
+ for ( int j = 1; j < n; ++j ) {
+ int iPosX = ( itLon + itStepLon * j ) >> 7;
+ int iPosY = ( itLat + itStepLat * j ) >> 7;
- if ( iPosX >= tileWidth
- || iPosX < 0
- || iPosY >= tileHeight
- || iPosY < 0 )
- {
- nextTile( iPosX, iPosY );
- itLon = (int)( ( m_prevLon + m_toTileCoordinatesLon ) * 128.0 );
- itLat = (int)( ( m_prevLat + m_toTileCoordinatesLat ) * 128.0 );
- iPosX = ( itLon + itStepLon * j ) >> 7;
- iPosY = ( itLat + itStepLat * j ) >> 7;
+ if ( iPosX >= tileWidth
+ || iPosX < 0
+ || iPosY >= tileHeight
+ || iPosY < 0 )
+ {
+ nextTile( iPosX, iPosY );
+ itLon = (int)( ( m_prevLon + m_toTileCoordinatesLon ) * 128.0 );
+ itLat = (int)( ( m_prevLat + m_toTileCoordinatesLat ) * 128.0 );
+ iPosX = ( itLon + itStepLon * j ) >> 7;
+ iPosY = ( itLat + itStepLat * j ) >> 7;
+ }
+
+ *scanLine = m_tile->pixel( iPosX, iPosY );
+ ++scanLine;
}
-
- *scanLine = m_tile->pixel( iPosX, iPosY );
- ++scanLine;
}
}
@@ -448,6 +483,23 @@
}
}
+
+bool AbstractScanlineTextureMapper::isOutOfTileRange( int itLon, int itLat,
+ int itStepLon, int itStepLat,
+ int tileWidth, int tileHeight,
+ int n ) const
+{
+ int minIPosX = ( itLon + itStepLon ) >> 7;
+ int minIPosY = ( itLat + itStepLat ) >> 7;
+ int maxIPosX = ( itLon + itStepLon * ( n - 1 ) ) >> 7;
+ int maxIPosY = ( itLat + itStepLat * ( n - 1 ) ) >> 7;
+ return ( maxIPosX >= tileWidth || maxIPosX < 0
+ || maxIPosY >= tileHeight || maxIPosY < 0
+ || minIPosX >= tileWidth || minIPosX < 0
+ || minIPosY >= tileHeight || minIPosY < 0 );
+}
+
+
int AbstractScanlineTextureMapper::interpolationStep( ViewParams *viewParams ) const
{
if ( viewParams->mapQuality() == PrintQuality ) {
--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.h #1077194:1077195
@@ -53,7 +53,7 @@
private Q_SLOTS:
void notifyMapChanged();
-
+
protected:
void pixelValueF( qreal lon, qreal lat,
QRgb* scanLine );
@@ -85,6 +85,18 @@
qreal rad2PixelX( const qreal longitude ) const;
qreal rad2PixelY( const qreal latitude ) const;
+ // Checks whether the pixelValueApprox method will make use of more than
+ // one tile
+ bool isOutOfTileRange( int itLon, int itLat,
+ int itStepLon, int itStepLat,
+ int tileWidth, int tileHeight,
+ int n ) const;
+
+ bool isOutOfTileRangeF( qreal itLon, qreal itLat,
+ qreal itStepLon, qreal itStepLat,
+ int tileWidth, int tileHeight,
+ int n ) const;
+
// maximum values for global texture coordinates
// ( with origin in upper left corner, measured in pixel)
int m_maxGlobalX;
--- trunk/KDE/kdeedu/marble/src/lib/TextureTile.cpp #1077194:1077195
@@ -31,7 +31,7 @@
{
const int height = img.height();
const int bpl = img.bytesPerLine() / 4;
- uint *data = (QRgb*)(img.scanLine(0));
+ uint *data = reinterpret_cast<QRgb*>(img.bits());
uint **jumpTable = new uint*[height];
for ( int y = 0; y < height; ++y ) {
More information about the Marble-commits
mailing list