void QFontEngineQPF::draw(QPaintEngine *p, qreal _x, qreal _y, const QTextItemInt &si)
{
    QPaintEngineState *pState = p->state;
    QRasterPaintEngine *paintEngine = static_cast<QRasterPaintEngine*>(p);

    QTransform matrix = pState->transform();
    matrix.translate(_x, _y);
    QFixed x = QFixed::fromReal(matrix.dx());
    QFixed y = QFixed::fromReal(matrix.dy());

    QVarLengthArray<QFixedPoint> positions;
    QVarLengthArray<glyph_t> glyphs;
    getGlyphPositions(si.glyphs, si.num_glyphs, matrix, si.flags, glyphs, positions);
    if (glyphs.size() == 0)
        return;

    for(int i = 0; i < glyphs.size(); i++) {
        const Glyph *glyph = findGlyph(glyphs[i]);
        if (!glyph)
            continue;

        const bool mono = false; // ###

        paintEngine->alphaPenBlt(reinterpret_cast<const uchar *>(glyph) + sizeof(Glyph), glyph->bytesPerLine, mono,
                                     qRound(positions[i].x) + glyph->x,
                                     qRound(positions[i].y) + glyph->y,
                                     glyph->width, glyph->height);
    }
}
Exemplo n.º 2
0
void PathPaintEngine::updateState(const QPaintEngineState& state)
{
	if (state.state() & DirtyTransform)
		transform = state.transform();
	dashPattern = state.pen().dashPattern();
	isCosmetic  = state.pen().isCosmetic(); 
}
Exemplo n.º 3
0
void LiveViewPaintEngine::updateState(const QPaintEngineState &state)
{
	WatchPaintEngine::updateState(state);
	if (state.state() & QPaintEngine::DirtyBrush) {
		QBrush brush = state.brush();
		_isBrushBlack = false;
		if (brush.style() == Qt::SolidPattern) {
			const QColor color = brush.color();
			if (color == Qt::black) {
				_isBrushBlack = true;
			}
		}
	}
}
Exemplo n.º 4
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);
    }
}
 virtual void updateState( const QPaintEngineState &state )
 {
     if ( state.state() & QPaintEngine::DirtyPen )
     {
         d_pen = state.pen();
     }
     if ( state.state() & QPaintEngine::DirtyBrush )
     {
         d_brush = state.brush();
     }
     if ( state.state() & QPaintEngine::DirtyBrushOrigin )
     {
         d_origin = state.brushOrigin();
     }
 }
Exemplo n.º 6
0
void QgsDxfPaintEngine::updateState( const QPaintEngineState& state )
{
  if ( state.state() & QPaintEngine::DirtyTransform )
  {
    mTransform = state.transform();
  }
  if ( state.state() & QPaintEngine::DirtyPen )
  {
    mPen = state.pen();
  }
  if ( state.state() & QPaintEngine::DirtyBrush )
  {
    mBrush = state.brush();
  }
}
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());
}
Exemplo n.º 8
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();
}
Exemplo n.º 9
0
void WatchPaintEngine::updateState(const QPaintEngineState &state)
{
	const QPaintEngine::DirtyFlags flags = state.state();

	TRACE(qDebug() << __func__ << flags);

	if (flags & QPaintEngine::DirtyTransform)
	{
		TRACE(qDebug() << " " << "DirtyTransform" << state.transform());
		_transform = state.transform();
		_painter.setTransform(_transform);
	}

	if (flags & QPaintEngine::DirtyBackground)
	{
		_painter.setBackground(state.backgroundBrush());
	}

	if (flags & QPaintEngine::DirtyBackgroundMode)
	{
		_painter.setBackgroundMode(state.backgroundMode());
	}

	if (flags & QPaintEngine::DirtyBrush)
	{
		QBrush brush = state.brush();
		_hasBrush = brush.style() != Qt::NoBrush;
		_painter.setBrush(brush);
	}
	if (flags & QPaintEngine::DirtyBrushOrigin)
	{
		_painter.setBrushOrigin(state.brushOrigin());
	}
	if (flags & QPaintEngine::DirtyClipEnabled)
	{
		TRACE(qDebug() << " " << "DirtyClipEnabled" << state.isClipEnabled());
		_clipEnabled = state.isClipEnabled();
		_painter.setClipping(_clipEnabled);
	}
	if (flags & QPaintEngine::DirtyClipPath)
	{
		TRACE(qDebug() << " " << "DirtyClipPath" << state.clipPath().boundingRect());
		QRegion region = state.clipPath().boundingRect().toAlignedRect();
		updateClipRegion(region, state.clipOperation());
		_painter.setClipPath(state.clipPath(), state.clipOperation());
	}
	if (flags & QPaintEngine::DirtyClipRegion)
	{
		TRACE(qDebug() << " " << "DirtyClipRegion" << state.clipRegion());
		updateClipRegion(state.clipRegion(), state.clipOperation());
		_painter.setClipRegion(state.clipRegion(), state.clipOperation());
	}
	if (flags & QPaintEngine::DirtyCompositionMode)
	{
		TRACE(qDebug() << " " << "DirtyCompositionMode" << state.compositionMode());
		_painter.setCompositionMode(state.compositionMode());
	}
	if (flags & QPaintEngine::DirtyFont)
	{
		_painter.setFont(state.font());
	}
	if (flags & QPaintEngine::DirtyHints)
	{
		_painter.setRenderHints(state.renderHints());
	}
	if (flags & QPaintEngine::DirtyPen)
	{
		QPen pen = state.pen();
		_hasPen = pen.style() != Qt::NoPen;
		_penWidth = pen.widthF();
		_painter.setPen(pen);
	}

	TRACE(qDebug() << __func__ << "end");
}
void QCairoPaintEngine::updateState(const QPaintEngineState &state)
{
    if (!cr || !surface) {
        qDebug()<<"Cairo Error [QCairoPaintEngine::updateState]: no cairo or no surface!";
        return;
    }
    cdirtyflags=cdirtyflags|state.state();
    if ((state.state()&QPaintEngine::DirtyTransform)==QPaintEngine::DirtyTransform) {
        cmatrix=state.matrix();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyTransform);
    }
    if ((state.state()&QPaintEngine::DirtyPen)==QPaintEngine::DirtyPen) {
        //qDebug()<<"updateState "<<state.state()<<state.pen();
        cpen=state.pen();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyPen);
    }
    if ((state.state()&QPaintEngine::DirtyBrush)==QPaintEngine::DirtyBrush) {
        cbrush=state.brush();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyBrush);
    }
    if ((state.state()&QPaintEngine::DirtyFont)==QPaintEngine::DirtyFont) {
        cfont=state.font();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyFont);
    }
    if (((state.state()&QPaintEngine::DirtyClipRegion)==QPaintEngine::DirtyClipRegion)) {
        cclipregion=state.clipRegion();
        updateClip();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyClipRegion);
    }
    if (((state.state()&QPaintEngine::DirtyClipPath)==QPaintEngine::DirtyClipPath)) {
        cclippath=state.clipPath();
        updateClip();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyClipPath);
    }
    if (((state.state()&QPaintEngine::DirtyClipEnabled)==QPaintEngine::DirtyClipEnabled)) {
        cclipenabled=state.isClipEnabled();
        updateClip();
        cdirtyflags=cdirtyflags&(~QPaintEngine::DirtyClipEnabled);
    }
    updateMatrix();
    /*updateBrush();
    updatePen();
    updateFont();*/
}