summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Rahn <rahn@kde.org>2016-11-10 00:00:46 (GMT)
committerTorsten Rahn <trahn@testo.de>2016-11-10 00:08:44 (GMT)
commit070c60b5d9901d61a1758459b51095e5355da113 (patch)
tree8494be156a5a6e4fc88348d82c159b095aa6ba7d
parent0db4edeb1116464bec680b33d68cac091ed27cf4 (diff)
Add batch rendering visualization for the desktop:
This debug mode can be enabled via the "B" key stroke. Ideally while rendering items the painter should perform a minimal amount of Pen/Brush state changes. This goal is reached when items with the same pen/brush assigned get rendered in a single batch. This visualization mode changes the color of the pen and brush whenever a new different pen/brush is assigned. As a result it's possible to observe - different sub chunks of roads which should be merged into a single item - objects that should be rendered in the same batch should have the same color for a given frame. TODO: - Add this feature to Marble Maps - add defines to the debug methods to prevent compilation into the stable release.
-rw-r--r--src/lib/marble/ClipPainter.cpp68
-rw-r--r--src/lib/marble/ClipPainter.h6
-rw-r--r--src/lib/marble/MarbleMap.cpp17
-rw-r--r--src/lib/marble/MarbleMap.h10
-rw-r--r--src/lib/marble/MarbleWidget.cpp10
-rw-r--r--src/lib/marble/MarbleWidget.h9
-rw-r--r--src/lib/marble/MarbleWidgetInputHandler.cpp3
7 files changed, 122 insertions, 1 deletions
diff --git a/src/lib/marble/ClipPainter.cpp b/src/lib/marble/ClipPainter.cpp
index b283793..23f3e40 100644
--- a/src/lib/marble/ClipPainter.cpp
+++ b/src/lib/marble/ClipPainter.cpp
@@ -89,7 +89,10 @@ class ClipPainterPrivate
qreal m_labelAreaMargin;
+ int m_debugPenBatchColor;
+ int m_debugBrushBatchColor;
int m_debugPolygonsLevel;
+ bool m_debugBatchRender;
};
}
@@ -288,6 +291,61 @@ void ClipPainter::drawPolyline(const QPolygonF & polygon, QVector<QPointF>& labe
}
}
+void ClipPainter::setPen(const QColor &color) {
+ if (d->m_debugBatchRender) {
+ qDebug() << Q_FUNC_INFO;
+ }
+ setPen(QPen(color));
+}
+
+void ClipPainter::setPen(Qt::PenStyle style) {
+ if (d->m_debugBatchRender) {
+ qDebug() << Q_FUNC_INFO;
+ }
+ setPen(QPen(style));
+}
+
+void ClipPainter::setPen(const QPen & pen) {
+ if (d->m_debugBatchRender) {
+ qDebug() << Q_FUNC_INFO;
+ if (pen != QPainter::pen()) {
+ qDebug() << "--" << pen.color() << QPainter::pen().color() ;
+ QPen newPen = pen;
+ newPen.setColor((Qt::GlobalColor)(d->m_debugPenBatchColor));
+ QPainter::setPen(newPen);
+ d->m_debugPenBatchColor++;
+ d->m_debugPenBatchColor %= 20;
+ }
+ else {
+ qDebug() << "++";
+ QPainter::setPen(pen);
+ }
+ }
+ else {
+ QPainter::setPen(pen);
+ }
+}
+
+void ClipPainter::setBrush(const QBrush & brush) {
+ if (d->m_debugBatchRender) {
+ qDebug() << Q_FUNC_INFO;
+ if (brush != QPainter::brush()) {
+ qDebug() << "--" << brush.color() << QPainter::brush().color() ;
+ QBrush batchColor(QColor((Qt::GlobalColor)(d->m_debugBrushBatchColor)));
+ QPainter::setBrush(batchColor);
+ d->m_debugBrushBatchColor++;
+ d->m_debugBrushBatchColor %= 20;
+ }
+ else {
+ qDebug() << "++";
+ QPainter::setBrush(brush);
+ }
+ }
+ else {
+ QPainter::setBrush(brush);
+ }
+}
+
void ClipPainterPrivate::labelPosition(const QPolygonF & polygon, QVector<QPointF>& labelNodes,
LabelPositionFlags labelPositionFlags)
{
@@ -409,7 +467,10 @@ ClipPainterPrivate::ClipPainterPrivate( ClipPainter * parent )
m_currentPoint(QPointF()),
m_previousPoint(QPointF()),
m_labelAreaMargin(10.0),
- m_debugPolygonsLevel(0)
+ m_debugPenBatchColor(0),
+ m_debugBrushBatchColor(0),
+ m_debugPolygonsLevel(0),
+ m_debugBatchRender(false)
{
q = parent;
}
@@ -1174,6 +1235,11 @@ void ClipPainter::setDebugPolygonsLevel( int level ) {
d->m_debugPolygonsLevel = level;
}
+void ClipPainter::setDebugBatchRender( bool enabled ) {
+ d->m_debugBatchRender = enabled;
+}
+
+
void ClipPainterPrivate::debugDrawNodes( const QPolygonF & polygon )
{
diff --git a/src/lib/marble/ClipPainter.h b/src/lib/marble/ClipPainter.h
index a404c85..cfb81a4 100644
--- a/src/lib/marble/ClipPainter.h
+++ b/src/lib/marble/ClipPainter.h
@@ -65,7 +65,13 @@ class MARBLE_EXPORT ClipPainter : public QPainter
void drawPolyline( const QPolygonF &, QVector<QPointF>& labelNodes,
LabelPositionFlags labelPositionFlag = LineCenter );
+ void setPen(const QColor &);
+ void setPen(const QPen & pen);
+ void setPen(Qt::PenStyle style);
+ void setBrush(const QBrush & brush);
+
void setDebugPolygonsLevel( int );
+ void setDebugBatchRender( bool );
// void clearNodeCount(){ m_debugNodeCount = 0; }
// int nodeCount(){ return m_debugNodeCount; }
diff --git a/src/lib/marble/MarbleMap.cpp b/src/lib/marble/MarbleMap.cpp
index 92afd82..7de325f 100644
--- a/src/lib/marble/MarbleMap.cpp
+++ b/src/lib/marble/MarbleMap.cpp
@@ -140,6 +140,7 @@ public:
ViewportParams m_viewport;
bool m_showFrameRate;
bool m_showDebugPolygons;
+ bool m_showDebugBatchRender;
StyleBuilder m_styleBuilder;
QList<RenderPlugin *> m_renderPlugins;
@@ -166,6 +167,7 @@ MarbleMapPrivate::MarbleMapPrivate( MarbleMap *parent, MarbleModel *model ) :
m_viewParams(),
m_showFrameRate( false ),
m_showDebugPolygons( false ),
+ m_showDebugBatchRender( false ),
m_styleBuilder(),
m_layerManager( parent ),
m_customPaintLayer( parent ),
@@ -826,6 +828,7 @@ void MarbleMap::paint( GeoPainter &painter, const QRect &dirtyRect )
painter.setDebugPolygonsLevel(2);
}
}
+ painter.setDebugBatchRender(d->m_showDebugBatchRender);
if ( !d->m_model->mapTheme() ) {
mDebug() << "No theme yet!";
@@ -1253,6 +1256,20 @@ bool MarbleMap::showDebugPolygons() const
return d->m_showDebugPolygons;
}
+void MarbleMap::setShowDebugBatchRender( bool visible)
+{
+ qDebug() << Q_FUNC_INFO << visible;
+ if (visible != d->m_showDebugBatchRender) {
+ d->m_showDebugBatchRender = visible;
+ emit repaintNeeded();
+ }
+}
+
+bool MarbleMap::showDebugBatchRender() const
+{
+ return d->m_showDebugBatchRender;
+}
+
void MarbleMap::setShowDebugPlacemarks( bool visible)
{
if (visible != d->m_placemarkLayer.isDebugModeEnabled()) {
diff --git a/src/lib/marble/MarbleMap.h b/src/lib/marble/MarbleMap.h
index c9500cd..cc1f7ea 100644
--- a/src/lib/marble/MarbleMap.h
+++ b/src/lib/marble/MarbleMap.h
@@ -651,6 +651,16 @@ class MARBLE_EXPORT MarbleMap : public QObject
/**
* @brief Set whether to enter the debug mode for
+ * visualizing batch rendering
+ * @param visible visibility of the batch rendering
+ */
+ void setShowDebugBatchRender( bool visible);
+
+ bool showDebugBatchRender() const;
+
+
+ /**
+ * @brief Set whether to enter the debug mode for
* placemark drawing
* @param visible visibility of the node debug mode
*/
diff --git a/src/lib/marble/MarbleWidget.cpp b/src/lib/marble/MarbleWidget.cpp
index a48539b..d5eed53 100644
--- a/src/lib/marble/MarbleWidget.cpp
+++ b/src/lib/marble/MarbleWidget.cpp
@@ -930,6 +930,16 @@ bool MarbleWidget::showDebugPolygons() const
return d->m_map.showDebugPolygons();
}
+void MarbleWidget::setShowDebugBatchRender( bool visible)
+{
+ d->m_map.setShowDebugBatchRender( visible );
+}
+
+bool MarbleWidget::showDebugBatchRender() const
+{
+ return d->m_map.showDebugBatchRender();
+}
+
void MarbleWidget::setShowDebugPlacemarks( bool visible)
{
d->m_map.setShowDebugPlacemarks( visible );
diff --git a/src/lib/marble/MarbleWidget.h b/src/lib/marble/MarbleWidget.h
index 66db8d5..68de6f7 100644
--- a/src/lib/marble/MarbleWidget.h
+++ b/src/lib/marble/MarbleWidget.h
@@ -949,6 +949,15 @@ class MARBLE_EXPORT MarbleWidget : public QWidget
/**
* @brief Set whether to enter the debug mode for
+ * batch rendering
+ * @param visible visibility of the batch rendering
+ */
+ void setShowDebugBatchRender( bool visible);
+
+ bool showDebugBatchRender() const;
+
+ /**
+ * @brief Set whether to enter the debug mode for
* placemark drawing
* @param visible visibility of the node debug mode
*/
diff --git a/src/lib/marble/MarbleWidgetInputHandler.cpp b/src/lib/marble/MarbleWidgetInputHandler.cpp
index 908c0cc..738552e 100644
--- a/src/lib/marble/MarbleWidgetInputHandler.cpp
+++ b/src/lib/marble/MarbleWidgetInputHandler.cpp
@@ -119,6 +119,9 @@ bool MarbleWidgetInputHandler::handleKeyPress(QKeyEvent *event)
case Qt::Key_P:
d->m_marbleWidget->setShowDebugPolygons(!d->m_marbleWidget->showDebugPolygons());
break;
+ case Qt::Key_B:
+ d->m_marbleWidget->setShowDebugBatchRender(!d->m_marbleWidget->showDebugBatchRender());
+ break;
}
}
return MarbleDefaultInputHandler::handleKeyPress(event);