LCOV - code coverage report
Current view: top level - eq/client - windowStatistics.cpp (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 25 27 92.6 %
Date: 2014-06-18 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             : 
      35           5 : WindowStatistics::WindowStatistics( const Statistic::Type type,
      36             :                                     Window* window )
      37           5 :         : StatisticSampler< Window >( type, window )
      38             : {
      39           5 :     const int32_t hint = _owner->getIAttribute( WindowSettings::IATTR_HINT_STATISTICS );
      40           5 :     if( hint == OFF )
      41           5 :         return;
      42             : 
      43           5 :     const std::string& name = window->getName();
      44           5 :     if( name.empty( ))
      45             :         snprintf( event.data.statistic.resourceName, 32, "Window %s",
      46           4 :                   window->getID().getShortString().c_str( ));
      47             :     else
      48           1 :         snprintf( event.data.statistic.resourceName, 32, "%s", name.c_str());
      49           5 :     event.data.statistic.resourceName[31] = 0;
      50             : 
      51           5 :     if( type != Statistic::WINDOW_FPS && hint == NICEST )
      52           4 :         window->finish();
      53             : 
      54           5 :     event.data.statistic.startTime  = window->getConfig()->getTime();
      55             : }
      56             : 
      57             : 
      58          10 : WindowStatistics::~WindowStatistics()
      59             : {
      60           5 :     const int32_t hint = _owner->getIAttribute( WindowSettings::IATTR_HINT_STATISTICS );
      61           5 :     if( hint == OFF )
      62           0 :         return;
      63             : 
      64           5 :     if( event.data.statistic.frameNumber == 0 ) // does not belong to a frame
      65           0 :         return;
      66             : 
      67           5 :     if( event.data.statistic.type != Statistic::WINDOW_FPS && hint == NICEST )
      68           4 :         _owner->finish();
      69             : 
      70           5 :     event.data.statistic.endTime = _owner->getConfig()->getTime();
      71           5 :     if( event.data.statistic.endTime <= event.data.statistic.startTime )
      72           1 :         event.data.statistic.endTime = event.data.statistic.startTime + 1;
      73           5 :     _owner->processEvent( event.data );
      74           5 : }
      75             : 
      76          36 : }

Generated by: LCOV version 1.10