void WidgetRenderer::handlePaint(QPaintEvent *event) { Q_UNUSED(event); QPainter painter(m_videoWidget); m_drawFrameRect = m_videoWidget->calculateDrawFrameRect(); painter.drawImage(drawFrameRect(), currentFrame()); frameRendered(); }
void ProcessHandler::onDataWrittenToSocket() { ///always running in the main thread assert( QThread::currentThread() == qApp->thread() ); QString str = QString::fromUtf8(_bgProcessOutputSocket->readLine()); while ( str.endsWith(QLatin1Char('\n')) ) { str.chop(1); } _processLog.append(QString::fromUtf8("Message received: ") + str + QLatin1Char('\n')); if ( str.startsWith(QString::fromUtf8(kFrameRenderedStringShort) )) { str = str.remove(QString::fromUtf8(kFrameRenderedStringShort)); double progressPercent = 0.; int foundProgress = str.lastIndexOf(QString::fromUtf8(kProgressChangedStringShort)); if (foundProgress != -1) { QString progressStr = str.mid(foundProgress); progressStr.remove(QString::fromUtf8(kProgressChangedStringShort)); progressPercent = progressStr.toDouble(); str = str.mid(0, foundProgress); } if (!str.isEmpty()) { //The report does not have extended timer infos Q_EMIT frameRendered(str.toInt(), progressPercent); } } else if ( str.startsWith(QString::fromUtf8(kRenderingFinishedStringShort)) ) { ///don't do anything } else if ( str.startsWith(QString::fromUtf8(kBgProcessServerCreatedShort)) ) { str = str.remove(QString::fromUtf8(kBgProcessServerCreatedShort)); ///the bg process wants us to create the pipe for its input if (!_bgProcessInputSocket) { _bgProcessInputSocket = new QLocalSocket(); QObject::connect( _bgProcessInputSocket, SIGNAL(connected()), this, SLOT(onInputPipeConnectionMade()) ); _bgProcessInputSocket->connectToServer(str,QLocalSocket::ReadWrite); } } else if ( str.startsWith(QString::fromUtf8(kRenderingStartedShort)) ) { ///if the user pressed cancel prior to the pipe being created, wait for it to be created and send the abort ///message right away if (_earlyCancel) { _bgProcessInputSocket->waitForConnected(5000); _earlyCancel = false; onProcessCanceled(); } } else { _processLog.append(QString::fromUtf8("Error: Unable to interpret message.\n")); throw std::runtime_error("ProcessHandler::onDataWrittenToSocket() received erroneous message"); } }
void ProcessHandler::onDataWrittenToSocket() { ///always running in the main thread assert(QThread::currentThread() == qApp->thread()); QString str = _bgProcessOutputSocket->readLine(); while(str.endsWith('\n')) { str.chop(1); } _processLog.append("Message received: " + str + '\n'); if (str.startsWith(kFrameRenderedStringShort)) { str = str.remove(kFrameRenderedStringShort); emit frameRendered(str.toInt()); } else if (str.startsWith(kRenderingFinishedStringShort)) { ///don't do anything } else if (str.startsWith(kProgressChangedStringShort)) { str = str.remove(kProgressChangedStringShort); emit frameProgress(str.toInt()); } else if (str.startsWith(kBgProcessServerCreatedShort)) { str = str.remove(kBgProcessServerCreatedShort); ///the bg process wants us to create the pipe for its input if (!_bgProcessInputSocket) { _bgProcessInputSocket = new QLocalSocket(); QObject::connect(_bgProcessInputSocket, SIGNAL(connected()), this, SLOT(onInputPipeConnectionMade())); _bgProcessInputSocket->connectToServer(str,QLocalSocket::ReadWrite); } } else if(str.startsWith(kRenderingStartedShort)) { ///if the user pressed cancel prior to the pipe being created, wait for it to be created and send the abort ///message right away if (_earlyCancel) { _bgProcessInputSocket->waitForConnected(5000); _earlyCancel = false; onProcessCanceled(); } } else { _processLog.append("Error: Unable to interpret message.\n"); throw std::runtime_error("ProcessHandler::onDataWrittenToSocket() received erroneous message"); } }
void GLRenderWidgetImplementation::paintEvent(QPaintEvent *) { QPainter painter(this); m_drawFrameRect = m_videoWidget->calculateDrawFrameRect(); if (m_yuvSupport && frameIsSet()) { glEnable(GL_FRAGMENT_PROGRAM_ARB); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_program); const float tx_array[] = { 0, 0, 1, 0, 1, 1, 0, 1}; const QRectF r = drawFrameRect(); const float v_array[] = { float(r.left()), float(r.top()), float(r.right()), float(r.top()), float(r.right()), float(r.bottom()), float(r.left()), float(r.bottom()) }; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_texture[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, m_texture[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, m_texture[2]); glActiveTexture(GL_TEXTURE0); glVertexPointer(2, GL_FLOAT, 0, v_array); glTexCoordPointer(2, GL_FLOAT, 0, tx_array); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDrawArrays(GL_QUADS, 0, 4); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_FRAGMENT_PROGRAM_ARB); } else { painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.drawImage(drawFrameRect(), currentFrame()); } frameRendered(); }