summaryrefslogtreecommitdiffstats
path: root/src/plugins/qnx/common/windowgrabber.h
diff options
context:
space:
mode:
authorDan Cape <dcape@qnx.com>2016-04-22 14:40:23 -0400
committerYoann Lopes <yoann.lopes@qt.io>2016-04-27 10:58:11 +0000
commitc1cfbd98d2c03a2aff305c4fc190424906d7f465 (patch)
tree56528f42875ef1d93881657ef3711119c5e4989e /src/plugins/qnx/common/windowgrabber.h
parent80deebcee3e9b14046a042cf6a66467ff078d57b (diff)
QNX: Avoid reading frames faster than they're rendered
The previous code would capture frames with a 60Hz timer into two pixmaps alternating pixmaps with each successive frame. Rendering was somewhat disconnected from this, if rendering was unable to occur at 60fps, multiple frames might be copied for each frame rendered. This meant that it might try copying a video frame into a pixmap that was currently being used by the GPU with bad effects. The primary effect being severe flicker on i.mx6 targets. The change is to ensure that we don't read the window data until we're just about to make use of it. This means we don't ever get ahead of ourselves and read the video window once for every frame rendered. The code has been significantly refactored. There is now a class that manages the pixmaps and egl images. This is created on demand and the images are created and destroyed when sizes change. Since this all now occurs in the proper thread, much of the nonsense of setting _q_GLThreadCallback to arrange a call from the render thread is avoided. Remove BlackBerry ifdefs that are no longer used. Change-Id: I4bf5efa4c39c8170e3f55499c167ee10e521e100 Reviewed-by: James McDonnell <jmcdonnell@qnx.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/plugins/qnx/common/windowgrabber.h')
-rw-r--r--src/plugins/qnx/common/windowgrabber.h61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/plugins/qnx/common/windowgrabber.h b/src/plugins/qnx/common/windowgrabber.h
index bcf0ce66c..06ed6f435 100644
--- a/src/plugins/qnx/common/windowgrabber.h
+++ b/src/plugins/qnx/common/windowgrabber.h
@@ -41,12 +41,41 @@
#include <EGL/eglext.h>
#include <QAbstractNativeEventFilter>
#include <QObject>
+#include <QSize>
#include <QTimer>
#include <screen/screen.h>
QT_BEGIN_NAMESPACE
+class WindowGrabberImage : public QObject
+{
+ Q_OBJECT
+
+public:
+ WindowGrabberImage();
+ ~WindowGrabberImage();
+
+ bool initialize(screen_context_t screenContext);
+
+ void destroy();
+
+ QImage getImage(screen_window_t window, const QSize &size);
+ GLuint getTexture(screen_window_t window, const QSize &size);
+
+private:
+ bool grab(screen_window_t window);
+ bool resize(const QSize &size);
+
+ QSize m_size;
+ screen_pixmap_t m_pixmap;
+ screen_buffer_t m_pixmapBuffer;
+ EGLImageKHR m_eglImage;
+ GLuint m_glTexture;
+ unsigned char *m_bufferAddress;
+ int m_bufferStride;
+};
+
class WindowGrabber : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
@@ -57,8 +86,6 @@ public:
void setFrameRate(int frameRate);
- void createEglImages();
-
void setWindowId(const QByteArray &windowId);
void start();
@@ -75,17 +102,19 @@ public:
bool eglImageSupported();
void checkForEglImageExtension();
- bool eglImagesInitialized();
+
+ int getNextTextureId();
+ QImage getNextImage();
signals:
- void frameGrabbed(const QImage &frame, int);
+ void updateScene(const QSize &size);
private slots:
- void grab();
+ void triggerUpdate();
private:
+ bool selectBuffer();
void cleanup();
- void updateFrameSize();
QTimer m_timer;
@@ -93,24 +122,14 @@ private:
screen_window_t m_window;
screen_context_t m_screenContext;
- screen_pixmap_t m_screenPixmaps[2];
- screen_buffer_t m_screenPixmapBuffers[2];
-
- char *m_screenBuffers[2];
- int m_screenBufferWidth;
- int m_screenBufferHeight;
- int m_screenBufferStride;
+ WindowGrabberImage *m_images[2];
+ QSize m_size;
- bool m_active : 1;
- bool m_screenContextInitialized : 1;
- bool m_screenPixmapBuffersInitialized : 1;
+ bool m_active;
int m_currentFrame;
- EGLImageKHR img[2];
- GLuint imgTextures[2];
- bool m_eglImageSupported : 1;
- bool m_eglImagesInitialized : 1;
- bool m_eglImageCheck : 1; // We must not send a grabed frame before this is true
+ bool m_eglImageSupported;
+ bool m_eglImageCheck; // We must not send a grabed frame before this is true
};
QT_END_NAMESPACE