LCOV - code coverage report
Current view: top level - eq/glx - windowSystem.h (source / functions) Hit Total Coverage
Test: Equalizer Lines: 18 43 41.9 %
Date: 2017-12-16 05:07:20 Functions: 7 8 87.5 %

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

Generated by: LCOV version 1.11