summaryrefslogtreecommitdiffstats
path: root/src/plugins/android
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-10-02 13:48:43 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-10-02 13:48:43 +0200
commit87e5e24f52f0702620cd6ff656db540f01a28cc5 (patch)
tree7f83b2423b1a06b21085a76da3347088ca30e8cf /src/plugins/android
parentc5ebfb0c19deff34eea5099ba59750b746257d71 (diff)
parent46a83d5b86a792e62f14674e27c5d95695f2b44d (diff)
Merge remote-tracking branch 'origin/5.5' into 5.6
Diffstat (limited to 'src/plugins/android')
-rw-r--r--src/plugins/android/src/common/qandroidvideorendercontrol.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp
index bf95c42f6..cd9c9d1d6 100644
--- a/src/plugins/android/src/common/qandroidvideorendercontrol.cpp
+++ b/src/plugins/android/src/common/qandroidvideorendercontrol.cpp
@@ -73,29 +73,60 @@ public:
: QAbstractVideoBuffer(GLTextureHandle)
, m_control(control)
, m_textureUpdated(false)
+ , m_mapMode(NotMapped)
{
}
virtual ~AndroidTextureVideoBuffer() {}
- MapMode mapMode() const { return NotMapped; }
- uchar *map(MapMode, int*, int*) { return 0; }
- void unmap() {}
+ MapMode mapMode() const { return m_mapMode; }
+
+ uchar *map(MapMode mode, int *numBytes, int *bytesPerLine)
+ {
+ if (m_mapMode == NotMapped && mode == ReadOnly) {
+ updateFrame();
+ m_mapMode = mode;
+ m_image = m_control->m_fbo->toImage();
+
+ if (numBytes)
+ *numBytes = m_image.byteCount();
+
+ if (bytesPerLine)
+ *bytesPerLine = m_image.bytesPerLine();
+
+ return m_image.bits();
+ } else {
+ return 0;
+ }
+ }
+
+ void unmap()
+ {
+ m_image = QImage();
+ m_mapMode = NotMapped;
+ }
QVariant handle() const
{
+ AndroidTextureVideoBuffer *that = const_cast<AndroidTextureVideoBuffer*>(this);
+ that->updateFrame();
+ return m_control->m_fbo->texture();
+ }
+
+private:
+ void updateFrame()
+ {
if (!m_textureUpdated) {
// update the video texture (called from the render thread)
m_control->renderFrameToFbo();
m_textureUpdated = true;
}
-
- return m_control->m_fbo->texture();
}
-private:
- mutable QAndroidVideoRendererControl *m_control;
- mutable bool m_textureUpdated;
+ QAndroidVideoRendererControl *m_control;
+ bool m_textureUpdated;
+ MapMode m_mapMode;
+ QImage m_image;
};
QAndroidVideoRendererControl::QAndroidVideoRendererControl(QObject *parent)