LCOV - code coverage report
Current view: top level - eq - windowSystem.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 44 76 57.9 %
Date: 2017-12-16 05:07:20 Functions: 15 22 68.2 %

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

Generated by: LCOV version 1.11