LCOV - code coverage report
Current view: top level - eq/client/glx - window.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 3 3 100.0 %
Date: 2014-06-18 Functions: 2 3 66.7 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2005-2014, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2014, Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *                    2009, Maxim Makhinya
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef EQ_GLX_WINDOW_H
      21             : #define EQ_GLX_WINDOW_H
      22             : 
      23             : #include <eq/client/glx/types.h>
      24             : #include <eq/client/glWindow.h>       // base class
      25             : 
      26             : namespace eq
      27             : {
      28             : namespace glx
      29             : {
      30             : namespace detail { class Window; }
      31             : 
      32             : /** The interface defining the minimum functionality for a glX window. */
      33             : class WindowIF : public GLWindow
      34             : {
      35             : public:
      36          17 :     WindowIF( NotifierInterface& parent,
      37          17 :               const WindowSettings& settings ) : GLWindow( parent, settings ) {}
      38          17 :     virtual ~WindowIF() {}
      39             : 
      40             :     /** @return the glX rendering context. @version 1.0 */
      41             :     virtual GLXContext getGLXContext() const = 0;
      42             : 
      43             :     /** @return the X11 drawable ID. @version 1.0 */
      44             :     virtual XID getXDrawable() const = 0;
      45             : 
      46             :     /** @return X11 display connection. @version 1.0 */
      47             :     virtual Display* getXDisplay() = 0;
      48             : 
      49             : #  pragma clang diagnostic push
      50             : #  pragma clang diagnostic ignored "-Woverloaded-virtual"
      51             :     /** Process the given event. @version 1.5.1 */
      52             :     virtual bool processEvent( const WindowEvent& event ) = 0;
      53             : #  pragma clang diagnostic pop
      54             : };
      55             : 
      56             : /** Equalizer default implementation of a glX window */
      57             : class Window : public WindowIF
      58             : {
      59             : public:
      60             :     /**
      61             :      * Construct a new glX/X11 system window.
      62             :      * @version 1.7.2
      63             :      */
      64             :     Window( NotifierInterface& parent, const WindowSettings& settings,
      65             :             Display* xDisplay, const GLXEWContext* glxewContext,
      66             :             MessagePump* messagePump );
      67             : 
      68             :     /** Destruct this glX window. @version 1.0 */
      69             :     virtual ~Window();
      70             : 
      71             :     /** @name GLX/X11 initialization */
      72             :     //@{
      73             :     /**
      74             :      * Initialize this window for the glX window system.
      75             :      *
      76             :      * This method first call chooseGLXFBConfig(), then createGLXContext()
      77             :      * with the chosen framebuffer config, and finally creates a drawable
      78             :      * using configInitGLXDrawable().
      79             :      *
      80             :      * @return true if the initialization was successful, false otherwise.
      81             :      * @version 1.0
      82             :      */
      83             :     bool configInit() override;
      84             : 
      85             :     /** @version 1.0 */
      86             :     void configExit() override;
      87             : 
      88             :     /**
      89             :      * Choose a GLX framebuffer config based on the window's attributes.
      90             :      *
      91             :      * The returned FB config has to be freed using XFree().
      92             :      *
      93             :      * @return a pixel format, or 0 if no pixel format was found.
      94             :      * @version 1.0
      95             :      */
      96             :     virtual GLXFBConfig* chooseGLXFBConfig();
      97             : 
      98             :     /**
      99             :      * Create a glX context.
     100             :      *
     101             :      * This method does not set the window's glX context.
     102             :      *
     103             :      * @param fbConfig the framebuffer config for the context.
     104             :      * @return the context, or 0 if context creation failed.
     105             :      * @version 1.0
     106             :      */
     107             :     virtual GLXContext createGLXContext( GLXFBConfig* fbConfig );
     108             : 
     109             :     /**
     110             :      * Initialize the window's drawable (fullscreen, pbuffer or window) and
     111             :      * bind the glX context.
     112             :      *
     113             :      * Sets the window's X11 drawable on success
     114             :      *
     115             :      * @param fbConfig the framebuffer config for the context.
     116             :      * @return true if the drawable was created, false otherwise.
     117             :      * @version 1.0
     118             :      */
     119             :     virtual bool configInitGLXDrawable( GLXFBConfig* fbConfig );
     120             : 
     121             :     /**
     122             :      * Initialize the window with a window and bind the glX context.
     123             :      *
     124             :      * Sets the window's X11 drawable on success
     125             :      *
     126             :      * @param fbConfig the framebuffer config for the context.
     127             :      * @return true if the window was created, false otherwise.
     128             :      * @version 1.0
     129             :      */
     130             :     virtual bool configInitGLXWindow( GLXFBConfig* fbConfig );
     131             : 
     132             :     /**
     133             :      * Initialize the window with a PBuffer and bind the glX context.
     134             :      *
     135             :      * Sets the window's X11 drawable on success
     136             :      *
     137             :      * @param fbConfig the framebuffer config for the context.
     138             :      * @return true if the PBuffer was created, false otherwise.
     139             :      * @version 1.0
     140             :      */
     141             :     virtual bool configInitGLXPBuffer( GLXFBConfig* fbConfig );
     142             : 
     143             :     /**
     144             :      * Register with the pipe's GLXEventHandler, called by setXDrawable().
     145             :      * @version 1.0
     146             :      */
     147             :     EQ_API virtual void initEventHandler();
     148             : 
     149             :     /**
     150             :      * Deregister with the GLXEventHandler, called by setXDrawable().
     151             :      * @version 1.0
     152             :      */
     153             :     EQ_API virtual void exitEventHandler();
     154             :     //@}
     155             : 
     156             :     /** @name Data Access. */
     157             :     //@{
     158             :     /** @return the glX rendering context. @version 1.0 */
     159             :     EQ_API GLXContext getGLXContext() const override;
     160             : 
     161             :     /**  @return  the X11 drawable ID. @version 1.0 */
     162             :     EQ_API XID getXDrawable() const override;
     163             : 
     164             :     /** @return the X11 display. @version 1.0 */
     165             :     EQ_API Display* getXDisplay() override;
     166             : 
     167             :     /** @return the GLXEW context. @version 1.0*/
     168             :     EQ_API const GLXEWContext* glxewGetContext() const;
     169             : 
     170             :     /**
     171             :      * Set the X11 drawable ID for this window.
     172             :      *
     173             :      * This function should only be called from configInit() or
     174             :      * configExit().
     175             :      *
     176             :      * @param drawable the X11 drawable ID.
     177             :      * @version 1.0
     178             :      */
     179             :     virtual void setXDrawable( XID drawable );
     180             : 
     181             :     /**
     182             :      * Set the glX rendering context for this window.
     183             :      *
     184             :      * This function should only be called from configInit() or
     185             :      * configExit().
     186             :      * The context has to be set to 0 before it is destroyed.
     187             :      *
     188             :      * @param context the glX rendering context.
     189             :      * @version 1.0
     190             :      */
     191             :     virtual void setGLXContext( GLXContext context );
     192             :     //@}
     193             : 
     194             :     /** @name Operations. */
     195             :     //@{
     196             :     /** @version 1.0 */
     197             :     void makeCurrent( const bool cache = true ) const override;
     198             : 
     199             :     /** @version 1.0 */
     200             :     void swapBuffers() override;
     201             : 
     202             :     /** Implementation untested for glX. @version 1.0 */
     203             :     void joinNVSwapBarrier( const uint32_t group,
     204             :                             const uint32_t barrier ) override;
     205             : 
     206             :     /** Unbind a GLX_NV_swap_barrier. @version 1.0 */
     207             :     void leaveNVSwapBarrier();
     208             : 
     209             :     /** @version 1.5.1 */
     210             :     EQ_API bool processEvent( const WindowEvent& event ) override;
     211             :     //@}
     212             : 
     213             : private:
     214             :     detail::Window* const _impl;
     215             : 
     216             :     /** Create an unmapped X11 window. */
     217             :     XID _createGLXWindow( GLXFBConfig* fbConfig, const PixelViewport& pvp );
     218             : 
     219             :     /** Init sync-to-vertical-retrace setting. */
     220             :     void _initSwapSync();
     221             : };
     222             : }
     223             : }
     224             : #endif // EQ_GLX_WINDOW_H

Generated by: LCOV version 1.10