7#include <QtQuick/qsgtextureprovider.h>
9#include <QtQuick/private/qsgcontext_p.h>
10#include <private/qsgadaptationlayer_p.h>
11#include <private/qnumeric_p.h>
13#include <QtCore/qmath.h>
14#include <QtGui/qpainter.h>
15#include <QtCore/QRunnable>
43 : pixmapChanged(
false)
336 if (
d->fillMode ==
mode)
367 return d->paintedWidth;
373 return d->paintedHeight;
607 if (!
d->pix.width() || !
d->pix.height()) {
611 const qreal pixWidth =
d->pix.width() /
d->devicePixelRatio;
612 const qreal pixHeight =
d->pix.height() /
d->devicePixelRatio;
614 const qreal widthScale =
w / pixWidth;
616 const qreal heightScale =
h / pixHeight;
617 if (widthScale <= heightScale) {
619 d->paintedHeight = widthScale * pixHeight;
620 }
else if (heightScale < widthScale) {
621 d->paintedWidth = heightScale * pixWidth;
622 d->paintedHeight =
h;
629 if (!
d->pix.width() || !
d->pix.height())
631 const qreal pixWidth =
d->pix.width() /
d->devicePixelRatio;
632 const qreal pixHeight =
d->pix.height() /
d->devicePixelRatio;
635 if (widthScale < heightScale) {
636 widthScale = heightScale;
637 }
else if (heightScale < widthScale) {
638 heightScale = widthScale;
641 d->paintedHeight = heightScale * pixHeight;
642 d->paintedWidth = widthScale * pixWidth;
643 }
else if (
d->fillMode ==
Pad) {
644 d->paintedWidth =
d->pix.width() /
d->devicePixelRatio;
645 d->paintedHeight =
d->pix.height() /
d->devicePixelRatio;
647 d->paintedWidth =
width();
656 if (newGeometry.
size() != oldGeometry.
size())
678 qWarning(
"QQuickImage::textureProvider: can only be queried on the rendering thread of an exposed window");
693void QQuickImage::invalidateSceneGraph()
697 d->provider =
nullptr;
705 d->provider =
nullptr;
717 d->provider->m_smooth =
d->smooth;
718 d->provider->m_mipmap =
d->mipmap;
719 d->provider->updateTexture(
texture);
729 d->pixmapChanged =
true;
730 node =
d->sceneGraphContext()->createInternalImageNode(
d->sceneGraphRenderContext());
743 xOffset = (
width() - pixWidth) / 2;
749 yOffset = (
height() - pixHeight) / 2;
753 switch (
d->fillMode) {
756 sourceRect =
d->pix.rect();
760 targetRect =
QRectF(xOffset, yOffset,
d->paintedWidth,
d->paintedHeight);
761 sourceRect =
d->pix.rect();
769 if (wscale > hscale) {
770 int src = (hscale / wscale) *
qreal(
d->pix.height());
779 int src = (wscale / hscale) *
qreal(
d->pix.width());
799 sourceRect =
QRectF(-xOffset, 0,
width(),
d->pix.height());
814 targetRect =
QRectF(
x + xOffset,
y + yOffset,
w,
h);
821 QRectF nsrect(sourceRect.
x() / nsWidth,
822 sourceRect.
y() / nsHeight,
823 sourceRect.
width() / nsWidth,
824 sourceRect.
height() / nsHeight);
834 if (
d->pixmapChanged) {
841 d->pixmapChanged =
false;
852 node->
setMirror(
d->mirrorHorizontally,
d->mirrorVertically);
869 d->pixmapChanged =
true;
884 if (
d->vAlign == align)
902 if (
d->hAlign == align)
936 if (
d->mipmap == use)
939 emit mipmapChanged(
d->mipmap);
941 d->pixmapChanged =
true;
971#include "moc_qquickimage_p_p.cpp"
973#include "moc_qquickimage_p.cpp"
virtual void pixmapChange()
void setPixmap(const QQuickPixmap &pixmap)
QQuickImageTextureProvider * provider
void setImage(const QImage &img)
QSGTexture * texture() const override
Returns a pointer to the texture object.
QQuickImageTextureProvider()
void updateTexture(QSGTexture *texture)
void setFillMode(FillMode)
VAlignment verticalAlignment
void horizontalAlignmentChanged(HAlignment alignment)
QSGNode * updatePaintNode(QSGNode *, UpdatePaintNodeData *) override
Called on the render thread when it is time to sync the state of the item with the scene graph.
QQuickImage(QQuickItem *parent=nullptr)
\qmltype Image \instantiates QQuickImage \inqmlmodule QtQuick\inherits Item
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void updatePaintedGeometry()
\qmlproperty enumeration QtQuick::Image::status \readonly
QSGTextureProvider * textureProvider() const override
Returns the texture provider for an item.
QRectF boundingRect() const override
Returns the extents of the item in its own coordinate system: a rectangle from {0,...
void pixmapChange() override
HAlignment horizontalAlignment
void releaseResources() override
This function is called when an item should release graphics resources which are not already managed ...
void verticalAlignmentChanged(VAlignment alignment)
void setVerticalAlignment(VAlignment align)
void setHorizontalAlignment(HAlignment align)
void paintedGeometryChanged()
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
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.
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
bool heightValid() const
Returns whether the height property has been set explicitly.
bool widthValid() const
Returns whether the width property has been set explicitly.
qreal height
This property holds the height of this item.
void update()
Schedules a call to updatePaintNode() for this item.
virtual bool isTextureProvider() const
Returns true if this item is a texture provider.
void setImplicitSize(qreal, qreal)
void setImage(const QImage &)
void setPixmap(const QQuickPixmap &other)
static void schedule(QQuickWindow *window, QObject *object)
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
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 QSizeF size() const noexcept
Returns the size of the rectangle.
virtual void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)=0
virtual void setTexture(QSGTexture *texture)=0
virtual void setTargetRect(const QRectF &rect)=0
virtual void setFiltering(QSGTexture::Filtering filtering)=0
virtual void setSubSourceRect(const QRectF &rect)=0
virtual void setInnerTargetRect(const QRectF &rect)=0
virtual void setAntialiasing(bool antialiasing)
virtual void setMipmapFiltering(QSGTexture::Filtering filtering)=0
virtual void setMirror(bool horizontally, bool vertically)=0
virtual void setVerticalWrapMode(QSGTexture::WrapMode wrapMode)=0
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
The QSGTextureProvider class encapsulates texture based entities in QML.
void textureChanged()
This signal is emitted when the texture changes.
void setHorizontalWrapMode(WrapMode hwrap)
Sets the horizontal wrap mode to hwrap.
void setFiltering(Filtering filter)
Sets the sampling mode to filter.
void setMipmapFiltering(Filtering filter)
Sets the mipmap sampling mode to filter.
WrapMode
Specifies how the sampler should treat texture coordinates.
void setVerticalWrapMode(WrapMode vwrap)
Sets the vertical wrap mode to vwrap.
static QThread * currentThread()
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
static Q_DECL_CONST_FUNCTION bool qt_is_finite(double d)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent