mirror of
https://github.com/thead-yocto-mirror/meta-qt5
synced 2026-09-17 20:51:54 +02:00
159 lines
5.5 KiB
Diff
159 lines
5.5 KiB
Diff
From e7b9af7232c4f7eb50933dde208e58438bedd964 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 10/11] QOpenGLPaintDevice sub-area support
|
|
|
|
Allows creating QOpenGLPaintDevice targetting sub-area
|
|
of binded framebuffer.
|
|
|
|
Upstream-Status: Pending
|
|
|
|
Change-Id: Ida2f079aa1ac0b87d36b54129e226399dbcdda80
|
|
|
|
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
|
|
---
|
|
src/gui/opengl/qopenglpaintdevice.cpp | 11 +++++++++++
|
|
src/gui/opengl/qopenglpaintdevice.h | 2 ++
|
|
src/gui/opengl/qopenglpaintdevice_p.h | 1 +
|
|
src/gui/opengl/qopenglpaintengine.cpp | 9 +++++++--
|
|
src/gui/opengl/qopenglpaintengine_p.h | 1 +
|
|
src/gui/opengl/qopengltextureglyphcache.cpp | 2 +-
|
|
6 files changed, 23 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
|
|
index e908fd8..8f0ef56 100644
|
|
--- a/src/gui/opengl/qopenglpaintdevice.cpp
|
|
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
|
|
@@ -135,6 +135,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);
|
|
+}
|
|
+
|
|
/*!
|
|
\internal
|
|
*/
|
|
@@ -212,6 +218,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 dda3bfe..9965553 100644
|
|
--- a/src/gui/opengl/qopenglpaintdevice.h
|
|
+++ b/src/gui/opengl/qopenglpaintdevice.h
|
|
@@ -53,6 +53,7 @@ public:
|
|
QOpenGLPaintDevice();
|
|
explicit QOpenGLPaintDevice(const QSize &size);
|
|
QOpenGLPaintDevice(int width, int height);
|
|
+ QOpenGLPaintDevice(int x, int y, int width, int height);
|
|
QOpenGLPaintDevice(QOpenGLPaintDevicePrivate *dd);
|
|
virtual ~QOpenGLPaintDevice();
|
|
|
|
@@ -60,6 +61,7 @@ public:
|
|
QPaintEngine *paintEngine() const;
|
|
|
|
QOpenGLContext *context() const;
|
|
+ QPoint offset() const;
|
|
QSize size() const;
|
|
void setSize(const QSize &size);
|
|
void setDevicePixelRatio(qreal devicePixelRatio);
|
|
diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h
|
|
index 0b01129..211f2f3 100644
|
|
--- a/src/gui/opengl/qopenglpaintdevice_p.h
|
|
+++ b/src/gui/opengl/qopenglpaintdevice_p.h
|
|
@@ -65,6 +65,7 @@ public:
|
|
|
|
public:
|
|
QSize size;
|
|
+ QPoint offset;
|
|
QOpenGLContext *ctx;
|
|
|
|
qreal dpmx;
|
|
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
|
|
index c490726..1d775fd 100644
|
|
--- a/src/gui/opengl/qopenglpaintengine.cpp
|
|
+++ b/src/gui/opengl/qopenglpaintengine.cpp
|
|
@@ -2002,7 +2002,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;
|
|
@@ -2089,7 +2092,7 @@ void QOpenGL2PaintEngineEx::ensureActive()
|
|
d->device->ensureActiveTarget();
|
|
|
|
d->transferMode(BrushDrawingMode);
|
|
- d->funcs.glViewport(0, 0, d->width, d->height);
|
|
+ d->funcs.glViewport(d->x, d->y, d->width, d->height);
|
|
d->needsSync = false;
|
|
d->lastMaskTextureUsed = 0;
|
|
d->shaderManager->setDirty();
|
|
@@ -2132,6 +2135,7 @@ void QOpenGL2PaintEngineExPrivate::updateClipScissorTest()
|
|
if (bounds == QRect(0, 0, width, height)) {
|
|
funcs.glDisable(GL_SCISSOR_TEST);
|
|
} else {
|
|
+ bounds = QRect(bounds.x(), bounds.y(), bounds.width(), bounds.height());
|
|
funcs.glEnable(GL_SCISSOR_TEST);
|
|
setScissor(bounds);
|
|
}
|
|
@@ -2140,12 +2144,13 @@ 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();
|
|
|
|
funcs.glScissor(left, bottom, width, height);
|
|
diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
|
|
index 5ef0366..c5b517d 100644
|
|
--- a/src/gui/opengl/qopenglpaintengine_p.h
|
|
+++ b/src/gui/opengl/qopenglpaintengine_p.h
|
|
@@ -256,6 +256,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 6e16b2d..ddec9bb 100644
|
|
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
|
|
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
|
|
@@ -308,7 +308,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
|
|
funcs->glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)oldFbo);
|
|
|
|
if (pex != 0) {
|
|
- funcs->glViewport(0, 0, pex->width, pex->height);
|
|
+ funcs->glViewport(pex->x, pex->y, pex->width, pex->height);
|
|
pex->updateClipScissorTest();
|
|
} else {
|
|
if (m_vao.isCreated()) {
|
|
--
|
|
2.1.1
|
|
|