Changeset 769 for trunk/src/gui/egl


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
10 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/egl/egl.pri

    r561 r769  
    1 CONFIG += egl
     1contains(QT_CONFIG, egl): {
     2        CONFIG += egl
    23
    3 HEADERS += \
    4     egl/qegl_p.h \
    5     egl/qeglproperties_p.h
     4HEADERS += \
     5    egl/qegl_p.h \
     6    egl/qeglproperties_p.h
    67
    7 SOURCES += \
    8     egl/qegl.cpp \
    9     egl/qeglproperties.cpp
     8SOURCES += \
     9    egl/qegl.cpp \
     10    egl/qeglproperties.cpp
    1011
    11 wince*: SOURCES += egl/qegl_wince.cpp
     12wince*: SOURCES += egl/qegl_wince.cpp
    1213
    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
    2329}
  • trunk/src/gui/egl/qegl.cpp

    r651 r769  
    4343#include <QtGui/qpixmap.h>
    4444#include <QtGui/qwidget.h>
     45
    4546#include <QtCore/qdebug.h>
    4647#include "qegl_p.h"
    4748
    4849QT_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
    4978
    5079// Current GL and VG contexts.  These are used to determine if
     
    5584static QEglContext * volatile currentVGContext = 0;
    5685
     86
     87
    5788QEglContext::QEglContext()
    5889    : apiType(QEgl::OpenGL)
    59     , dpy(EGL_NO_DISPLAY)
    6090    , ctx(EGL_NO_CONTEXT)
    6191    , cfg(0)
     
    6595    , sharing(false)
    6696{
     97
    6798}
    6899
    69100QEglContext::~QEglContext()
    70101{
    71     destroy();
     102    destroy();
    72103
    73104    if (currentGLContext == this)
     
    75106    if (currentVGContext == this)
    76107        currentVGContext = 0;
     108
    77109}
    78110
     
    85117{
    86118    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);
    95119}
    96120
     
    103127        // Get the number of matching configurations for this set of properties.
    104128        EGLint matching = 0;
    105         if (!eglChooseConfig(dpy, props.properties(), 0, 0, &matching) || !matching)
     129        if (!eglChooseConfig(d, props.properties(), 0, 0, &matching) || !matching)
    106130            continue;
    107131
     
    109133        // matching configuration.
    110134        if (match == QEgl::BestPixelFormat) {
    111             eglChooseConfig(dpy, props.properties(), &cfg, 1, &matching);
     135            eglChooseConfig(d, props.properties(), &cfg, 1, &matching);
    112136            if (matching < 1)
    113137                continue;
     
    119143        EGLint size = matching;
    120144        EGLConfig *configs = new EGLConfig [size];
    121         eglChooseConfig(dpy, props.properties(), configs, size, &matching);
     145        eglChooseConfig(d, props.properties(), configs, size, &matching);
    122146        for (EGLint index = 0; index < size; ++index) {
    123147            EGLint red, green, blue, alpha;
    124             eglGetConfigAttrib(dpy, configs[index], EGL_RED_SIZE, &red);
    125             eglGetConfigAttrib(dpy, configs[index], EGL_GREEN_SIZE, &green);
    126             eglGetConfigAttrib(dpy, configs[index], EGL_BLUE_SIZE, &blue);
    127             eglGetConfigAttrib(dpy, 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);
    128152            if (red == props.value(EGL_RED_SIZE) &&
    129153                    green == props.value(EGL_GREEN_SIZE) &&
     
    180204        shareContext = 0;
    181205    if (shareContext) {
    182         ctx = eglCreateContext(dpy, cfg, shareContext->ctx, contextProps.properties());
     206        ctx = eglCreateContext(d, cfg, shareContext->ctx, contextProps.properties());
    183207        if (ctx == EGL_NO_CONTEXT) {
    184208            qWarning() << "QEglContext::createContext(): Could not share context:" << errorString(eglGetError());
     
    189213    }
    190214    if (ctx == EGL_NO_CONTEXT) {
    191         ctx = eglCreateContext(dpy, cfg, 0, contextProps.properties());
     215        ctx = eglCreateContext(d, cfg, 0, contextProps.properties());
    192216        if (ctx == EGL_NO_CONTEXT) {
    193217            qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << errorString(eglGetError());
     
    205229        if (surface == currentSurface)
    206230            doneCurrent();
    207         eglDestroySurface(dpy, surface);
     231        eglDestroySurface(d, surface);
    208232    }
    209233}
    210234
    211235// Destroy the context.  Note: this does not destroy the surface.
    212 void QEglContext::destroy()
     236void QEglContext::destroy()
    213237{
    214238    if (ctx != EGL_NO_CONTEXT && ownsContext)
    215         eglDestroyContext(dpy, ctx);
    216     dpy = EGL_NO_DISPLAY;
     239        eglDestroyContext(display(), ctx);
    217240    ctx = EGL_NO_CONTEXT;
    218241    cfg = 0;
     
    249272#endif
    250273
    251     bool ok = eglMakeCurrent(dpy, surface, surface, ctx);
     274    bool ok = eglMakeCurrent(d, surface, surface, ctx);
    252275    if (!ok)
    253276        qWarning() << "QEglContext::makeCurrent():" << errorString(eglGetError());
     
    278301#endif
    279302
    280     bool ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
     303    bool ok = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
    281304    if (!ok)
    282305        qWarning() << "QEglContext::doneCurrent():" << errorString(eglGetError());
     
    300323        return false;
    301324
    302     bool ok = eglSwapBuffers(dpy, surface);
     325    bool ok = eglSwapBuffers(d, surface);
    303326    if (!ok)
    304327        qWarning() << "QEglContext::swapBuffers():" << errorString(eglGetError());
     
    339362bool QEglContext::configAttrib(int name, EGLint *value) const
    340363{
    341     return eglGetConfigAttrib(dpy, cfg, name, value);
     364    return eglGetConfigAttrib(display(), cfg, name, value);
     365}
     366
     367void QEglContext::clearError()
     368{
     369    eglGetError();
     370}
     371
     372EGLint QEglContext::error()
     373{
     374    return eglGetError();
    342375}
    343376
     
    351384    for (int name = 0x3020; name <= 0x304F; ++name) {
    352385        EGLint value;
    353         if (name != EGL_NONE && eglGetConfigAttrib(dpy, cfg, name, &value))
     386        if (name != EGL_NONE && eglGetConfigAttrib(d, cfg, name, &value))
    354387            props.setValue(name, value);
    355388    }
     
    358391}
    359392
    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);
     393EGLDisplay QEglContext::display()
     394{
     395    if (!QEglContextTracker::displayOpened()) {
     396        dpy = eglGetDisplay(nativeDisplay());
     397        QEglContextTracker::setDisplayOpened();
    366398        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");
    368404            return EGL_NO_DISPLAY;
    369405        }
     406
    370407        if (!eglInitialize(dpy, NULL, NULL)) {
    371             qWarning() << "QEglContext::defaultDisplay(): Cannot initialize EGL display:" << errorString(eglGetError());
     408            qWarning() << "QEglContext::display(): Cannot initialize EGL display:" << errorString(eglGetError());
    372409            return EGL_NO_DISPLAY;
    373410        }
    374 #ifdef EGL_OPENGL_ES_API
    375         eglBindAPI(EGL_OPENGL_ES_API);
    376 #endif
    377     }
     411    }
     412
    378413    return dpy;
    379414}
     415
     416
     417
     418
     419
     420
     421
    380422
    381423// Return the error string associated with a specific code.
     
    411453    QEglProperties props;
    412454    EGLint count = 0;
    413     if (!eglGetConfigs(dpy, 0, 0, &count) || count < 1)
     455    if (!eglGetConfigs(d, 0, 0, &count) || count < 1)
    414456        return;
    415457    EGLConfig *configs = new EGLConfig [count];
    416     eglGetConfigs(dpy, configs, count, &count);
     458    eglGetConfigs(d, configs, count, &count);
    417459    for (EGLint index = 0; index < count; ++index) {
    418460        props = configProperties(configs[index]);
     
    424466QString QEglContext::extensions()
    425467{
    426     const char* exts = eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS);
     468    const char* exts = eglQueryString(QEglContext::d), EGL_EXTENSIONS);
    427469    return QString(QLatin1String(exts));
    428470}
     
    432474    QList<QByteArray> extensions =
    433475        QByteArray(reinterpret_cast<const char *>
    434             (eglQueryString(QEglContext::defaultDisplay(0), EGL_EXTENSIONS))).split(' ');
     476            (eglQueryString(QEglContext::d), EGL_EXTENSIONS))).split(' ');
    435477    return extensions.contains(extensionName);
    436478}
  • trunk/src/gui/egl/qegl_p.h

    r651 r769  
    8787    void setApi(QEgl::API api) { apiType = api; }
    8888
    89     bool openDisplay(QPaintDevice *device);
    9089    bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
    9190    bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0);
     91
    9292    EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0);
    9393    void destroySurface(EGLSurface surface);
    94 
    95     void destroy();
    9694
    9795    bool makeCurrent(EGLSurface surface);
     
    105103    bool configAttrib(int name, EGLint *value) const;
    106104
    107     static void clearError() { eglGetError(); }
    108     static EGLint error() { return eglGetError(); }
     105    static void clearError()
     106    static EGLint error()
    109107    static QString errorString(EGLint code);
    110108
    111     EGLDisplay display() const { return dpy; }
     109   
    112110
    113111    EGLContext context() const { return ctx; }
     
    119117    QEglProperties configProperties(EGLConfig cfg = 0) const;
    120118
    121     static EGLDisplay defaultDisplay(QPaintDevice *device);
    122 
    123119    void dumpAllConfigs();
    124120
     
    128124private:
    129125    QEgl::API apiType;
    130     EGLDisplay dpy;
    131126    EGLContext ctx;
    132127    EGLConfig cfg;
     
    136131    bool sharing;
    137132
    138     static EGLDisplay getDisplay(QPaintDevice *device);
     133    static EGLDisplay dpy;
     134    static EGLNativeDisplayType nativeDisplay();
    139135
    140136    static QEglContext *currentContext(QEgl::API api);
  • trunk/src/gui/egl/qegl_qws.cpp

    r651 r769  
    6565}
    6666
    67 EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
    68 {
    69     Q_UNUSED(device);
    70     return eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY));
    71 }
    72 
    7367static QScreen *screenForDevice(QPaintDevice *device)
    7468{
  • trunk/src/gui/egl/qegl_symbian.cpp

    r651 r769  
    7979    EGLSurface surf;
    8080    if (devType == QInternal::Widget)
    81         surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, 0);
     81        surf = eglCreateWindowSurface(dpy, cfg, windowDrawable, );
    8282    else
    83         surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, 0);
     83        surf = eglCreatePixmapSurface(dpy, cfg, pixmapDrawable, );
    8484    if (surf == EGL_NO_SURFACE)
    8585        qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
    8686    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;
    9587}
    9688
  • trunk/src/gui/egl/qegl_wince.cpp

    r651 r769  
    8888}
    8989
    90 EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
     90EGL)
    9191{
    92     EGLDisplay dpy = 0;
    93     HWND win = (static_cast<QWidget*>(device))->winId();
    94     HDC myDc = GetDC(win);
     92    HDC myDc = GetDC(0);
     93
    9594    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;
    9797    }
    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);
    10499}
    105100
  • trunk/src/gui/egl/qegl_x11.cpp

    r651 r769  
    9494}
    9595
    96 EGLDisplay QEglContext::getDisplay(QPaintDevice *device)
     96EGL)
    9797{
    98     Q_UNUSED(device);
    9998    Display *xdpy = QX11Info::display();
    10099    if (!xdpy) {
    101100        qWarning("QEglContext::getDisplay(): X11 display is not open");
    102         return EGL_NO_DISPLAY;
     101        return EGL;
    103102    }
    104     return eglGetDisplay(EGLNativeDisplayType(xdpy));
     103    return );
    105104}
    106105
  • trunk/src/gui/egl/qeglproperties.cpp

    r651 r769  
    4040****************************************************************************/
    4141
    42 #include "qeglproperties_p.h"
    43 
    44 QT_BEGIN_NAMESPACE
    45 
    4642#include <QtCore/qdebug.h>
    4743#include <QtCore/qstringlist.h>
     44
     45
     46
     47
    4848
    4949#include "qegl_p.h"
     
    6161    for (int name = 0x3020; name <= 0x304F; ++name) {
    6262        EGLint value;
    63         if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::defaultDisplay(0), cfg, name, &value))
     63        if (name != EGL_NONE && eglGetConfigAttrib(QEglContext::d), cfg, name, &value))
    6464            setValue(name, value);
    6565    }
     
    274274{
    275275    EGLint count = 0;
    276     eglGetConfigs(QEglContext::defaultDisplay(0), 0, 0, &count);
     276    eglGetConfigs(QEglContext::d), 0, 0, &count);
    277277    if (count < 1)
    278278        return;
    279279
    280280    EGLConfig *configs = new EGLConfig [count];
    281     eglGetConfigs(QEglContext::defaultDisplay(0), configs, count, &count);
     281    eglGetConfigs(QEglContext::d), configs, count, &count);
    282282    for (EGLint index = 0; index < count; ++index)
    283283        qWarning() << QEglProperties(configs[index]).toString();
  • trunk/src/gui/egl/qeglproperties_p.h

    r651 r769  
    5959QT_BEGIN_INCLUDE_NAMESPACE
    6060
     61
     62
     63
     64
     65
    6166#if defined(QT_GLES_EGL)
    62 #include <GLES/egl.h>
     67#include <GLES/egl.h>
    6368#else
    64 #include <EGL/egl.h>
     69#include <EGL/egl.h>
    6570#endif
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
    6690
    6791#if defined(Q_WS_X11)
     
    99123        BestPixelFormat
    100124    };
    101 };
     125}
    102126
    103127class QX11Info;
Note: See TracChangeset for help on using the changeset viewer.