LCOV - code coverage report
Current view: top level - eq/qt - windowFactory.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 1 20 5.0 %
Date: 2017-12-16 05:07:20 Functions: 2 4 50.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2015-2017, 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             : 
      22             : #include "detail/window.h"
      23             : 
      24             : #include <eq/pipe.h>
      25             : #include <eq/window.h>
      26             : 
      27             : #include <QGuiApplication>
      28             : 
      29             : namespace eq
      30             : {
      31             : namespace qt
      32             : {
      33           0 : Window* WindowFactory::onCreateImpl(eq::Window& window,
      34             :                                     const WindowSettings& settings,
      35             :                                     QThread* thread_)
      36             : {
      37             :     // Trying to infer the screen to use from the pipe device number.
      38             :     // We will simply assume that each QScreen belongs to a display and that
      39             :     // each GPU drives a different display. This will work for most setups,
      40             :     // but will break at the moment a single GPU is driving more than one
      41             :     // screen. The only solution in those cases is to adjust manually the
      42             :     // configuration to the setup.
      43             :     QGuiApplication* app =
      44           0 :         dynamic_cast<QGuiApplication*>(QCoreApplication::instance());
      45           0 :     LBASSERT(app);
      46             : 
      47           0 :     QList<QScreen*> screens = app->screens();
      48           0 :     QScreen* screen = nullptr;
      49           0 :     const unsigned int device = window.getPipe()->getDevice();
      50           0 :     if (device == LB_UNDEFINED_UINT32)
      51           0 :         screen = app->primaryScreen();
      52           0 :     else if (int(device) >= screens.size())
      53             :     {
      54           0 :         LBWARN << "Cannot used device number " << device << ", Qt detected "
      55           0 :                                                             "only "
      56             :                << screens.size() << " screens. Using the default"
      57           0 :                                     " screen instead"
      58           0 :                << std::endl;
      59           0 :         screen = app->primaryScreen();
      60             :     }
      61             :     else
      62           0 :         screen = screens[device];
      63             : 
      64           0 :     return new Window(window, settings, screen, thread_);
      65             : }
      66             : 
      67           0 : void WindowFactory::onDestroyImpl(detail::Window* window)
      68             : {
      69           0 :     delete window;
      70           0 : }
      71             : }
      72          30 : }

Generated by: LCOV version 1.11