src/gui/egl/qegl_p.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QEGL_P_H
       
    43 #define QEGL_P_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists for the convenience of
       
    50 // the QtOpenGL and QtOpenVG modules.  This header file may change from
       
    51 // version to version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include <QtCore/qsize.h>
       
    57 #include <QtGui/qimage.h>
       
    58 
       
    59 #include <private/qeglproperties_p.h>
       
    60 
       
    61 QT_BEGIN_INCLUDE_NAMESPACE
       
    62 
       
    63 #if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED)
       
    64 #undef EGLNativeWindowType
       
    65 #undef EGLNativePixmapType
       
    66 #undef EGLNativeDisplayType
       
    67 typedef NativeWindowType EGLNativeWindowType;
       
    68 typedef NativePixmapType EGLNativePixmapType;
       
    69 typedef NativeDisplayType EGLNativeDisplayType;
       
    70 #define QEGL_NATIVE_TYPES_DEFINED 1
       
    71 #endif
       
    72 QT_END_INCLUDE_NAMESPACE
       
    73 
       
    74 QT_BEGIN_NAMESPACE
       
    75 
       
    76 class Q_GUI_EXPORT QEglContext
       
    77 {
       
    78 public:
       
    79     QEglContext();
       
    80     ~QEglContext();
       
    81 
       
    82     bool isValid() const;
       
    83     bool isCurrent() const;
       
    84 
       
    85     QEgl::API api() const { return apiType; }
       
    86     void setApi(QEgl::API api) { apiType = api; }
       
    87 
       
    88     bool openDisplay(QPaintDevice *device);
       
    89     bool chooseConfig(const QEglProperties& properties, QEgl::PixelFormatMatch match = QEgl::ExactPixelFormat);
       
    90     bool createContext(QEglContext *shareContext = 0, const QEglProperties *properties = 0);
       
    91     EGLSurface createSurface(QPaintDevice *device, const QEglProperties *properties = 0);
       
    92     void destroySurface(EGLSurface surface);
       
    93 
       
    94     void destroy();
       
    95 
       
    96     bool makeCurrent(EGLSurface surface);
       
    97     bool doneCurrent();
       
    98     bool lazyDoneCurrent();
       
    99     bool swapBuffers(EGLSurface surface);
       
   100 
       
   101     void waitNative();
       
   102     void waitClient();
       
   103 
       
   104     bool configAttrib(int name, EGLint *value) const;
       
   105 
       
   106     static void clearError() { eglGetError(); }
       
   107     static EGLint error() { return eglGetError(); }
       
   108     static QString errorString(EGLint code);
       
   109 
       
   110     EGLDisplay display() const { return dpy; }
       
   111 
       
   112     EGLContext context() const { return ctx; }
       
   113     void setContext(EGLContext context) { ctx = context; ownsContext = false;}
       
   114 
       
   115     EGLConfig config() const { return cfg; }
       
   116     void setConfig(EGLConfig config) { cfg = config; }
       
   117 
       
   118     QEglProperties configProperties(EGLConfig cfg = 0) const;
       
   119 
       
   120     static EGLDisplay defaultDisplay(QPaintDevice *device);
       
   121 
       
   122     void dumpAllConfigs();
       
   123 
       
   124     static QString extensions();
       
   125     static bool hasExtension(const char* extensionName);
       
   126 
       
   127 private:
       
   128     QEgl::API apiType;
       
   129     EGLDisplay dpy;
       
   130     EGLContext ctx;
       
   131     EGLConfig cfg;
       
   132     EGLSurface currentSurface;
       
   133     bool current;
       
   134     bool ownsContext;
       
   135 
       
   136     static EGLDisplay getDisplay(QPaintDevice *device);
       
   137 
       
   138     static QEglContext *currentContext(QEgl::API api);
       
   139     static void setCurrentContext(QEgl::API api, QEglContext *context);
       
   140 };
       
   141 
       
   142 QT_END_NAMESPACE
       
   143 
       
   144 #endif // QEGL_P_H