LCOV - code coverage report
Current view: top level - eq - windowStatistics.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 23 28 82.1 %
Date: 2017-12-16 05:07:20 Functions: 4 5 80.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2012, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *               2010-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 "windowStatistics.h"
      20             : 
      21             : #include "config.h"
      22             : #include "global.h"
      23             : #include "pipe.h"
      24             : #include "window.h"
      25             : 
      26             : #include <cstdio>
      27             : 
      28             : #ifdef _MSC_VER
      29             : #define snprintf _snprintf
      30             : #endif
      31             : 
      32             : namespace eq
      33             : {
      34           1 : WindowStatistics::WindowStatistics(const Statistic::Type type, Window* window)
      35           1 :     : StatisticSampler<Window>(type, window)
      36             : {
      37             :     const int32_t hint =
      38           1 :         _owner->getIAttribute(WindowSettings::IATTR_HINT_STATISTICS);
      39           1 :     if (hint == OFF)
      40           0 :         return;
      41             : 
      42           1 :     const std::string& name = window->getName();
      43           1 :     if (name.empty())
      44           0 :         snprintf(statistic.resourceName, 32, "Window %s",
      45           0 :                  window->getID().getShortString().c_str());
      46             :     else
      47           1 :         snprintf(statistic.resourceName, 32, "%s", name.c_str());
      48           1 :     statistic.resourceName[31] = 0;
      49             : 
      50           1 :     if (type != Statistic::WINDOW_FPS && hint == NICEST)
      51           1 :         window->finish();
      52             : 
      53           1 :     statistic.startTime = window->getConfig()->getTime();
      54             : }
      55             : 
      56           2 : WindowStatistics::~WindowStatistics()
      57             : {
      58             :     const int32_t hint =
      59           1 :         _owner->getIAttribute(WindowSettings::IATTR_HINT_STATISTICS);
      60           1 :     if (hint == OFF)
      61           0 :         return;
      62             : 
      63           1 :     if (statistic.frameNumber == 0) // does not belong to a frame
      64           0 :         return;
      65             : 
      66           1 :     if (statistic.type != Statistic::WINDOW_FPS && hint == NICEST)
      67           1 :         _owner->finish();
      68             : 
      69           1 :     statistic.endTime = _owner->getConfig()->getTime();
      70           1 :     if (statistic.endTime <= statistic.startTime)
      71           1 :         statistic.endTime = statistic.startTime + 1;
      72           1 :     _owner->processEvent(statistic);
      73           1 : }
      74          30 : }

Generated by: LCOV version 1.11