LCOV - code coverage report
Current view: top level - gfx/gl - GLXLibrary.h (source / functions) Hit Total Coverage
Test: output.info Lines: 4 54 7.4 %
Date: 2017-07-14 16:53:18 Functions: 1 29 3.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef GFX_GLXLIBRARY_H
       7             : #define GFX_GLXLIBRARY_H
       8             : 
       9             : #include "GLContextTypes.h"
      10             : #include "prlink.h"
      11             : typedef realGLboolean GLboolean;
      12             : 
      13             : // stuff from glx.h
      14             : #include "X11/Xlib.h"
      15             : typedef struct __GLXcontextRec* GLXContext;
      16             : typedef XID GLXPixmap;
      17             : typedef XID GLXDrawable;
      18             : /* GLX 1.3 and later */
      19             : typedef struct __GLXFBConfigRec* GLXFBConfig;
      20             : // end of stuff from glx.h
      21             : #include "prenv.h"
      22             : 
      23             : struct PRLibrary;
      24             : class gfxASurface;
      25             : 
      26             : namespace mozilla {
      27             : namespace gl {
      28             : 
      29             : class GLXLibrary
      30             : {
      31             : public:
      32           3 :     GLXLibrary()
      33           3 :         : mSymbols{nullptr}
      34             :         , mInitialized(false)
      35             :         , mTriedInitializing(false)
      36             :         , mUseTextureFromPixmap(false)
      37             :         , mDebug(false)
      38             :         , mHasRobustness(false)
      39             :         , mHasCreateContextAttribs(false)
      40             :         , mHasVideoSync(false)
      41             :         , mIsATI(false), mIsNVIDIA(false)
      42             :         , mClientIsMesa(false)
      43           3 :         , mOGLLibrary(nullptr)
      44           3 :     {}
      45             : 
      46             :     bool EnsureInitialized();
      47             : 
      48             : private:
      49             :     void BeforeGLXCall() const;
      50             :     void AfterGLXCall() const;
      51             : 
      52             : public:
      53             : 
      54             : #ifdef DEBUG
      55             : #define BEFORE_CALL BeforeGLXCall();
      56             : #define AFTER_CALL AfterGLXCall();
      57             : #else
      58             : #define BEFORE_CALL
      59             : #define AFTER_CALL
      60             : #endif
      61             : 
      62             : #define WRAP(X) \
      63             :     { \
      64             :         BEFORE_CALL \
      65             :         const auto ret = mSymbols. X ; \
      66             :         AFTER_CALL \
      67             :         return ret; \
      68             :     }
      69             : #define VOID_WRAP(X) \
      70             :     { \
      71             :         BEFORE_CALL \
      72             :         mSymbols. X ; \
      73             :         AFTER_CALL \
      74             :     }
      75             : 
      76           0 :     void           fDestroyContext(Display* display, GLXContext context) const
      77           0 :         VOID_WRAP( fDestroyContext(display, context) )
      78             : 
      79           0 :     Bool      fMakeCurrent(Display* display, GLXDrawable drawable, GLXContext context) const
      80           0 :         WRAP( fMakeCurrent(display, drawable, context) )
      81             : 
      82           0 :     GLXContext fGetCurrentContext() const
      83           0 :         WRAP(  fGetCurrentContext() )
      84             : 
      85           0 :     GLXFBConfig* fChooseFBConfig(Display* display, int screen, const int* attrib_list, int* nelements) const
      86           0 :         WRAP(    fChooseFBConfig(display, screen, attrib_list, nelements) )
      87             : 
      88           0 :     GLXFBConfig* fGetFBConfigs(Display* display, int screen, int* nelements) const
      89           0 :         WRAP(    fGetFBConfigs(display, screen, nelements) )
      90             : 
      91           0 :     GLXContext fCreateNewContext(Display* display, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct) const
      92           0 :         WRAP(  fCreateNewContext(display, config, render_type, share_list, direct) )
      93             : 
      94           0 :     int       fGetFBConfigAttrib(Display* display, GLXFBConfig config, int attribute, int* value) const
      95           0 :         WRAP( fGetFBConfigAttrib(display, config, attribute, value) )
      96             : 
      97           0 :     void           fSwapBuffers(Display* display, GLXDrawable drawable) const
      98           0 :         VOID_WRAP( fSwapBuffers(display, drawable) )
      99             : 
     100           0 :     const char* fQueryExtensionsString(Display* display, int screen) const
     101           0 :         WRAP(   fQueryExtensionsString(display, screen) )
     102             : 
     103           0 :     const char* fGetClientString(Display* display, int screen) const
     104           0 :         WRAP(   fGetClientString(display, screen) )
     105             : 
     106           0 :     const char* fQueryServerString(Display* display, int screen, int name) const
     107           0 :         WRAP(   fQueryServerString(display, screen, name) )
     108             : 
     109           0 :     GLXPixmap fCreatePixmap(Display* display, GLXFBConfig config, Pixmap pixmap, const int* attrib_list) const
     110           0 :         WRAP( fCreatePixmap(display, config, pixmap, attrib_list) )
     111             : 
     112             :     GLXPixmap fCreateGLXPixmapWithConfig(Display* display, GLXFBConfig config, Pixmap pixmap) const
     113             :         WRAP( fCreateGLXPixmapWithConfig(display, config, pixmap) )
     114             : 
     115           0 :     void           fDestroyPixmap(Display* display, GLXPixmap pixmap) const
     116           0 :         VOID_WRAP( fDestroyPixmap(display, pixmap) )
     117             : 
     118           0 :     Bool      fQueryVersion(Display* display, int* major, int* minor) const
     119           0 :         WRAP( fQueryVersion(display, major, minor) )
     120             : 
     121           0 :     void           fBindTexImage(Display* display, GLXDrawable drawable, int buffer, const int* attrib_list) const
     122           0 :         VOID_WRAP( fBindTexImageEXT(display, drawable, buffer, attrib_list) )
     123             : 
     124           0 :     void           fReleaseTexImage(Display* display, GLXDrawable drawable, int buffer) const
     125           0 :         VOID_WRAP( fReleaseTexImageEXT(display, drawable, buffer) )
     126             : 
     127             :     void           fWaitGL() const
     128             :         VOID_WRAP( fWaitGL() )
     129             : 
     130           0 :     void           fWaitX() const
     131           0 :         VOID_WRAP( fWaitX() )
     132             : 
     133           0 :     GLXContext fCreateContextAttribs(Display* display, GLXFBConfig config, GLXContext share_list, Bool direct, const int* attrib_list) const
     134           0 :         WRAP(  fCreateContextAttribsARB(display, config, share_list, direct, attrib_list) )
     135             : 
     136           0 :     int       fGetVideoSync(unsigned int* count) const
     137           0 :         WRAP( fGetVideoSyncSGI(count) )
     138             : 
     139           0 :     int       fWaitVideoSync(int divisor, int remainder, unsigned int* count) const
     140           0 :         WRAP( fWaitVideoSyncSGI(divisor, remainder, count) )
     141             : 
     142           0 :     void           fSwapInterval(Display* dpy, GLXDrawable drawable, int interval) const
     143           0 :         VOID_WRAP( fSwapIntervalEXT(dpy, drawable, interval) )
     144             : 
     145             : #undef WRAP
     146             : #undef VOID_WRAP
     147             : #undef BEFORE_CALL
     148             : #undef AFTER_CALL
     149             : 
     150             :     ////
     151             : 
     152             :     GLXPixmap CreatePixmap(gfxASurface* aSurface);
     153             :     void DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap);
     154             :     void BindTexImage(Display* aDisplay, GLXPixmap aPixmap);
     155             :     void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap);
     156             :     void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap);
     157             : 
     158             :     ////
     159             : 
     160           0 :     bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
     161           0 :     bool HasRobustness() { return mHasRobustness; }
     162           0 :     bool HasCreateContextAttribs() { return mHasCreateContextAttribs; }
     163             :     bool SupportsTextureFromPixmap(gfxASurface* aSurface);
     164             :     bool SupportsVideoSync();
     165           0 :     bool SupportsSwapControl() const { return bool(mSymbols.fSwapIntervalEXT); }
     166           0 :     bool IsATI() { return mIsATI; }
     167           0 :     bool IsMesa() { return mClientIsMesa; }
     168             : 
     169           0 :     PRFuncPtr GetGetProcAddress() const {
     170           0 :         return (PRFuncPtr)mSymbols.fGetProcAddress;
     171             :     }
     172             : 
     173             : private:
     174             :     struct {
     175             :         void         (GLAPIENTRY *fDestroyContext) (Display*, GLXContext);
     176             :         Bool         (GLAPIENTRY *fMakeCurrent) (Display*, GLXDrawable, GLXContext);
     177             :         GLXContext   (GLAPIENTRY *fGetCurrentContext) ();
     178             :         void*        (GLAPIENTRY *fGetProcAddress) (const char*);
     179             :         GLXFBConfig* (GLAPIENTRY *fChooseFBConfig) (Display*, int, const int*, int*);
     180             :         GLXFBConfig* (GLAPIENTRY *fGetFBConfigs) (Display*, int, int*);
     181             :         GLXContext   (GLAPIENTRY *fCreateNewContext) (Display*, GLXFBConfig, int,
     182             :                                                       GLXContext, Bool);
     183             :         int          (GLAPIENTRY *fGetFBConfigAttrib) (Display*, GLXFBConfig, int, int*);
     184             :         void         (GLAPIENTRY *fSwapBuffers) (Display*, GLXDrawable);
     185             :         const char*  (GLAPIENTRY *fQueryExtensionsString) (Display*, int);
     186             :         const char*  (GLAPIENTRY *fGetClientString) (Display*, int);
     187             :         const char*  (GLAPIENTRY *fQueryServerString) (Display*, int, int);
     188             :         GLXPixmap    (GLAPIENTRY *fCreatePixmap) (Display*, GLXFBConfig, Pixmap,
     189             :                                                   const int*);
     190             :         GLXPixmap    (GLAPIENTRY *fCreateGLXPixmapWithConfig) (Display*, GLXFBConfig,
     191             :                                                               Pixmap);
     192             :         void         (GLAPIENTRY *fDestroyPixmap) (Display*, GLXPixmap);
     193             :         Bool         (GLAPIENTRY *fQueryVersion) (Display*, int*, int*);
     194             :         void         (GLAPIENTRY *fWaitGL) ();
     195             :         void         (GLAPIENTRY *fWaitX) ();
     196             :         void         (GLAPIENTRY *fBindTexImageEXT) (Display*, GLXDrawable, int,
     197             :                                                      const int*);
     198             :         void         (GLAPIENTRY *fReleaseTexImageEXT) (Display*, GLXDrawable, int);
     199             :         GLXContext   (GLAPIENTRY *fCreateContextAttribsARB) (Display*, GLXFBConfig,
     200             :                                                              GLXContext, Bool,
     201             :                                                              const int*);
     202             :         int          (GLAPIENTRY *fGetVideoSyncSGI) (unsigned int*);
     203             :         int          (GLAPIENTRY *fWaitVideoSyncSGI) (int, int, unsigned int*);
     204             :         void         (GLAPIENTRY *fSwapIntervalEXT) (Display*, GLXDrawable, int);
     205             :     } mSymbols;
     206             : 
     207             : #ifdef DEBUG
     208             :     void BeforeGLXCall();
     209             :     void AfterGLXCall();
     210             : #endif
     211             : 
     212             :     bool mInitialized;
     213             :     bool mTriedInitializing;
     214             :     bool mUseTextureFromPixmap;
     215             :     bool mDebug;
     216             :     bool mHasRobustness;
     217             :     bool mHasCreateContextAttribs;
     218             :     bool mHasVideoSync;
     219             :     bool mIsATI;
     220             :     bool mIsNVIDIA;
     221             :     bool mClientIsMesa;
     222             :     PRLibrary* mOGLLibrary;
     223             : };
     224             : 
     225             : // a global GLXLibrary instance
     226             : extern GLXLibrary sGLXLibrary;
     227             : 
     228             : } /* namespace gl */
     229             : } /* namespace mozilla */
     230             : #endif /* GFX_GLXLIBRARY_H */
     231             : 

Generated by: LCOV version 1.13