Exemplo n.º 1
0
void QAlphaPaintEngine::updateState(const QPaintEngineState &state)
{
    Q_D(QAlphaPaintEngine);

    DirtyFlags flags = state.state();
    if (flags & QPaintEngine::DirtyTransform) {
        d->m_transform = state.transform();
        d->m_complexTransform = (d->m_transform.type() > QTransform::TxScale);
        d->m_emulateProjectiveTransforms = !(d->m_savedcaps & QPaintEngine::PerspectiveTransform)
                                           && !(d->m_savedcaps & QPaintEngine::AlphaBlend)
                                           && (d->m_transform.type() >= QTransform::TxProject);
    }
    if (flags & QPaintEngine::DirtyPen) {
        d->m_pen = state.pen();
        if (d->m_pen.style() == Qt::NoPen) {
            d->m_advancedPen = false;
            d->m_alphaPen = false;
        } else {
            d->m_advancedPen = (d->m_pen.brush().style() != Qt::SolidPattern);
            d->m_alphaPen = !d->m_pen.brush().isOpaque();
        }
    }

    if (d->m_pass != 0) {
        d->m_continueCall = true;
        return;
    }
    d->m_continueCall = false;

    if (flags & QPaintEngine::DirtyOpacity) {
        d->m_alphaOpacity = (state.opacity() != 1.0f);
    }

    if (flags & QPaintEngine::DirtyBrush) {
        if (state.brush().style() == Qt::NoBrush) {
            d->m_advancedBrush = false;
            d->m_alphaBrush = false;
        } else {
            d->m_advancedBrush = (state.brush().style() != Qt::SolidPattern);
            d->m_alphaBrush = !state.brush().isOpaque();
        }
    }


    d->m_hasalpha = d->m_alphaOpacity || d->m_alphaBrush || d->m_alphaPen;

    if (d->m_picengine) {
        const QPainter *p = painter();
        d->m_picpainter->setPen(p->pen());
        d->m_picpainter->setBrush(p->brush());
        d->m_picpainter->setBrushOrigin(p->brushOrigin());
        d->m_picpainter->setFont(p->font());
        d->m_picpainter->setOpacity(p->opacity());
        d->m_picpainter->setTransform(p->combinedTransform());
        d->m_picengine->updateState(state);
    }
}
Exemplo n.º 2
0
/*!
  Constructor for State paint operation
  \param state Paint engine state
 */
QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
    d_type( State )
{
    d_stateData = new StateData();

    d_stateData->flags = state.state();

    if ( d_stateData->flags & QPaintEngine::DirtyPen )
        d_stateData->pen = state.pen();

    if ( d_stateData->flags & QPaintEngine::DirtyBrush )
        d_stateData->brush = state.brush();

    if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin )
        d_stateData->brushOrigin = state.brushOrigin();

    if ( d_stateData->flags & QPaintEngine::DirtyFont )
        d_stateData->font = state.font();

    if ( d_stateData->flags & QPaintEngine::DirtyBackground )
    {
        d_stateData->backgroundMode = state.backgroundMode();
        d_stateData->backgroundBrush = state.backgroundBrush();
    }

    if ( d_stateData->flags & QPaintEngine::DirtyTransform )
        d_stateData->transform = state.transform();

    if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled )
        d_stateData->isClipEnabled = state.isClipEnabled();

    if ( d_stateData->flags & QPaintEngine::DirtyClipRegion )
    {
        d_stateData->clipRegion = state.clipRegion();
        d_stateData->clipOperation = state.clipOperation();
    }

    if ( d_stateData->flags & QPaintEngine::DirtyClipPath )
    {
        d_stateData->clipPath = state.clipPath();
        d_stateData->clipOperation = state.clipOperation();
    }

    if ( d_stateData->flags & QPaintEngine::DirtyHints )
        d_stateData->renderHints = state.renderHints();

    if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode )
        d_stateData->compositionMode = state.compositionMode();

    if ( d_stateData->flags & QPaintEngine::DirtyOpacity )
        d_stateData->opacity = state.opacity();
}
void QPicturePaintEngine::updateState(const QPaintEngineState &state)
{
    QPaintEngine::DirtyFlags flags = state.state();
    if (flags & DirtyPen) updatePen(state.pen());
    if (flags & DirtyBrush) updateBrush(state.brush());
    if (flags & DirtyBrushOrigin) updateBrushOrigin(state.brushOrigin());
    if (flags & DirtyFont) updateFont(state.font());
    if (flags & DirtyBackground) updateBackground(state.backgroundMode(), state.backgroundBrush());
    if (flags & DirtyTransform) updateMatrix(state.transform());
    if (flags & DirtyClipEnabled) updateClipEnabled(state.isClipEnabled());
    if (flags & DirtyClipRegion) updateClipRegion(state.clipRegion(), state.clipOperation());
    if (flags & DirtyClipPath) updateClipPath(state.clipPath(), state.clipOperation());
    if (flags & DirtyHints) updateRenderHints(state.renderHints());
    if (flags & DirtyCompositionMode) updateCompositionMode(state.compositionMode());
    if (flags & DirtyOpacity) updateOpacity(state.opacity());
}