46 #include "private/qpaintengine_alpha_p.h" 48 #include "private/qpicture_p.h" 49 #include "private/qfont_p.h" 50 #include "QtGui/qpicture.h" 69 d->m_continueCall =
true;
77 d->m_alphaPen =
false;
78 d->m_alphaBrush =
false;
79 d->m_alphaOpacity =
false;
80 d->m_hasalpha =
false;
81 d->m_advancedPen =
false;
82 d->m_advancedBrush =
false;
83 d->m_complexTransform =
false;
84 d->m_emulateProjectiveTransforms =
false;
101 d->m_continueCall =
true;
102 if (
d->m_pass != 0) {
114 DirtyFlags flags = state.
state();
123 d->m_pen = state.
pen();
125 d->m_advancedPen =
false;
126 d->m_alphaPen =
false;
129 d->m_alphaPen = !
d->m_pen.brush().isOpaque();
133 if (
d->m_pass != 0) {
134 d->m_continueCall =
true;
137 d->m_continueCall =
false;
140 d->m_alphaOpacity = (state.
opacity() != 1.0f);
145 d->m_advancedBrush =
false;
146 d->m_alphaBrush =
false;
154 d->m_hasalpha =
d->m_alphaOpacity ||
d->m_alphaBrush ||
d->m_alphaPen;
157 d->m_picengine->updateState(state);
164 QRectF tr =
d->addPenWidth(path);
166 if (
d->m_pass == 0) {
167 d->m_continueCall =
false;
168 if (
d->m_hasalpha ||
d->m_advancedPen ||
d->m_advancedBrush
169 ||
d->m_emulateProjectiveTransforms)
174 d->m_picengine->drawPath(path);
176 d->m_continueCall = !
d->fullyContained(tr);
185 for (
int i=0; i<pointCount; ++i)
190 QRectF tr =
d->addPenWidth(path);
192 if (
d->m_pass == 0) {
193 d->m_continueCall =
false;
194 if (
d->m_hasalpha ||
d->m_advancedPen ||
d->m_advancedBrush
195 ||
d->m_emulateProjectiveTransforms)
201 d->m_picengine->drawPolygon(points, pointCount, mode);
203 d->m_continueCall = !
d->fullyContained(tr);
211 QRectF tr =
d->m_transform.mapRect(r);
212 if (
d->m_pass == 0) {
213 d->m_continueCall =
false;
219 d->m_picengine->drawPixmap(r, pm, sr);
222 d->m_continueCall = !
d->fullyContained(tr);
230 QRectF tr =
d->m_transform.mapRect(r);
231 if (
d->m_pass == 0) {
232 d->m_continueCall =
false;
238 d->m_picengine->drawImage(r, image, sr);
241 d->m_continueCall = !
d->fullyContained(tr);
250 tr =
d->m_transform.mapRect(tr);
252 if (
d->m_pass == 0) {
253 d->m_continueCall =
false;
254 if (
d->m_alphaPen ||
d->m_alphaOpacity ||
d->m_advancedPen) {
257 if (
d->m_picengine) {
258 d->m_picengine->drawTextItem(p, textItem);
261 d->m_continueCall = !
d->fullyContained(tr);
269 QRectF brect =
d->m_transform.mapRect(r);
271 if (
d->m_pass == 0) {
272 d->m_continueCall =
false;
273 if (pixmap.
hasAlpha() ||
d->m_alphaOpacity ||
d->m_complexTransform || pixmap.
isQBitmap()) {
274 d->addAlphaRect(brect);
277 d->m_picengine->drawTiledPixmap(r, pixmap, s);
279 d->m_continueCall = !
d->fullyContained(brect);
292 return d->m_continueCall;
301 d->m_picpainter->end();
304 d->m_alphargn =
d->m_alphargn.intersected(
QRect(0, 0,
d->m_pdev->width(),
d->m_pdev->height()));
308 if (rects.
size() > 10) {
309 QRect br =
d->m_alphargn.boundingRect();
315 d->m_cliprgn =
d->m_alphargn;
337 for (
int i=0; i<rects.
size(); ++i)
338 d->drawAlphaImage(rects.
at(i));
353 d->m_pic->d_ptr->in_memory_only =
true;
355 d->m_picengine =
d->m_picpainter->paintEngine();
360 d->m_picpainter->setPen(
painter()->pen());
361 d->m_picpainter->setBrush(
painter()->brush());
362 d->m_picpainter->setBrushOrigin(
painter()->brushOrigin());
363 d->m_picpainter->setFont(
painter()->font());
364 d->m_picpainter->setOpacity(
painter()->opacity());
365 d->m_picpainter->setTransform(
painter()->combinedTransform());
366 d->m_picengine->syncState();
374 delete d->m_picpainter;
390 m_alphaOpacity(false),
391 m_advancedPen(false),
392 m_advancedBrush(false),
393 m_complexTransform(false)
452 picscale.
scale(xscale, yscale);
461 int incx = int(rect.
width() / divw);
462 int incy = int(rect.
height() / divh);
464 for (
int y=0; y<divh; ++y) {
465 int ypos = int((incy * y) + rect.
y());
466 int height = int((y == (divh - 1)) ? (rect.
height() - (incy * y)) : incy) + 1;
468 for (
int x=0; x<divw; ++x) {
469 int xpos = int((incx * x) + rect.
x());
470 int width = int((x == (divw - 1)) ? (rect.
width() - (incx * x)) : incx) + 1;
472 QSize imgsize((
int)(width * xscale), (
int)(height * yscale));
474 img.
fill(0xffffffff);
483 QRect r(xpos, ypos, width, height);
484 q->painter()->drawImage(r, img);
516 #endif // QT_NO_PRINTER void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
The QPainter class performs low-level painting on widgets and other paint devices.
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
qreal y() const
Returns the y-coordinate of the rectangle's top edge.
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
QRegion intersected(const QRegion &r) const
Returns a region which is the intersection of this region and r.
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
virtual 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...
qreal opacity() const
Returns the opacity in the current paint engine state.
QAlphaPaintEnginePrivate()
#define QT_END_NAMESPACE
This macro expands to.
QRectF addPenWidth(const QPainterPath &path)
QRect toRect(const QRectF &rect) const
virtual void drawPath(const QPainterPath &path)
The default implementation ignores the path and does nothing.
PaintEngineFeatures gccaps
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
QPaintEngineState * state
Q_GUI_EXPORT int qt_defaultDpiY()
void drawAlphaImage(const QRectF &rect)
Qt::PenStyle style() const
Returns the pen style.
QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
void fill(uint pixel)
Fills the entire image with the given pixelValue.
QTransform transform() const
Returns the matrix in the current paint engine state.
void setCapStyle(Qt::PenCapStyle style)
Sets the cap style of the generated outlines to style.
Q_GUI_EXPORT int qt_defaultDpiX()
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 restore()
Restores the current painter state (pops a saved state off the stack).
bool hasAlphaChannel() const
Returns true if the image has a format that respects the alpha channel, otherwise returns false...
void addPolygon(const QPolygonF &polygon)
Adds the given polygon to the path as an (unclosed) subpath.
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
virtual bool end()
Reimplement this function to finish painting on the current paint device.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
void setBrushOrigin(int x, int y)
Sets the brush's origin to point (x, y).
void save()
Saves the current painter state (pushes the state onto a stack).
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
virtual void drawImage(const QRectF &r, const QImage &image, const QRectF &sr)
qreal x() const
Returns the x-coordinate of this point.
static const QRectF boundingRect(const QPointF *points, int pointCount)
bool fullyContained(const QRectF &rect) const
int width() const
Returns the width.
QPainter * painter() const
Returns the paint engine's painter.
#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. ...
QPainterPath createStroke(const QPainterPath &path) const
Generates a new path that is a fillable area representing the outline of the given path...
void drawPicture(const QPointF &p, const QPicture &picture)
Replays the given picture at the given point.
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
bool isCosmetic() const
Returns true if the pen is cosmetic; otherwise returns false.
Qt::PenJoinStyle joinStyle() const
Returns the pen's join style.
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
qreal height() const
Returns the height of the rectangle.
~QAlphaPaintEnginePrivate()
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
The QPolygonF class provides a vector of points using floating point precision.
void append(const T &t)
Inserts value at the end of the vector.
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...
static const char * data(const QByteArray &arr)
bool isQBitmap() const
Returns true if this is a QBitmap; otherwise returns false.
qreal width() const
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
The QPainterPathStroker class is used to generate fillable outlines for a given painter path...
Qt::BrushStyle style() const
Returns the brush style.
QPrinter::PrinterMode mode
bool isOpaque() const
Returns true if the brush is fully opaque otherwise false.
qreal descent() const
Corresponds to the descent of the piece of text that is drawn.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
const T & at(int i) const
Returns the item at index position i in the vector.
qreal width() const
Specifies the total width of the text to be drawn.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
void setViewTransformEnabled(bool enable)
Enables view transformations if enable is true, or disables view transformations if enable is false...
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void addAlphaRect(const QRectF &rect)
QRectF controlPointRect() const
Returns the rectangle containing all the points and control points in this path.
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
The QFont class specifies a font used for drawing text.
bool hasAlpha() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false...
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style of the generated outlines to style.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
virtual bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
int height() const
Returns the height.
qreal widthF() const
Returns the pen width with floating point precision.
The QRect class defines a rectangle in the plane using integer precision.
bool continueCall() const
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...
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...
The QSize class defines the size of a two-dimensional object using integer point precision.
void setFont(const QFont &f)
Sets the painter's font to the given font.
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation...
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
QPen pen() const
Returns the pen in the current paint engine state.
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
void flushAndInit(bool init=true)
virtual void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
The QTextItem class provides all the information required to draw text in a custom paint engine...
Qt::PenCapStyle capStyle() const
Returns the pen's cap style.
QRegion alphaClipping() const
The QPicture class is a paint device that records and replays QPainter commands.
static const int tileSize
int size() const
Returns the number of items in the vector.
void resetState(QPainter *p)
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
void setWidth(qreal width)
Sets the width of the generated outline painter path to width.
virtual 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...