7#include <QtCore/QMutex>
8#include <QtQuick/qsgtexture.h>
9#include <QtGui/QPaintEngine>
11#define HAS_SHADOW(offsetX, offsetY, blur, color) (color.isValid() && color.alpha() && (blur || offsetX || offsetY))
18 class ShadowImageMaker
21 virtual ~ShadowImageMaker() {}
31 QPainter shadowPainter(&shadowImage);
32 shadowPainter.setRenderHints(
p->renderHints());
33 shadowPainter.translate(offsetX - boundsAligned.
left(), offsetY - boundsAligned.
top());
34 paint(&shadowPainter);
41 shadowPainter.begin(&shadowImage);
43 shadowPainter.fillRect(shadowImage.rect(),
color);
46 p->drawImage(boundsAligned.
topLeft(), shadowImage);
54 class FillRectShadow :
public ShadowImageMaker
71 class FillPathShadow :
public ShadowImageMaker
88 class StrokePathShadow :
public ShadowImageMaker
102 return m_path.boundingRect().adjusted(-
d, -
d,
d,
d);
110 class DrawImageShadow :
public ShadowImageMaker
131 FillRectShadow shadowMaker(shadowRect,
p->brush());
132 shadowMaker.paintShapeAndShadow(
p, offsetX, offsetY, blur,
color);
137 FillPathShadow shadowMaker(
path,
p->brush());
138 shadowMaker.paintShapeAndShadow(
p, offsetX, offsetY, blur,
color);
143 StrokePathShadow shadowMaker(
path,
p->pen());
144 shadowMaker.paintShapeAndShadow(
p, offsetX, offsetY, blur,
color);
155 if (!
state.lineDash.isEmpty()) {
164 p->setTransform(
state.matrix *
p->transform());
169 if (
state.fillStyle !=
p->brush())
170 p->setBrush(
state.fillStyle);
172 if (
state.font !=
p->font())
175 if (
state.globalAlpha !=
p->opacity()) {
176 p->setOpacity(
state.globalAlpha);
179 if (
state.globalCompositeOperation !=
p->compositionMode())
180 p->setCompositionMode(
state.globalCompositeOperation);
182 p->setClipping(
state.clip);
184 p->setClipPath(
state.clipPath);
203 if (sw == -1 || sh == -1) {
207 if (sx != 0 || sy != 0 || sw !=
image.width() || sh !=
image.height())
210 if (sw != dw || sh != dh)
214 p->beginNativePainting();
218 shadowMaker.paintShapeAndShadow(
p,
state.shadowOffsetX,
state.shadowOffsetY,
state.shadowBlur,
state.shadowColor);
220 p->drawImage(dx, dy,
image);
223 p->endNativePainting();
233 p->scale(scaleFactor.
x(), scaleFactor.
y());
237 setPainterState(
p,
state, pen);
245 p->setWorldTransform(
state.matrix * originMatrix);
253 p->setCompositionMode(cm);
262 p->fillRect(
r,
p->brush());
290 p->setBrush(
state.fillStyle);
298 QPen nPen =
p->pen();
306 QPen nPen =
p->pen();
315 QPen nPen =
p->pen();
323 QPen nPen =
p->pen();
337 QPen nPen =
p->pen();
348 QPen nPen =
p->pen();
356 QPen nPen =
p->pen();
371 p->fillPath(
path,
p->brush());
386 p->setClipping(
state.clip);
388 p->setClipPath(
state.clipPath);
394 p->setOpacity(
state.globalAlpha);
400 p->setCompositionMode(
state.globalCompositeOperation);
449 static bool registered =
false;
451 qRegisterMetaType<QQuickContext2DCommandBuffer*>(
"QQuickContext2DCommandBuffer*");
The QColor class provides colors based on RGB, HSV or CMYK values.
@ Format_ARGB32_Premultiplied
The QPainter class performs low-level painting on widgets and other paint devices.
void strokePath(const QPainterPath &path, const QPen &pen)
Draws the outline (strokes) the path path with the pen specified by pen.
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void fillPath(const QPainterPath &path, const QBrush &brush)
Fills the given path using the given brush.
CompositionMode
Defines the modes supported for digital image compositing.
@ CompositionMode_SourceIn
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen's cap style to the given style.
void setStyle(Qt::PenStyle)
[0]
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
void setJoinStyle(Qt::PenJoinStyle pcs)
Sets the pen's join style to the given style.
void setDashOffset(qreal doffset)
Sets the dash offset (the starting point on the dash pattern) for this pen to the offset specified.
void setMiterLimit(qreal limit)
Sets the miter limit of this pen to the given limit.
void setDashPattern(const QList< qreal > &pattern)
Sets the dash pattern for this pen to the given pattern.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
\inmodule QtCore\reentrant
QQuickContext2D::PaintCommand takeNextCommand()
Qt::PenJoinStyle takeLineJoin()
const QImage & takeImage()
qreal takeShadowOffsetY()
~QQuickContext2DCommandBuffer()
void replay(QPainter *painter, QQuickContext2D::State &state, const QVector2D &scaleFactor)
QQmlRefPointer< QQuickCanvasPixmap > takePixmap()
QQuickContext2DCommandBuffer()
QPainter::CompositionMode takeGlobalCompositeOperation()
qreal takeShadowOffsetX()
Qt::PenCapStyle takeLineCap()
@ GlobalCompositeOperation
\inmodule QtCore\reentrant
QRect toAlignedRect() const noexcept
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 QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
\inmodule QtCore\reentrant
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QSize size() const noexcept
Returns the size of the rectangle.
The QVector2D class represents a vector or vertex in 2D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
EGLint EGLint EGLint EGLint int int * ints
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
constexpr const T & qMax(const T &a, const T &b)
GLenum GLenum GLsizei count
GLsizei const GLubyte * commands
GLenum GLuint GLintptr offset
GLsizei const GLchar *const * path
GLint GLenum GLboolean normalized
static const QRectF boundingRect(const QPointF *points, int pointCount)
static void strokeShadowPath(QPainter *p, const QPainterPath &path, qreal offsetX, qreal offsetY, qreal blur, const QColor &color)
#define HAS_SHADOW(offsetX, offsetY, blur, color)
static void fillShadowPath(QPainter *p, const QPainterPath &path, qreal offsetX, qreal offsetY, qreal blur, const QColor &color)
static void fillRectShadow(QPainter *p, QRectF shadowRect, qreal offsetX, qreal offsetY, qreal blur, const QColor &color)
QT_BEGIN_NAMESPACE void qt_image_boxblur(QImage &image, int radius, bool quality)
static void qt_drawImage(QPainter *p, QQuickContext2D::State &state, QImage image, const QRectF &sr, const QRectF &dr, bool shadow=false)