blob: 3f39ef23f366e989c116542a9fa4c1f9ebd5c436 (
plain)
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
|
#include "glvsynctestwidget.h"
#include <QPainter>
#include "waveform/sharedglcontext.h"
#include "waveform/renderers/waveformwidgetrenderer.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderersimplesignal.h"
#include "waveform/renderers/glvsynctestrenderer.h"
#include "waveform/renderers/waveformrendererpreroll.h"
#include "waveform/renderers/waveformrendermark.h"
#include "waveform/renderers/waveformrendermarkrange.h"
#include "waveform/renderers/waveformrendererendoftrack.h"
#include "waveform/renderers/waveformrenderbeat.h"
#include "util/performancetimer.h"
GLVSyncTestWidget::GLVSyncTestWidget(const char* group, QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
WaveformWidgetAbstract(group) {
qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
makeCurrent();
}
addRenderer<WaveformRenderBackground>(); // 172 µs
// addRenderer<WaveformRendererEndOfTrack>(); // 677 µs 1145 µs (active)
// addRenderer<WaveformRendererPreroll>(); // 652 µs 2034 µs (active)
// addRenderer<WaveformRenderMarkRange>(); // 793 µs
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
addRenderer<GLVSyncTestRenderer>(); // 841 µs // 2271 µs
#endif // !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2
// addRenderer<WaveformRenderMark>(); // 711 µs
// addRenderer<WaveformRenderBeat>(); // 1183 µs
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_OpaquePaintEvent);
setAutoBufferSwap(false);
m_initSuccess = init();
qDebug() << "GLVSyncTestWidget.isSharing() =" << isSharing();
}
GLVSyncTestWidget::~GLVSyncTestWidget() {
}
void GLVSyncTestWidget::castToQWidget() {
m_widget = static_cast<QWidget*>(static_cast<QGLWidget*>(this));
}
void GLVSyncTestWidget::paintEvent(QPaintEvent* event) {
Q_UNUSED(event);
}
mixxx::Duration GLVSyncTestWidget::render() {
PerformanceTimer timer;
mixxx::Duration t1;
//mixxx::Duration t2;
timer.start();
// QPainter makes QGLContext::currentContext() == context()
// this may delayed until previous buffer swap finished
QPainter painter(this);
t1 = timer.restart();
draw(&painter, NULL);
//t2 = timer.restart();
//qDebug() << "GLVSyncTestWidget "<< t1 << t2;
return t1; // return timer for painter setup
}
|