1

I have my own class which inherits from Qt5.6 QGraphcisView.

Also I have a QGraphicsPixmapItem on scene. (Forgot to say) ANGLE is enabled!

CMyGraphicsView::CMyGraphicsView(QWidget *parent) : QGraphcisView(parent)
{
    QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
    QGLFormat fmt(QGL::SampleBuffers);
    fmt.setSwapInterval(2);
    gl = new QGLWidget(fmt);
    setViewport(gl);
....
}

I do update of pixmap frequently to make animation like video. In fact it is video because I implement my own QAbstractVideoSurface for QMediaPlayer and I receive video frames which I update on scene.

bool MyPlayer::present(const QVideoFrame &Frame)
{
    MyPlayer* player = reinterpret_cast<MyPlayer*>(parent());
    if (Frame.isValid())
    {
        QVideoFrame myframe(Frame);

        if (!myframe.map(QAbstractVideoBuffer::ReadOnly))
            return false;

        QImage image(
            (const unsigned char*)myframe.bits(),
            myframe.width(),
            myframe.height(),
            myframe.bytesPerLine(),
            QVideoFrame::imageFormatFromPixelFormat( myframe.pixelFormat() )
        );

        QPixmap pixmap = QPixmap::fromImage(image, Qt::NoFormatConversion);
        pixmap_frame_->setPixmap(pixmap);
        myframe.unmap();
        return true;
    }
    return false;
}

Issue is that on Intel integrated video card i see that animation is flickering like update is not synchronized with display VSYNC.

On NVIDIA cards seem all is ok and no issue.

I read from Qt documentation that making fmt.setSwapInterval(2) should allow me to do update of screen every 2nd VSYNC refresh, so I expect to have smooth 30fps animation on 60Hz display. Besides that seem setSwapInterval() makes nothing neither for Intel nor for NVIDIA:

On Intel cards it is always flickering and on NVIDIA card it is always smooth not depending on swapInterval() or any other QGLFormat options.

I also tried to do fmt.setDoubleBuffer(true); but also does not help in case of Intel cards. How can i fix flickering issue?

Of cause i can put on scene directly QGraphicsVideoItem - then it is ok, but i cannot use this option because later I need to modify frame pixels on the fly - for that i need QAbstractVideoSurface.

nckm
  • 103
  • 1
  • 10

0 Answers0