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 15 : const Viewport Viewport::FULL;
26 :
27 13 : 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 13 : Viewport contribution( segmentVP );
32 13 : contribution.intersect( viewVP );
33 13 : contribution.transform( viewVP );
34 :
35 : // extend by overdraw percentage
36 13 : LBASSERT( pvp.hasArea( ));
37 :
38 13 : const float xDelta(( static_cast< float >( overdraw.x() + pvp.w ) /
39 13 : static_cast< float >( pvp.w ) - 1.0f ) *
40 13 : contribution.w );
41 13 : contribution.x -= xDelta;
42 13 : contribution.w += (( static_cast< float >( overdraw.z() + pvp.w ) /
43 13 : static_cast< float >( pvp.w ) - 1.0f ) *
44 13 : contribution.w );
45 13 : contribution.w += xDelta;
46 :
47 13 : const float yDelta(( static_cast< float >( overdraw.y() + pvp.h ) /
48 13 : static_cast< float >( pvp.h ) - 1.0f ) *
49 13 : contribution.h );
50 13 : contribution.y -= yDelta;
51 13 : contribution.h += (( static_cast< float >( overdraw.w() + pvp.h ) /
52 13 : static_cast< float >( pvp.h ) - 1.0f ) *
53 13 : contribution.h );
54 13 : contribution.h += yDelta;
55 :
56 13 : x = contribution.x + x * contribution.w;
57 13 : y = contribution.y + y * contribution.h;
58 13 : w *= contribution.w;
59 13 : h *= contribution.h;
60 13 : }
61 :
62 : }
63 45 : }
|