Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/egl/qegl_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5454//
    5555
    56 #include <QtCore/qsize.h>
    57 #include <QtGui/qimage.h>
    58 
    59 #include <private/qeglproperties_p.h>
    60 
    6156QT_BEGIN_INCLUDE_NAMESPACE
    6257
     58#ifndef QT_NO_EGL
     59#if defined(QT_OPENGL_ES_2)
     60#   include <GLES2/gl2.h>
     61#endif
     62
     63#if defined(QT_GLES_EGL)
     64#   include <GLES/egl.h>
     65#else
     66#   include <EGL/egl.h>
     67#endif
     68#if !defined(EGL_VERSION_1_2)
     69typedef unsigned int EGLenum;
     70typedef void *EGLClientBuffer;
     71#endif
     72#else
     73
     74//types from egltypes.h for compiling stub without EGL headers
     75typedef int EGLBoolean;
     76typedef int EGLint;
     77typedef int EGLenum;
     78typedef int    NativeDisplayType;
     79typedef void*  NativeWindowType;
     80typedef void*  NativePixmapType;
     81typedef int EGLDisplay;
     82typedef int EGLConfig;
     83typedef int EGLSurface;
     84typedef int EGLContext;
     85typedef int EGLClientBuffer;
     86#define EGL_NONE            0x3038  /* Attrib list terminator */
     87
     88#endif
     89
     90#if defined(Q_WS_X11)
     91// If <EGL/egl.h> included <X11/Xlib.h>, then the global namespace
     92// may have been polluted with X #define's.  The following makes sure
     93// the X11 headers were included properly and then cleans things up.
     94#include <X11/Xlib.h>
     95#include <X11/Xutil.h>
     96#undef Bool
     97#undef Status
     98#undef None
     99#undef KeyPress
     100#undef KeyRelease
     101#undef FocusIn
     102#undef FocusOut
     103#undef Type
     104#undef FontChange
     105#undef CursorShape
     106#undef Unsorted
     107#undef GrayScale
     108#endif
     109
     110// Internally we use the EGL-prefixed native types which are used in EGL >= 1.3.
     111// For older versions of EGL, we have to define these types ourselves here:
    63112#if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED)
    64113#undef EGLNativeWindowType
     
    70119#define QEGL_NATIVE_TYPES_DEFINED 1
    71120#endif
     121
    72122QT_END_INCLUDE_NAMESPACE
    73123
     124#include <QtGui/qpaintdevice.h>
     125#include <QFlags>
     126
    74127QT_BEGIN_NAMESPACE
    75128
    76 class Q_GUI_EXPORT QEglContext
    77 {
    78 public:
    79     QEglContext();
    80     ~QEglContext();
    81 
    82     bool isValid() const;
    83     bool isCurrent() const;
    84     bool isSharing() const { return sharing; }
    85 
    86     QEgl::API api() const { return apiType; }
    87     void setApi(QEgl::API api) { apiType = api; }
    88 
    89     bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
    90     bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0);
    91     void destroyContext();
    92     EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0);
    93     void destroySurface(EGLSurface surface);
    94 
    95     bool makeCurrent(EGLSurface surface);
    96     bool doneCurrent();
    97     bool lazyDoneCurrent();
    98     bool swapBuffers(EGLSurface surface);
    99 
    100     void waitNative();
    101     void waitClient();
    102 
    103     bool configAttrib(int name, EGLint *value) const;
    104 
    105     static void clearError();
    106     static EGLint error();
    107     static QString errorString(EGLint code);
    108 
    109     static EGLDisplay display();
    110 
    111     EGLContext context() const { return ctx; }
    112     void setContext(EGLContext context) { ctx = context; ownsContext = false;}
    113 
    114     EGLConfig config() const { return cfg; }
    115     void setConfig(EGLConfig config) { cfg = config; }
    116 
    117     QEglProperties configProperties(EGLConfig cfg = 0) const;
    118 
    119     void dumpAllConfigs();
    120 
    121     static QString extensions();
    122     static bool hasExtension(const char* extensionName);
    123 
    124 private:
    125     QEgl::API apiType;
    126     EGLContext ctx;
    127     EGLConfig cfg;
    128     EGLSurface currentSurface;
    129     bool current;
    130     bool ownsContext;
    131     bool sharing;
    132 
    133     static EGLDisplay dpy;
    134     static EGLNativeDisplayType nativeDisplay();
    135 
    136     static QEglContext *currentContext(QEgl::API api);
    137     static void setCurrentContext(QEgl::API api, QEglContext *context);
    138 };
     129#define QEGL_NO_CONFIG ((EGLConfig)-1)
     130
     131#ifndef EGLAPIENTRY
     132#define EGLAPIENTRY
     133#endif
     134
     135// Try to get some info to debug the symbian build failues:
     136#ifdef Q_OS_SYMBIAN
     137
     138#ifdef EGL_KHR_image
     139#warning "EGL_KHR_image is defined"
     140#else
     141#warning "EGL_KHR_image is NOT defined"
     142#endif
     143
     144#ifdef EGL_KHR_image_base
     145#warning "EGL_KHR_image_base is defined"
     146#else
     147#warning "EGL_KHR_image_base is NOT defined"
     148#endif
     149
     150#ifdef EGL_EGLEXT_PROTOTYPES
     151#warning "EGL_EGLEXT_PROTOTYPES is defined"
     152#else
     153#warning "EGL_EGLEXT_PROTOTYPES NOT not defined"
     154#endif
     155
     156#endif
     157
     158
     159// Declare/define the bits of EGL_KHR_image_base we need:
     160#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_base)
     161#ifdef Q_OS_SYMBIAN
     162//symbian version of eglext.h differs from the khronos reference
     163typedef int EGLImageKHR;
     164#else
     165typedef void *EGLImageKHR;
     166#endif
     167
     168#define EGL_NO_IMAGE_KHR            ((EGLImageKHR)0)
     169#define EGL_IMAGE_PRESERVED_KHR     0x30D2
     170#define EGL_KHR_image_base
     171#endif
     172
     173#if !defined(EGL_KHR_image) && !defined(EGL_KHR_image_pixmap)
     174#define EGL_NATIVE_PIXMAP_KHR       0x30B0
     175#define EGL_KHR_image_pixmap
     176#endif
     177
     178
     179class QEglProperties;
     180
     181namespace QEgl {
     182    enum API
     183    {
     184        OpenGL,
     185        OpenVG
     186    };
     187
     188    enum PixelFormatMatch
     189    {
     190        ExactPixelFormat,
     191        BestPixelFormat
     192    };
     193
     194    enum ConfigOption
     195    {
     196        NoOptions   = 0,
     197        Translucent = 0x01,
     198        Renderable  = 0x02  // Config will be compatable with the paint engines (VG or GL)
     199    };
     200    Q_DECLARE_FLAGS(ConfigOptions, ConfigOption)
     201
     202    // Most of the time we use the same config for things like widgets & pixmaps, so rather than
     203    // go through the eglChooseConfig loop every time, we use defaultConfig, which will return
     204    // the config for a particular device/api/option combo. This function assumes that once a
     205    // config is chosen for a particular combo, it's safe to always use that combo.
     206    Q_GUI_EXPORT EGLConfig  defaultConfig(int devType, API api, ConfigOptions options);
     207
     208    Q_GUI_EXPORT EGLConfig  chooseConfig(const QEglProperties* configAttribs, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
     209    Q_GUI_EXPORT EGLSurface createSurface(QPaintDevice *device, EGLConfig cfg, const QEglProperties *surfaceAttribs = 0);
     210
     211    Q_GUI_EXPORT void dumpAllConfigs();
     212
     213#ifdef QT_NO_EGL
     214    Q_GUI_EXPORT QString errorString(EGLint code = 0);
     215#else
     216    Q_GUI_EXPORT QString errorString(EGLint code = eglGetError());
     217#endif
     218
     219    Q_GUI_EXPORT QString extensions();
     220    Q_GUI_EXPORT bool hasExtension(const char* extensionName);
     221
     222    Q_GUI_EXPORT EGLDisplay display();
     223
     224    Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay();
     225    Q_GUI_EXPORT EGLNativeWindowType  nativeWindow(QWidget*);
     226    Q_GUI_EXPORT EGLNativePixmapType  nativePixmap(QPixmap*);
     227
     228    // Extension functions
     229    Q_GUI_EXPORT EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
     230    Q_GUI_EXPORT EGLBoolean  eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img);
     231    Q_GUI_EXPORT EGLBoolean eglSwapBuffersRegion2NOK(EGLDisplay dpy, EGLSurface surface, EGLint count, const EGLint *rects);
     232
     233#ifdef Q_WS_X11
     234    Q_GUI_EXPORT VisualID getCompatibleVisualId(EGLConfig config);
     235#endif
     236}
     237
     238Q_DECLARE_OPERATORS_FOR_FLAGS(QEgl::ConfigOptions)
    139239
    140240QT_END_NAMESPACE
    141241
    142 #endif // QEGL_P_H
     242#endif //QEGL_P_H
Note: See TracChangeset for help on using the changeset viewer.