diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-02-16 12:29:36 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2010-03-02 08:24:23 (GMT) |
commit | 28b85c76dd0ba4796ec519b890f6fab0fc813061 (patch) | |
tree | 4defe4c405a29fb1c07bb4392258e8f1ccf4f0e7 /src/gui | |
parent | 56d32b57814cb35409bc9b0076ec753de488ae7f (diff) | |
download | Qt-28b85c76dd0ba4796ec519b890f6fab0fc813061.zip Qt-28b85c76dd0ba4796ec519b890f6fab0fc813061.tar.gz Qt-28b85c76dd0ba4796ec519b890f6fab0fc813061.tar.bz2 |
Move static methods from QEglContext to QEgl namespace
Reviewed-By: Aleksandar Sasha Babic
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/egl/qegl.cpp | 83 | ||||
-rw-r--r-- | src/gui/egl/qegl_p.h | 18 | ||||
-rw-r--r-- | src/gui/egl/qegl_wince.cpp | 6 | ||||
-rw-r--r-- | src/gui/egl/qegl_x11.cpp | 8 | ||||
-rw-r--r-- | src/gui/egl/qeglcontext_p.h | 18 | ||||
-rw-r--r-- | src/gui/egl/qeglproperties.cpp | 6 |
6 files changed, 75 insertions, 64 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 5052dfc..ef5eb67 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -57,8 +57,6 @@ QT_BEGIN_NAMESPACE static QEglContext * volatile currentGLContext = 0; static QEglContext * volatile currentVGContext = 0; -EGLDisplay QEglContext::dpy = EGL_NO_DISPLAY; - QEglContext::QEglContext() : apiType(QEgl::OpenGL) , ctx(EGL_NO_CONTEXT) @@ -98,7 +96,8 @@ bool QEglContext::chooseConfig do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; - if (!eglChooseConfig(display(), props.properties(), 0, 0, &matching) || !matching) + EGLDisplay dpy = QEgl::display(); + if (!eglChooseConfig(dpy, props.properties(), 0, 0, &matching) || !matching) continue; // If we want the best pixel format, then return the first @@ -145,7 +144,7 @@ bool QEglContext::chooseConfig qWarning() << "QEglContext::chooseConfig(): Could not find a suitable EGL configuration"; qWarning() << "Requested:" << props.toString(); qWarning() << "Available:"; - dumpAllConfigs(); + QEgl::dumpAllConfigs(); } return false; } @@ -175,9 +174,9 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties if (shareContext && shareContext->ctx == EGL_NO_CONTEXT) shareContext = 0; if (shareContext) { - ctx = eglCreateContext(display(), cfg, shareContext->ctx, contextProps.properties()); + ctx = eglCreateContext(QEgl::display(), cfg, shareContext->ctx, contextProps.properties()); if (ctx == EGL_NO_CONTEXT) { - qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError()); + qWarning() << "QEglContext::createContext(): Could not share context:" << QEgl::errorString(); shareContext = 0; } else { sharing = true; @@ -186,7 +185,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties if (ctx == EGL_NO_CONTEXT) { ctx = eglCreateContext(display(), cfg, 0, contextProps.properties()); if (ctx == EGL_NO_CONTEXT) { - qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError()); + qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << QEgl::errorString(); return false; } } @@ -243,9 +242,9 @@ bool QEglContext::makeCurrent(EGLSurface surface) eglBindAPI(EGL_OPENVG_API); #endif - bool ok = eglMakeCurrent(display(), surface, surface, ctx); + bool ok = eglMakeCurrent(QEgl::display(), surface, surface, ctx); if (!ok) - qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); + qWarning() << "QEglContext::makeCurrent():" << QEgl::errorString(); return ok; } @@ -272,9 +271,9 @@ bool QEglContext::doneCurrent() eglBindAPI(EGL_OPENVG_API); #endif - bool ok = eglMakeCurrent(display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + bool ok = eglMakeCurrent(QEgl::display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (!ok) - qWarning() << "QEglContext::doneCurrent():" << errorString(eglGetError()); + qWarning() << "QEglContext::doneCurrent():" << QEgl::errorString(); return ok; } @@ -294,9 +293,9 @@ bool QEglContext::swapBuffers(EGLSurface surface) if(ctx == EGL_NO_CONTEXT) return false; - bool ok = eglSwapBuffers(display(), surface); + bool ok = eglSwapBuffers(QEgl::display(), surface); if (!ok) - qWarning() << "QEglContext::swapBuffers():" << errorString(eglGetError()); + qWarning() << "QEglContext::swapBuffers():" << QEgl::errorString(); return ok; } @@ -333,43 +332,33 @@ void QEglContext::waitClient() // Query the value of a configuration attribute. bool QEglContext::configAttrib(int name, EGLint *value) const { - return eglGetConfigAttrib(display(), cfg, name, value); + return eglGetConfigAttrib(QEgl::display(), cfg, name, value); } -// Retrieve all of the properties on "cfg". If zero, return -// the context's configuration. -QEglProperties QEglContext::configProperties(EGLConfig cfg) const +QEglProperties QEglContext::configProperties() const { - if (!cfg) - cfg = config(); - QEglProperties props; - for (int name = 0x3020; name <= 0x304F; ++name) { - EGLint value; - if (name != EGL_NONE && eglGetConfigAttrib(display(), cfg, name, &value)) - props.setValue(name, value); - } - eglGetError(); // Clear the error state. - return props; + return QEglProperties(config()); } -EGLDisplay QEglContext::display() +EGLDisplay QEgl::display() { + static EGLDisplay dpy = EGL_NO_DISPLAY; static bool openedDisplay = false; if (!openedDisplay) { dpy = eglGetDisplay(nativeDisplay()); openedDisplay = true; if (dpy == EGL_NO_DISPLAY) { - qWarning("QEglContext::display(): Falling back to EGL_DEFAULT_DISPLAY"); + qWarning("QEgl::display(): Falling back to EGL_DEFAULT_DISPLAY"); dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); } if (dpy == EGL_NO_DISPLAY) { - qWarning("QEglContext::display(): Can't even open the default display"); + qWarning("QEgl::display(): Can't even open the default display"); return EGL_NO_DISPLAY; } if (!eglInitialize(dpy, NULL, NULL)) { - qWarning() << "QEglContext::display(): Cannot initialize EGL display:" << errorString(eglGetError()); + qWarning() << "QEgl::display(): Cannot initialize EGL display:" << QEgl::errorString(); return EGL_NO_DISPLAY; } } @@ -378,14 +367,14 @@ EGLDisplay QEglContext::display() } #if !defined(Q_WS_X11) && !defined(Q_WS_WINCE) // WinCE & X11 implement this properly -EGLNativeDisplayType QEglContext::nativeDisplay() +EGLNativeDisplayType QEgl::nativeDisplay() { return EGL_DEFAULT_DISPLAY; } #endif // Return the error string associated with a specific code. -QString QEglContext::errorString(EGLint code) +QString QEgl::errorString(EGLint code) { static const char * const errors[] = { "Success (0x3000)", // No tr @@ -411,8 +400,24 @@ QString QEglContext::errorString(EGLint code) } } +QString QEgl::errorString() +{ + return errorString(error()); +} + +void QEgl::clearError() +{ + eglGetError(); +} + +EGLint QEgl::error() +{ + return eglGetError(); +} + + // Dump all of the EGL configurations supported by the system. -void QEglContext::dumpAllConfigs() +void QEgl::dumpAllConfigs() { QEglProperties props; EGLint count = 0; @@ -421,23 +426,23 @@ void QEglContext::dumpAllConfigs() EGLConfig *configs = new EGLConfig [count]; eglGetConfigs(display(), configs, count, &count); for (EGLint index = 0; index < count; ++index) { - props = configProperties(configs[index]); + props = QEglProperties(configs[index]); qWarning() << props.toString(); } delete [] configs; } -QString QEglContext::extensions() +QString QEgl::extensions() { - const char* exts = eglQueryString(QEglContext::display(), EGL_EXTENSIONS); + const char* exts = eglQueryString(QEgl::display(), EGL_EXTENSIONS); return QString(QLatin1String(exts)); } -bool QEglContext::hasExtension(const char* extensionName) +bool QEgl::hasExtension(const char* extensionName) { QList<QByteArray> extensions = QByteArray(reinterpret_cast<const char *> - (eglQueryString(QEglContext::display(), EGL_EXTENSIONS))).split(' '); + (eglQueryString(QEgl::display(), EGL_EXTENSIONS))).split(' '); return extensions.contains(extensionName); } diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index eb83002..e48e4a0 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -96,6 +96,8 @@ QT_END_INCLUDE_NAMESPACE QT_BEGIN_NAMESPACE +class QEglProperties; + namespace QEgl { enum API { @@ -108,6 +110,22 @@ namespace QEgl { ExactPixelFormat, BestPixelFormat }; + +// EGLConfig chooseConfig(const QEglProperties* properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat); +// EGLSurface createSurface(QPaintDevice *device, EGLConfig config, const QEglProperties *properties = 0); + + Q_GUI_EXPORT void dumpAllConfigs(); + + Q_GUI_EXPORT void clearError(); + Q_GUI_EXPORT EGLint error(); + Q_GUI_EXPORT QString errorString(EGLint code); + Q_GUI_EXPORT QString errorString(); + + Q_GUI_EXPORT QString extensions(); + Q_GUI_EXPORT bool hasExtension(const char* extensionName); + + Q_GUI_EXPORT EGLDisplay display(); + Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay(); }; diff --git a/src/gui/egl/qegl_wince.cpp b/src/gui/egl/qegl_wince.cpp index 00341ba..2f79005 100644 --- a/src/gui/egl/qegl_wince.cpp +++ b/src/gui/egl/qegl_wince.cpp @@ -80,16 +80,16 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties props = 0; EGLSurface surf; if (devType == QInternal::Widget) - surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props); + surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); else - surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, props); + surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props); if (surf == EGL_NO_SURFACE) { qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); } return surf; } -EGLNativeDisplayType QEglContext::nativeDisplay() +EGLNativeDisplayType QEgl::nativeDisplay() { HWND win = (static_cast<QWidget*>(device))->winId(); HDC myDc = GetDC(win); diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index cd55849..4a813c6 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -84,17 +84,17 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties props = 0; EGLSurface surf; if (devType == QInternal::Widget) - surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props); + surf = eglCreateWindowSurface(QEgl::display(), cfg, windowDrawable, props); else - surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, props); + surf = eglCreatePixmapSurface(QEgl::display(), cfg, pixmapDrawable, props); if (surf == EGL_NO_SURFACE) { qWarning() << "QEglContext::createSurface(): Unable to create EGL surface:" - << errorString(eglGetError()); + << QEgl::errorString(); } return surf; } -EGLNativeDisplayType QEglContext::nativeDisplay() +EGLNativeDisplayType QEgl::nativeDisplay() { Display *xdpy = QX11Info::display(); if (!xdpy) { diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index 3857fb7..c656d1d 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -90,24 +90,15 @@ public: bool configAttrib(int name, EGLint *value) const; - static void clearError() { eglGetError(); } - static EGLint error() { return eglGetError(); } - static QString errorString(EGLint code); - - static EGLDisplay display(); - EGLContext context() const { return ctx; } void setContext(EGLContext context) { ctx = context; ownsContext = false;} + EGLDisplay display() {return QEgl::display();} + EGLConfig config() const { return cfg; } void setConfig(EGLConfig config) { cfg = config; } - QEglProperties configProperties(EGLConfig cfg = 0) const; - - void dumpAllConfigs(); - - static QString extensions(); - static bool hasExtension(const char* extensionName); + QEglProperties configProperties() const; private: QEgl::API apiType; @@ -118,9 +109,6 @@ private: bool ownsContext; bool sharing; - static EGLDisplay dpy; - static EGLNativeDisplayType nativeDisplay(); - static QEglContext *currentContext(QEgl::API api); static void setCurrentContext(QEgl::API api, QEglContext *context); }; diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp index b83ae4e..86e158b 100644 --- a/src/gui/egl/qeglproperties.cpp +++ b/src/gui/egl/qeglproperties.cpp @@ -61,7 +61,7 @@ QEglProperties::QEglProperties(EGLConfig cfg) props.append(EGL_NONE); for (int name = 0x3020; name <= 0x304F; ++name) { EGLint value; - if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::display(), cfg, name, &value)) + if (name != EGL_NONE && eglGetConfigAttrib(QEgl::display(), cfg, name, &value)) setValue(name, value); } eglGetError(); // Clear the error state. @@ -274,12 +274,12 @@ static void addTag(QString& str, const QString& tag) void QEglProperties::dumpAllConfigs() { EGLint count = 0; - eglGetConfigs(QEglContext::display(), 0, 0, &count); + eglGetConfigs(QEgl::display(), 0, 0, &count); if (count < 1) return; EGLConfig *configs = new EGLConfig [count]; - eglGetConfigs(QEglContext::display(), configs, count, &count); + eglGetConfigs(QEgl::display(), configs, count, &count); for (EGLint index = 0; index < count; ++index) qWarning() << QEglProperties(configs[index]).toString(); delete [] configs; |