aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/adaptations/software
diff options
context:
space:
mode:
authorLaszlo Agocs <[email protected]>2021-05-26 14:31:12 +0200
committerLaszlo Agocs <[email protected]>2021-05-27 18:25:15 +0200
commit17babc38b42adf577d6ebf33018f9e809263cc6d (patch)
tree23ee3aeaa5090164c940f1e0a324051dae568eb3 /src/quick/scenegraph/adaptations/software
parenta317f5b31dc88b2c1ad09b99c7013d8d14b4e316 (diff)
Add the possibility of flipping vertically to Image
[ChangeLog][QtQuick] Added mirrorVertically to Image to allow vertically mirroring an image. This complements the existing mirror property that performs a horizontal flip. Task-number: QTBUG-93972 Change-Id: Ib571ec27c299d918976d833fb8c8f57d2e385a56 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Eirik Aavitsland <[email protected]>
Diffstat (limited to 'src/quick/scenegraph/adaptations/software')
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp26
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h5
2 files changed, 17 insertions, 14 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
index f237fa26d4..f238f85f06 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
@@ -312,7 +312,8 @@ QSGSoftwareInternalImageNode::QSGSoftwareInternalImageNode()
: m_innerSourceRect(0, 0, 1, 1)
, m_subSourceRect(0, 0, 1, 1)
, m_texture(nullptr)
- , m_mirror(false)
+ , m_mirrorHorizontally(false)
+ , m_mirrorVertically(false)
, m_textureIsLayer(false)
, m_smooth(true)
, m_tileHorizontal(false)
@@ -364,13 +365,14 @@ void QSGSoftwareInternalImageNode::setTexture(QSGTexture *texture)
markDirty(DirtyMaterial);
}
-void QSGSoftwareInternalImageNode::setMirror(bool mirror)
+void QSGSoftwareInternalImageNode::setMirror(bool mirrorHorizontally, bool mirrorVertically)
{
- if (m_mirror != mirror) {
- m_mirror = mirror;
- m_cachedMirroredPixmapIsDirty = true;
- markDirty(DirtyMaterial);
- }
+ if (mirrorHorizontally == m_mirrorHorizontally && mirrorVertically == m_mirrorVertically)
+ return;
+ m_mirrorHorizontally = mirrorHorizontally;
+ m_mirrorVertically = mirrorVertically;
+ m_cachedMirroredPixmapIsDirty = true;
+ markDirty(DirtyMaterial);
}
void QSGSoftwareInternalImageNode::setMipmapFiltering(QSGTexture::Filtering /*filtering*/)
@@ -410,11 +412,11 @@ void QSGSoftwareInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrap
void QSGSoftwareInternalImageNode::update()
{
if (m_cachedMirroredPixmapIsDirty) {
- if (m_mirror || m_textureIsLayer) {
+ if (m_mirrorHorizontally || m_mirrorVertically || m_textureIsLayer) {
QTransform transform(
- (m_mirror ? -1 : 1), 0,
- 0 , (m_textureIsLayer ? -1 :1),
- 0 , 0
+ (m_mirrorHorizontally ? -1 : 1), 0,
+ 0 , (m_textureIsLayer ? -1 : 1) * (m_mirrorVertically ? -1 : 1),
+ 0 , 0
);
m_cachedMirroredPixmap = pixmap().transformed(transform);
} else {
@@ -457,7 +459,7 @@ void QSGSoftwareInternalImageNode::paint(QPainter *painter)
// Disable antialiased clipping. It causes transformed tiles to have gaps.
painter->setRenderHint(QPainter::Antialiasing, false);
- const QPixmap &pm = m_mirror || m_textureIsLayer ? m_cachedMirroredPixmap : pixmap();
+ const QPixmap &pm = m_mirrorHorizontally || m_mirrorVertically || m_textureIsLayer ? m_cachedMirroredPixmap : pixmap();
if (m_innerTargetRect != m_targetRect) {
// border image
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
index af912e1a3f..fadd6428dc 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
@@ -113,7 +113,7 @@ public:
void setInnerSourceRect(const QRectF &rect) override;
void setSubSourceRect(const QRectF &rect) override;
void setTexture(QSGTexture *texture) override;
- void setMirror(bool mirror) override;
+ void setMirror(bool mirrorHorizontally, bool mirrorVertically) override;
void setMipmapFiltering(QSGTexture::Filtering filtering) override;
void setFiltering(QSGTexture::Filtering filtering) override;
void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override;
@@ -137,7 +137,8 @@ private:
QPointer<QSGTexture> m_texture;
QPixmap m_cachedMirroredPixmap;
- bool m_mirror;
+ bool m_mirrorHorizontally;
+ bool m_mirrorVertically;
bool m_textureIsLayer;
bool m_smooth;
bool m_tileHorizontal;