qt*: refresh the patches
[scm/bb/tizen-distro.git] / meta-qt5 / recipes-qt / qt5 / qtbase / 0011-QOpenGLPaintDevice-sub-area-support.patch
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
5
6 Allows creating QOpenGLPaintDevice targetting sub-area
7 of binded framebuffer.
8
9 Upstream-Status: Pending
10
11 Change-Id: Ida2f079aa1ac0b87d36b54129e226399dbcdda80
12
13 Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
14 ---
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(-)
21
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
27  public:
28      QOpenGLPaintDevicePrivate(const QSize &size);
29  
30 +    QPoint offset;
31      QSize size;
32      QOpenGLContext *ctx;
33  
34 @@ -159,6 +160,12 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
35  {
36  }
37  
38 +QOpenGLPaintDevice::QOpenGLPaintDevice(int x, int y, int width, int height)
39 +    : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height)))
40 +{
41 +    d_ptr->offset = QPoint(x,y);
42 +}
43 +
44  /*!
45      Destroys the QOpenGLPaintDevice.
46  */
47 @@ -228,6 +235,11 @@ QOpenGLContext *QOpenGLPaintDevice::context() const
48      return d_ptr->ctx;
49  }
50  
51 +QPoint QOpenGLPaintDevice::offset() const
52 +{
53 +    return d_ptr->offset;
54 +}
55 +
56  /*!
57      Returns the pixel size of the paint device.
58  
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:
64      QOpenGLPaintDevice();
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();
69  
70      int devType() const { return QInternal::OpenGL; }
71      QPaintEngine *paintEngine() const;
72  
73      QOpenGLContext *context() const;
74 +    QPoint offset() const;
75      QSize size() 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;
85  
86 +    const QPoint offset = d->device->offset();
87      const QSize sz = d->device->size();
88 +    d->x = offset.x();
89 +    d->y = offset.y();
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();
95  
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);
99          d->needsSync = false;
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);
105      } else {
106 +        bounds = QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
107          funcs.glEnable(GL_SCISSOR_TEST);
108          setScissor(bounds);
109      }
110 @@ -2121,12 +2125,13 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
111  
112  void QOpenGL2PaintEngineExPrivate::setScissor(const QRect &rect)
113  {
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()) {
119          bottom = rect.top();
120      }
121 +    bottom += y;
122      const int height = rect.height();
123  
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;
133 +    int x, y;
134      int width, height;
135      QOpenGLContext *ctx;
136      EngineMode mode;
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);
143  
144      if (pex != 0) {
145 -        funcs->glViewport(0, 0, pex->width, pex->height);
146 +        funcs->glViewport(pex->x, pex->y, pex->width, pex->height);
147          pex->updateClipScissorTest();
148      } else {
149          if (m_vao.isCreated()) {
150 -- 
151 2.1.1
152