aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/scenegraph/softwarecontext/context.cpp8
-rw-r--r--src/plugins/scenegraph/softwarecontext/context.h2
-rw-r--r--src/plugins/scenegraph/softwarecontext/softwarelayer.cpp20
-rw-r--r--src/plugins/scenegraph/softwarecontext/softwarelayer.h4
4 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/scenegraph/softwarecontext/context.cpp b/src/plugins/scenegraph/softwarecontext/context.cpp
index b3b97a7d7c..6f5c997499 100644
--- a/src/plugins/scenegraph/softwarecontext/context.cpp
+++ b/src/plugins/scenegraph/softwarecontext/context.cpp
@@ -121,6 +121,8 @@ void Renderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state)
PixmapRenderer::PixmapRenderer(QSGRenderContext *context)
: QSGRenderer(context)
+ , m_mirrorHorizontal(false)
+ , m_mirrorVertical(false)
{
}
@@ -147,6 +149,12 @@ void PixmapRenderer::render(QPixmap *target)
painter.setRenderHint(QPainter::Antialiasing);
painter.setWindow(m_projectionRect);
+ if (m_mirrorHorizontal || m_mirrorVertical) {
+ QMatrix mirroringMatrix;
+ mirroringMatrix.scale(m_mirrorHorizontal ? -1 : 1, m_mirrorVertical ? -1 : 1);
+ painter.setMatrix(mirroringMatrix);
+ }
+
RenderingVisitor(&painter).visitChildren(rootNode());
}
diff --git a/src/plugins/scenegraph/softwarecontext/context.h b/src/plugins/scenegraph/softwarecontext/context.h
index 0d734df943..b8cd5bb066 100644
--- a/src/plugins/scenegraph/softwarecontext/context.h
+++ b/src/plugins/scenegraph/softwarecontext/context.h
@@ -68,6 +68,8 @@ public:
void render(QPixmap *target);
QRect m_projectionRect;
+ bool m_mirrorHorizontal;
+ bool m_mirrorVertical;
};
class RenderContext : public QSGRenderContext
diff --git a/src/plugins/scenegraph/softwarecontext/softwarelayer.cpp b/src/plugins/scenegraph/softwarecontext/softwarelayer.cpp
index 2ee14610ce..13531c5549 100644
--- a/src/plugins/scenegraph/softwarecontext/softwarelayer.cpp
+++ b/src/plugins/scenegraph/softwarecontext/softwarelayer.cpp
@@ -26,6 +26,8 @@ SoftwareLayer::SoftwareLayer(QSGRenderContext *renderContext)
, m_context(renderContext)
, m_renderer(0)
, m_device_pixel_ratio(1)
+ , m_mirrorHorizontal(false)
+ , m_mirrorVertical(false)
, m_live(true)
, m_grab(true)
, m_recursive(false)
@@ -151,6 +153,22 @@ void SoftwareLayer::setDevicePixelRatio(qreal ratio)
m_device_pixel_ratio = ratio;
}
+void SoftwareLayer::setMirrorHorizontal(bool mirror)
+{
+ if (m_mirrorHorizontal == mirror)
+ return;
+ m_mirrorHorizontal = mirror;
+ markDirtyTexture();
+}
+
+void SoftwareLayer::setMirrorVertical(bool mirror)
+{
+ if (m_mirrorVertical == mirror)
+ return;
+ m_mirrorVertical = mirror;
+ markDirtyTexture();
+}
+
void SoftwareLayer::markDirtyTexture()
{
m_dirtyTexture = true;
@@ -198,6 +216,8 @@ void SoftwareLayer::grab()
m_renderer->setDeviceRect(m_size);
m_renderer->setViewportRect(m_size);
+ m_renderer->m_mirrorHorizontal = m_mirrorHorizontal;
+ m_renderer->m_mirrorVertical = m_mirrorVertical;
m_renderer->m_projectionRect = QRect(m_rect.x() * m_device_pixel_ratio,
m_rect.y() * m_device_pixel_ratio,
m_rect.width() * m_device_pixel_ratio,
diff --git a/src/plugins/scenegraph/softwarecontext/softwarelayer.h b/src/plugins/scenegraph/softwarecontext/softwarelayer.h
index 67d7953400..c4375b1dec 100644
--- a/src/plugins/scenegraph/softwarecontext/softwarelayer.h
+++ b/src/plugins/scenegraph/softwarecontext/softwarelayer.h
@@ -60,6 +60,8 @@ public:
virtual void setFormat(GLenum);
virtual void setHasMipmaps(bool);
virtual void setDevicePixelRatio(qreal ratio);
+ virtual void setMirrorHorizontal(bool mirror);
+ virtual void setMirrorVertical(bool mirror);
public slots:
virtual void markDirtyTexture();
@@ -75,6 +77,8 @@ private:
QSize m_size;
QPixmap m_pixmap;
qreal m_device_pixel_ratio;
+ bool m_mirrorHorizontal;
+ bool m_mirrorVertical;
bool m_live;
bool m_grab;
bool m_recursive;