1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#include "waveform/renderers/glvsynctestrenderer.h"
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
#include "waveform/renderers/waveformwidgetrenderer.h"
#include "waveform/waveform.h"
#include "waveform/waveformwidgetfactory.h"
#include "util/performancetimer.h"
GLVSyncTestRenderer::GLVSyncTestRenderer(
WaveformWidgetRenderer* waveformWidgetRenderer)
: WaveformRendererSignalBase(waveformWidgetRenderer),
m_drawcount(0) {
initializeOpenGLFunctions();
}
GLVSyncTestRenderer::~GLVSyncTestRenderer() {
}
void GLVSyncTestRenderer::onSetup(const QDomNode &node) {
Q_UNUSED(node);
}
inline void setPoint(QPointF& point, qreal x, qreal y) {
point.setX(x);
point.setY(y);
}
void GLVSyncTestRenderer::draw(QPainter* painter, QPaintEvent* /*event*/) {
PerformanceTimer timer;
//mixxx::Duration t5, t6, t7, t8, t9, t10, t11, t12, t13;
timer.start();
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}
const WaveformData* data = waveform->data();
if (data == NULL) {
return;
}
double firstVisualIndex = m_waveformRenderer->getFirstDisplayedPosition() * dataSize;
double lastVisualIndex = m_waveformRenderer->getLastDisplayedPosition() * dataSize;
const int firstIndex = int(firstVisualIndex + 0.5);
firstVisualIndex = firstIndex - firstIndex % 2;
const int lastIndex = int(lastVisualIndex + 0.5);
lastVisualIndex = lastIndex + lastIndex % 2;
//t5 = timer.restart(); // 910 ns
// Reset device for native painting
painter->beginNativePainting();
//t6 = timer.restart(); // 29,150 ns
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//t7 = timer.restart(); // 5,770 ns
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
if (m_orientation == Qt::Vertical) {
glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
glScalef(-1.0f, 1.0f, 1.0f);
}
//t8 = timer.restart(); // 2,611 ns
if (m_alignment == Qt::AlignCenter) {
glOrtho(firstVisualIndex, lastVisualIndex, -255.0, 255.0, -10.0, 10.0);
} else if (m_alignment == Qt::AlignBottom) {
glOrtho(firstVisualIndex, lastVisualIndex, 0.0, 255.0, -10.0, 10.0);
} else {
glOrtho(firstVisualIndex, lastVisualIndex, 255.0, 0.0, -10.0, 10.0);
}
//t9 = timer.restart(); // 1,320 ns
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
//t10 = timer.restart(); // 915 ns
if (++m_drawcount & 1) {
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glColor3f(1.0f, 1.0f, 1.0f);
} else {
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
glColor3f(1.0f, 0.0f, 0.0f);
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glRectf(0, 0, 1, 1);
//t11 = timer.restart(); // 217,985 ns
glEnd();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
//t12 = timer.restart(); // 22,426 ns
painter->endNativePainting();
//t13 = timer.restart(); // 1,430 ns
//qDebug() << t5 << t6 << t7 << t8 << t9 << t10 << t11 << t12 << t13;
//qDebug() << timer.restart(); // 129,498 ns
}
#endif // !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
|