4#include "private/qpaintengine_p.h"
5#include "private/qpainter_p.h"
6#include "private/qpicture_p.h"
7#include "private/qfont_p.h"
19#include <private/qtextengine_p.h>
57#ifdef QT_PICTURE_DEBUG
58 qDebug(
"QPicturePaintEngine::begin()");
64 d->pic_d = pic->d_func();
67 d->s.setDevice(&
d->pic_d->pictb);
68 d->s.setVersion(
d->pic_d->formatMajor);
75 if (
d->pic_d->formatMajor >= 4) {
82 d->pic_d->formatOk =
false;
90#ifdef QT_PICTURE_DEBUG
91 qDebug(
"QPicturePaintEngine::end()");
96 int data_start = cs_start +
sizeof(
quint16);
97 int brect_start = data_start + 2*
sizeof(
qint16) + 2*
sizeof(
quint8);
98 int pos =
d->pic_d->pictb.pos();
99 d->pic_d->pictb.seek(brect_start);
100 if (
d->pic_d->formatMajor >= 4) {
106 d->pic_d->pictb.seek(cs_start);
110 d->pic_d->pictb.close();
115#define SERIALIZE_CMD(c) \
117 d->s << (quint8) c; \
118 d->s << (quint8) 0; \
119 pos = d->pic_d->pictb.pos()
124#ifdef QT_PICTURE_DEBUG
125 qDebug() <<
" -> updatePen(): width:" << pen.
width() <<
"style:"
130 if (
d->pic_d->in_memory_only) {
131 int index =
d->pic_d->pen_list.size();
132 d->pic_d->pen_list.append(pen);
137 writeCmdLength(
pos,
QRect(),
false);
143#ifdef QT_PICTURE_DEBUG
144 qDebug() <<
" -> updateCompositionMode():" << cmode;
155#ifdef QT_PICTURE_DEBUG
167#ifdef QT_PICTURE_DEBUG
168 qDebug() <<
" -> updateOpacity():" << opacity;
172 d->s << double(opacity);
179#ifdef QT_PICTURE_DEBUG
180 qDebug() <<
" -> updateBrush(): style:" <<
brush.style();
184 if (
d->pic_d->in_memory_only) {
185 int index =
d->pic_d->brush_list.size();
186 d->pic_d->brush_list.append(
brush);
191 writeCmdLength(
pos,
QRect(),
false);
197#ifdef QT_PICTURE_DEBUG
198 qDebug() <<
" -> updateBrushOrigin(): " <<
p;
203 writeCmdLength(
pos,
QRect(),
false);
209#ifdef QT_PICTURE_DEBUG
222#ifdef QT_PICTURE_DEBUG
223 qDebug() <<
" -> updateBackground(): mode:" << bgMode <<
"style:" << bgBrush.
style();
228 writeCmdLength(
pos,
QRect(),
false);
238#ifdef QT_PICTURE_DEBUG
250#ifdef QT_PICTURE_DEBUG
251 qDebug() <<
" -> updateClipRegion(): op:" << op
256 d->s << region <<
qint8(op);
263#ifdef QT_PICTURE_DEBUG
264 qDebug() <<
" -> updateClipPath(): op:" << op
265 <<
"bounding rect:" <<
path.boundingRect();
277#ifdef QT_PICTURE_DEBUG
278 qDebug() <<
" -> updateRenderHints(): " << hints;
283 writeCmdLength(
pos,
QRect(),
false);
286void QPicturePaintEngine::writeCmdLength(
int pos,
const QRectF &
r,
bool corr)
289 int newpos =
d->pic_d->pictb.pos();
294 d->pic_d->pictb.seek(
pos - 1);
298 d->pic_d->pictb.seek(
pos - 1);
300 char *
p =
d->pic_d->pictb.buffer().data();
305 d->pic_d->pictb.seek(newpos);
307 if (br.width() > 0.0 || br.height() > 0.0) {
310 br.setCoords(br.left() -
w2, br.top() -
w2,
311 br.right() +
w2, br.bottom() +
w2);
314 if (
painter()->hasClipping()) {
319 if (br.width() > 0.0 || br.height() > 0.0) {
320 int minx =
qFloor(br.left());
321 int miny =
qFloor(br.top());
322 int maxx =
qCeil(br.right());
323 int maxy =
qCeil(br.bottom());
325 if (
d->pic_d->brect.width() > 0 ||
d->pic_d->brect.height() > 0) {
326 minx =
qMin(minx,
d->pic_d->brect.left());
327 miny =
qMin(miny,
d->pic_d->brect.top());
328 maxx =
qMax(maxx,
d->pic_d->brect.x() +
d->pic_d->brect.width());
329 maxy =
qMax(maxy,
d->pic_d->brect.y() +
d->pic_d->brect.height());
330 d->pic_d->brect =
QRect(minx, miny, maxx - minx, maxy - miny);
332 d->pic_d->brect =
QRect(minx, miny, maxx - minx, maxy - miny);
341#ifdef QT_PICTURE_DEBUG
347 writeCmdLength(
pos,
rect,
true);
353#ifdef QT_PICTURE_DEBUG
354 qDebug() <<
" -> drawPath():" <<
path.boundingRect();
359 writeCmdLength(
pos,
path.boundingRect(),
true);
365#ifdef QT_PICTURE_DEBUG
366 qDebug() <<
" -> drawPolygon(): size=" << numPoints;
372 for (
int i=0;
i<numPoints; ++
i)
384 writeCmdLength(
pos,
polygon.boundingRect(),
true);
390#ifdef QT_PICTURE_DEBUG
391 qDebug() <<
" -> drawPixmap():" <<
r;
396 if (
d->pic_d->in_memory_only) {
397 int index =
d->pic_d->pixmap_list.size();
398 d->pic_d->pixmap_list.append(pm);
401 d->s <<
r << pm << sr;
403 writeCmdLength(
pos,
r,
false);
409#ifdef QT_PICTURE_DEBUG
410 qDebug() <<
" -> drawTiledPixmap():" <<
r <<
s;
414 if (
d->pic_d->in_memory_only) {
415 int index =
d->pic_d->pixmap_list.size();
416 d->pic_d->pixmap_list.append(
pixmap);
421 writeCmdLength(
pos,
r,
false);
425 Qt::ImageConversionFlags
flags)
428#ifdef QT_PICTURE_DEBUG
429 qDebug() <<
" -> drawImage():" <<
r << sr;
433 if (
d->pic_d->in_memory_only) {
434 int index =
d->pic_d->image_list.size();
435 d->pic_d->image_list.append(
image);
440 writeCmdLength(
pos,
r,
false);
446#ifdef QT_PICTURE_DEBUG
447 qDebug() <<
" -> drawTextItem():" <<
p << ti.
text();
451 if (si.
chars ==
nullptr)
454 if (
d->pic_d->formatMajor >= 9) {
462 qreal justificationWidth = 0;
468 }
else if (
d->pic_d->formatMajor >= 8) {
const QColor & color() const
Returns the brush color.
Qt::BrushStyle style() const
Returns the brush style.
\inmodule QtCore\reentrant
void setOverline(bool)
If enable is true, sets overline on; otherwise sets overline off.
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
int pointSize() const
Returns the point size of the font.
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
The QPaintEngineState class provides information about the active paint engine's current state....
QTransform transform() const
QBrush backgroundBrush() const
Returns the background brush in the current paint engine state.
QPainterPath clipPath() const
Returns the clip path in the current paint engine state.
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.
bool isClipEnabled() const
Returns whether clipping is enabled or not in the current paint engine state.
QBrush brush() const
Returns the brush in the current paint engine state.
QRegion clipRegion() const
Returns the clip region in the current paint engine state.
QPainter::RenderHints renderHints() const
Returns the render hints in the current paint engine state.
QFont font() const
Returns the font in the current paint engine state.
QPen pen() const
Returns the pen 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...
Qt::BGMode backgroundMode() const
Returns the background mode in the current paint engine state.
QPainter::CompositionMode compositionMode() const
Returns the composition mode in the current paint engine state.
void setActive(bool newState)
Sets the active state of the paint engine to state.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
QPainter * painter() const
Returns the paint engine's painter.
QPaintEngineState * state
The QPainter class performs low-level painting on widgets and other paint devices.
const QPen & pen() const
Returns the painter's current pen.
const QTransform & transform() const
Alias for worldTransform().
CompositionMode
Defines the modes supported for digital image compositing.
QRectF clipBoundingRect() const
Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rec...
QColor color() const
Returns the color of this pen's brush.
int width() const
Returns the pen width with integer precision.
Qt::PenStyle style() const
Returns the pen style.
void updateOpacity(qreal opacity)
void drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor) override
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
void updateMatrix(const QTransform &matrix)
void updatePen(const QPen &pen)
void drawPolygon(const QPointF *points, int numPoints, PolygonDrawMode mode) override
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op)
void drawPath(const QPainterPath &path) override
The default implementation ignores the path and does nothing.
void drawTextItem(const QPointF &p, const QTextItem &ti) override
This function draws the text item textItem at position p.
void updateBrushOrigin(const QPointF &origin)
void updateFont(const QFont &font)
void updateCompositionMode(QPainter::CompositionMode cmode)
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override
Reimplement this function to draw the pixmap in the given rect, starting at the given p.
void updateClipEnabled(bool enabled)
void updateState(const QPaintEngineState &state) override
Reimplement this function to update the state of a paint engine.
bool end() override
Reimplement this function to finish painting on the current paint device.
void updateBrush(const QBrush &brush)
void drawEllipse(const QRectF &rect) override
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op)
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.
void updateRenderHints(QPainter::RenderHints hints)
void updateBackground(Qt::BGMode bgmode, const QBrush &bgBrush)
bool begin(QPaintDevice *pdev) override
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
The QPicture class is a paint device that records and replays QPainter commands.
QRect boundingRect() const
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
The QPolygonF class provides a list of points using floating point precision.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
QFont font() const
Returns the font that should be used to draw the text.
RenderFlags renderFlags() const
Returns the render flags used.
qreal ascent() const
Corresponds to the \l{QFontMetrics::ascent()}{ascent} of the piece of text that is drawn.
QString text() const
Returns the text that should be drawn.
Combined button and popup list for selecting options.
Q_CORE_EXPORT quint16 qChecksum(QByteArrayView data, Qt::ChecksumType standard=Qt::ChecksumIso3309)
Q_GUI_EXPORT int qt_defaultDpi()
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLenum GLsizei const GLchar * buf
GLfixed GLfixed GLint GLint GLfixed points
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
GLsizei const GLchar *const * path
static const QRectF boundingRect(const QPointF *points, int pointCount)
const char * qt_mfhdr_tag
QT_BEGIN_NAMESPACE typedef signed char qint8
constexpr qreal toReal() const