Esempio n. 1
0
void WidgetRenderer::paintEvent(QPaintEvent *)
{
    DPTR_D(WidgetRenderer);
    QMutexLocker locker(&d.img_mutex);
    Q_UNUSED(locker);
    QPainter p(this);
    //fill background color only when the displayed frame rect not equas to renderer's
    if (d.out_rect != rect()) {
        p.fillRect(rect(), QColor(0, 0, 0));
    }
    if (d.image.isNull()) {
        //TODO: when setInSize()?
        d.image = QImage(rendererSize(), QImage::Format_RGB32);
        d.image.fill(Qt::black); //maemo 4.7.0: QImage.fill(uint)
    }
    //assume that the image data is already scaled to out_size(NOT renderer size!)
    if (!d.scale_in_renderer || d.image.size() == d.out_rect.size()) {
        //d.preview = d.image;
        p.drawImage(d.out_rect.topLeft(), d.image);
    } else {
        //qDebug("size not fit. may slow. %dx%d ==> %dx%d"
        //       , d.image.size().width(), image.size().height(), d.renderer_width, d.renderer_height);
        p.drawImage(d.out_rect, d.image);
        //what's the difference?
        //p.drawImage(QPoint(), image.scaled(d.renderer_width, d.renderer_height));
    }

}
Esempio n. 2
0
void GraphicsItemRenderer::drawFrame()
{
    DPTR_D(GraphicsItemRenderer);
    if (!d.painter)
        return;
    //fill background color only when the displayed frame rect not equas to renderer's
    if (d.image.isNull()) {
        //TODO: when setInSize()?
        d.image = QImage(rendererSize(), QImage::Format_RGB32);
        d.image.fill(Qt::black); //maemo 4.7.0: QImage.fill(uint)
    }
    //assume that the image data is already scaled to out_size(NOT renderer size!)
    if (!d.scale_in_renderer || d.image.size() == d.out_rect.size()) {
        d.painter->drawImage(d.out_rect.topLeft(), d.image);
    } else {
        d.painter->drawImage(d.out_rect, d.image);
    }
}
Esempio n. 3
0
void QPainterRenderer::drawBackground()
{
    DPTR_D(QPainterRenderer);
    if (!d.painter)
        return;
    const QRegion bgRegion(backgroundRegion());
    if (bgRegion.isEmpty())
        return;
#if 0
    d.painter->save();
    d.painter->setClipRegion(bgRegion);
    d.painter->fillRect(QRect(QPoint(), rendererSize()), backgroundColor());
    d.painter->restore();
#else
    const QVector<QRect> bg(bgRegion.rects());
    foreach (const QRect& r, bg) {
        d.painter->fillRect(r, backgroundColor());
    }
Esempio n. 4
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();
}
Esempio n. 5
0
void GraphicsItemRenderer::drawFrame()
{
    DPTR_D(GraphicsItemRenderer);
    if (!d.painter)
        return;
    if (d.checkGL()) {
        d.glv.render(boundingRect(), realROI(), d.matrix*sceneTransform());
        return;
    }
    //fill background color only when the displayed frame rect not equas to renderer's
    if (d.image.isNull()) {
        //TODO: when setInSize()?
        d.image = QImage(rendererSize(), QImage::Format_RGB32);
        d.image.fill(Qt::black); //maemo 4.7.0: QImage.fill(uint)
    }
    const QRect roi = realROI();
    //assume that the image data is already scaled to out_size(NOT renderer size!)
    if (roi.size() == d.out_rect.size()) {
        d.painter->drawImage(d.out_rect.topLeft(), d.image, roi);
    } else {
        d.painter->drawImage(d.out_rect, d.image, roi);
    }
}