m_curWinWidth = width() - margins.width();
m_curWinHeight = height() - margins.height();
// Re-calculate
+ m_frameInfo.updated = true;
CaptureWin::resizeScaleCrop();
// Lock viewport size to follow calculated size
m_videoSurface.lockSize(m_scaledSize);
void CaptureWinGL::setRenderFrame()
{
#ifdef HAVE_QTGL
- m_curWinWidth = m_videoSurface.width();
- m_curWinHeight = m_videoSurface.height();
-#endif
- // No recalculation is performed if all parameters are unchanged
- CaptureWin::resizeScaleCrop();
-
- // Get/copy (TODO: remove CaptureWinGLEngine and use direct or use pointer)
-#ifdef HAVE_QTGL
m_videoSurface.setFrame(m_frameInfo.frameWidth, m_frameInfo.frameHeight,
m_cropInfo.cropW, m_cropInfo.cropH,
m_frameInfo.format,
m_frameInfo.planeData[0],
m_frameInfo.planeData[1]);
#endif
+ m_frameInfo.updated = false;
+ m_cropInfo.updated = false;
}
bool CaptureWinGL::hasNativeFormat(__u32 format)
m_supportedFormat(false),
m_filled(false)
{
-
CaptureWin::buildWindow(&m_videoSurface);
- m_scaledSize.setWidth(0);
- m_scaledSize.setHeight(0);
}
CaptureWinQt::~CaptureWinQt()
{
m_curWinWidth = m_videoSurface.width();
m_curWinHeight = m_videoSurface.height();
+ m_frameInfo.updated = true;
CaptureWin::resizeScaleCrop();
paintFrame();
+ event->accept();
}
void CaptureWinQt::setRenderFrame()
if (!m_supportedFormat)
dstFmt = QImage::Format_RGB888;
- if (m_frame->width() != m_frameInfo.frameWidth
- || m_frame->height() != m_frameInfo.frameHeight
- || m_frame->format() != dstFmt) {
+ if (m_frameInfo.updated || m_frame->format() != dstFmt) {
delete m_frame;
m_frame = new QImage(m_frameInfo.frameWidth, m_frameInfo.frameHeight, dstFmt);
- // Force a recalculation by setting this to 0.
- m_cropInfo.bytes = 0;
-
- m_curWinWidth = m_videoSurface.width();
- m_curWinHeight = m_videoSurface.height();
- CaptureWin::resizeScaleCrop();
}
+ m_frameInfo.updated = false;
+
paintFrame();
}
void CaptureWinQt::paintFrame()
{
if (m_cropInfo.updated) {
- m_cropInfo.offset = m_cropInfo.cropH * (m_frame->depth() / 8)
- * m_frameInfo.frameWidth + m_cropInfo.cropW * (m_frame->depth() / 8);
-
- // Even though the values above can be valid, it might be that there is no
- // data at all. This makes sure that it is.
- m_cropInfo.bytes = m_cropInfo.height * m_cropInfo.width
- * (m_frame->depth() / 8);
- m_cropInfo.updated = 0;
+ m_cropInfo.offset = m_cropInfo.cropH * (m_frame->depth() / 8)
+ * m_frameInfo.frameWidth + m_cropInfo.cropW * (m_frame->depth() / 8);
+
+ // Even though the values above can be valid, it might be that there is no
+ // data at all. This makes sure that it is.
+ m_cropInfo.bytes = m_cropInfo.height * m_cropInfo.width
+ * (m_frame->depth() / 8);
+ m_cropInfo.updated = false;
}
if (!m_supportedFormat || !m_cropInfo.bytes) {
m_frameInfo.frameWidth = 0;
m_frameInfo.planeData[0] = NULL;
m_frameInfo.planeData[1] = NULL;
+ m_scaledSize.setWidth(0);
+ m_scaledSize.setHeight(0);
m_cropInfo.cropH = 0;
m_cropInfo.cropW = 0;
m_cropInfo.height = 0;
}
void CaptureWin::setFrame(int width, int height, __u32 format,
- unsigned char *data, unsigned char *data2, const QString &info)
+ unsigned char *data, unsigned char *data2, const QString &info)
{
- m_frameInfo.frameHeight = height;
- m_frameInfo.frameWidth = width;
- m_frameInfo.format = format;
- m_frameInfo.planeData[0] = data;
- m_frameInfo.planeData[1] = data2;
- m_frameInfo.info = info;
-
+ m_frameInfo.planeData[0] = data;
+ m_frameInfo.planeData[1] = data2;
+ m_frameInfo.info = info;
+
+ m_frameInfo.updated = false;
+ if (width != m_frameInfo.frameWidth || height != m_frameInfo.frameHeight
+ || format != m_frameInfo.format) {
+ m_frameInfo.frameHeight = height;
+ m_frameInfo.frameWidth = width;
+ m_frameInfo.format = format;
+ m_frameInfo.updated = true;
+ resizeScaleCrop();
+ }
m_information.setText(m_frameInfo.info);
setRenderFrame();
void CaptureWin::resizeScaleCrop()
{
- m_scaledSize = scaleFrameSize(QSize(m_curWinWidth, m_curWinHeight),
- QSize(m_frameInfo.frameWidth, m_frameInfo.frameHeight));
- m_cropInfo.updated = 0;
- if (!m_cropInfo.bytes
- || m_cropInfo.cropH != cropHeight(m_frameInfo.frameWidth, m_frameInfo.frameHeight)
- || m_cropInfo.cropW != cropWidth(m_frameInfo.frameWidth, m_frameInfo.frameHeight)) {
+ m_cropInfo.updated = 0;
+ if (m_frameInfo.updated) {
+ m_scaledSize = scaleFrameSize(QSize(m_curWinWidth, m_curWinHeight),
+ QSize(m_frameInfo.frameWidth, m_frameInfo.frameHeight));
m_cropInfo.cropH = cropHeight(m_frameInfo.frameWidth, m_frameInfo.frameHeight);
m_cropInfo.cropW = cropWidth(m_frameInfo.frameWidth, m_frameInfo.frameHeight);
m_cropInfo.height = m_frameInfo.frameHeight - (m_cropInfo.cropH * 2);
};
struct frameInfo {
- __u32 format;
+ __u32 format;
int frameHeight;
int frameWidth;
- unsigned char *planeData[2];
- QString info;
+ unsigned char *planeData[2];
+ QString info;
+ bool updated;
};
class CaptureWin : public QWidget