summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglpaintdevice.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-09-08 13:09:00 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-09-08 16:36:16 (GMT)
commit31d8058a32a1d2d2d6bc1ba3d48f5a382d7b87a7 (patch)
treee9402324bd0eadd51802a3df9b43157639f01123 /src/opengl/qglpaintdevice.cpp
parente3e7cf545116c194bd5cfe79b28ea37c8bf78219 (diff)
downloadQt-31d8058a32a1d2d2d6bc1ba3d48f5a382d7b87a7.zip
Qt-31d8058a32a1d2d2d6bc1ba3d48f5a382d7b87a7.tar.gz
Qt-31d8058a32a1d2d2d6bc1ba3d48f5a382d7b87a7.tar.bz2
Make QGLPixmapData work with the new QGLPaintDevice API
This patch changes the ordering of QGL2PaintEngine::begin a bit because QGLPixmapData needs to use the paint engine's drawTexture method within beginPaint(). Also, this initialises needsSync to true and removes the setState call. So now all the state initialisation is done in ensureActive rather than begin.
Diffstat (limited to 'src/opengl/qglpaintdevice.cpp')
-rw-r--r--src/opengl/qglpaintdevice.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index 4cdeb76..15ea217 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -44,8 +44,10 @@
#include <private/qglpixelbuffer_p.h>
#include <private/qglframebufferobject_p.h>
#include <private/qwindowsurface_gl_p.h>
+#include <private/qpixmapdata_gl_p.h>
QGLPaintDevice::QGLPaintDevice()
+ : m_thisFBO(0)
{
}
@@ -56,14 +58,17 @@ QGLPaintDevice::~QGLPaintDevice()
void QGLPaintDevice::beginPaint()
{
- // Record the currently bound FBO so we can restore it again
- // in endPaint()
+ // Make sure our context is the current one:
QGLContext *ctx = context();
- ctx->makeCurrent();
+ if (ctx != QGLContext::currentContext())
+ ctx->makeCurrent();
+
+ // Record the currently bound FBO so we can restore it again
+ // in endPaint() and bind this device's FBO
m_previousFBO = ctx->d_func()->current_fbo;
- if (m_previousFBO != 0) {
- ctx->d_ptr->current_fbo = 0;
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+ if (m_previousFBO != m_thisFBO) {
+ ctx->d_ptr->current_fbo = m_thisFBO;
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO);
}
}
@@ -73,8 +78,10 @@ void QGLPaintDevice::ensureActiveTarget()
if (ctx != QGLContext::currentContext())
ctx->makeCurrent();
- if (ctx->d_ptr->current_fbo != 0)
- glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+ if (ctx->d_ptr->current_fbo != m_thisFBO) {
+ ctx->d_ptr->current_fbo = m_thisFBO;
+ glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO);
+ }
}
void QGLPaintDevice::endPaint()
@@ -193,6 +200,12 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd)
case QInternal::FramebufferObject:
glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice);
break;
+ case QInternal::Pixmap: {
+ QPixmapData* pmd = static_cast<QPixmap*>(pd)->pixmapData();
+ Q_ASSERT(pmd->classId() == QPixmapData::OpenGLClass);
+ glpd = static_cast<QGLPixmapData*>(pmd)->glDevice();
+ break;
+ }
default:
qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType());
break;