summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-04-16 08:55:12 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-04-16 15:28:26 (GMT)
commita241ebac49f01ba0e26a177f1aadbd18c7e9cae7 (patch)
treec7e577ecf60c990a1a5a1902ba0637bd3187a4d6 /src/opengl/gl2paintengineex
parent1e1371e19ae62a5bf57dcad8d53ac70dcd2ad0cb (diff)
downloadQt-a241ebac49f01ba0e26a177f1aadbd18c7e9cae7.zip
Qt-a241ebac49f01ba0e26a177f1aadbd18c7e9cae7.tar.gz
Qt-a241ebac49f01ba0e26a177f1aadbd18c7e9cae7.tar.bz2
Use FBOs as pixmap backend in GL graphics system.
We now use FBOs to implement render-to-pixmap for the GL pixmap backend. A multisample FBO is used for rendering, and is then blitted onto a non-multisample FBO dynamically bound to the relevant texture. Reviewed-by: Tom
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e166b54..fe70020 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -175,6 +175,8 @@ public:
// Clipping & state stuff stolen from QOpenGLPaintEngine:
void updateDepthClip();
uint use_system_clip : 1;
+
+ QPaintEngine *last_engine;
};
@@ -616,7 +618,6 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());
-
// Check to see if there's any hints
if (path.shape() == QVectorPath::RectangleHint) {
QGLRect rect(points[0].x(), points[0].y(), points[2].x(), points[2].y());
@@ -1034,6 +1035,14 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
qt_resolve_version_1_3_functions(d->ctx);
qt_resolve_glsl_extensions(d->ctx);
+ d->last_engine = d->ctx->d_ptr->active_engine;
+ d->ctx->d_ptr->active_engine = this;
+
+ if (d->last_engine) {
+ QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(d->last_engine);
+ static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr)->transferMode(DefaultMode);
+ }
+
if (!d->shaderManager)
d->shaderManager = new QGLPEXShaderManager(d->ctx);
@@ -1054,6 +1063,19 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
d->use_system_clip = !systemClip().isEmpty();
glDisable(GL_DEPTH_TEST);
+ glDisable(GL_SCISSOR_TEST);
+
+ QGLPixmapData *source = d->drawable.copyOnBegin();
+ if (source) {
+ d->transferMode(ImageDrawingMode);
+
+ source->bind();
+
+ glDisable(GL_BLEND);
+
+ QRect rect(0, 0, source->width(), source->height());
+ d->drawTexture(QRectF(rect), QRectF(rect), rect.size());
+ }
updateClipRegion(QRegion(), Qt::NoClip);
return true;
@@ -1067,6 +1089,20 @@ bool QGL2PaintEngineEx::end()
d->transferMode(DefaultMode);
d->drawable.swapBuffers();
d->drawable.doneCurrent();
+ d->ctx->d_ptr->active_engine = d->last_engine;
+
+ if (d->last_engine) {
+ QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(d->last_engine);
+ QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr);
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_SCISSOR_TEST);
+
+ glViewport(0, 0, p->width, p->height);
+ engine->setState(engine->state());
+ p->updateDepthClip();
+ }
+
return false;
}