42 #include "private/qpaintengine_p.h" 43 #include "private/qpainter_p.h" 44 #include "private/qpicture_p.h" 45 #include "private/qfont_p.h" 57 #include <private/qtextengine_p.h> 95 #ifdef QT_PICTURE_DEBUG 96 qDebug() <<
"QPicturePaintEngine::begin()";
102 d->pic_d = pic->d_func();
105 d->s.setDevice(&
d->pic_d->pictb);
106 d->s.setVersion(
d->pic_d->formatMajor);
112 d->pic_d->brect =
QRect();
113 if (
d->pic_d->formatMajor >= 4) {
120 d->pic_d->formatOk =
false;
128 #ifdef QT_PICTURE_DEBUG 129 qDebug() <<
"QPicturePaintEngine::end()";
133 int cs_start =
sizeof(
quint32);
134 int data_start = cs_start +
sizeof(
quint16);
135 int brect_start = data_start + 2*
sizeof(
qint16) + 2*
sizeof(
quint8);
136 int pos =
d->pic_d->pictb.pos();
137 d->pic_d->pictb.seek(brect_start);
138 if (
d->pic_d->formatMajor >= 4) {
144 d->pic_d->pictb.seek(cs_start);
148 d->pic_d->pictb.close();
153 #define SERIALIZE_CMD(c) \ 155 d->s << (quint8) c; \ 156 d->s << (quint8) 0; \ 157 pos = d->pic_d->pictb.pos() 162 #ifdef QT_PICTURE_DEBUG 163 qDebug() <<
" -> updatePen(): width:" << pen.
width() <<
"style:" 168 if (
d->pic_d->in_memory_only) {
169 int index =
d->pic_d->pen_list.size();
170 d->pic_d->pen_list.append(pen);
181 #ifdef QT_PICTURE_DEBUG 182 qDebug() <<
" -> updateCompositionMode():" << cmode;
193 #ifdef QT_PICTURE_DEBUG 205 #ifdef QT_PICTURE_DEBUG 206 qDebug() <<
" -> updateOpacity():" << opacity;
210 d->s << double(opacity);
217 #ifdef QT_PICTURE_DEBUG 218 qDebug() <<
" -> updateBrush(): style:" << brush.
style();
222 if (
d->pic_d->in_memory_only) {
223 int index =
d->pic_d->brush_list.size();
224 d->pic_d->brush_list.append(brush);
235 #ifdef QT_PICTURE_DEBUG 236 qDebug() <<
" -> updateBrushOrigin(): " << p;
247 #ifdef QT_PICTURE_DEBUG 260 #ifdef QT_PICTURE_DEBUG 261 qDebug() <<
" -> updateBackground(): mode:" << bgMode <<
"style:" << bgBrush.
style();
276 #ifdef QT_PICTURE_DEBUG 277 qDebug() <<
" -> updateMatrix():" << matrix;
281 d->s << matrix << (
qint8)
false;
288 #ifdef QT_PICTURE_DEBUG 289 qDebug() <<
" -> updateClipRegion(): op:" << op
294 d->s << region <<
qint8(op);
301 #ifdef QT_PICTURE_DEBUG 302 qDebug() <<
" -> updateClipPath(): op:" << op
308 d->s << path <<
qint8(op);
315 #ifdef QT_PICTURE_DEBUG 316 qDebug() <<
" -> updateRenderHints(): " << hints;
327 int newpos =
d->pic_d->pictb.pos();
328 int length = newpos - pos;
332 d->pic_d->pictb.seek(pos - 1);
336 d->pic_d->pictb.seek(pos - 1);
338 char *p =
d->pic_d->pictb.buffer().data();
339 memmove(p+pos+4, p+pos, length);
343 d->pic_d->pictb.seek(newpos);
352 if (
painter()->hasClipping()) {
363 if (
d->pic_d->brect.width() > 0 ||
d->pic_d->brect.height() > 0) {
364 minx =
qMin(minx,
d->pic_d->brect.left());
365 miny =
qMin(miny,
d->pic_d->brect.top());
366 maxx =
qMax(maxx,
d->pic_d->brect.x() +
d->pic_d->brect.width());
367 maxy =
qMax(maxy,
d->pic_d->brect.y() +
d->pic_d->brect.height());
368 d->pic_d->brect =
QRect(minx, miny, maxx - minx, maxy - miny);
370 d->pic_d->brect =
QRect(minx, miny, maxx - minx, maxy - miny);
379 #ifdef QT_PICTURE_DEBUG 380 qDebug() <<
" -> drawEllipse():" << rect;
391 #ifdef QT_PICTURE_DEBUG 403 #ifdef QT_PICTURE_DEBUG 404 qDebug() <<
" -> drawPolygon(): size=" << numPoints;
409 for (
int i=0; i<numPoints; ++i)
410 polygon << points[i];
427 #ifdef QT_PICTURE_DEBUG 428 qDebug() <<
" -> drawPixmap():" << r;
433 if (
d->pic_d->in_memory_only) {
434 int index =
d->pic_d->pixmap_list.size();
435 d->pic_d->pixmap_list.append(pm);
436 d->s << r << index << sr;
438 d->s << r << pm << sr;
446 #ifdef QT_PICTURE_DEBUG 447 qDebug() <<
" -> drawTiledPixmap():" << r << s;
451 if (
d->pic_d->in_memory_only) {
452 int index =
d->pic_d->pixmap_list.size();
453 d->pic_d->pixmap_list.append(pixmap);
454 d->s << r << index << s;
456 d->s << r << pixmap << s;
462 Qt::ImageConversionFlags flags)
465 #ifdef QT_PICTURE_DEBUG 466 qDebug() <<
" -> drawImage():" << r << sr;
470 if (
d->pic_d->in_memory_only) {
471 int index =
d->pic_d->image_list.size();
472 d->pic_d->image_list.append(image);
473 d->s << r << index << sr << (
quint32) flags;
475 d->s << r << image << sr << (
quint32) flags;
483 #ifdef QT_PICTURE_DEBUG 484 qDebug() <<
" -> drawTextItem():" << p << ti.
text();
491 if (
d->pic_d->formatMajor >= 9) {
499 qreal justificationWidth = 0;
505 }
else if (
d->pic_d->formatMajor >= 8) {
515 d->s << p << ti.
text();
522 QPaintEngine::DirtyFlags flags = state.
state();
539 #endif // QT_NO_PICTURE void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
The QPainter class performs low-level painting on widgets and other paint devices.
Qt::BGMode backgroundMode() const
Returns the background mode in the current paint engine state.
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
void updateOpacity(qreal opacity)
qreal opacity() const
Returns the opacity in the current paint engine state.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
const QTransform & transform() const
Returns the world transformation matrix.
#define QT_END_NAMESPACE
This macro expands to.
const QColor & color() const
Returns the brush color.
CompositionMode
Defines the modes supported for digital image compositing.
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
QPaintEngineState * state
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Qt::PenStyle style() const
Returns the pen style.
void updateBackground(Qt::BGMode bgmode, const QBrush &bgBrush)
The QByteArray class provides an array of bytes.
QTransform transform() const
Returns the matrix in the current paint engine state.
void drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
The QPointF class defines a point in the plane using floating point precision.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r...
void updateBrush(const QBrush &brush)
int left() const
Returns the x-coordinate of the rectangle's left edge.
QColor color() const
Returns the color of this pen's brush.
int width() const
Returns the width of the rectangle.
QRect boundingRect() const
Returns the bounding rectangle of this region.
int height() const
Returns the height of the rectangle.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
QRectF boundingRect() const
Returns the bounding rectangle of the polygon, or QRectF(0,0,0,0) if the polygon is empty...
QString text() const
Returns the text that should be drawn.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
qreal x() const
Returns the x-coordinate of this point.
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision...
static const QRectF boundingRect(const QPointF *points, int pointCount)
void updatePen(const QPen &pen)
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len)
QRegion clipRegion() const
Returns the currently set clip region.
QPainter * painter() const
Returns the paint engine's painter.
void updateFont(const QFont &font)
const QPen & pen() const
Returns the painter's current pen.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBrush brush() const
Returns the brush in the current paint engine state.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Qt::ClipOperation clipOperation() const
Returns the clip operation in the current paint engine state.
QPointF brushOrigin() const
Returns the brush origin in the current paint engine state.
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
void setActive(bool newState)
Sets the active state of the paint engine to state.
QRect boundingRect() const
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data...
QFont font() const
Returns the font in the current paint engine state.
qreal height() const
Returns the height of the rectangle.
The QPolygonF class provides a vector of points using floating point precision.
void updateClipEnabled(bool enabled)
void drawPolygon(const QPointF *points, int numPoints, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
qreal ascent() const
Corresponds to the ascent of the piece of text that is drawn.
The QImage class provides a hardware-independent image representation that allows direct access to th...
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
qreal width() const
Returns the width of the rectangle.
RenderFlags renderFlags() const
Returns the render flags used.
The QRegion class specifies a clip region for a painter.
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
Qt::BrushStyle style() const
Returns the brush style.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
void drawTextItem(const QPointF &p, const QTextItem &ti)
This function draws the text item textItem at position p.
void updateMatrix(const QTransform &matrix)
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
Reimplement this function to draw the pixmap in the given rect, starting at the given p...
int width() const
Returns the pen width with integer precision.
const char * constData() const
Returns a pointer to the data stored in the byte array.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
void updateCompositionMode(QPainter::CompositionMode cmode)
int top() const
Returns the y-coordinate of the rectangle's top edge.
#define Q_DECLARE_PUBLIC(Class)
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
The QFont class specifies a font used for drawing text.
Q_GUI_EXPORT int qt_defaultDpi()
void setOverline(bool)
If enable is true, sets overline on; otherwise sets overline off.
void setCoords(qreal x1, qreal y1, qreal x2, qreal y2)
Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its botto...
QExplicitlySharedDataPointer< QFontPrivate > d
The QRect class defines a rectangle in the plane using integer precision.
void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op)
const char * qt_mfhdr_tag
qreal y() const
Returns the y-coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
The QPaintEngineState class provides information about the active paint engine's current state...
int pointSize() const
Returns the point size of the font.
The QDataStream class provides serialization of binary data to a QIODevice.
QPen pen() const
Returns the pen in the current paint engine state.
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op)
void updateBrushOrigin(const QPointF &origin)
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QTextItem class provides all the information required to draw text in a custom paint engine...
The QPicture class is a paint device that records and replays QPainter commands.
void drawEllipse(const QRectF &rect)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
QFont font() const
Returns the font that should be used to draw the text.
bool end()
Reimplement this function to finish painting on the current paint device.
void updateRenderHints(QPainter::RenderHints hints)
void writeCmdLength(int pos, const QRectF &r, bool corr)
QBrush backgroundBrush() const
Returns the background brush in the current paint engine state.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.