LCOV - code coverage report
Current view: top level - eq/fabric - viewport.cpp (source / functions) Hit Total Coverage
Test: Equalizer Lines: 28 28 100.0 %
Date: 2017-12-16 05:07:20 Functions: 3 3 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2008-2010, Stefan Eilemann <eile@equalizergraphics.com>
       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 "viewport.h"
      19             : #include "pixelViewport.h"
      20             : 
      21             : namespace eq
      22             : {
      23             : namespace fabric
      24             : {
      25          20 : const Viewport Viewport::FULL;
      26             : 
      27          12 : void Viewport::applyView(const Viewport& segmentVP, const Viewport& viewVP,
      28             :                          const PixelViewport& pvp, const Vector4i& overdraw)
      29             : {
      30             :     // part of view covered by segment/view channel
      31          12 :     Viewport contribution(segmentVP);
      32          12 :     contribution.intersect(viewVP);
      33          12 :     contribution.transform(viewVP);
      34             : 
      35             :     // extend by overdraw percentage
      36          12 :     LBASSERT(pvp.hasArea());
      37             : 
      38             :     const float xDelta(
      39          12 :         (static_cast<float>(overdraw.x() + pvp.w) / static_cast<float>(pvp.w) -
      40             :          1.0f) *
      41          12 :         contribution.w);
      42          12 :     contribution.x -= xDelta;
      43          12 :     contribution.w +=
      44          12 :         ((static_cast<float>(overdraw.z() + pvp.w) / static_cast<float>(pvp.w) -
      45          12 :           1.0f) *
      46          24 :          contribution.w);
      47          12 :     contribution.w += xDelta;
      48             : 
      49             :     const float yDelta(
      50          12 :         (static_cast<float>(overdraw.y() + pvp.h) / static_cast<float>(pvp.h) -
      51             :          1.0f) *
      52          12 :         contribution.h);
      53          12 :     contribution.y -= yDelta;
      54          12 :     contribution.h +=
      55          12 :         ((static_cast<float>(overdraw.w() + pvp.h) / static_cast<float>(pvp.h) -
      56          12 :           1.0f) *
      57          24 :          contribution.h);
      58          12 :     contribution.h += yDelta;
      59             : 
      60          12 :     x = contribution.x + x * contribution.w;
      61          12 :     y = contribution.y + y * contribution.h;
      62          12 :     w *= contribution.w;
      63          12 :     h *= contribution.h;
      64          12 : }
      65             : }
      66          60 : }

Generated by: LCOV version 1.11