42 #include "private/qpaintengine_blitter_p.h" 44 #include "private/qblittable_p.h" 45 #include "private/qpaintengine_raster_p.h" 46 #include "private/qpainter_p.h" 47 #include "private/qapplication_p.h" 48 #include "private/qpixmap_blitter_p.h" 50 #ifndef QT_NO_BLITTABLE 53 #define STATE_XFORM_SCALE 0x00000001 54 #define STATE_XFORM_COMPLEX 0x00000002 56 #define STATE_BRUSH_PATTERN 0x00000010 57 #define STATE_BRUSH_ALPHA 0x00000020 59 #define STATE_PEN_ENABLED 0x00000100 61 #define STATE_ANTIALIASING 0x00001000 62 #define STATE_ALPHA 0x00002000 63 #define STATE_BLENDING_COMPLEX 0x00004000 65 #define STATE_CLIPSYS_COMPLEX 0x00010000 66 #define STATE_CLIP_COMPLEX 0x00020000 144 *state = on ? (*state | mask) : (*state & ~mask);
149 return !state || (state & mask && !(state & ~mask));
247 , caps(pmData->blittable()->capabilities())
254 void fillRect(
const QRectF& rect,
const QColor&,
bool alpha);
274 if (!pmData->blittable()->isLocked())
275 rasterBuffer->prepare(pmData->buffer());
280 pmData->blittable()->unlock();
288 updateOpacityState(s);
289 updateCompositionModeState(s);
290 updateRenderHintsState(s);
291 updateTransformState(s);
311 bool translucent = s->
opacity < 1;
353 pmData->unmarkRasterOverlay(rect);
356 targetRect = q->state()->matrix.mapRect(rect);
362 pmData->blittable()->alphaFillRect(targetRect & clipData->
clipRect, color, q->state()->compositionMode());
364 pmData->blittable()->fillRect(targetRect & clipData->
clipRect, color);
367 for (
int i = 0; i < rects.
size(); ++i) {
369 if (!intersectRect.
isEmpty()) {
372 pmData->blittable()->alphaFillRect(intersectRect, color, q->state()->compositionMode());
374 pmData->blittable()->fillRect(intersectRect, color);
379 if (targetRect.
x() >= 0 && targetRect.
y() >= 0
380 && targetRect.
width() <= q->paintDevice()->width()
381 && targetRect.
height() <= q->paintDevice()->height()) {
384 pmData->blittable()->alphaFillRect(targetRect, color, q->state()->compositionMode());
386 pmData->blittable()->fillRect(targetRect, color);
388 QRectF deviceRect(0, 0, q->paintDevice()->width(), q->paintDevice()->height());
391 pmData->blittable()->alphaFillRect(deviceRect & targetRect, color, q->state()->compositionMode());
393 pmData->blittable()->fillRect(deviceRect & targetRect, color);
405 if (intersectedRect.
size() != target.
size()) {
408 qreal deltaTop = target.
top() - intersectedRect.
top();
412 source.
adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
417 qreal deltaTop = (target.
top() - intersectedRect.
top()) * vFactor;
418 qreal deltaLeft = (target.
left() - intersectedRect.
left()) * hFactor;
420 qreal deltaRight = (target.
right() - intersectedRect.
right()) * hFactor;
421 source.
adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
424 pmData->unmarkRasterOverlay(intersectedRect);
426 pmData->blittable()->drawPixmapOpacity(intersectedRect, pm, source, q->state()->compositionMode(), q->state()->opacity);
428 pmData->blittable()->drawPixmap(intersectedRect, pm, source);
441 d->updatePenState(
state());
449 d->updateBrushState(
state());
457 d->updateOpacityState(
state());
465 d->updateCompositionModeState(
state());
473 d->updateRenderHintsState(
state());
481 d->updateTransformState(
state());
488 d->updateClipState(
state());
494 #ifdef QT_BLITTER_RASTEROVERLAY 496 d->pmData->unmergeOverlay();
503 #ifdef QT_BLITTER_RASTEROVERLAY 505 d->pmData->mergeOverlay();
516 d->updateCompleteState(s);
528 d->pmData->markRasterOverlay(path);
536 if (
d->caps.canBlitterAlphaFillRect()) {
537 d->fillRect(rect, color,
true);
538 }
else if (
d->caps.canBlitterFillRect() && color.
alpha() == 0xff) {
539 d->fillRect(rect, color,
false);
542 d->pmData->markRasterOverlay(rect);
555 &&
d->caps.canBlitterAlphaFillRect()) {
559 &&
d->caps.canBlitterFillRect()) {
563 ((
d->caps.canBlitterDrawPixmapOpacity(brush.
texture())) ||
564 (
d->caps.canBlitterDrawPixmap(rect, brush.
texture(), rect)))) {
565 bool rectIsFilled =
false;
567 qreal x = transformedRect.
x();
568 qreal y = transformedRect.
y();
573 srcX = pm.
width() + srcX;
574 const int startX = srcX;
577 srcY = pm.
height() + srcY;
578 while (!rectIsFilled) {
581 if (x + blitWidth > transformedRect.
right())
582 blitWidth = transformedRect.
right() -x;
583 if (y + blitHeight > transformedRect.
bottom())
584 blitHeight = transformedRect.
bottom() - y;
589 int tmpSrcX = srcX + (targetRect.
x() - x);
590 int tmpSrcY = srcY + (targetRect.
y() - y);
592 d->pmData->blittable()->drawPixmap(targetRect, pm, srcRect);
596 QRect unclippedTargetRect(x, y, blitWidth, blitHeight);
599 for (
int i = 0; i < intersectedRects.
rects().
size(); ++i) {
603 int tmpSrcX = srcX + (targetRect.
x() - x);
604 int tmpSrcY = srcY + (targetRect.
y() - y);
606 d->pmData->blittable()->drawPixmap(targetRect, pm, srcRect);
611 x = transformedRect.
x();
622 d->pmData->markRasterOverlay(rect);
631 if (
d->caps.canBlitterDrawRectMask()) {
632 for (
int i=0; i<rectCount; ++i)
635 d->pmData->markRasterOverlay(rects, rectCount);
643 if (
d->caps.canBlitterDrawRectMask()) {
644 for (
int i = 0; i < rectCount; ++i)
647 d->pmData->markRasterOverlay(rects, rectCount);
662 canDrawOpacity =
d->caps.canBlitterDrawPixmapOpacity(pm);
663 if (canDrawOpacity || (
d->caps.canBlitterDrawPixmap(r, pm, sr))) {
672 d->clipAndDrawPixmap(clipData->
clipRect, targetRect, pm, sr, canDrawOpacity);
675 for (
int i = 0; i<rects.
size(); ++i)
676 d->clipAndDrawPixmap(rects.
at(i), targetRect, pm, sr, canDrawOpacity);
680 d->clipAndDrawPixmap(deviceRect, targetRect, pm, sr, canDrawOpacity);
684 d->pmData->markRasterOverlay(r);
694 d->pmData->markRasterOverlay(points, pointCount);
702 d->pmData->markRasterOverlay(points, pointCount);
710 d->pmData->markRasterOverlay(path);
718 d->pmData->markRasterOverlay(points, pointCount);
726 d->pmData->markRasterOverlay(r);
736 Qt::ImageConversionFlags
flags)
740 d->pmData->markRasterOverlay(r);
748 d->pmData->markRasterOverlay(r);
756 d->pmData->markRasterOverlay(pos, ti);
764 d->pmData->markRasterOverlay(points, pointCount);
772 d->pmData->markRasterOverlay(points, pointCount);
780 d->pmData->markRasterOverlay(path);
790 #ifdef QT_BLITTER_RASTEROVERLAY 792 qWarning(
"not implemented: markRasterOverlay for QStaticTextItem");
797 #endif //QT_NO_BLITTABLE
The QColor class provides colors based on RGB, HSV or CMYK values.
virtual void compositionModeChanged()
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
virtual void fill(const QVectorPath &path, const QBrush &brush)
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 clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity)
#define STATE_BRUSH_PATTERN
#define QT_END_NAMESPACE
This macro expands to.
void updateTransformState(QPainterState *s)
#define STATE_ANTIALIASING
int width() const
Returns the width of the pixmap.
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns 0...
void setSourceOverScaledPixmapMask()
QSize size() const
Returns the size of the pixmap.
QRasterPaintEngineState * state()
QPainter::RenderHints renderHints
QBlitterPaintEnginePrivate(QBlittablePixmapData *p)
QPainter::CompositionMode composition_mode
Qt::BrushStyle qbrush_style(const QBrush &b)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
void updateRenderHintsState(QPainterState *s)
qreal width() const
Returns the width.
void fillPath(const QPainterPath &path, QSpanData *fillData)
The QPointF class defines a point in the plane using floating point precision.
qreal height() const
Returns the height.
void updateState(uint mask, bool on)
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
void drawEllipse(const QRectF &rect)
Reimplemented Function
bool begin(QPaintDevice *device)
Reimplemented Function
bool canBlitterDrawRectMask() const
bool canBlitterAlphaFillRect() const
int width() const
Returns the width of the rectangle.
void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr)
Reimplemented Function
void setState(QPainterState *s)
virtual uint flags() const
void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr)
Reimplement this function to draw the pixmap in the given rect, starting at the given p...
#define STATE_BLENDING_COMPLEX
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
CapabilitiesToStateMask(QBlittable::Capabilities capabilities)
static bool checkStateAgainstMask(uint state, uint mask)
CapabilitiesToStateMask caps
QRect intersected(const QRect &other) const
Returns the intersection of this rectangle and the given rectangle.
void fillPath(const QPainterPath &path, QSpanData *fillData)
int height() const
Returns the height of the rectangle.
QRectF intersected(const QRectF &other) const
Returns the intersection of this rectangle and the given rectangle.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
virtual void transformChanged()
#define STATE_CLIP_COMPLEX
virtual void drawRects(const QRect *rects, int rectCount)
The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF an...
#define STATE_PEN_ENABLED
QTransform transform() const
Returns the current transformation matrix for the brush.
The QPen class defines how a QPainter should draw lines and outlines of shapes.
void setSourcePixmapMask()
bool end()
Reimplemented Function
void compositionModeChanged()
void renderHintsChanged()
void drawRects(const QRect *rects, int rectCount)
Reimplemented Function
qreal x() const
Returns the x-coordinate of this point.
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 void renderHintsChanged()
void drawEllipse(const QRectF &rect)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect...
#define STATE_CLIPSYS_COMPLEX
void drawImage(const QPointF &p, const QImage &img)
void drawImage(const QPointF &p, const QImage &img)
virtual void fillRect(const QRectF &rect, const QBrush &brush)
void updateBrushState(QPainterState *s)
virtual void brushChanged()
void updateCompleteState(QPainterState *s)
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
virtual void penChanged()
void drawPoints(const QPointF *points, int pointCount)
Reimplemented Function
void updateOpacityState(QPainterState *s)
void drawPixmap(const QPointF &p, const QPixmap &pm)
void setSourceOverPixmapMask()
qreal height() const
Returns the height of the rectangle.
void drawStaticTextItem(QStaticTextItem *textItem)
Reimplemented Function
void setAlphaFillRectMask()
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
qreal width() const
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
#define STATE_BRUSH_ALPHA
Qt::BrushStyle style() const
Returns the brush style.
QPixmap texture() const
Returns the custom brush pattern, or a null pixmap if no custom brush pattern has been set...
QRect toRect() const
Returns a QRect based on the values of this rectangle.
void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
QBlittablePixmapData * pmData
void fill(const QVectorPath &path, const QBrush &brush)
const T & at(int i) const
Returns the item at index position i in the vector.
void drawPixmap(const QPointF &p, const QPixmap &pm)
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
virtual void opacityChanged()
QSize size() const
Returns the size of the image, i.
void setState(QPainterState *s)
#define STATE_XFORM_SCALE
void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
The QBrush class defines the fill pattern of shapes drawn by QPainter.
#define Q_DECLARE_PUBLIC(Class)
ushort alpha
Returns the alpha color component of this color.
int y() const
Returns the y-coordinate of the rectangle's top edge.
qreal x() const
Returns the x-coordinate of the rectangle's left edge.
virtual void clipEnabledChanged()
void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
QBlittable::Capabilities m_capabilities
void adjust(qreal x1, qreal y1, qreal x2, qreal y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
int x() const
Returns the x-coordinate of the rectangle's left edge.
void updateCompositionModeState(QPainterState *s)
bool canBlitterFillRect() const
The QPoint class defines a point in the plane using integer precision.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
void fillRect(const QRectF &rect, const QBrush &brush)
Reimplemented Function
const qreal * points() const
virtual bool begin(QPaintDevice *pdev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
static QReadWriteLock lock
The QRect class defines a rectangle in the plane using integer precision.
const QColor & qbrush_color(const QBrush &b)
QSizeF size() const
Returns the size of the rectangle.
bool canBlitterDrawPixmapOpacity(const QPixmap &pm) const
void setOpacityPixmapMask()
QRect rect() const
Returns the pixmap's enclosing rectangle.
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...
void fillRect(const QRectF &rect, const QColor &, bool alpha)
void updatePenState(QPainterState *s)
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
int height() const
Returns the height of the pixmap.
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplemented Function
static void updateStateBits(uint *state, uint mask, bool on)
void drawTextItem(const QPointF &p, const QTextItem &textItem)
Reimplemented Function
void stroke(const QVectorPath &path, const QPen &pen)
void drawStaticTextItem(QStaticTextItem *)
void updateClipState(QPainterState *s)
virtual bool end()
Reimplement this function to finish painting on the current paint device.
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
void stroke(const QVectorPath &path, const QPen &pen)
The QTextItem class provides all the information required to draw text in a custom paint engine...
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
bool hasAlphaChannel() const
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false...
#define STATE_XFORM_COMPLEX
Qt::PenStyle qpen_style(const QPen &p)
int size() const
Returns the number of items in the vector.
void clipEnabledChanged()
QBlitterPaintEngine(QBlittablePixmapData *p)
QPixmapData * pixmapData() const
bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const