LCOV - code coverage report
Current view: directory - gfx/gl - GLXLibrary.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 2 50.0 %
Date: 2012-06-02 Functions: 3 1 33.3 %

       1                 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  * ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Initial Developer of the Original Code is Mozilla Foundation.
      16                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      17                 :  * the Initial Developer. All Rights Reserved.
      18                 :  *
      19                 :  * Contributor(s):
      20                 :  *   Bas Schouten <bschouten@mozilla.com>
      21                 :  *   Vladimir Vukicevic <vladimir@pobox.com>
      22                 :  *   Matt Woodrow <mwoodrow@mozilla.com>
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef GFX_GLXLIBRARY_H
      39                 : #define GFX_GLXLIBRARY_H
      40                 : 
      41                 : #include "GLContext.h"
      42                 : typedef realGLboolean GLboolean;
      43                 : #include <GL/glx.h>
      44                 : 
      45                 : namespace mozilla {
      46                 : namespace gl {
      47                 : 
      48                 : class GLXLibrary
      49                 : {
      50                 : public:
      51            1464 :     GLXLibrary() : mInitialized(false), mTriedInitializing(false),
      52                 :                    mHasTextureFromPixmap(false), mDebug(false),
      53            1464 :                    mHasRobustness(false), mOGLLibrary(nsnull) {}
      54                 : 
      55                 :     void xDestroyContext(Display* display, GLXContext context);
      56                 :     Bool xMakeCurrent(Display* display, 
      57                 :                       GLXDrawable drawable, 
      58                 :                       GLXContext context);
      59                 :     GLXContext xGetCurrentContext();
      60                 :     static void* xGetProcAddress(const char *procName);
      61                 :     GLXFBConfig* xChooseFBConfig(Display* display, 
      62                 :                                  int screen, 
      63                 :                                  const int *attrib_list, 
      64                 :                                  int *nelements);
      65                 :     GLXFBConfig* xGetFBConfigs(Display* display, 
      66                 :                                int screen, 
      67                 :                                int *nelements);
      68                 :     GLXContext xCreateNewContext(Display* display, 
      69                 :                                  GLXFBConfig config, 
      70                 :                                  int render_type, 
      71                 :                                  GLXContext share_list, 
      72                 :                                  Bool direct);
      73                 :     XVisualInfo* xGetVisualFromFBConfig(Display* display, 
      74                 :                                         GLXFBConfig config);
      75                 :     int xGetFBConfigAttrib(Display *display,
      76                 :                            GLXFBConfig config,
      77                 :                            int attribute,
      78                 :                            int *value);
      79                 :     void xSwapBuffers(Display *display, GLXDrawable drawable);
      80                 :     const char * xQueryExtensionsString(Display *display,
      81                 :                                         int screen);
      82                 :     const char * xGetClientString(Display *display,
      83                 :                                   int screen);
      84                 :     const char * xQueryServerString(Display *display,
      85                 :                                     int screen, int name);
      86                 :     GLXPixmap xCreatePixmap(Display *display, 
      87                 :                             GLXFBConfig config,
      88                 :                             Pixmap pixmap,
      89                 :                             const int *attrib_list);
      90                 :     GLXPixmap xCreateGLXPixmapWithConfig(Display *display,
      91                 :                                          GLXFBConfig config,
      92                 :                                          Pixmap pixmap);
      93                 :     void xDestroyPixmap(Display *display, GLXPixmap pixmap);
      94                 :     GLXContext xCreateContext(Display *display,
      95                 :                               XVisualInfo *vis,
      96                 :                               GLXContext shareList,
      97                 :                               Bool direct);
      98                 :     Bool xQueryVersion(Display *display,
      99                 :                        int *major,
     100                 :                        int *minor);
     101                 :     void xBindTexImage(Display *display,
     102                 :                        GLXDrawable drawable,
     103                 :                        int buffer,
     104                 :                        const int *attrib_list);
     105                 :     void xReleaseTexImage(Display *display,
     106                 :                           GLXDrawable drawable,
     107                 :                           int buffer);
     108                 :     void xWaitGL();
     109                 :     void xWaitX();
     110                 : 
     111                 :     GLXContext xCreateContextAttribs(Display* display, 
     112                 :                                      GLXFBConfig config, 
     113                 :                                      GLXContext share_list, 
     114                 :                                      Bool direct,
     115                 :                                      const int* attrib_list);
     116                 : 
     117                 :     bool EnsureInitialized();
     118                 : 
     119                 :     GLXPixmap CreatePixmap(gfxASurface* aSurface);
     120                 :     void DestroyPixmap(GLXPixmap aPixmap);
     121                 :     void BindTexImage(GLXPixmap aPixmap);
     122                 :     void ReleaseTexImage(GLXPixmap aPixmap);
     123                 : 
     124               0 :     bool HasTextureFromPixmap() { return mHasTextureFromPixmap; }
     125               0 :     bool HasRobustness() { return mHasRobustness; }
     126                 :     bool SupportsTextureFromPixmap(gfxASurface* aSurface);
     127                 : 
     128                 : private:
     129                 :     
     130                 :     typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
     131                 :                                                           GLXContext);
     132                 :     PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
     133                 :     typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
     134                 :                                                        GLXDrawable,
     135                 :                                                        GLXContext);
     136                 :     PFNGLXMAKECURRENTPROC xMakeCurrentInternal;
     137                 :     typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
     138                 :     PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal;
     139                 :     typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *);
     140                 :     PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
     141                 :     typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *,
     142                 :                                                               int,
     143                 :                                                               const int *,
     144                 :                                                               int *);
     145                 :     PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
     146                 :     typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *,
     147                 :                                                             int,
     148                 :                                                             int *);
     149                 :     PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
     150                 :     typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *,
     151                 :                                                               GLXFBConfig,
     152                 :                                                               int,
     153                 :                                                               GLXContext,
     154                 :                                                               Bool);
     155                 :     PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
     156                 :     typedef XVisualInfo* (GLAPIENTRY * PFNGLXGETVISUALFROMFBCONFIG) (Display *,
     157                 :                                                                      GLXFBConfig);
     158                 :     PFNGLXGETVISUALFROMFBCONFIG xGetVisualFromFBConfigInternal;
     159                 :     typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *, 
     160                 :                                                         GLXFBConfig,
     161                 :                                                         int,
     162                 :                                                         int *);
     163                 :     PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
     164                 : 
     165                 :     typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *,
     166                 :                                                    GLXDrawable);
     167                 :     PFNGLXSWAPBUFFERS xSwapBuffersInternal;
     168                 :     typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *,
     169                 :                                                                      int);
     170                 :     PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
     171                 :     typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *,
     172                 :                                                                int);
     173                 :     PFNGLXGETCLIENTSTRING xGetClientStringInternal;
     174                 :     typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *,
     175                 :                                                                  int,
     176                 :                                                                  int);
     177                 :     PFNGLXQUERYSERVERSTRING xQueryServerStringInternal;
     178                 : 
     179                 :     typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *,
     180                 :                                                          GLXFBConfig,
     181                 :                                                          Pixmap,
     182                 :                                                          const int *);
     183                 :     PFNGLXCREATEPIXMAP xCreatePixmapInternal;
     184                 :     typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
     185                 :                                                         (Display *,
     186                 :                                                          GLXFBConfig,
     187                 :                                                          Pixmap);
     188                 :     PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
     189                 :     typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *,
     190                 :                                                      GLXPixmap);
     191                 :     PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
     192                 :     typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXT) (Display *,
     193                 :                                                            XVisualInfo *,
     194                 :                                                            GLXContext,
     195                 :                                                            Bool);
     196                 :     PFNGLXCREATECONTEXT xCreateContextInternal;
     197                 :     typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *,
     198                 :                                                     int *,
     199                 :                                                     int *);
     200                 :     PFNGLXQUERYVERSION xQueryVersionInternal;
     201                 : 
     202                 :     typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *,
     203                 :                                                     GLXDrawable,
     204                 :                                                     int,
     205                 :                                                     const int *);
     206                 :     PFNGLXBINDTEXIMAGE xBindTexImageInternal;
     207                 : 
     208                 :     typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *,
     209                 :                                                        GLXDrawable,
     210                 :                                                        int);
     211                 :     PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal;
     212                 : 
     213                 :     typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
     214                 :     PFNGLXWAITGL xWaitGLInternal;
     215                 :     
     216                 :     typedef void (GLAPIENTRY * PFNGLXWAITX) ();
     217                 :     PFNGLXWAITGL xWaitXInternal;
     218                 : 
     219                 :     typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display *,
     220                 :                                                                   GLXFBConfig,
     221                 :                                                                   GLXContext,
     222                 :                                                                   Bool,
     223                 :                                                                   const int *);
     224                 :     PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal;
     225                 : 
     226                 : #ifdef DEBUG
     227                 :     void BeforeGLXCall();
     228                 :     void AfterGLXCall();
     229                 : #endif
     230                 : 
     231                 :     bool mInitialized;
     232                 :     bool mTriedInitializing;
     233                 :     bool mHasTextureFromPixmap;
     234                 :     bool mDebug;
     235                 :     bool mHasRobustness;
     236                 :     PRLibrary *mOGLLibrary;
     237                 : };
     238                 : 
     239                 : // a global GLXLibrary instance
     240                 : extern GLXLibrary sGLXLibrary;
     241                 : 
     242                 : } /* namespace gl */
     243                 : } /* namespace mozilla */
     244                 : #endif /* GFX_GLXLIBRARY_H */
     245                 : 

Generated by: LCOV version 1.7