diff mbox series

[5/6] kernel-shark: Improve the appearance on high screen resolution

Message ID 20190515190911.20755-6-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Headers show
Series Various modifications and fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov May 15, 2019, 7:09 p.m. UTC
Some of the components of the plots haven't been properly scaled
when displayed on high screen resolution.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsGLWidget.cpp  | 24 ++++++++++++++----------
 kernel-shark/src/KsGLWidget.hpp  |  2 +-
 kernel-shark/src/KsPlotTools.cpp |  4 +++-
 3 files changed, 18 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsGLWidget.cpp b/kernel-shark/src/KsGLWidget.cpp
index 789514a..ce68052 100644
--- a/kernel-shark/src/KsGLWidget.cpp
+++ b/kernel-shark/src/KsGLWidget.cpp
@@ -84,24 +84,29 @@  void KsGLWidget::resizeGL(int w, int h)
 /** Reimplemented function used to plot trace graphs. */
 void KsGLWidget::paintGL()
 {
+	float size = 1.5 * _dpr;
+
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	/* Draw the time axis. */
 	if(_data)
-		_drawAxisX();
+		_drawAxisX(size);
 
 	/* Process and draw all graphs by using the built-in logic. */
 	_makeGraphs(_cpuList, _taskList);
 	for (auto const &g: _graphs)
-		g->draw(1.5 * _dpr);
+		g->draw(size);
 
 	/* Process and draw all plugin-specific shapes. */
 	_makePluginShapes(_cpuList, _taskList);
 	while (!_shapes.empty()) {
 		auto s = _shapes.front();
+		_shapes.pop_front();
+
+		s->_size = size;
 		s->draw();
+
 		delete s;
-		_shapes.pop_front();
 	}
 
 	/*
@@ -448,22 +453,21 @@  void KsGLWidget::findGraphIds(const kshark_entry &e,
 		*graphTask = -1;
 }
 
-void KsGLWidget::_drawAxisX()
+void KsGLWidget::_drawAxisX(float size)
 {
 	KsPlot::Point a0(_hMargin, _vMargin / 4), a1(_hMargin, _vMargin / 2);
-	KsPlot::Point b0(width()/2, _vMargin / 4), b1(width() / 2, _vMargin / 2);
+	KsPlot::Point b0(width() / 2, _vMargin / 4), b1(width() / 2, _vMargin / 2);
 	KsPlot::Point c0(width() - _hMargin, _vMargin / 4),
 			 c1(width() - _hMargin, _vMargin / 2);
-	int lineSize = 2 * _dpr;
 
 	a0._size = c0._size = _dpr;
 
 	a0.draw();
 	c0.draw();
-	KsPlot::drawLine(a0, a1, {}, lineSize);
-	KsPlot::drawLine(b0, b1, {}, lineSize);
-	KsPlot::drawLine(c0, c1, {}, lineSize);
-	KsPlot::drawLine(a0, c0, {}, lineSize);
+	KsPlot::drawLine(a0, a1, {}, size);
+	KsPlot::drawLine(b0, b1, {}, size);
+	KsPlot::drawLine(c0, c1, {}, size);
+	KsPlot::drawLine(a0, c0, {}, size);
 }
 
 void KsGLWidget::_makeGraphs(QVector<int> cpuList, QVector<int> taskList)
diff --git a/kernel-shark/src/KsGLWidget.hpp b/kernel-shark/src/KsGLWidget.hpp
index bc5cacf..e141b0a 100644
--- a/kernel-shark/src/KsGLWidget.hpp
+++ b/kernel-shark/src/KsGLWidget.hpp
@@ -190,7 +190,7 @@  private:
 
 	int 		_dpr;
 
-	void _drawAxisX();
+	void _drawAxisX(float size);
 
 	void _makeGraphs(QVector<int> cpuMask, QVector<int> taskMask);
 
diff --git a/kernel-shark/src/KsPlotTools.cpp b/kernel-shark/src/KsPlotTools.cpp
index 2b16a51..f95ada5 100644
--- a/kernel-shark/src/KsPlotTools.cpp
+++ b/kernel-shark/src/KsPlotTools.cpp
@@ -1089,8 +1089,10 @@  void Graph::draw(float size)
 	/* Draw as vartical lines all bins containing data. */
 	for (int i = 0; i < _size; ++i)
 		if (_bins[i]._idFront >= 0 || _bins[i]._idBack >= 0)
-			if (_bins[i]._visMask & KS_EVENT_VIEW_FILTER_MASK)
+			if (_bins[i]._visMask & KS_EVENT_VIEW_FILTER_MASK) {
+				_bins[i]._size = size;
 				_bins[i].draw();
+			}
 
 	auto lamCheckEnsblVal = [this] (int v) {
 		return v > 0 || (v == 0 && !this->_zeroSuppress);