コード例 #1
0
void QQuickShapeSoftwareRenderNode::render(const RenderState *state)
{
    if (m_sp.isEmpty())
        return;

    QSGRendererInterface *rif = m_item->window()->rendererInterface();
    QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource));
    Q_ASSERT(p);

    const QRegion *clipRegion = state->clipRegion();
    if (clipRegion && !clipRegion->isEmpty())
        p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform

    p->setTransform(matrix()->toTransform());
    p->setOpacity(inheritedOpacity());

    for (const ShapePathRenderData &d : qAsConst(m_sp)) {
        if (d.hidden) {
            continue;
        }

//        QTransform oldTransform = p->transform();
//        p->setTransform(d.transform, true);

//        p->setOpacity(inheritedOpacity() * d.opacity);
        p->setPen(d.strokeWidth >= 0.0f && d.pen.color() != Qt::transparent ? d.pen : Qt::NoPen);
        p->setBrush(d.brush.color() != Qt::transparent ? d.brush : Qt::NoBrush);
        p->drawPath(d.path);

//        p->setTransform(oldTransform);
    }
}
コード例 #2
0
    virtual void render(const RenderState&)
    {
        QMatrix4x4 renderMatrix = matrix() ? *matrix() : QMatrix4x4();

        // Have to apply render scale manualy because it is not applied on page item.
        // http://trac.webkit.org/changeset/104450
        renderMatrix.scale(m_scale);

        // FIXME: Support non-rectangular clippings.
        layerTreeRenderer()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect());
    }
コード例 #3
0
    virtual void render(const RenderState& state)
    {
        TransformationMatrix renderMatrix;
        if (pageNode()->devicePixelRatio() != 1.0) {
            renderMatrix.scale(pageNode()->devicePixelRatio());
            if (matrix())
                renderMatrix.multiply(*matrix());
        } else if (matrix())
            renderMatrix = *matrix();

        // When rendering to an intermediate surface, Qt will
        // mirror the projection matrix to fit on the destination coordinate system.
        const QMatrix4x4* projection = state.projectionMatrix;
        bool mirrored = projection && (*projection)(0, 0) * (*projection)(1, 1) - (*projection)(0, 1) * (*projection)(1, 0) > 0;

        // FIXME: Support non-rectangular clippings.
        coordinatedGraphicsScene()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect(), mirrored ? TextureMapper::PaintingMirrored : 0);
    }