4#include "private/qpaintengine_blitter_p.h"
6#include "private/qblittable_p.h"
7#include "private/qpaintengine_raster_p.h"
8#include "private/qpainter_p.h"
9#include "private/qpixmap_blitter_p.h"
11#ifndef QT_NO_BLITTABLE
14#define STATE_XFORM_SCALE 0x00000001
15#define STATE_XFORM_COMPLEX 0x00000002
17#define STATE_BRUSH_PATTERN 0x00000010
18#define STATE_BRUSH_ALPHA 0x00000020
20#define STATE_PEN_ENABLED 0x00000100
22#define STATE_ANTIALIASING 0x00001000
23#define STATE_ALPHA 0x00002000
24#define STATE_BLENDING_COMPLEX 0x00004000
26#define STATE_CLIPSYS_COMPLEX 0x00010000
27#define STATE_CLIP_COMPLEX 0x00020000
34 : m_capabilities(capabilities)
38 , alphaFillRectMask(0)
39 , opacityPixmapMask(0)
40 , capabillitiesState(0)
45 setSourcePixmapMask();
47 setSourceOverPixmapMask();
49 setSourceOverScaledPixmapMask();
51 setAlphaFillRectMask();
53 setOpacityPixmapMask();
58 return checkStateAgainstMask(capabillitiesState, fillRectMask);
63 return checkStateAgainstMask(capabillitiesState, alphaFillRectMask);
68 return checkStateAgainstMask(capabillitiesState, drawRectMask);
75 if (checkStateAgainstMask(capabillitiesState, drawPixmapMask)) {
78 if (
r.size() != sr.
size())
94 return checkStateAgainstMask(capabillitiesState, opacityPixmapMask);
111 updateStateBits(&capabillitiesState,
mask, on);
126 void setFillRectMask() {
137 updateStateBits(&fillRectMask,
STATE_ALPHA,
false);
144 void setAlphaFillRectMask() {
155 updateStateBits(&alphaFillRectMask,
STATE_ALPHA,
false);
162 void setSourcePixmapMask() {
172 updateStateBits(&drawPixmapMask,
STATE_ALPHA,
false);
179 void setSourceOverPixmapMask() {
180 setSourcePixmapMask();
183 void setSourceOverScaledPixmapMask() {
184 setSourceOverPixmapMask();
188 void setOpacityPixmapMask() {
198 updateStateBits(&opacityPixmapMask,
STATE_ALPHA,
true);
205 QBlittable::Capabilities m_capabilities;
209 uint alphaFillRectMask;
210 uint opacityPixmapMask;
211 uint capabillitiesState;
286 bool translucent =
s->opacity < 1;
331 targetRect =
q->state()->matrix.mapRect(
rect);
343 if (!intersectRect.
isEmpty()) {
353 if (targetRect.
x() >= 0 && targetRect.
y() >= 0
354 && targetRect.
width() <=
q->paintDevice()->width()
355 && targetRect.
height() <=
q->paintDevice()->height()) {
383 if (intersectedRect.
size() !=
target.size()) {
390 source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
395 qreal deltaTop = (
target.top() - intersectedRect.
top()) * vFactor;
399 source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom);
419 d->updatePenState(
state());
427 d->updateBrushState(
state());
435 d->updateOpacityState(
state());
443 d->updateCompositionModeState(
state());
451 d->updateRenderHintsState(
state());
459 d->updateTransformState(
state());
466 d->updateClipState(
state());
473#ifdef QT_BLITTER_RASTEROVERLAY
474 d->pmData->unmergeOverlay();
482#ifdef QT_BLITTER_RASTEROVERLAY
484 d->pmData->mergeOverlay();
495 d->updateCompleteState(
s);
507 d->pmData->markRasterOverlay(
path);
515 if (
d->caps.canBlitterAlphaFillRect()) {
517 }
else if (
d->caps.canBlitterFillRect() &&
color.alpha() == 0xff) {
521 d->pmData->markRasterOverlay(
rect);
528 if (
rect.size().isEmpty())
534 &&
d->caps.canBlitterAlphaFillRect()) {
538 &&
d->caps.canBlitterFillRect()) {
542 ((
d->caps.canBlitterDrawPixmapOpacity(
brush.texture())) ||
544 bool rectIsFilled =
false;
553 const int startX =
srcX;
557 while (!rectIsFilled) {
560 if (
x + blitWidth > transformedRect.
right())
561 blitWidth = transformedRect.
right() -
x;
562 if (
y + blitHeight > transformedRect.
bottom())
563 blitHeight = transformedRect.
bottom() -
y;
568 int tmpSrcX =
srcX + (targetRect.
x() -
x);
569 int tmpSrcY =
srcY + (targetRect.
y() -
y);
571 d->pmData->blittable()->drawPixmap(targetRect, pm, srcRect);
574 QRect unclippedTargetRect(
x,
y, blitWidth, blitHeight);
576 for (
const QRect &targetRect : targetRegion) {
577 if (!targetRect.isValid() || targetRect.isEmpty())
579 int tmpSrcX =
srcX + (targetRect.x() -
x);
580 int tmpSrcY =
srcY + (targetRect.y() -
y);
581 QRect srcRect(tmpSrcX, tmpSrcY, targetRect.width(), targetRect.height());
582 d->pmData->blittable()->drawPixmap(targetRect, pm, srcRect);
587 x = transformedRect.
x();
598 d->pmData->markRasterOverlay(
rect);
607 if (
d->caps.canBlitterDrawRectMask()) {
608 for (
int i=0;
i<rectCount; ++
i)
611 d->pmData->markRasterOverlay(rects, rectCount);
619 if (
d->caps.canBlitterDrawRectMask()) {
620 for (
int i = 0;
i < rectCount; ++
i)
623 d->pmData->markRasterOverlay(rects, rectCount);
638 canDrawOpacity =
d->caps.canBlitterDrawPixmapOpacity(pm);
639 if (canDrawOpacity || (
d->caps.canBlitterDrawPixmap(
r, pm, sr))) {
651 d->clipAndDrawPixmap(
rect, targetRect, pm, sr, canDrawOpacity);
655 d->clipAndDrawPixmap(
deviceRect, targetRect, pm, sr, canDrawOpacity);
659 d->pmData->markRasterOverlay(
r);
669 d->pmData->markRasterOverlay(
points, pointCount);
677 d->pmData->markRasterOverlay(
points, pointCount);
685 d->pmData->markRasterOverlay(
path);
693 d->pmData->markRasterOverlay(
points, pointCount);
701 d->pmData->markRasterOverlay(
r);
711 Qt::ImageConversionFlags
flags)
715 d->pmData->markRasterOverlay(
r);
723 d->pmData->markRasterOverlay(
r);
731 d->pmData->markRasterOverlay(
pos, ti);
739 d->pmData->markRasterOverlay(
points, pointCount);
747 d->pmData->markRasterOverlay(
points, pointCount);
755 d->pmData->markRasterOverlay(
path);
765#ifdef QT_BLITTER_RASTEROVERLAY
767 qWarning(
"not implemented: markRasterOverlay for QStaticTextItem");
782 if (
d->caps.canBlitterDrawCachedGlyphs(
s->transform(), glyphFormat, complexClip)) {
CapabilitiesToStateMask(QBlittable::Capabilities capabilities)
bool canBlitterAlphaFillRect() const
bool canBlitterFillRect() const
bool canBlitterDrawCachedGlyphs(const QTransform &transform, QFontEngine::GlyphFormat requestedGlyphFormat, bool complexClip) const
void updateState(uint mask, bool on)
bool canBlitterDrawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) const
bool canBlitterDrawPixmapOpacity(const QPixmap &pm) const
bool canBlitterDrawRectMask() const
virtual void drawPixmapOpacity(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect, QPainter::CompositionMode cmode, qreal opacity)
virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect)=0
virtual void alphaFillRect(const QRectF &rect, const QColor &color, QPainter::CompositionMode cmode)
virtual void fillRect(const QRectF &rect, const QColor &color)=0
@ SourceOverPixmapCapability
@ DrawScaledCachedGlyphsCapability
@ OpacityPixmapCapability
@ SubPixelGlyphsCapability
@ AlphaFillRectCapability
@ SourceOverScaledPixmapCapability
void updateOpacityState(QPainterState *s)
void updateBrushState(QPainterState *s)
void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity)
QBlitterPaintEnginePrivate(QBlittablePlatformPixmap *p)
QBlittablePlatformPixmap * pmData
void fillRect(const QRectF &rect, const QColor &color, bool alpha)
void updateCompositionModeState(QPainterState *s)
void updateTransformState(QPainterState *s)
void updatePenState(QPainterState *s)
void updateRenderHintsState(QPainterState *s)
CapabilitiesToStateMask caps
void updateClipState(QPainterState *s)
void updateCompleteState(QPainterState *s)
void drawStaticTextItem(QStaticTextItem *) override
void fill(const QVectorPath &path, const QBrush &brush) override
void stroke(const QVectorPath &path, const QPen &pen) override
void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override
void fillPath(const QPainterPath &path, QSpanData *fillData) override
virtual bool begin(QPaintDevice *pdev) override
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
void drawImage(const QPointF &p, const QImage &img) override
bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QFontEngine *fontEngine) override
void setState(QPainterState *s) override
virtual void penChanged() override
void drawRects(const QRect *rects, int rectCount) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) override
Reimplement this function to draw the pixmap in the given rect, starting at the given p.
virtual bool end() override
Reimplement this function to finish painting on the current paint device.
virtual void opacityChanged() override
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
void drawPoints(const QPointF *points, int pointCount) override
Draws the first pointCount points in the buffer points.
void drawEllipse(const QRectF &rect) override
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
void drawTextItem(const QPointF &p, const QTextItem &textItem) override
This function draws the text item textItem at position p.
virtual void compositionModeChanged() override
void fillRect(const QRectF &rect, const QBrush &brush) override
virtual void clipEnabledChanged() override
virtual void transformChanged() override
void drawPixmap(const QPointF &p, const QPixmap &pm) override
virtual void renderHintsChanged() override
virtual void brushChanged() override
The QColor class provides colors based on RGB, HSV or CMYK values.
int alpha() const noexcept
Returns the alpha color component of this color.
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns \nullptr...
@ CompositionMode_SourceOver
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
int height() const
Returns the height of the pixmap.
QSize size() const
Returns the size of the pixmap.
int width() const
Returns the width of the pixmap.
QPlatformPixmap * handle() const
QRect rect() const
Returns the pixmap's enclosing rectangle.
bool hasAlphaChannel() const
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QImage::Format prepare(QImage *image)
const QClipData * clip() const
QScopedPointer< QRasterBuffer > rasterBuffer
The QRasterPaintEngine class enables hardware acceleration of painting operations in Qt for Embedded ...
void compositionModeChanged() override
void drawStaticTextItem(QStaticTextItem *textItem) override
\reimp
void fill(const QVectorPath &path, const QBrush &brush) override
void transformChanged() override
void setState(QPainterState *s) override
void drawEllipse(const QRectF &rect) override
\reimp
virtual bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions, QFontEngine *fontEngine)
void brushChanged() override
void renderHintsChanged() override
void drawPoints(const QPointF *points, int pointCount) override
\reimp
QRasterPaintEngineState * state()
const QClipData * clipData() const
virtual void fillPath(const QPainterPath &path, QSpanData *fillData)
bool end() override
\reimp
void stroke(const QVectorPath &path, const QPen &pen) override
void drawTextItem(const QPointF &p, const QTextItem &textItem) override
\reimp
void opacityChanged() override
void drawPixmap(const QPointF &p, const QPixmap &pm) override
void drawImage(const QPointF &p, const QImage &img) override
bool begin(QPaintDevice *device) override
\reimp
void clipEnabledChanged() override
void penChanged() override
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override
\reimp
void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr) override
\reimp
void fillRect(const QRectF &rect, const QBrush &brush) override
\reimp
virtual void fillPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
friend class QBlitterPaintEngine
void drawRects(const QRect *rects, int rectCount) override
\reimp
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
constexpr QRect toRect() const noexcept
Returns a QRect based on the values of this rectangle.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
QRect intersected(const QRect &other) const noexcept
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
The QRegion class specifies a clip region for a painter.
QRegion intersected(const QRegion &r) const
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
Combined button and popup list for selecting options.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLint GLint GLint srcY
GLenum const void GLbitfield GLsizei numGlyphs
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei GLsizei GLchar * source
GLuint GLenum GLenum transform
GLfixed GLfixed GLint GLint GLfixed points
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
GLfloat GLfloat GLfloat alpha
#define STATE_BRUSH_ALPHA
#define STATE_ANTIALIASING
#define STATE_BLENDING_COMPLEX
#define STATE_XFORM_SCALE
#define STATE_BRUSH_PATTERN
#define STATE_CLIP_COMPLEX
#define STATE_XFORM_COMPLEX
#define STATE_CLIPSYS_COMPLEX
#define STATE_PEN_ENABLED
Qt::BrushStyle qbrush_style(const QBrush &b)
Qt::PenStyle qpen_style(const QPen &p)
const QColor & qbrush_color(const QBrush &b)