bool GraphicsItemRenderer::onSetHue(qreal h)
{
    if (!isOpenGL())
        return false;
    d_func().glv.setHue(h);
    return true;
}
bool GraphicsItemRenderer::onSetSaturation(qreal s)
{
    if (!isOpenGL())
        return false;
    d_func().glv.setSaturation(s);
    return true;
}
bool GraphicsItemRenderer::onSetBrightness(qreal b)
{
    if (!isOpenGL())
        return false;
    d_func().glv.setBrightness(b);
    return true;
}
bool GraphicsItemRenderer::onSetContrast(qreal c)
{
    if (!isOpenGL())
        return false;
    d_func().glv.setContrast(c);
    return true;
}
Example #5
0
bool QQuickItemRenderer::onSetOrientation(int value)
{
    Q_UNUSED(value);
    if (!isOpenGL()) {
        if (value == 90 || value == 270)
            return false;
    }
    emit orientationChanged();
    return true;
}
bool GraphicsItemRenderer::onSetSaturation(qreal s)
{
    if (!isOpenGL())
        return false;
#if QTAV_HAVE(OPENGL)
    d_func().glv.setSaturation(s);
    update();
    return true;
#endif
    return false;
}
bool GraphicsItemRenderer::onSetContrast(qreal c)
{
    if (!isOpenGL())
        return false;
#if QTAV_HAVE(OPENGL)
    d_func().glv.setContrast(c);
    update();
    return true;
#endif
    return false;
}
bool GraphicsItemRenderer::onSetBrightness(qreal b)
{
    if (!isOpenGL())
        return false;
#if QTAV_HAVE(OPENGL)
    d_func().glv.setBrightness(b);
    update();
    return true;
#endif
    return false;
}
Example #9
0
bool GraphicsItemRenderer::onSetHue(qreal h)
{
    if (!isOpenGL())
        return false;
    Q_UNUSED(h);
#if QTAV_HAVE(OPENGL)
    d_func().glv.setHue(h);
    update();
    return true;
#endif
    return false;
}
Example #10
0
void QuickVideoPreview::displayFrame(const QtAV::VideoFrame &frame)
{
    int diff = qAbs(qint64(frame.timestamp()*1000.0) - m_extractor.position());
    if (diff > m_extractor.precision()) {
        //qWarning("timestamp difference (%d/%lld) is too large! ignore", diff);
    }
    if (isOpenGL() || frame.imageFormat() != QImage::Format_Invalid) {
        receive(frame);
        return;
    }
    VideoFrame f(frame.to(VideoFormat::Format_RGB32, boundingRect().toRect().size()));
    if (!f.isValid())
        return;
    receive(f);
}
Example #11
0
bool QQuickItemRenderer::receiveFrame(const VideoFrame &frame)
{
    DPTR_D(QQuickItemRenderer);
    d.video_frame = frame;
    if (!isOpenGL()) {
        d.image = QImage((uchar*)frame.constBits(), frame.width(), frame.height(), frame.bytesPerLine(), frame.imageFormat());
        QRect r = realROI();
        if (r != QRect(0, 0, frame.width(), frame.height()))
            d.image = d.image.copy(r);
    }
    d.frame_changed = true;
//    update();  // why update slow? because of calling in a different thread?
    //QMetaObject::invokeMethod(this, "update"); // slower than directly postEvent
    QCoreApplication::postEvent(this, new QEvent(QEvent::User));
    return true;
}
Example #12
0
bool GraphicsItemRenderer::receiveFrame(const VideoFrame& frame)
{
#if QTAV_HAVE(OPENGL)
    DPTR_D(GraphicsItemRenderer);
    if (isOpenGL()) {
        d.video_frame = frame;
        if (d.checkGL())
            d.glv.setCurrentFrame(frame);
    } else
#endif
    {
        prepareFrame(frame);
    }
    scene()->update(sceneBoundingRect());
    //update(); //does not cause an immediate paint. my not redraw.
    return true;
}
bool GraphicsItemRenderer::receiveFrame(const VideoFrame& frame)
{
    DPTR_D(GraphicsItemRenderer);
    if (isOpenGL()) {
        {
            QMutexLocker locker(&d.img_mutex);
            Q_UNUSED(locker);
            d.video_frame = frame;
        }
        if (d.checkGL())
            d.glv.setCurrentFrame(frame);
    } else {
        prepareFrame(frame);
    }
    scene()->update(sceneBoundingRect());
    //update(); //does not cause an immediate paint. my not redraw.
    return true;
}
Example #14
0
QSGNode *QQuickItemRenderer::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data)
{
    Q_UNUSED(data);
    DPTR_D(QQuickItemRenderer);
    if (d.frame_changed) {
        if (!node) {
            if (isOpenGL()) {
                node = new SGVideoNode();
            } else {
                node = new QSGSimpleTextureNode();
            }
        }
    }
    if (!node) {
        d.frame_changed = false;
        return 0;
    }
    d.node = node;
    handlePaintEvent();
    d.node = 0;
    return node;
}
Example #15
0
void QQuickItemRenderer::drawFrame()
{
    DPTR_D(QQuickItemRenderer);
    if (!d.node)
        return;
    if (isOpenGL()) {
        SGVideoNode *sgvn = static_cast<SGVideoNode*>(d.node);
        Q_ASSERT(sgvn);
        if (d.frame_changed)
            sgvn->setCurrentFrame(d.video_frame);
        d.frame_changed = false;
        d.video_frame = VideoFrame();
        sgvn->setTexturedRectGeometry(d.out_rect, normalizedROI(), d.orientation);
        return;
    }
    if (!d.frame_changed) {
        static_cast<QSGSimpleTextureNode*>(d.node)->setRect(d.out_rect);
        d.node->markDirty(QSGNode::DirtyGeometry);
        return;
    }
    if (d.image.isNull()) {
        d.image = QImage(rendererSize(), QImage::Format_RGB32);
        d.image.fill(Qt::black);
    }
    static_cast<QSGSimpleTextureNode*>(d.node)->setRect(d.out_rect);

    if (d.texture)
        delete d.texture;

    if (d.orientation == 0) {
        d.texture = window()->createTextureFromImage(d.image);
    } else if (d.orientation == 180) {
        d.texture = window()->createTextureFromImage(d.image.mirrored(true, true));
    }
    static_cast<QSGSimpleTextureNode*>(d.node)->setTexture(d.texture);
    d.node->markDirty(QSGNode::DirtyGeometry);
    d.frame_changed = false;
    d.video_frame = VideoFrame();
}
bool GraphicsItemRenderer::isSupported(VideoFormat::PixelFormat pixfmt) const
{
    if (isOpenGL())
        return true;
    return QPainterRenderer::isSupported(pixfmt);
}