LCOV - code coverage report
Current view: top level - eq/qt - windowFactory.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 18 5.6 %
Date: 2016-09-29 05:02:09 Functions: 2 4 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2015, Stefan.Eilemann@epfl.ch
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #include "windowFactory.h"
      19             : 
      20             : #include "window.h"
      21             : #include "windowImpl.h"
      22             : 
      23             : #include "eq/pipe.h"
      24             : 
      25             : #include <QGuiApplication>
      26             : 
      27             : namespace eq
      28             : {
      29             : namespace qt
      30             : {
      31             : 
      32           0 : detail::Window* WindowFactory::onCreateImpl( const eq::Pipe* pipe,
      33             :                                              const WindowSettings& settings,
      34             :                                              QThread* thread_ )
      35             : {
      36             :     // Trying to infer the screen to use from the pipe device number.
      37             :     // We will simply assume that each QScreen belongs to a display and that
      38             :     // each GPU drives a different display. This will work for most setups,
      39             :     // but will break at the moment a single GPU is driving more than one
      40             :     // screen. The only solution in those cases is to adjust manually the
      41             :     // configuration to the setup.
      42             :     QGuiApplication* app =
      43           0 :         dynamic_cast< QGuiApplication* >( QCoreApplication::instance( ));
      44           0 :     LBASSERT(app);
      45             : 
      46           0 :     QList< QScreen* > screens = app->screens();
      47             :     QScreen* screen;
      48           0 :     const unsigned int device = pipe->getDevice();
      49           0 :     if( device == LB_UNDEFINED_UINT32 )
      50           0 :         screen = app->primaryScreen();
      51           0 :     else if( int(device) >= screens.size( ))
      52             :     {
      53           0 :         LBWARN << "Cannot used device number " << device << ", Qt detected "
      54           0 :                   "only " << screens.size() << " screens. Using the default"
      55           0 :                   " screen instead" << std::endl;
      56           0 :         screen = app->primaryScreen();
      57             :     }
      58             :     else
      59             :     {
      60           0 :         screen = screens[device];
      61             :     }
      62           0 :     return Window::createImpl( settings, screen, thread_ );
      63             : }
      64             : 
      65           0 : void WindowFactory::onDestroyImpl( detail::Window* window )
      66             : {
      67           0 :     delete window;
      68           0 : }
      69             : 
      70             : }
      71          42 : }

Generated by: LCOV version 1.11