aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-qt/qt5/qtbase-5.0.2/0018-QOpenGLPaintDevice-sub-area-support.patch
blob: cbf4aed1f48c7756617dfd1038b05cd10abdfe10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
From c2c17a3198c85366f34b24abc80b20f27307d751 Mon Sep 17 00:00:00 2001
From: Jani Hautakangas <jani.hautakangas@ixonos.com>
Date: Thu, 16 May 2013 09:52:07 +0300
Subject: [PATCH 18/22] QOpenGLPaintDevice sub-area support

Allows creating QOpenGLPaintDevice targetting sub-area
of binded framebuffer.

Upstream-Status: Pending

Change-Id: Ida2f079aa1ac0b87d36b54129e226399dbcdda80
---
 src/gui/opengl/qopenglpaintdevice.cpp       | 12 ++++++++++++
 src/gui/opengl/qopenglpaintdevice.h         |  2 ++
 src/gui/opengl/qopenglpaintengine.cpp       | 10 +++++++---
 src/gui/opengl/qopenglpaintengine_p.h       |  1 +
 src/gui/opengl/qopengltextureglyphcache.cpp |  2 +-
 5 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index 0b3d9dc..5f4f1c9 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -111,6 +111,7 @@ class QOpenGLPaintDevicePrivate
 public:
     QOpenGLPaintDevicePrivate(const QSize &size);
 
+    QPoint offset;
     QSize size;
     QOpenGLContext *ctx;
 
@@ -158,6 +159,12 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
 {
 }
 
+QOpenGLPaintDevice::QOpenGLPaintDevice(int x, int y, int width, int height)
+    : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height)))
+{
+    d_ptr->offset = QPoint(x,y);
+}
+
 /*!
     Destroys the QOpenGLPaintDevice.
 */
@@ -226,6 +233,11 @@ QOpenGLContext *QOpenGLPaintDevice::context() const
     return d_ptr->ctx;
 }
 
+QPoint QOpenGLPaintDevice::offset() const
+{
+    return d_ptr->offset;
+}
+
 /*!
     Returns the pixel size of the paint device.
 
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index 66850c7..6f8a849 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -62,12 +62,14 @@ public:
     QOpenGLPaintDevice();
     explicit QOpenGLPaintDevice(const QSize &size);
     QOpenGLPaintDevice(int width, int height);
+    QOpenGLPaintDevice(int x, int y, int width, int height);
     virtual ~QOpenGLPaintDevice();
 
     int devType() const { return QInternal::OpenGL; }
     QPaintEngine *paintEngine() const;
 
     QOpenGLContext *context() const;
+    QPoint offset() const;
     QSize size() const;
     void setSize(const QSize &size);
 
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 9fd8a7a..df29159 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -1935,7 +1935,10 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
     for (int i = 0; i < QT_GL_VERTEX_ARRAY_TRACKED_COUNT; ++i)
         d->vertexAttributeArraysEnabledState[i] = false;
 
+    const QPoint offset = d->device->offset();
     const QSize sz = d->device->size();
+    d->x = offset.x();
+    d->y = offset.y();
     d->width = sz.width();
     d->height = sz.height();
     d->mode = BrushDrawingMode;
@@ -2023,7 +2026,7 @@ void QOpenGL2PaintEngineEx::ensureActive()
         d->device->ensureActiveTarget();
 
         d->transferMode(BrushDrawingMode);
-        glViewport(0, 0, d->width, d->height);
+        glViewport(d->x, d->y, d->width, d->height);
         d->needsSync = false;
         d->lastMaskTextureUsed = 0;
         d->shaderManager->setDirty();
@@ -2066,6 +2069,7 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
     if (bounds == QRect(0, 0, width, height)) {
         glDisable(GL_SCISSOR_TEST);
     } else {
+        bounds = QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
         glEnable(GL_SCISSOR_TEST);
         setScissor(bounds);
     }
@@ -2074,14 +2078,14 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
 
 void QOpenGL2PaintEngineExPrivate::setScissor(const QRect &rect)
 {
-    const int left = rect.left();
+    const int left = rect.left() + x;
     const int width = rect.width();
     int bottom = height - (rect.top() + rect.height());
     if (device->paintFlipped()) {
         bottom = rect.top();
     }
+    bottom += y;
     const int height = rect.height();
-
     glScissor(left, bottom, width, height);
 }
 
diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
index 93e1b42..d84e8c7 100644
--- a/src/gui/opengl/qopenglpaintengine_p.h
+++ b/src/gui/opengl/qopenglpaintengine_p.h
@@ -261,6 +261,7 @@ public:
     QOpenGL2PaintEngineEx* q;
     QOpenGLEngineShaderManager* shaderManager;
     QOpenGLPaintDevice* device;
+    int x, y;
     int width, height;
     QOpenGLContext *ctx;
     EngineMode mode;
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index b751629..8822faf 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -268,7 +268,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
     funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_func()->current_fbo);
 
     if (pex != 0) {
-        glViewport(0, 0, pex->width, pex->height);
+        glViewport(pex->x, pex->y, pex->width, pex->height);
         pex->updateClipScissorTest();
     } else {
         m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
-- 
1.8.3.2