#include "loqgraphicsvideoitem.h"
#include "loappconfig.h"

LoQGraphicsVideoItem::LoQGraphicsVideoItem(QGraphicsItem *parent) :
    QGraphicsVideoItem(parent),
    m_painterCompositionMode(QPainter::CompositionMode_SourceOver)
{
    QString glVendor = LoAppConfig::getInstance()->OpenGLVendor();
    if(glVendor.contains("NVIDIA Corporation")) { // QPainter::RasterOp_SourceAndNotDestination
        m_painterCompositionMode = QPainter::RasterOp_SourceAndNotDestination;
    }
}

void LoQGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    if(m_painterCompositionMode != QPainter::CompositionMode_SourceOver) {
        painter->save();
        painter->setCompositionMode(static_cast<QPainter::CompositionMode>(m_painterCompositionMode));
        QGraphicsVideoItem::paint(painter, option, widget);
        painter->restore();
    } else {
        QGraphicsVideoItem::paint(painter, option, widget);
    }
}
