void QPicturePaintEngine::updateBackground(Qt::BGMode bgMode, const QBrush &bgBrush)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateBackground(): mode:" << bgMode << "style:" << bgBrush.style();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetBkColor);
    d->s << bgBrush.color();
    writeCmdLength(pos, QRect(), false);

    SERIALIZE_CMD(QPicturePrivate::PdcSetBkMode);
    d->s << (qint8) bgMode;
    writeCmdLength(pos, QRectF(), false);
}
void QPicturePaintEngine::updateMatrix(const QTransform &matrix)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateMatrix():" << matrix;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetWMatrix);
    d->s << matrix << (qint8) false;
    writeCmdLength(pos, QRectF(), false);
}
void QPicturePaintEngine::drawEllipse(const QRectF &rect)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> drawEllipse():" << rect;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcDrawEllipse);
    d->s << rect;
    writeCmdLength(pos, rect, true);
}
void QPicturePaintEngine::updateBrushOrigin(const QPointF &p)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateBrushOrigin(): " << p;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetBrushOrigin);
    d->s << p;
    writeCmdLength(pos, QRect(), false);
}
void QPicturePaintEngine::drawPath(const QPainterPath &path)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> drawPath():" << path.boundingRect();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcDrawPath);
    d->s << path;
    writeCmdLength(pos, path.boundingRect(), true);
}
void QPicturePaintEngine::updateOpacity(qreal opacity)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateOpacity():" << opacity;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetOpacity);
    d->s << double(opacity);
    writeCmdLength(pos, QRectF(), false);
}
void QPicturePaintEngine::updateClipEnabled(bool enabled)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateClipEnabled():" << enabled;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetClipEnabled);
    d->s << enabled;
    writeCmdLength(pos, QRectF(), false);
}
void QPicturePaintEngine::updateCompositionMode(QPainter::CompositionMode cmode)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateCompositionMode():" << cmode;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetCompositionMode);
    d->s << (qint32)cmode;
    writeCmdLength(pos, QRectF(), false);
}
void QPicturePaintEngine::updateRenderHints(QPainter::RenderHints hints)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateRenderHints(): " << hints;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetRenderHint);
    d->s << (quint32) hints;
    writeCmdLength(pos, QRect(), false);
}
void QPicturePaintEngine::updateClipRegion(const QRegion &region, Qt::ClipOperation op)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateClipRegion(): op:" << op
             << "bounding rect:" << region.boundingRect();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetClipRegion);
    d->s << region << qint8(op);
    writeCmdLength(pos, QRectF(), false);
}
void QPicturePaintEngine::updateFont(const QFont &font)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateFont(): pt sz:" << font.pointSize();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetFont);
    QFont fnt = font;
    d->s << fnt;
    writeCmdLength(pos, QRectF(), false);
}
예제 #12
0
void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> drawTextItem():" << p << ti.text();
#endif

    const QTextItemInt &si = static_cast<const QTextItemInt &>(ti);
    if (si.chars == 0)
        QPaintEngine::drawTextItem(p, ti); // Draw as path

    if (d->pic_d->formatMajor >= 9) {
        int pos;
        SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem);
        QFont fnt = ti.font();
        fnt.setUnderline(false);
        fnt.setStrikeOut(false);
        fnt.setOverline(false);

        qreal justificationWidth = 0;
        if (si.justified)
            justificationWidth = si.width.toReal();

        d->s << p << ti.text() << fnt << ti.renderFlags() << double(fnt.d->dpi)/qt_defaultDpi() << justificationWidth;
        writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
    } else if (d->pic_d->formatMajor >= 8) {
        // old old (buggy) format
        int pos;
        SERIALIZE_CMD(QPicturePrivate::PdcDrawTextItem);
        d->s << QPointF(p.x(), p.y() - ti.ascent()) << ti.text() << ti.font() << ti.renderFlags();
        writeCmdLength(pos, /*brect=*/QRectF(), /*corr=*/false);
    } else {
        // old (buggy) format
        int pos;
        SERIALIZE_CMD(QPicturePrivate::PdcDrawText2);
        d->s << p << ti.text();
        writeCmdLength(pos, QRectF(p, QSizeF(1,1)), true);
    }
}
void QPicturePaintEngine::drawPolygon(const QPointF *points, int numPoints, PolygonDrawMode mode)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> drawPolygon(): size=" << numPoints;
#endif
    int pos;

    QPolygonF polygon;
    for (int i=0; i<numPoints; ++i)
        polygon << points[i];

    if (mode == PolylineMode) {
        SERIALIZE_CMD(QPicturePrivate::PdcDrawPolyline);
        d->s << polygon;
    } else {
        SERIALIZE_CMD(QPicturePrivate::PdcDrawPolygon);
        d->s << polygon;
        d->s << (qint8)(mode == OddEvenMode ? 0 : 1);
    }

    writeCmdLength(pos, polygon.boundingRect(), true);
}
void QPicturePaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> drawTiledPixmap():" << r << s;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcDrawTiledPixmap);
    if (d->pic_d->in_memory_only) {
        int index = d->pic_d->pixmap_list.size();
        d->pic_d->pixmap_list.append(pixmap);
        d->s << r << index << s;
    } else {
        d->s << r << pixmap << s;
    }
    writeCmdLength(pos, r, false);
}
void QPicturePaintEngine::updateBrush(const QBrush &brush)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateBrush(): style:" << brush.style();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetBrush);
    if (d->pic_d->in_memory_only) {
        int index = d->pic_d->brush_list.size();
        d->pic_d->brush_list.append(brush);
        d->s << index;
    } else {
        d->s << brush;
    }
    writeCmdLength(pos, QRect(), false);
}
void QPicturePaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
                                    Qt::ImageConversionFlags flags)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> drawImage():" << r << sr;
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcDrawImage);
    if (d->pic_d->in_memory_only) {
        int index = d->pic_d->image_list.size();
        d->pic_d->image_list.append(image);
        d->s << r << index << sr << (quint32) flags;
    } else {
        d->s << r << image << sr << (quint32) flags;
    }
    writeCmdLength(pos, r, false);
}
void QPicturePaintEngine::updatePen(const QPen &pen)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updatePen(): width:" << pen.width() << "style:"
             << pen.style() << "color:" << pen.color();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetPen);
    if (d->pic_d->in_memory_only) {
        int index = d->pic_d->pen_list.size();
        d->pic_d->pen_list.append(pen);
        d->s << index;
    } else {
        d->s << pen;
    }
    writeCmdLength(pos, QRect(), false);
}