1 #include <qmetatype.h> // Needs to come before egl.h.
2 #include <qdatastream.h> // Needs to come before egl.h.
3 #include <qtextstream.h> // Needs to come before egl.h.
4 #include <qcursor.h> // Needs to come before egl.h.
5 #include <qcoreevent.h> // Needs to come before egl.h.
8 #include <QSurfaceFormat>
11 #include "mainwindow.h"
13 #include <movit/resource_pool.h>
19 #include "ref_counted_gl_sync.h"
26 #include <movit/util.h>
31 GLWidget::GLWidget(QWidget *parent)
32 : QGLWidget(parent, global_share_widget),
33 resource_pool(new movit::ResourcePool)
41 void GLWidget::initializeGL()
43 printf("egl context=%p\n", eglGetCurrentContext());
44 //printf("threads: %p %p\n", QThread::currentThread(), qGuiApp->thread());
46 static std::once_flag flag;
47 std::call_once(flag, [this]{
48 global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format()));
49 global_mixer->start();
51 global_mixer->set_frame_ready_callback(output, [this]{
52 QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
53 emit transition_names_updated(global_mixer->get_transition_names());
57 glDisable(GL_DEPTH_TEST);
58 glDepthMask(GL_FALSE);
61 void GLWidget::resizeGL(int width, int height)
63 glViewport(0, 0, width, height);
66 void GLWidget::paintGL()
68 Mixer::DisplayFrame frame;
69 if (!global_mixer->get_display_frame(output, &frame)) {
70 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
71 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
75 glWaitSync(frame.ready_fence.get(), /*flags=*/0, GL_TIMEOUT_IGNORED);
77 frame.chain->render_to_screen();
81 void GLWidget::mousePressEvent(QMouseEvent *event)