~mterry/qtvideo-node/dont-install-tests

« back to all changes in this revision

Viewing changes to src/shadervideonode.cpp

Use static shader object, as Qt caches the pointer to it
Using QAbstractVideoSurface::stop() obsoletes the check for the CameraControl pointer on every frame.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
void ShaderVideoNode::setCurrentFrame(const QVideoFrame &frame)
38
38
{
39
 
    /* The AAL+ CameraControl pointer is updated with every frame
40
 
     * Reason is, that the pointer might change. For example when switching the camera.
41
 
     * As the camera-backend does not know anything about this video node and vice versa,
42
 
     * it's impossible request that check/set when a new CameraControl becomes active.
43
 
     *
44
 
     * But the overhead of setting the pointer is very minor.
45
 
     */
46
 
    if (!frame.availableMetaData().contains("CamControl")) {
47
 
        qDebug() << "No camera control included in video frame";
48
 
        return;
 
39
    if (!m_material->cameraControl()) {
 
40
        if (!frame.availableMetaData().contains("CamControl")) {
 
41
            qWarning() << "No camera control included in video frame";
 
42
            return;
 
43
        }
 
44
 
 
45
        int ci = frame.metaData("CamControl").toInt();
 
46
        if (ci == 0) {
 
47
            qWarning() << "No valid camera control pointer in video frame";
 
48
            return;
 
49
        }
 
50
        m_material->setCamControl((CameraControl*)ci);
49
51
    }
50
52
 
51
 
    int ci = frame.metaData("CamControl").toInt();
52
 
    m_material->setCamControl((CameraControl*)ci);
53
 
 
54
 
    if (ci > 0)
55
 
        markDirty(DirtyMaterial);
 
53
    markDirty(DirtyMaterial);
56
54
}