5#include <private/qquickpainteditem_p.h>
7#include <QtQuick/private/qsgdefaultpainternode_p.h>
8#include <QtQuick/private/qsgcontext_p.h>
9#include <private/qsgadaptationlayer_p.h>
87 , fillColor(
Qt::transparent)
89 , opaquePainting(
false)
120 if (
d->textureProvider)
138 if (
rect.isNull() && !
d->dirtyRect.isNull())
155 return d->opaquePainting;
172 if (
d->opaquePainting == opaque)
175 d->opaquePainting = opaque;
248 return d->performanceHints;
262 PerformanceHints oldHints =
d->performanceHints;
264 d->performanceHints |=
hint;
266 d->performanceHints &= ~hint;
267 if (oldHints !=
d->performanceHints)
281 if (
d->performanceHints == hints)
283 d->performanceHints = hints;
290 return d->textureSize;
311 if (
d->textureSize ==
size)
313 d->textureSize =
size;
330 QSizeF sz =
d->contentsSize *
d->contentsScale;
353 return d->contentsSize;
360 if (
d->contentsSize ==
size)
363 d->contentsSize =
size;
391 return d->contentsScale;
398 if (
d->contentsScale ==
scale)
427 if (
d->fillColor ==
c)
455 return d->renderTarget;
509 if (
d->textureProvider) {
510 d->textureProvider->node =
nullptr;
511 d->textureProvider->fireTextureChanged();
518 node =
d->sceneGraphContext()->createPainterNode(
this);
522 bool hasTextureSize =
d->textureSize.width() > 0 &&
d->textureSize.height() > 0;
527 && (
d->contentsScale != 1
528 || (
d->contentsSize.width() > 0 &&
d->contentsSize.height() > 0))) {
540 *
window()->effectiveDevicePixelRatio();
556 if (
d->textureProvider) {
557 d->textureProvider->node = node;
558 d->textureProvider->fireTextureChanged();
570 if (
d->textureProvider) {
572 d->textureProvider =
nullptr;
577void QQuickPaintedItem::invalidateSceneGraph()
580 delete d->textureProvider;
581 d->textureProvider =
nullptr;
608 qWarning(
"QQuickPaintedItem::textureProvider: can only be queried on the rendering thread of an exposed window");
611 if (!
d->textureProvider)
613 d->textureProvider->node =
d->node;
614 return d->textureProvider;
630#include "moc_qquickpainteditem.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setAntialiasing(bool)
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual QSGTextureProvider * textureProvider() const
Returns the texture provider for an item.
QQuickWindow * window() const
Returns the window in which this item is rendered.
qreal width
This property holds the width of this item.
virtual void itemChange(ItemChange, const ItemChangeData &)
Called when change occurs for this item.
bool antialiasing
\qmlproperty bool QtQuick::Item::antialiasing
qreal height
This property holds the height of this item.
qreal scale
\qmlproperty real QtQuick::Item::scale This property holds the scale factor for this item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
@ ItemDevicePixelRatioHasChanged
void update()
Schedules a call to updatePaintNode() for this item.
virtual bool isTextureProvider() const
Returns true if this item is a texture provider.
QQuickPaintedItemPrivate()
void fireTextureChanged()
QSGTexture * texture() const override
Returns a pointer to the texture object.
The QQuickPaintedItem class provides a way to use the QPainter API in the QML Scene Graph.
QSize contentsSize
Obsolete method for setting the contents size.
void contentsScaleChanged()
void setMipmap(bool enable)
If enable is true, mipmapping is enabled on the associated texture.
void setPerformanceHints(PerformanceHints hints)
Sets the performance hints to hints.
void setTextureSize(const QSize &size)
QColor fillColor
The item's background fill color.
void itemChange(ItemChange, const ItemChangeData &) override
\reimp
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
\reimp
void setRenderTarget(RenderTarget target)
void setContentsScale(qreal)
void setFillColor(const QColor &)
RenderTarget renderTarget
The item's render target.
PerformanceHint
This enum describes flags that you can enable to improve rendering performance in QQuickPaintedItem.
QSGTextureProvider * textureProvider() const override
\reimp
bool mipmap() const
Returns true if mipmaps are enabled; otherwise, false is returned.
QQuickPaintedItem(QQuickItem *parent=nullptr)
Constructs a QQuickPaintedItem with the given parent item.
bool isTextureProvider() const override
\reimp
void releaseResources() override
\reimp
QRectF contentsBoundingRect() const
PerformanceHints performanceHints() const
Returns the performance hints.
void setPerformanceHint(PerformanceHint hint, bool enabled=true)
Sets the given performance hint on the item if enabled is true; otherwise clears the performance hint...
QSize textureSize
Defines the size of the texture.
void setContentsSize(const QSize &)
~QQuickPaintedItem() override
Destroys the QQuickPaintedItem.
void setAntialiasing(bool enable)
If enable is true, antialiased painting is enabled.
void renderTargetChanged()
bool opaquePainting() const
Returns true if this item is opaque; otherwise, false is returned.
bool antialiasing() const
Returns true if antialiased painting is enabled; otherwise, false is returned.
void setOpaquePainting(bool opaque)
If opaque is true, the item is opaque; otherwise, it is considered as translucent.
void textureSizeChanged()
RenderTarget
This enum describes QQuickPaintedItem's render targets.
void contentsSizeChanged()
qreal contentsScale
Obsolete method for scaling the contents.
static void schedule(QQuickWindow *window, QObject *object)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
QRect toAlignedRect() const noexcept
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
\inmodule QtCore\reentrant
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
virtual QSGTexture * texture() const =0
virtual void setTextureSize(const QSize &size)=0
virtual void setSmoothPainting(bool s)=0
virtual void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target)=0
virtual void setLinearFiltering(bool linearFiltering)=0
virtual void setFastFBOResizing(bool dynamic)=0
virtual void setDirty(const QRect &dirtyRect=QRect())=0
virtual void setFillColor(const QColor &c)=0
virtual void setSize(const QSize &size)=0
virtual void setContentsScale(qreal s)=0
virtual void setOpaquePainting(bool opaque)=0
virtual void setMipmapping(bool mipmapping)=0
The QSGTextureProvider class encapsulates texture based entities in QML.
void textureChanged()
This signal is emitted when the texture changes.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
static QThread * currentThread()
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum GLenum GLenum GLenum scale
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)