diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 8 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 4 | ||||
-rw-r--r-- | src/opengl/opengl.pro | 2 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 33 | ||||
-rw-r--r-- | src/opengl/qgl.h | 2 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 10 | ||||
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 8 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer.cpp | 6 | ||||
-rw-r--r-- | src/opengl/qglpixelbuffer_p.h | 12 |
9 files changed, 57 insertions, 28 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 0cc7430..c89d34f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -516,6 +516,8 @@ void QGL2PaintEngineEx::beginNativePainting() ensureActive(); d->transferMode(BrushDrawingMode); + d->nativePaintingActive = true; + QGLContext *ctx = d->ctx; glUseProgram(0); @@ -583,6 +585,12 @@ void QGL2PaintEngineEx::endNativePainting() { Q_D(QGL2PaintEngineEx); d->needsSync = true; + d->nativePaintingActive = false; +} + +bool QGL2PaintEngineEx::isNativePaintingActive() const { + Q_D(const QGL2PaintEngineEx); + return d->nativePaintingActive; } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 34d72d1..2ac2ca4 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -154,11 +154,11 @@ public: void setRenderTextActive(bool); + bool isNativePaintingActive() const; private: Q_DISABLE_COPY(QGL2PaintEngineEx) }; - class QGL2PaintEngineExPrivate : public QPaintEngineExPrivate { Q_DECLARE_PUBLIC(QGL2PaintEngineEx) @@ -178,6 +178,7 @@ public: elementIndicesVBOId(0), snapToPixelGrid(false), addOffset(false), + nativePaintingActive(false), inverseScale(1), lastMaskTextureUsed(0) { } @@ -280,6 +281,7 @@ public: bool snapToPixelGrid; bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix + bool nativePaintingActive; GLfloat pmvMatrix[3][3]; GLfloat inverseScale; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 9473343..15795d2 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -77,7 +77,7 @@ SOURCES += qgl.cpp \ } x11 { - contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) { + contains(QT_CONFIG, egl) { SOURCES += qgl_x11egl.cpp \ qglpixelbuffer_egl.cpp \ qgl_egl.cpp \ diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5595e02..394bcbc 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -49,7 +49,7 @@ #include "private/qpixmap_x11_p.h" #define INT32 dummy_INT32 #define INT8 dummy_INT8 -#if !defined(QT_OPENGL_ES) +#ifdef QT_NO_EGL # include <GL/glx.h> #endif #undef INT32 @@ -1582,7 +1582,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) # endif vi = 0; #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL ownsEglContext = false; eglContext = 0; eglSurface = EGL_NO_SURFACE; @@ -2767,6 +2767,18 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text return; } #else + + if (d_ptr->active_engine && + d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine); + if (!eng->isNativePaintingActive()) { + QRectF src(0, 0, target.width(), target.height()); + QSize size(target.width(), target.height()); + eng->drawTexture(target, textureId, size, src); + return; + } + } + const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2817,6 +2829,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text Q_UNUSED(textureTarget); qWarning("drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget) not supported with OpenGL ES, use rect version instead"); #else + const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D); GLint oldTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture); @@ -2830,6 +2843,18 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth); glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight); + if (d_ptr->active_engine && + d_ptr->active_engine->type() == QPaintEngine::OpenGL2) { + QGL2PaintEngineEx *eng = static_cast<QGL2PaintEngineEx*>(d_ptr->active_engine); + if (!eng->isNativePaintingActive()) { + QRectF dest(point, QSizeF(textureWidth, textureHeight)); + QRectF src(0, 0, textureWidth, textureHeight); + QSize size(textureWidth, textureHeight); + eng->drawTexture(dest, textureId, size, src); + return; + } + } + qDrawTextureRect(QRectF(point, QSizeF(textureWidth, textureHeight)), textureWidth, textureHeight, textureTarget); if (!wasEnabled) @@ -3950,7 +3975,7 @@ bool QGLWidget::event(QEvent *e) } } -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL // A re-parent is likely to destroy the X11 window and re-create it. It is important // that we free the EGL surface _before_ the winID changes - otherwise we can leak. if (e->type() == QEvent::ParentAboutToChange) @@ -4909,7 +4934,7 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#if !defined(QT_OPENGL_ES_1) +#ifndef QT_OPENGL_ES_1 Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) #endif diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 64f54a3..b1e2ede 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -376,7 +376,7 @@ protected: #if defined(Q_WS_WIN) virtual int choosePixelFormat(void* pfd, HDC pdc); #endif -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && defined(QT_NO_EGL) virtual void* tryVisual(const QGLFormat& f, int bufDepth = 1); virtual void* chooseVisual(); #endif diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 1f28b08..ee580a6 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -64,7 +64,7 @@ #include "qcache.h" #include "qglpaintdevice_p.h" -#if defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2) +#ifndef QT_NO_EGL #include <QtGui/private/qegl_p.h> #endif @@ -96,7 +96,7 @@ class QMacWindowChangeEvent; class QWSGLWindowSurface; #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL class QEglContext; #endif @@ -164,7 +164,7 @@ public: #ifdef Q_WS_QWS , wsurf(0) #endif -#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) , eglSurfaceWindowId(0) #endif { @@ -194,7 +194,7 @@ public: QGLContext *olcx; #elif defined(Q_WS_X11) QGLOverlayWidget *olw; -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL void recreateEglSurface(bool force); WId eglSurfaceWindowId; #endif @@ -344,7 +344,7 @@ public: HBITMAP hbitmap; HDC hbitmap_hdc; #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL bool ownsEglContext; QEglContext *eglContext; EGLSurface eglSurface; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index af0100b..6f210ce 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -378,8 +378,6 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // eglCreateImageKHR & eglDestroyImageKHR without support for pixmaps, so we must // check we have the EGLImage from pixmap functionality. if (QEgl::hasExtension("EGL_KHR_image") || QEgl::hasExtension("EGL_KHR_image_pixmap")) { - Q_ASSERT(eglCreateImageKHR); - Q_ASSERT(eglDestroyImageKHR); // Being able to create an EGLImage from a native pixmap is also pretty useless // without the ability to bind that EGLImage as a texture, which is provided by @@ -436,15 +434,13 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // If the pixmap doesn't already have a valid surface, try binding it via EGLImage // first, as going through EGLImage should be faster and better supported: if (!textureIsBound && haveEglImageTFP) { - Q_ASSERT(eglCreateImageKHR); - EGLImageKHR eglImage; EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; - eglImage = eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)QEgl::nativePixmap(pixmap), attribs); QGLContext* ctx = q; @@ -457,7 +453,7 @@ QGLTexture *QGLContextPrivate::bindTextureFromNativePixmap(QPixmap *pixmap, cons // Once the egl image is bound, the texture becomes a new sibling image and we can safely // destroy the EGLImage we created for the pixmap: if (eglImage != EGL_NO_IMAGE_KHR) - eglDestroyImageKHR(QEgl::display(), eglImage); + QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); } if (!textureIsBound && haveTFP) { diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index eca9550..9a8b243 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -137,14 +137,14 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form #if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES) qctx->d_func()->dc = dc; qctx->d_func()->rc = ctx; -#elif (defined(Q_WS_X11) && !defined(QT_OPENGL_ES)) +#elif (defined(Q_WS_X11) && defined(QT_NO_EGL)) qctx->d_func()->cx = ctx; qctx->d_func()->pbuf = (void *) pbuf; qctx->d_func()->vi = 0; #elif defined(Q_WS_MAC) qctx->d_func()->cx = ctx; qctx->d_func()->vi = 0; -#elif defined(QT_OPENGL_ES) +#elif !defined(QT_NO_EGL) qctx->d_func()->eglContext = ctx; qctx->d_func()->eglSurface = pbuf; #endif @@ -254,7 +254,7 @@ bool QGLPixelBuffer::doneCurrent() \sa size() */ -#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && !defined(QT_OPENGL_ES) +#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) && defined(QT_NO_EGL) GLuint QGLPixelBuffer::generateDynamicTexture() const { Q_D(const QGLPixelBuffer); diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index c85dc5a..2a1f671 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -60,7 +60,7 @@ QT_BEGIN_INCLUDE_NAMESPACE #include <private/qgl_p.h> #include <private/qglpaintdevice_p.h> -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && defined(QT_NO_EGL) #include <GL/glx.h> // The below is needed to for compilation on HPUX, due to broken GLX @@ -127,10 +127,8 @@ struct GLXFBConfig { #elif defined(Q_WS_WIN) DECLARE_HANDLE(HPBUFFERARB); -#elif defined(QT_OPENGL_ES_2) -#include <EGL/egl.h> -#elif defined(QT_OPENGL_ES) -#include <GLES/egl.h> +#elif !defined(QT_NO_EGL) +#include <QtGui/private/qegl_p.h> #endif QT_END_INCLUDE_NAMESPACE @@ -174,7 +172,7 @@ public: QPointer<QGLWidget> req_shareWidget; QSize req_size; -#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) +#if defined(Q_WS_X11) && defined(QT_NO_EGL) GLXPbuffer pbuf; GLXContext ctx; #elif defined(Q_WS_WIN) @@ -195,7 +193,7 @@ public: AGLContext share_ctx; # endif #endif -#if defined(QT_OPENGL_ES) +#ifndef QT_NO_EGL EGLSurface pbuf; QEglContext *ctx; int textureFormat; |