summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp37
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h1
-rw-r--r--src/opengl/qgl_p.h2
-rw-r--r--src/opengl/qpixmapdata_gl.cpp69
4 files changed, 76 insertions, 33 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e7b6ee4..40f3a8d 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -449,6 +449,43 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
+void QGL2PaintEngineEx::sync()
+{
+ Q_D(QGL2PaintEngineEx);
+ ensureActive();
+ d->transferMode(BrushDrawingMode);
+
+ QGLContext *ctx = d->ctx;
+ glUseProgram(0);
+
+#ifndef QT_OPENGL_ES_2
+ // be nice to people who mix OpenGL 1.x code with QPainter commands
+ // by setting modelview and projection matrices to mirror the GL 1
+ // paint engine
+ const QTransform& mtx = state()->matrix;
+
+ float mv_matrix[4][4] =
+ {
+ { mtx.m11(), mtx.m12(), 0, mtx.m13() },
+ { mtx.m21(), mtx.m22(), 0, mtx.m23() },
+ { 0, 0, 1, 0 },
+ { mtx.dx(), mtx.dy(), 0, mtx.m33() }
+ };
+
+ const QSize sz = d->drawable.size();
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(&mv_matrix[0][0]);
+#endif
+
+ glDisable(GL_BLEND);
+ glActiveTexture(GL_TEXTURE0);
+}
+
void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
{
if (newMode == mode)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index dececa3..7213474 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -126,6 +126,7 @@ public:
return static_cast<const QOpenGL2PaintEngineState *>(QPaintEngineEx::state());
}
void updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op);
+ virtual void sync();
private:
Q_DISABLE_COPY(QGL2PaintEngineEx)
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index b1a63b5..b3523d4 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -440,7 +440,7 @@ inline bool qt_gl_preferGL2Engine()
return true;
#else
return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
- && !qgetenv("QT_GL_USE_OPENGL2ENGINE").isEmpty();
+ && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty();
#endif
}
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp
index 85bcda5..8d94c8b 100644
--- a/src/opengl/qpixmapdata_gl.cpp
+++ b/src/opengl/qpixmapdata_gl.cpp
@@ -372,45 +372,50 @@ QPaintEngine* QGLPixmapData::paintEngine() const
if (m_engine)
return m_engine;
- else if (!useFramebufferObjects()) {
- m_dirty = true;
- if (m_source.size() != size())
- m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied);
- if (m_hasFillColor) {
- m_source.fill(PREMUL(m_fillColor.rgba()));
- m_hasFillColor = false;
- }
- return m_source.paintEngine();
- }
- extern QGLWidget* qt_gl_share_widget();
+ if (useFramebufferObjects()) {
+ extern QGLWidget* qt_gl_share_widget();
- if (!QGLContext::currentContext())
- qt_gl_share_widget()->makeCurrent();
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
+ if (!QGLContext::currentContext())
+ qt_gl_share_widget()->makeCurrent();
+ QGLShareContextScope ctx(qt_gl_share_widget()->context());
- if (textureBufferStack.size() <= currentTextureBuffer) {
- textureBufferStack << createTextureBuffer(size());
- } else {
- QSize sz = textureBufferStack.at(currentTextureBuffer).fbo->size();
- if (sz.width() < m_width || sz.height() < m_height) {
- if (sz.width() < m_width)
- sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5)));
- if (sz.height() < m_height)
- sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5)));
- delete textureBufferStack.at(currentTextureBuffer).fbo;
- textureBufferStack[currentTextureBuffer] =
- createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine);
- qDebug() << "Creating new pixmap texture buffer:" << sz;
+ if (textureBufferStack.size() <= currentTextureBuffer) {
+ textureBufferStack << createTextureBuffer(size());
+ } else {
+ QSize sz = textureBufferStack.at(currentTextureBuffer).fbo->size();
+ if (sz.width() < m_width || sz.height() < m_height) {
+ if (sz.width() < m_width)
+ sz.setWidth(qMax(m_width, qRound(sz.width() * 1.5)));
+ if (sz.height() < m_height)
+ sz.setHeight(qMax(m_height, qRound(sz.height() * 1.5)));
+ delete textureBufferStack.at(currentTextureBuffer).fbo;
+ textureBufferStack[currentTextureBuffer] =
+ createTextureBuffer(sz, textureBufferStack.at(currentTextureBuffer).engine);
+ qDebug() << "Creating new pixmap texture buffer:" << sz;
+ }
}
- }
- m_renderFbo = textureBufferStack.at(currentTextureBuffer).fbo;
- m_engine = textureBufferStack.at(currentTextureBuffer).engine;
+ if (textureBufferStack.at(currentTextureBuffer).fbo->isValid()) {
+ m_renderFbo = textureBufferStack.at(currentTextureBuffer).fbo;
+ m_engine = textureBufferStack.at(currentTextureBuffer).engine;
+
+ ++currentTextureBuffer;
+
+ return m_engine;
+ }
- ++currentTextureBuffer;
+ qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine";
+ }
- return m_engine;
+ m_dirty = true;
+ if (m_source.size() != size())
+ m_source = QImage(size(), QImage::Format_ARGB32_Premultiplied);
+ if (m_hasFillColor) {
+ m_source.fill(PREMUL(m_fillColor.rgba()));
+ m_hasFillColor = false;
+ }
+ return m_source.paintEngine();
}
GLuint QGLPixmapData::bind(bool copyBack) const