void QNanoQuickItemPainter::render()
{
    m_painter->reset(); // reset context data as painter is shared.
    // Update antialiasing if needed
    nvgInternalParams(m_painter->nvgCtx())->edgeAntiAlias = m_antialiasing;

    m_painter->setPixelAlign(static_cast<QNanoPainter::PixelAlign>(m_pixelAlign));
    m_painter->setPixelAlignText(static_cast<QNanoPainter::PixelAlign>(m_pixelAlignText));
    m_painter->m_devicePixelRatio = m_devicePixelRatio;

    // Draw only when item has visible size. This way setup and painting is
    // not called until size has been properly set.
    if ((m_itemWidth > 0 && m_itemHeight > 0) || m_setupDone) {
        m_setupDone = true;
        prepaint();
        paint(m_painter.data());
        postpaint();
    }
}
Ejemplo n.º 2
0
void VisWidget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    prepaint();

    // Clear
    qglClearColor(backgroundColor);
    glClear(GL_COLOR_BUFFER_BIT);

    beginNativeGL();
    {
        drawNativeGL();
    }
    endNativeGL();

    QPainter painter(this);
    //painter.begin(this);
    painter.setRenderHint(QPainter::Antialiasing);
    qtPaint(&painter);
    painter.end();
}