LCOV - code coverage report
Current view: top level - eq/server/config - display.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 56 82 68.3 %
Date: 2017-12-16 05:07:20 Functions: 4 4 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2011-2015, Stefan Eilemann <eile@eyescale.h>
       3             :  *               2012-2014, Daniel Nachbaur <danielnachbaur@gmail.com>
       4             :  *
       5             :  * This library is free software; you can redistribute it and/or modify it under
       6             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       7             :  * by the Free Software Foundation.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      10             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      11             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      12             :  * details.
      13             :  *
      14             :  * You should have received a copy of the GNU Lesser General Public License
      15             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      16             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      17             :  */
      18             : 
      19             : #include "display.h"
      20             : 
      21             : #include "../canvas.h"
      22             : #include "../channel.h"
      23             : #include "../config.h"
      24             : #include "../layout.h"
      25             : #include "../node.h"
      26             : #include "../observer.h"
      27             : #include "../pipe.h"
      28             : #include "../segment.h"
      29             : #include "../view.h"
      30             : #include "../window.h"
      31             : #include "resources.h"
      32             : 
      33             : #include <eq/fabric/configParams.h>
      34             : 
      35             : namespace eq
      36             : {
      37             : namespace server
      38             : {
      39             : namespace config
      40             : {
      41             : namespace
      42             : {
      43           2 : void _choosePixelViewport(Window& window)
      44             : {
      45           2 :     int32_t width = window.getIAttribute(WindowSettings::IATTR_HINT_WIDTH);
      46           2 :     int32_t height = window.getIAttribute(WindowSettings::IATTR_HINT_HEIGHT);
      47           2 :     if (width == fabric::UNDEFINED && height == fabric::UNDEFINED)
      48             :     {
      49           2 :         window.setViewport(Viewport(.25f, .2f, .5f, .5f));
      50             : 
      51             :         // Make the window aspect ratio 16:10, assuming square pixels
      52           2 :         PixelViewport pvp = window.getPixelViewport();
      53           2 :         pvp.w = pvp.h * 1.6f;
      54             : 
      55             :         // Position window in the middle of the first monitor, assuming 16:10 AR
      56           2 :         pvp.x = pvp.w / 2;
      57           2 :         window.setPixelViewport(pvp);
      58           2 :         return;
      59             :     }
      60             : 
      61           0 :     const PixelViewport& pvp = window.getPipe()->getPixelViewport();
      62             :     const int32_t drawable =
      63           0 :         window.getIAttribute(WindowSettings::IATTR_HINT_DRAWABLE);
      64             : 
      65           0 :     if (width > 0)
      66             :     {
      67           0 :         if (drawable == fabric::WINDOW && pvp.isValid())
      68           0 :             width = std::min(pvp.w, width);
      69             :     }
      70           0 :     else if (pvp.isValid())
      71           0 :         width = pvp.w * .5f;
      72             :     else
      73           0 :         width = 860; // An arbitrary value
      74             : 
      75           0 :     if (height > 0)
      76             :     {
      77           0 :         if (drawable == fabric::WINDOW && pvp.isValid())
      78           0 :             height = std::min(pvp.h, height);
      79             :     }
      80           0 :     else if (pvp.isValid())
      81           0 :         height = pvp.h * .5f;
      82             :     else
      83           0 :         height = 540; // An arbitrary value
      84             : 
      85           0 :     const uint32_t x = (pvp.w - width) * 0.5;
      86           0 :     const uint32_t y = (pvp.h - height) * 0.5;
      87             : 
      88           0 :     window.setPixelViewport(PixelViewport(x, y, width, height));
      89             : }
      90             : }
      91             : 
      92           2 : void Display::discoverLocal(Config* config, const ConfigParams& params)
      93             : {
      94           2 :     Node* node = config->findAppNode();
      95           2 :     LBASSERT(node);
      96           2 :     if (!node)
      97           0 :         return;
      98             : 
      99           2 :     const Pipes& pipes = node->getPipes();
     100           2 :     LBASSERT(!pipes.empty());
     101           2 :     if (pipes.empty())
     102           0 :         return;
     103             : 
     104           2 :     Pipe* pipe = pipes.front();
     105           2 :     Window* window = new Window(pipe);
     106           2 :     _choosePixelViewport(*window);
     107           2 :     window->setName(params.getName());
     108           2 :     window->setIAttribute(WindowSettings::IATTR_PLANES_STENCIL, 1);
     109             : 
     110           2 :     Channel* channel = new Channel(window);
     111           2 :     channel->setName(pipe->getName() + " channel");
     112           2 :     Observer* observer = new Observer(config);
     113             : 
     114           2 :     const PixelViewport& pvp = pipe->getPixelViewport();
     115           2 :     const PixelViewport& windowPvp = window->getPixelViewport();
     116           2 :     Wall wall;
     117             : 
     118           2 :     if (windowPvp.isValid())
     119           2 :         wall.resizeHorizontalToAR(float(windowPvp.w) / float(windowPvp.h));
     120           0 :     else if (pvp.isValid())
     121           0 :         wall.resizeHorizontalToAR(float(pvp.w) / float(pvp.h));
     122             : 
     123           2 :     Canvas* canvas = new Canvas(config);
     124           2 :     canvas->setWall(wall);
     125             : 
     126           2 :     Segment* segment = new Segment(canvas);
     127           2 :     segment->setChannel(channel);
     128             : 
     129           4 :     Strings names;
     130           2 :     const Nodes& nodes = config->getNodes();
     131           2 :     const bool scalability = nodes.size() > 1 || pipes.size() > 1;
     132             : 
     133           2 :     if (scalability)
     134           2 :         names.push_back(EQ_SERVER_CONFIG_LAYOUT_2D_DYNAMIC);
     135             : 
     136           2 :     names.push_back(EQ_SERVER_CONFIG_LAYOUT_SIMPLE);
     137             : 
     138           2 :     if (scalability)
     139             :     {
     140           2 :         names.push_back(EQ_SERVER_CONFIG_LAYOUT_DB_DS);
     141           2 :         names.push_back(EQ_SERVER_CONFIG_LAYOUT_DB_STATIC);
     142           2 :         names.push_back(EQ_SERVER_CONFIG_LAYOUT_DB_DYNAMIC);
     143           2 :         names.push_back(EQ_SERVER_CONFIG_LAYOUT_2D_STATIC);
     144           2 :         names.push_back(EQ_SERVER_CONFIG_LAYOUT_SUBPIXEL);
     145             : 
     146           2 :         if (params.getFlags() & fabric::ConfigParams::FLAG_MULTIPROCESS_DB &&
     147           0 :             nodes.size() > 1)
     148             :         {
     149           0 :             for (NodesCIter i = nodes.begin(); i != nodes.end(); ++i)
     150             :             {
     151           0 :                 if ((*i)->getPipes().size() > 1)
     152             :                 {
     153           0 :                     names.push_back(EQ_SERVER_CONFIG_LAYOUT_DB_2D);
     154           0 :                     break;
     155             :                 }
     156             :             }
     157             :         }
     158             :     }
     159             : 
     160          16 :     for (StringsCIter i = names.begin(); i != names.end(); ++i)
     161             :     {
     162          14 :         Layout* layout = new Layout(config);
     163          14 :         layout->setName(*i);
     164             : 
     165          14 :         View* view = new View(layout);
     166          14 :         view->setObserver(observer);
     167          14 :         view->setWall(wall);
     168             : 
     169          14 :         canvas->addLayout(layout);
     170             :     }
     171             : 
     172           2 :     config->activateCanvas(canvas);
     173             : }
     174             : }
     175             : }
     176          60 : }

Generated by: LCOV version 1.11