LCOV - code coverage report
Current view: top level - eq/client - windowSystem.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 31 71 43.7 %
Date: 2014-06-18 Functions: 11 20 55.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2007-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *                    2011, Daniel Pfeifer <daniel@pfeifer-mail.de>
       4             :  *                    2014, Daniel Nachbaur <danielnachbaur@gmail.com>
       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             : #include "windowSystem.h"
      21             : 
      22             : #include "gl.h"
      23             : 
      24             : #include <eq/util/objectManager.h>
      25             : #include <eq/fabric/gpuInfo.h>
      26             : #include <co/dataIStream.h>
      27             : #include <co/dataOStream.h>
      28             : 
      29             : namespace eq
      30             : {
      31             : static WindowSystemIF* _stack = 0;
      32             : 
      33          12 : WindowSystemIF::WindowSystemIF()
      34          12 :         : _next( _stack )
      35             : {
      36          12 :     _stack = this;
      37          12 : }
      38             : 
      39           0 : uint32_t WindowSystemIF::_setupLists( util::ObjectManager& gl, const void* key,
      40             :                                       const int num )
      41             : {
      42           0 :     GLuint lists = gl.getList( key );
      43           0 :     if( lists != util::ObjectManager::INVALID )
      44           0 :         gl.deleteList( key );
      45             : 
      46           0 :     if( num == 0 )
      47           0 :         lists = util::ObjectManager::INVALID;
      48             :     else
      49             :     {
      50           0 :         lists = gl.newList( key, num );
      51           0 :         LBASSERT( lists != util::ObjectManager::INVALID );
      52             :     }
      53           0 :     return lists;
      54             : }
      55             : 
      56         120 : WindowSystem::WindowSystem()
      57         120 :         : _impl( _stack )
      58             : {
      59         120 :     LBASSERTINFO( _stack, "no window system available" );
      60         120 : }
      61             : 
      62           0 : WindowSystem::WindowSystem( std::string const& type )
      63             : {
      64           0 :     _chooseImpl( type );
      65           0 : }
      66             : 
      67           0 : void WindowSystem::_chooseImpl( const std::string& name )
      68             : {
      69           0 :     LBASSERTINFO( _stack, "no window system available" );
      70             : 
      71           0 :     for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
      72             :     {
      73           0 :         if( ws->getName() == name )
      74             :         {
      75           0 :             _impl = ws;
      76           0 :             return;
      77             :         }
      78             :     }
      79             : 
      80           0 :     _impl = _stack;
      81           0 :     LBWARN << "Window system " << name << " not supported, " << "using "
      82           0 :            << _impl->getName() << " instead." << std::endl;
      83             : }
      84             : 
      85           0 : bool WindowSystem::supports( std::string const& type )
      86             : {
      87           0 :     for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
      88             :     {
      89           0 :         if( ws->getName() == type )
      90           0 :             return true;
      91             :     }
      92             : 
      93           0 :     return false;
      94             : }
      95             : 
      96           8 : void WindowSystem::configInit( Node* node )
      97             : {
      98          16 :     for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
      99           8 :         ws->configInit( node );
     100           8 : }
     101             : 
     102           8 : void WindowSystem::configExit( Node* node )
     103             : {
     104          16 :     for( WindowSystemIF* ws = _stack; ws; ws = ws->_next )
     105           8 :         ws->configExit(node );
     106           8 : }
     107             : 
     108          30 : std::string WindowSystem::getName() const
     109             : {
     110          30 :     LBASSERT( _impl );
     111          30 :     return _impl->getName();
     112             : }
     113             : 
     114          17 : SystemWindow* WindowSystem::createWindow( Window* window,
     115             :                                           const WindowSettings& settings ) const
     116             : {
     117          17 :     LBASSERT( _impl );
     118          17 :     return _impl->createWindow( window, settings );
     119             : }
     120             : 
     121          15 : SystemPipe* WindowSystem::createPipe( Pipe* pipe ) const
     122             : {
     123          15 :     LBASSERT( _impl );
     124          15 :     return _impl->createPipe( pipe );
     125             : }
     126             : 
     127          15 : MessagePump* WindowSystem::createMessagePump() const
     128             : {
     129          15 :     LBASSERT( _impl );
     130          15 :     return _impl->createMessagePump();
     131             : }
     132             : 
     133           0 : bool WindowSystem::setupFont( util::ObjectManager& gl, const void* key,
     134             :                               const std::string& name,
     135             :                               const uint32_t size ) const
     136             : {
     137           0 :     LBASSERT( _impl );
     138           0 :     return _impl->setupFont( gl, key, name, size );
     139             : }
     140             : 
     141           0 : bool WindowSystem::operator == ( const WindowSystem& other) const
     142             : {
     143           0 :     return _impl == other._impl;
     144             : }
     145             : 
     146           0 : bool WindowSystem::operator != ( const WindowSystem& other ) const
     147             : {
     148           0 :     return _impl != other._impl;
     149             : }
     150             : 
     151          15 : std::ostream& operator << ( std::ostream& os, const WindowSystem& ws )
     152             : {
     153          15 :     return os << ws.getName();
     154             : }
     155             : 
     156           0 : co::DataOStream& operator << ( co::DataOStream& os, const WindowSystem& ws )
     157             : {
     158           0 :     return os << ws.getName();
     159             : }
     160             : 
     161           0 : co::DataIStream& operator >> ( co::DataIStream& is, WindowSystem& ws )
     162             : {
     163           0 :     std::string name;
     164           0 :     is >> name;
     165           0 :     ws = WindowSystem( name );
     166           0 :     return is;
     167             : }
     168             : 
     169          36 : } // namespace eq

Generated by: LCOV version 1.10