1 From 3902dcd1d7da169229deffbff02ac1a159b08d44 Mon Sep 17 00:00:00 2001
2 From: Jani Hautakangas <jani.hautakangas@ixonos.com>
3 Date: Thu, 16 May 2013 09:52:07 +0300
4 Subject: [PATCH 11/13] QOpenGLPaintDevice sub-area support
6 Allows creating QOpenGLPaintDevice targetting sub-area
9 Upstream-Status: Pending
11 Change-Id: Ida2f079aa1ac0b87d36b54129e226399dbcdda80
13 Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
15 src/gui/opengl/qopenglpaintdevice.cpp | 12 ++++++++++++
16 src/gui/opengl/qopenglpaintdevice.h | 2 ++
17 src/gui/opengl/qopenglpaintengine.cpp | 9 +++++++--
18 src/gui/opengl/qopenglpaintengine_p.h | 1 +
19 src/gui/opengl/qopengltextureglyphcache.cpp | 2 +-
20 5 files changed, 23 insertions(+), 3 deletions(-)
22 diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
23 index 6750458..034630a 100644
24 --- a/src/gui/opengl/qopenglpaintdevice.cpp
25 +++ b/src/gui/opengl/qopenglpaintdevice.cpp
26 @@ -111,6 +111,7 @@ class QOpenGLPaintDevicePrivate
28 QOpenGLPaintDevicePrivate(const QSize &size);
34 @@ -159,6 +160,12 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
38 +QOpenGLPaintDevice::QOpenGLPaintDevice(int x, int y, int width, int height)
39 + : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height)))
41 + d_ptr->offset = QPoint(x,y);
45 Destroys the QOpenGLPaintDevice.
47 @@ -228,6 +235,11 @@ QOpenGLContext *QOpenGLPaintDevice::context() const
51 +QPoint QOpenGLPaintDevice::offset() const
53 + return d_ptr->offset;
57 Returns the pixel size of the paint device.
59 diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
60 index c05571c..01eb1bc 100644
61 --- a/src/gui/opengl/qopenglpaintdevice.h
62 +++ b/src/gui/opengl/qopenglpaintdevice.h
63 @@ -62,12 +62,14 @@ public:
65 explicit QOpenGLPaintDevice(const QSize &size);
66 QOpenGLPaintDevice(int width, int height);
67 + QOpenGLPaintDevice(int x, int y, int width, int height);
68 virtual ~QOpenGLPaintDevice();
70 int devType() const { return QInternal::OpenGL; }
71 QPaintEngine *paintEngine() const;
73 QOpenGLContext *context() const;
74 + QPoint offset() const;
76 void setSize(const QSize &size);
77 void setDevicePixelRatio(qreal devicePixelRatio);
78 diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
79 index 81a0d82..ce57261 100644
80 --- a/src/gui/opengl/qopenglpaintengine.cpp
81 +++ b/src/gui/opengl/qopenglpaintengine.cpp
82 @@ -1985,7 +1985,10 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
83 for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
84 d->vertexAttributeArraysEnabledState[i] = false;
86 + const QPoint offset = d->device->offset();
87 const QSize sz = d->device->size();
90 d->width = sz.width();
91 d->height = sz.height();
92 d->mode = BrushDrawingMode;
93 @@ -2070,7 +2073,7 @@ void QOpenGL2PaintEngineEx::ensureActive()
94 d->device->ensureActiveTarget();
96 d->transferMode(BrushDrawingMode);
97 - d->funcs.glViewport(0, 0, d->width, d->height);
98 + d->funcs.glViewport(d->x, d->y, d->width, d->height);
100 d->lastMaskTextureUsed = 0;
101 d->shaderManager->setDirty();
102 @@ -2113,6 +2116,7 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
103 if (bounds == QRect(0, 0, width, height)) {
104 funcs.glDisable(GL_SCISSOR_TEST);
106 + bounds = QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
107 funcs.glEnable(GL_SCISSOR_TEST);
110 @@ -2121,12 +2125,13 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
112 void QOpenGL2PaintEngineExPrivate::setScissor(const QRect &rect)
114 - const int left = rect.left();
115 + const int left = rect.left() + x;
116 const int width = rect.width();
117 int bottom = height - (rect.top() + rect.height());
118 if (device->paintFlipped()) {
122 const int height = rect.height();
124 funcs.glScissor(left, bottom, width, height);
125 diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
126 index 4f0e2e5..f211de1 100644
127 --- a/src/gui/opengl/qopenglpaintengine_p.h
128 +++ b/src/gui/opengl/qopenglpaintengine_p.h
129 @@ -264,6 +264,7 @@ public:
130 QOpenGL2PaintEngineEx* q;
131 QOpenGLEngineShaderManager* shaderManager;
132 QOpenGLPaintDevice* device;
137 diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
138 index 0610ab6..ea1e3b2 100644
139 --- a/src/gui/opengl/qopengltextureglyphcache.cpp
140 +++ b/src/gui/opengl/qopengltextureglyphcache.cpp
141 @@ -316,7 +316,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
142 funcs->glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)oldFbo);
145 - funcs->glViewport(0, 0, pex->width, pex->height);
146 + funcs->glViewport(pex->x, pex->y, pex->width, pex->height);
147 pex->updateClipScissorTest();
149 if (m_vao.isCreated()) {