LCOV - code coverage report
Current view: top level - eq/client/glx - windowSystem.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 23 48 47.9 %
Date: 2014-06-18 Functions: 8 10 80.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011 Daniel Pfeifer <daniel@pfeifer-mail.de>
       3             :  *               2011-2014, Stefan Eilemann <eile@eyescale.ch>
       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 "window.h"
      23             : #include "pipe.h"
      24             : #include "messagePump.h"
      25             : #include "eventHandler.h"
      26             : #include "../config.h"
      27             : #include "../gl.h"
      28             : #include "../pipe.h"
      29             : #include "../window.h"
      30             : 
      31             : #include <eq/fabric/gpuInfo.h>
      32             : #include <lunchbox/scopedMutex.h>
      33             : 
      34             : namespace eq
      35             : {
      36             : namespace glx
      37             : {
      38             : 
      39          24 : static class : WindowSystemIF
      40             : {
      41          30 :     std::string getName() const final { return "GLX"; }
      42             : 
      43          17 :     eq::SystemWindow* createWindow( eq::Window* window,
      44             :                                     const WindowSettings& settings ) const final
      45             :     {
      46          17 :         LBINFO << "Using glx::Window" << std::endl;
      47          17 :         Display* xDisplay = 0;
      48          17 :         GLXEWContext* glxewContext = 0;
      49          17 :         eq::Pipe* pipe = window->getPipe();
      50          17 :         Pipe* glxPipe = dynamic_cast< Pipe* >( pipe->getSystemPipe( ));
      51          17 :         if( glxPipe )
      52             :         {
      53          17 :             xDisplay = glxPipe->getXDisplay();
      54          17 :             glxewContext = glxPipe->glxewGetContext();
      55             :         }
      56          17 :         MessagePump* messagePump = 0;
      57          17 :         if( settings.getIAttribute(WindowSettings::IATTR_HINT_DRAWABLE) != OFF )
      58             :         {
      59             :             messagePump = dynamic_cast< MessagePump* >(
      60          15 :                                           pipe->isThreaded() ?
      61             :                                           pipe->getMessagePump() :
      62          15 :                                           pipe->getConfig()->getMessagePump( ));
      63             :         }
      64             :         return new Window( *window, settings, xDisplay, glxewContext,
      65          17 :                            messagePump );
      66             :     }
      67             : 
      68          15 :     eq::SystemPipe* createPipe( eq::Pipe* pipe ) const final
      69             :     {
      70          15 :         LBINFO << "Using glx::Pipe" << std::endl;
      71          15 :         return new Pipe( pipe );
      72             :     }
      73             : 
      74          15 :     eq::MessagePump* createMessagePump() const final
      75             :     {
      76          15 :         return new MessagePump;
      77             :     }
      78             : 
      79           0 :     bool setupFont( util::ObjectManager& gl, const void* key,
      80             :                     const std::string& name,
      81             :                     const uint32_t size ) const final
      82             :     {
      83           0 :         Display* display = XGetCurrentDisplay();
      84           0 :         LBASSERT( display );
      85           0 :         if( !display )
      86             :         {
      87           0 :             LBWARN << "No current X11 display, use eq::XSetCurrentDisplay()"
      88           0 :                    << std::endl;
      89           0 :             return false;
      90             :         }
      91             : 
      92             :         // see xfontsel
      93           0 :         std::stringstream font;
      94           0 :         font << "-*-";
      95             : 
      96           0 :         if( name.empty( ))
      97           0 :             font << "times";
      98             :         else
      99           0 :             font << name;
     100           0 :         font << "-*-r-*-*-" << size << "-*-*-*-*-*-*-*";
     101             : 
     102             :         // X11 font initialization is not thread safe. Using a mutex here is not
     103             :         // performance-critical
     104           0 :         static lunchbox::Lock lock;
     105           0 :         lunchbox::ScopedMutex<> mutex( lock );
     106             : 
     107           0 :         XFontStruct* fontStruct = XLoadQueryFont( display, font.str().c_str( ));
     108           0 :         if( !fontStruct )
     109             :         {
     110           0 :             LBWARN << "Can't load font " << font.str() << ", using fixed"
     111           0 :                    << std::endl;
     112           0 :             fontStruct = XLoadQueryFont( display, "fixed" );
     113             :         }
     114             : 
     115           0 :         LBASSERT( fontStruct );
     116             : 
     117           0 :         const GLuint lists = _setupLists( gl, key, 127 );
     118           0 :         glXUseXFont( fontStruct->fid, 0, 127, lists );
     119             : 
     120           0 :         XFreeFont( display, fontStruct );
     121           0 :         return true;
     122             :     }
     123             : 
     124          12 : } _glXFactory;
     125             : 
     126             : }
     127          36 : }

Generated by: LCOV version 1.10