Changeset 769 for trunk/src/gui/egl
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/egl/egl.pri
r561 r769 1 CONFIG += egl 1 contains(QT_CONFIG, egl): { 2 CONFIG += egl 2 3 3 HEADERS += \4 egl/qegl_p.h \5 egl/qeglproperties_p.h4 HEADERS += \ 5 egl/qegl_p.h \ 6 egl/qeglproperties_p.h 6 7 7 SOURCES += \8 egl/qegl.cpp \9 egl/qeglproperties.cpp8 SOURCES += \ 9 egl/qegl.cpp \ 10 egl/qeglproperties.cpp 10 11 11 wince*: SOURCES += egl/qegl_wince.cpp12 wince*: SOURCES += egl/qegl_wince.cpp 12 13 13 unix { 14 embedded { 15 SOURCES += egl/qegl_qws.cpp 16 } else { 17 symbian { 18 SOURCES += egl/qegl_symbian.cpp 19 } else { 20 SOURCES += egl/qegl_x11.cpp 21 } 22 } 14 unix { 15 embedded { 16 SOURCES += egl/qegl_qws.cpp 17 } else { 18 symbian { 19 SOURCES += egl/qegl_symbian.cpp 20 } else { 21 SOURCES += egl/qegl_x11.cpp 22 } 23 } 24 } 25 } else:symbian { 26 DEFINES += QT_NO_EGL 27 SOURCES += egl/qegl_stub.cpp 28 SOURCES += egl/qeglproperties_stub.cpp 23 29 } -
trunk/src/gui/egl/qegl.cpp
r651 r769 43 43 #include <QtGui/qpixmap.h> 44 44 #include <QtGui/qwidget.h> 45 45 46 #include <QtCore/qdebug.h> 46 47 #include "qegl_p.h" 47 48 48 49 QT_BEGIN_NAMESPACE 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 49 78 50 79 // Current GL and VG contexts. These are used to determine if … … 55 84 static QEglContext * volatile currentVGContext = 0; 56 85 86 87 57 88 QEglContext::QEglContext() 58 89 : apiType(QEgl::OpenGL) 59 , dpy(EGL_NO_DISPLAY)60 90 , ctx(EGL_NO_CONTEXT) 61 91 , cfg(0) … … 65 95 , sharing(false) 66 96 { 97 67 98 } 68 99 69 100 QEglContext::~QEglContext() 70 101 { 71 destroy ();102 destroy(); 72 103 73 104 if (currentGLContext == this) … … 75 106 if (currentVGContext == this) 76 107 currentVGContext = 0; 108 77 109 } 78 110 … … 85 117 { 86 118 return current; 87 }88 89 // Open the EGL display associated with "device".90 bool QEglContext::openDisplay(QPaintDevice *device)91 {92 if (dpy == EGL_NO_DISPLAY)93 dpy = defaultDisplay(device);94 return (dpy != EGL_NO_DISPLAY);95 119 } 96 120 … … 103 127 // Get the number of matching configurations for this set of properties. 104 128 EGLint matching = 0; 105 if (!eglChooseConfig(d py, props.properties(), 0, 0, &matching) || !matching)129 if (!eglChooseConfig(d, props.properties(), 0, 0, &matching) || !matching) 106 130 continue; 107 131 … … 109 133 // matching configuration. 110 134 if (match == QEgl::BestPixelFormat) { 111 eglChooseConfig(d py, props.properties(), &cfg, 1, &matching);135 eglChooseConfig(d, props.properties(), &cfg, 1, &matching); 112 136 if (matching < 1) 113 137 continue; … … 119 143 EGLint size = matching; 120 144 EGLConfig *configs = new EGLConfig [size]; 121 eglChooseConfig(d py, props.properties(), configs, size, &matching);145 eglChooseConfig(d, props.properties(), configs, size, &matching); 122 146 for (EGLint index = 0; index < size; ++index) { 123 147 EGLint red, green, blue, alpha; 124 eglGetConfigAttrib(d py, configs[index], EGL_RED_SIZE, &red);125 eglGetConfigAttrib(d py, configs[index], EGL_GREEN_SIZE, &green);126 eglGetConfigAttrib(d py, configs[index], EGL_BLUE_SIZE, &blue);127 eglGetConfigAttrib(d py, configs[index], EGL_ALPHA_SIZE, &alpha);148 eglGetConfigAttrib(d, configs[index], EGL_RED_SIZE, &red); 149 eglGetConfigAttrib(d, configs[index], EGL_GREEN_SIZE, &green); 150 eglGetConfigAttrib(d, configs[index], EGL_BLUE_SIZE, &blue); 151 eglGetConfigAttrib(d, configs[index], EGL_ALPHA_SIZE, &alpha); 128 152 if (red == props.value(EGL_RED_SIZE) && 129 153 green == props.value(EGL_GREEN_SIZE) && … … 180 204 shareContext = 0; 181 205 if (shareContext) { 182 ctx = eglCreateContext(d py, cfg, shareContext->ctx, contextProps.properties());206 ctx = eglCreateContext(d, cfg, shareContext->ctx, contextProps.properties()); 183 207 if (ctx == EGL_NO_CONTEXT) { 184 208 qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError()); … … 189 213 } 190 214 if (ctx == EGL_NO_CONTEXT) { 191 ctx = eglCreateContext(d py, cfg, 0, contextProps.properties());215 ctx = eglCreateContext(d, cfg, 0, contextProps.properties()); 192 216 if (ctx == EGL_NO_CONTEXT) { 193 217 qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError()); … … 205 229 if (surface == currentSurface) 206 230 doneCurrent(); 207 eglDestroySurface(d py, surface);231 eglDestroySurface(d, surface); 208 232 } 209 233 } 210 234 211 235 // Destroy the context. Note: this does not destroy the surface. 212 void QEglContext::destroy ()236 void QEglContext::destroy() 213 237 { 214 238 if (ctx != EGL_NO_CONTEXT && ownsContext) 215 eglDestroyContext(dpy, ctx); 216 dpy = EGL_NO_DISPLAY; 239 eglDestroyContext(display(), ctx); 217 240 ctx = EGL_NO_CONTEXT; 218 241 cfg = 0; … … 249 272 #endif 250 273 251 bool ok = eglMakeCurrent(d py, surface, surface, ctx);274 bool ok = eglMakeCurrent(d, surface, surface, ctx); 252 275 if (!ok) 253 276 qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError()); … … 278 301 #endif 279 302 280 bool ok = eglMakeCurrent(d py, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);303 bool ok = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 281 304 if (!ok) 282 305 qWarning() << "QEglContext::doneCurrent():" << errorString(eglGetError()); … … 300 323 return false; 301 324 302 bool ok = eglSwapBuffers(d py, surface);325 bool ok = eglSwapBuffers(d, surface); 303 326 if (!ok) 304 327 qWarning() << "QEglContext::swapBuffers():" << errorString(eglGetError()); … … 339 362 bool QEglContext::configAttrib(int name, EGLint *value) const 340 363 { 341 return eglGetConfigAttrib(dpy, cfg, name, value); 364 return eglGetConfigAttrib(display(), cfg, name, value); 365 } 366 367 void QEglContext::clearError() 368 { 369 eglGetError(); 370 } 371 372 EGLint QEglContext::error() 373 { 374 return eglGetError(); 342 375 } 343 376 … … 351 384 for (int name = 0x3020; name <= 0x304F; ++name) { 352 385 EGLint value; 353 if (name != EGL_NONE && eglGetConfigAttrib(d py, cfg, name, &value))386 if (name != EGL_NONE && eglGetConfigAttrib(d, cfg, name, &value)) 354 387 props.setValue(name, value); 355 388 } … … 358 391 } 359 392 360 // Initialize and return the default display. 361 EGLDisplay QEglContext::defaultDisplay(QPaintDevice *device) 362 { 363 static EGLDisplay dpy = EGL_NO_DISPLAY; 364 if (dpy == EGL_NO_DISPLAY) { 365 dpy = getDisplay(device); 393 EGLDisplay QEglContext::display() 394 { 395 if (!QEglContextTracker::displayOpened()) { 396 dpy = eglGetDisplay(nativeDisplay()); 397 QEglContextTracker::setDisplayOpened(); 366 398 if (dpy == EGL_NO_DISPLAY) { 367 qWarning() << "QEglContext::defaultDisplay(): Cannot open EGL display"; 399 qWarning("QEglContext::display(): Falling back to EGL_DEFAULT_DISPLAY"); 400 dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); 401 } 402 if (dpy == EGL_NO_DISPLAY) { 403 qWarning("QEglContext::display(): Can't even open the default display"); 368 404 return EGL_NO_DISPLAY; 369 405 } 406 370 407 if (!eglInitialize(dpy, NULL, NULL)) { 371 qWarning() << "QEglContext::d efaultDisplay(): Cannot initialize EGL display:" << errorString(eglGetError());408 qWarning() << "QEglContext::display(): Cannot initialize EGL display:" << errorString(eglGetError()); 372 409 return EGL_NO_DISPLAY; 373 410 } 374 #ifdef EGL_OPENGL_ES_API 375 eglBindAPI(EGL_OPENGL_ES_API); 376 #endif 377 } 411 } 412 378 413 return dpy; 379 414 } 415 416 417 418 419 420 421 380 422 381 423 // Return the error string associated with a specific code. … … 411 453 QEglProperties props; 412 454 EGLint count = 0; 413 if (!eglGetConfigs(d py, 0, 0, &count) || count < 1)455 if (!eglGetConfigs(d, 0, 0, &count) || count < 1) 414 456 return; 415 457 EGLConfig *configs = new EGLConfig [count]; 416 eglGetConfigs(d py, configs, count, &count);458 eglGetConfigs(d, configs, count, &count); 417 459 for (EGLint index = 0; index < count; ++index) { 418 460 props = configProperties(configs[index]); … … 424 466 QString QEglContext::extensions() 425 467 { 426 const char* exts = eglQueryString(QEglContext::d efaultDisplay(0), EGL_EXTENSIONS);468 const char* exts = eglQueryString(QEglContext::d), EGL_EXTENSIONS); 427 469 return QString(QLatin1String(exts)); 428 470 } … … 432 474 QList<QByteArray> extensions = 433 475 QByteArray(reinterpret_cast<const char *> 434 (eglQueryString(QEglContext::d efaultDisplay(0), EGL_EXTENSIONS))).split(' ');476 (eglQueryString(QEglContext::d), EGL_EXTENSIONS))).split(' '); 435 477 return extensions.contains(extensionName); 436 478 } -
trunk/src/gui/egl/qegl_p.h
r651 r769 87 87 void setApi(QEgl::API api) { apiType = api; } 88 88 89 bool openDisplay(QPaintDevice *device);90 89 bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat); 91 90 bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0); 91 92 92 EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0); 93 93 void destroySurface(EGLSurface surface); 94 95 void destroy();96 94 97 95 bool makeCurrent(EGLSurface surface); … … 105 103 bool configAttrib(int name, EGLint *value) const; 106 104 107 static void clearError() { eglGetError(); }108 static EGLint error() { return eglGetError(); }105 static void clearError() 106 static EGLint error() 109 107 static QString errorString(EGLint code); 110 108 111 EGLDisplay display() const { return dpy; }109 112 110 113 111 EGLContext context() const { return ctx; } … … 119 117 QEglProperties configProperties(EGLConfig cfg = 0) const; 120 118 121 static EGLDisplay defaultDisplay(QPaintDevice *device);122 123 119 void dumpAllConfigs(); 124 120 … … 128 124 private: 129 125 QEgl::API apiType; 130 EGLDisplay dpy;131 126 EGLContext ctx; 132 127 EGLConfig cfg; … … 136 131 bool sharing; 137 132 138 static EGLDisplay getDisplay(QPaintDevice *device); 133 static EGLDisplay dpy; 134 static EGLNativeDisplayType nativeDisplay(); 139 135 140 136 static QEglContext *currentContext(QEgl::API api); -
trunk/src/gui/egl/qegl_qws.cpp
r651 r769 65 65 } 66 66 67 EGLDisplay QEglContext::getDisplay(QPaintDevice *device)68 {69 Q_UNUSED(device);70 return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));71 }72 73 67 static QScreen *screenForDevice(QPaintDevice *device) 74 68 { -
trunk/src/gui/egl/qegl_symbian.cpp
r651 r769 79 79 EGLSurface surf; 80 80 if (devType == QInternal::Widget) 81 surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, 0);81 surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, ); 82 82 else 83 surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, 0);83 surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, ); 84 84 if (surf == EGL_NO_SURFACE) 85 85 qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError()); 86 86 return surf; 87 }88 89 EGLDisplay QEglContext::getDisplay(QPaintDevice *device)90 {91 EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);92 if (dpy == EGL_NO_DISPLAY)93 qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY");94 return dpy;95 87 } 96 88 -
trunk/src/gui/egl/qegl_wince.cpp
r651 r769 88 88 } 89 89 90 EGL Display QEglContext::getDisplay(QPaintDevice *device)90 EGL) 91 91 { 92 EGLDisplay dpy = 0; 93 HWND win = (static_cast<QWidget*>(device))->winId(); 94 HDC myDc = GetDC(win); 92 HDC myDc = GetDC(0); 93 95 94 if (!myDc) { 96 qWarning("QEglContext::defaultDisplay(): WinCE display is not open"); 95 qWarning("QEglContext::nativeDisplay(): WinCE display is not open"); 96 return EGL_DEFAULT_DISPLAY; 97 97 } 98 dpy = eglGetDisplay(EGLNativeDisplayType(myDc)); 99 if (dpy == EGL_NO_DISPLAY) { 100 qWarning("QEglContext::defaultDisplay(): Falling back to EGL_DEFAULT_DISPLAY"); 101 dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); 102 } 103 return dpy; 98 return EGLNativeDisplayType(myDc); 104 99 } 105 100 -
trunk/src/gui/egl/qegl_x11.cpp
r651 r769 94 94 } 95 95 96 EGL Display QEglContext::getDisplay(QPaintDevice *device)96 EGL) 97 97 { 98 Q_UNUSED(device);99 98 Display *xdpy = QX11Info::display(); 100 99 if (!xdpy) { 101 100 qWarning("QEglContext::getDisplay(): X11 display is not open"); 102 return EGL _NO_DISPLAY;101 return EGL; 103 102 } 104 return eglGetDisplay(EGLNativeDisplayType(xdpy));103 return ); 105 104 } 106 105 -
trunk/src/gui/egl/qeglproperties.cpp
r651 r769 40 40 ****************************************************************************/ 41 41 42 #include "qeglproperties_p.h"43 44 QT_BEGIN_NAMESPACE45 46 42 #include <QtCore/qdebug.h> 47 43 #include <QtCore/qstringlist.h> 44 45 46 47 48 48 49 49 #include "qegl_p.h" … … 61 61 for (int name = 0x3020; name <= 0x304F; ++name) { 62 62 EGLint value; 63 if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::d efaultDisplay(0), cfg, name, &value))63 if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::d), cfg, name, &value)) 64 64 setValue(name, value); 65 65 } … … 274 274 { 275 275 EGLint count = 0; 276 eglGetConfigs(QEglContext::d efaultDisplay(0), 0, 0, &count);276 eglGetConfigs(QEglContext::d), 0, 0, &count); 277 277 if (count < 1) 278 278 return; 279 279 280 280 EGLConfig *configs = new EGLConfig [count]; 281 eglGetConfigs(QEglContext::d efaultDisplay(0), configs, count, &count);281 eglGetConfigs(QEglContext::d), configs, count, &count); 282 282 for (EGLint index = 0; index < count; ++index) 283 283 qWarning() << QEglProperties(configs[index]).toString(); -
trunk/src/gui/egl/qeglproperties_p.h
r651 r769 59 59 QT_BEGIN_INCLUDE_NAMESPACE 60 60 61 62 63 64 65 61 66 #if defined(QT_GLES_EGL) 62 # include <GLES/egl.h>67 #include <GLES/egl.h> 63 68 #else 64 # include <EGL/egl.h>69 #include <EGL/egl.h> 65 70 #endif 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 66 90 67 91 #if defined(Q_WS_X11) … … 99 123 BestPixelFormat 100 124 }; 101 } ;125 } 102 126 103 127 class QX11Info;
Note:
See TracChangeset
for help on using the changeset viewer.