[mmap] partial revert of 8cef8db4 to disable using mmap file reader
[videoplayer.git] / GLvideo_mt.cpp
blobc717482919680c2fa191c5f92c70d1e0169eec7e
1 /* ***** BEGIN LICENSE BLOCK *****
3 * The MIT License
5 * Copyright (c) 2008 BBC Research
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
25 * ***** END LICENSE BLOCK ***** */
27 #include "GLvideo_mt.h"
28 #include "GLvideo_rt.h"
29 #include "videoTransport.h"
30 #include "frameQueue.h"
32 #include "GLvideo_params.h"
34 GLvideo_mt::GLvideo_mt(QWidget* parent, VideoTransport *v, GLvideo_params& vr_params) :
35 QGLWidget(parent), vt(v), renderThread(new GLvideo_rt(*this, vr_params)), vr_params(vr_params)
37 alwaysHideMouse = false;
38 setMouseTracking(true);
39 connect(&mouseHideTimer, SIGNAL(timeout()), this, SLOT(hideMouse()));
40 mouseHideTimer.setSingleShot(true);
43 GLvideo_mt::~GLvideo_mt()
45 if(renderThread) delete renderThread;
48 void GLvideo_mt::start()
50 renderThread->start(/*QThread::TimeCriticalPriority*/);
53 /* Reveal the mouse whenever it is moved,
54 * Cause it to be hidden 1second later */
55 void GLvideo_mt::mouseMoveEvent(QMouseEvent *ev)
57 ev=ev;
59 if (!mouseHideTimer.isActive() && alwaysHideMouse==false)
60 setCursor(QCursor(Qt::ArrowCursor));
61 mouseHideTimer.start(1000);
64 void GLvideo_mt::hideMouse()
66 setCursor(QCursor(Qt::BlankCursor));
69 void GLvideo_mt::setAlwaysHideMouse(bool h)
71 alwaysHideMouse=h;
73 if (alwaysHideMouse)
74 hideMouse();
77 void GLvideo_mt::initializeGL()
79 //handled by the worker thread
82 /* rendering is done here. */
83 void GLvideo_mt::paintGL()
87 void GLvideo_mt::paintEvent(QPaintEvent * event)
89 event=event;
90 //absorb any paint events - let the worker thread update the window
93 void GLvideo_mt::resizeEvent(QResizeEvent * event)
95 //added at the suggestion of Trolltech - if the rendering thread
96 //is slow to start the first window resize event will issue a makeCurrent() before
97 //the rendering thread does, stealing the openGL context from it
98 renderThread->resizeViewport(event->size().width(), event->size().height());