summaryrefslogtreecommitdiffstats
path: root/src/gui/egl
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-20 13:41:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-20 13:41:40 (GMT)
commit5c4234aa7499d879f50d1475aff8cce7d3ff6c11 (patch)
tree10c930f9d1526cb2bc779469e7b97cebc21619a0 /src/gui/egl
parentd05f83919949fd9604e6d96858a8404c9a580def (diff)
parentc9d73831910d4959e17899497335bd7fc4e08935 (diff)
downloadQt-5c4234aa7499d879f50d1475aff8cce7d3ff6c11.zip
Qt-5c4234aa7499d879f50d1475aff8cce7d3ff6c11.tar.gz
Qt-5c4234aa7499d879f50d1475aff8cce7d3ff6c11.tar.bz2
Merge branch 'qt-master-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into master-integration
* 'qt-master-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: (323 commits) Doc: these files are NOT part of the test suite of the Qt toolkit Autotest: make the licenseCheck test also check .qdoc files use egl properties when creating surfaces on symbian work around the current include file structure on Symbian^3 Get rid of the dependency on the Symbian app layer Fix incorrect license headers Fix incorrect license headers tst_qnetworkreply: Check if TCP/HTTP connection got re-used Fix bad conflict resolution from 4baa9dfb5273d7b501dcb3f456983262c53cc8d1 Fix building in a namespace on Windows Supressed Icon sizes on QPushButton in QS60Style Ensure that posted events are sent on Windows Fixed off-by-one blending errors in the NEON drawhelper code. Fixed libstdcpp.dll version autodetection for Symbian Fixed linkage failure when building qmake on Unix platforms Factored epocRoot implementation out of qmake Factored readRegistryKey implementation out of qmake Cetest extensions for Windows Mobile device power operations. Remote lib extensions for Windows Mobile device power operations. ColorDialog is always shown as stripped-down version (for QVGA) ...
Diffstat (limited to 'src/gui/egl')
-rw-r--r--src/gui/egl/qegl.cpp87
-rw-r--r--src/gui/egl/qegl_p.h12
-rw-r--r--src/gui/egl/qegl_qws.cpp6
-rw-r--r--src/gui/egl/qegl_symbian.cpp12
-rw-r--r--src/gui/egl/qegl_wince.cpp13
-rw-r--r--src/gui/egl/qegl_x11.cpp7
-rw-r--r--src/gui/egl/qeglproperties.cpp6
7 files changed, 61 insertions, 82 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp
index ae3d6c3..0ed95ea 100644
--- a/src/gui/egl/qegl.cpp
+++ b/src/gui/egl/qegl.cpp
@@ -54,9 +54,10 @@ QT_BEGIN_NAMESPACE
static QEglContext * volatile currentGLContext = 0;
static QEglContext * volatile currentVGContext = 0;
+EGLDisplay QEglContext::dpy = EGL_NO_DISPLAY;
+
QEglContext::QEglContext()
: apiType(QEgl::OpenGL)
- , dpy(EGL_NO_DISPLAY)
, ctx(EGL_NO_CONTEXT)
, cfg(0)
, currentSurface(EGL_NO_SURFACE)
@@ -68,7 +69,7 @@ QEglContext::QEglContext()
QEglContext::~QEglContext()
{
- destroy();
+ destroyContext();
if (currentGLContext == this)
currentGLContext = 0;
@@ -86,14 +87,6 @@ bool QEglContext::isCurrent() const
return current;
}
-// Open the EGL display associated with "device".
-bool QEglContext::openDisplay(QPaintDevice *device)
-{
- if (dpy == EGL_NO_DISPLAY)
- dpy = defaultDisplay(device);
- return (dpy != EGL_NO_DISPLAY);
-}
-
// Choose a configuration that matches "properties".
bool QEglContext::chooseConfig
(const QEglProperties& properties, QEgl::PixelFormatMatch match)
@@ -102,13 +95,13 @@ bool QEglContext::chooseConfig
do {
// Get the number of matching configurations for this set of properties.
EGLint matching = 0;
- if (!eglChooseConfig(dpy, props.properties(), 0, 0, &matching) || !matching)
+ if (!eglChooseConfig(display(), props.properties(), 0, 0, &matching) || !matching)
continue;
// If we want the best pixel format, then return the first
// matching configuration.
if (match == QEgl::BestPixelFormat) {
- eglChooseConfig(dpy, props.properties(), &cfg, 1, &matching);
+ eglChooseConfig(display(), props.properties(), &cfg, 1, &matching);
if (matching < 1)
continue;
return true;
@@ -118,13 +111,13 @@ bool QEglContext::chooseConfig
// first that matches the pixel format we wanted.
EGLint size = matching;
EGLConfig *configs = new EGLConfig [size];
- eglChooseConfig(dpy, props.properties(), configs, size, &matching);
+ eglChooseConfig(display(), props.properties(), configs, size, &matching);
for (EGLint index = 0; index < size; ++index) {
EGLint red, green, blue, alpha;
- eglGetConfigAttrib(dpy, configs[index], EGL_RED_SIZE, &red);
- eglGetConfigAttrib(dpy, configs[index], EGL_GREEN_SIZE, &green);
- eglGetConfigAttrib(dpy, configs[index], EGL_BLUE_SIZE, &blue);
- eglGetConfigAttrib(dpy, configs[index], EGL_ALPHA_SIZE, &alpha);
+ eglGetConfigAttrib(display(), configs[index], EGL_RED_SIZE, &red);
+ eglGetConfigAttrib(display(), configs[index], EGL_GREEN_SIZE, &green);
+ eglGetConfigAttrib(display(), configs[index], EGL_BLUE_SIZE, &blue);
+ eglGetConfigAttrib(display(), configs[index], EGL_ALPHA_SIZE, &alpha);
if (red == props.value(EGL_RED_SIZE) &&
green == props.value(EGL_GREEN_SIZE) &&
blue == props.value(EGL_BLUE_SIZE) &&
@@ -179,7 +172,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
if (shareContext && shareContext->ctx == EGL_NO_CONTEXT)
shareContext = 0;
if (shareContext) {
- ctx = eglCreateContext(dpy, cfg, shareContext->ctx, contextProps.properties());
+ ctx = eglCreateContext(display(), cfg, shareContext->ctx, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError());
shareContext = 0;
@@ -188,7 +181,7 @@ bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties
}
}
if (ctx == EGL_NO_CONTEXT) {
- ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties());
+ ctx = eglCreateContext(display(), cfg, 0, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError());
return false;
@@ -204,16 +197,15 @@ void QEglContext::destroySurface(EGLSurface surface)
if (surface != EGL_NO_SURFACE) {
if (surface == currentSurface)
doneCurrent();
- eglDestroySurface(dpy, surface);
+ eglDestroySurface(display(), surface);
}
}
// Destroy the context. Note: this does not destroy the surface.
-void QEglContext::destroy()
+void QEglContext::destroyContext()
{
if (ctx != EGL_NO_CONTEXT && ownsContext)
- eglDestroyContext(dpy, ctx);
- dpy = EGL_NO_DISPLAY;
+ eglDestroyContext(display(), ctx);
ctx = EGL_NO_CONTEXT;
cfg = 0;
}
@@ -248,7 +240,7 @@ bool QEglContext::makeCurrent(EGLSurface surface)
eglBindAPI(EGL_OPENVG_API);
#endif
- bool ok = eglMakeCurrent(dpy, surface, surface, ctx);
+ bool ok = eglMakeCurrent(display(), surface, surface, ctx);
if (!ok)
qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError());
return ok;
@@ -277,7 +269,7 @@ bool QEglContext::doneCurrent()
eglBindAPI(EGL_OPENVG_API);
#endif
- bool ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ bool ok = eglMakeCurrent(display(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!ok)
qWarning() << "QEglContext::doneCurrent():" << errorString(eglGetError());
return ok;
@@ -299,7 +291,7 @@ bool QEglContext::swapBuffers(EGLSurface surface)
if(ctx == EGL_NO_CONTEXT)
return false;
- bool ok = eglSwapBuffers(dpy, surface);
+ bool ok = eglSwapBuffers(display(), surface);
if (!ok)
qWarning() << "QEglContext::swapBuffers():" << errorString(eglGetError());
return ok;
@@ -338,7 +330,7 @@ void QEglContext::waitClient()
// Query the value of a configuration attribute.
bool QEglContext::configAttrib(int name, EGLint *value) const
{
- return eglGetConfigAttrib(dpy, cfg, name, value);
+ return eglGetConfigAttrib(display(), cfg, name, value);
}
// Retrieve all of the properties on "cfg". If zero, return
@@ -350,34 +342,45 @@ QEglProperties QEglContext::configProperties(EGLConfig cfg) const
QEglProperties props;
for (int name = 0x3020; name <= 0x304F; ++name) {
EGLint value;
- if (name != EGL_NONE && eglGetConfigAttrib(dpy, cfg, name, &value))
+ if (name != EGL_NONE && eglGetConfigAttrib(display(), cfg, name, &value))
props.setValue(name, value);
}
eglGetError(); // Clear the error state.
return props;
}
-// Initialize and return the default display.
-EGLDisplay QEglContext::defaultDisplay(QPaintDevice *device)
+EGLDisplay QEglContext::display()
{
- static EGLDisplay dpy = EGL_NO_DISPLAY;
- if (dpy == EGL_NO_DISPLAY) {
- dpy = getDisplay(device);
+ 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");
+ dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
+ }
if (dpy == EGL_NO_DISPLAY) {
- qWarning() << "QEglContext::defaultDisplay(): Cannot open EGL display";
+ qWarning("QEglContext::display(): Can't even open the default display");
return EGL_NO_DISPLAY;
}
+
if (!eglInitialize(dpy, NULL, NULL)) {
- qWarning() << "QEglContext::defaultDisplay(): Cannot initialize EGL display:" << errorString(eglGetError());
+ qWarning() << "QEglContext::display(): Cannot initialize EGL display:" << errorString(eglGetError());
return EGL_NO_DISPLAY;
}
-#ifdef EGL_OPENGL_ES_API
- eglBindAPI(EGL_OPENGL_ES_API);
-#endif
}
+
return dpy;
}
+#if !defined(Q_WS_X11) && !defined(Q_WS_WINCE) // WinCE & X11 implement this properly
+EGLNativeDisplayType QEglContext::nativeDisplay()
+{
+ return EGL_DEFAULT_DISPLAY;
+}
+#endif
+
// Return the error string associated with a specific code.
QString QEglContext::errorString(EGLint code)
{
@@ -410,10 +413,10 @@ void QEglContext::dumpAllConfigs()
{
QEglProperties props;
EGLint count = 0;
- if (!eglGetConfigs(dpy, 0, 0, &count) || count < 1)
+ if (!eglGetConfigs(display(), 0, 0, &count) || count < 1)
return;
EGLConfig *configs = new EGLConfig [count];
- eglGetConfigs(dpy, configs, count, &count);
+ eglGetConfigs(display(), configs, count, &count);
for (EGLint index = 0; index < count; ++index) {
props = configProperties(configs[index]);
qWarning() << props.toString();
@@ -423,7 +426,7 @@ void QEglContext::dumpAllConfigs()
QString QEglContext::extensions()
{
- const char* exts = eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS);
+ const char* exts = eglQueryString(QEglContext::display(), EGL_EXTENSIONS);
return QString(QLatin1String(exts));
}
@@ -431,7 +434,7 @@ bool QEglContext::hasExtension(const char* extensionName)
{
QList<QByteArray> extensions =
QByteArray(reinterpret_cast<const char *>
- (eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS))).split(' ');
+ (eglQueryString(QEglContext::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 a7de9c8..87ed818 100644
--- a/src/gui/egl/qegl_p.h
+++ b/src/gui/egl/qegl_p.h
@@ -86,14 +86,12 @@ public:
QEgl::API api() const { return apiType; }
void setApi(QEgl::API api) { apiType = api; }
- bool openDisplay(QPaintDevice *device);
bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0);
+ void destroyContext();
EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0);
void destroySurface(EGLSurface surface);
- void destroy();
-
bool makeCurrent(EGLSurface surface);
bool doneCurrent();
bool lazyDoneCurrent();
@@ -108,7 +106,7 @@ public:
static EGLint error() { return eglGetError(); }
static QString errorString(EGLint code);
- EGLDisplay display() const { return dpy; }
+ static EGLDisplay display();
EGLContext context() const { return ctx; }
void setContext(EGLContext context) { ctx = context; ownsContext = false;}
@@ -118,8 +116,6 @@ public:
QEglProperties configProperties(EGLConfig cfg = 0) const;
- static EGLDisplay defaultDisplay(QPaintDevice *device);
-
void dumpAllConfigs();
static QString extensions();
@@ -127,7 +123,6 @@ public:
private:
QEgl::API apiType;
- EGLDisplay dpy;
EGLContext ctx;
EGLConfig cfg;
EGLSurface currentSurface;
@@ -135,7 +130,8 @@ private:
bool ownsContext;
bool sharing;
- static EGLDisplay getDisplay(QPaintDevice *device);
+ 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/qegl_qws.cpp b/src/gui/egl/qegl_qws.cpp
index e999e0b..2a61beb 100644
--- a/src/gui/egl/qegl_qws.cpp
+++ b/src/gui/egl/qegl_qws.cpp
@@ -64,12 +64,6 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
return EGL_NO_SURFACE;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
-{
- Q_UNUSED(device);
- return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
-}
-
static QScreen *screenForDevice(QPaintDevice *device)
{
QScreen *screen = qt_screen;
diff --git a/src/gui/egl/qegl_symbian.cpp b/src/gui/egl/qegl_symbian.cpp
index 44ecd19..5a010cd 100644
--- a/src/gui/egl/qegl_symbian.cpp
+++ b/src/gui/egl/qegl_symbian.cpp
@@ -78,22 +78,14 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
props = 0;
EGLSurface surf;
if (devType == QInternal::Widget)
- surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, 0);
+ surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, props);
else
- surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, 0);
+ surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, props);
if (surf == EGL_NO_SURFACE)
qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
return surf;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
-{
- EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- if (dpy == EGL_NO_DISPLAY)
- qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY");
- return dpy;
-}
-
// Set pixel format and other properties based on a paint device.
void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
{
diff --git a/src/gui/egl/qegl_wince.cpp b/src/gui/egl/qegl_wince.cpp
index 026a7b1..c9c9773 100644
--- a/src/gui/egl/qegl_wince.cpp
+++ b/src/gui/egl/qegl_wince.cpp
@@ -87,20 +87,15 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
return surf;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
+EGLNativeDisplayType QEglContext::nativeDisplay()
{
- EGLDisplay dpy = 0;
HWND win = (static_cast<QWidget*>(device))->winId();
HDC myDc = GetDC(win);
if (!myDc) {
- qWarning("QEglContext::defaultDisplay(): WinCE display is not open");
+ qWarning("QEglContext::nativeDisplay(): WinCE display is not open");
+ return EGL_DEFAULT_DISPLAY;
}
- dpy = eglGetDisplay(EGLNativeDisplayType(myDc));
- if (dpy == EGL_NO_DISPLAY) {
- qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY");
- dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- }
- return dpy;
+ return EGLNativeDisplayType(myDc);
}
// Set pixel format and other properties based on a paint device.
diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp
index 2cf4e33..634ff13 100644
--- a/src/gui/egl/qegl_x11.cpp
+++ b/src/gui/egl/qegl_x11.cpp
@@ -93,15 +93,14 @@ EGLSurface QEglContext::createSurface(QPaintDevice *device, const QEglProperties
return surf;
}
-EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
+EGLNativeDisplayType QEglContext::nativeDisplay()
{
- Q_UNUSED(device);
Display *xdpy = QX11Info::display();
if (!xdpy) {
qWarning("QEglContext::getDisplay(): X11 display is not open");
- return EGL_NO_DISPLAY;
+ return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY);
}
- return eglGetDisplay(EGLNativeDisplayType(xdpy));
+ return EGLNativeDisplayType(xdpy);
}
static int countBits(unsigned long mask)
diff --git a/src/gui/egl/qeglproperties.cpp b/src/gui/egl/qeglproperties.cpp
index 2915fb9..236ec37 100644
--- a/src/gui/egl/qeglproperties.cpp
+++ b/src/gui/egl/qeglproperties.cpp
@@ -60,7 +60,7 @@ QEglProperties::QEglProperties(EGLConfig cfg)
props.append(EGL_NONE);
for (int name = 0x3020; name <= 0x304F; ++name) {
EGLint value;
- if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::defaultDisplay(0), cfg, name, &value))
+ if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::display(), cfg, name, &value))
setValue(name, value);
}
eglGetError(); // Clear the error state.
@@ -273,12 +273,12 @@ static void addTag(QString& str, const QString& tag)
void QEglProperties::dumpAllConfigs()
{
EGLint count = 0;
- eglGetConfigs(QEglContext::defaultDisplay(0), 0, 0, &count);
+ eglGetConfigs(QEglContext::display(), 0, 0, &count);
if (count < 1)
return;
EGLConfig *configs = new EGLConfig [count];
- eglGetConfigs(QEglContext::defaultDisplay(0), configs, count, &count);
+ eglGetConfigs(QEglContext::display(), configs, count, &count);
for (EGLint index = 0; index < count; ++index)
qWarning() << QEglProperties(configs[index]).toString();
delete [] configs;