[Marble-commits] KDE/kdeedu/marble/src/plugins/render/routing
Dennis Nienhüser
earthwings at gentoo.org
Thu Jan 6 14:55:40 CET 2011
SVN commit 1212304 by nienhueser:
Performance optimizations:
- Avoid dynamic_casts in eventFilter which is called quite often
- Only repaint marble widget when the button check state has really changed. zoomChanged() is called frequently.
- Activate item caching via pixmaps. This increases rendering speed nearly by a factor of 4 on my system, painting the float item without caching takes around 55 ms, less than 1 ms with.
M +10 -4 RoutingPlugin.cpp
--- trunk/KDE/kdeedu/marble/src/plugins/render/routing/RoutingPlugin.cpp #1212303:1212304
@@ -36,7 +36,6 @@
#include <QtGui/QActionGroup>
#include <QtGui/QPixmap>
#include <QtGui/QPlastiqueStyle>
-#include <QtCore/QDebug>
namespace Marble
{
@@ -138,11 +137,16 @@
int const minZoom = m_marbleWidget ? m_marbleWidget->minimumZoom() : 900;
int const maxZoom = m_marbleWidget ? m_marbleWidget->maximumZoom() : 2400;
- m_widget.zoomInButton->setEnabled( zoomValue < maxZoom );
- m_widget.zoomOutButton->setEnabled( zoomValue > minZoom );
+ bool const zoomInEnabled = zoomValue < maxZoom;
+ bool const zoomOutEnabled = zoomValue > minZoom;
+ if ( ( zoomInEnabled != m_widget.zoomInButton->isEnabled() ) ||
+ ( zoomOutEnabled != m_widget.zoomOutButton->isEnabled() ) ) {
+ m_widget.zoomInButton->setEnabled( zoomInEnabled );
+ m_widget.zoomOutButton->setEnabled( zoomOutEnabled );
forceRepaint();
}
+}
void RoutingPluginPrivate::updateGuidanceModeButton()
{
@@ -152,6 +156,7 @@
void RoutingPluginPrivate::forceRepaint()
{
+ m_widgetItem->update();
if ( m_marbleWidget ) {
// Trigger a repaint of the float item. Otherwise button state updates are delayed
m_marbleWidget->setAttribute( Qt::WA_NoSystemBackground, false );
@@ -384,6 +389,7 @@
d->m_widgetItem = new WidgetGraphicsItem( this );
d->m_widgetItem->setWidget( widget );
+ d->m_widgetItem->setCacheMode( MarbleGraphicsItem::DeviceCoordinateCache );
bool const smallScreen = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen;
if ( smallScreen ) {
@@ -408,7 +414,7 @@
bool RoutingPlugin::eventFilter( QObject *object, QEvent *e )
{
- if ( !enabled() || !visible() ) {
+ if ( d->m_marbleWidget || !enabled() || !visible() ) {
return AbstractFloatItem::eventFilter( object, e );
}
More information about the Marble-commits
mailing list