| 11 | } |
| 12 | |
| 13 | TriStepResult TriStepCopyRenderTarget::Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ) |
| 14 | { |
| 15 | if( ( !m_destinationRT && !m_destinationTexture ) || !m_sourceRT ) |
| 16 | { |
| 17 | return RS_OK; |
| 18 | } |
| 19 | |
| 20 | unsigned destX = m_destinationViewport ? m_destinationViewport->x : 0; |
| 21 | unsigned destY = m_destinationViewport ? m_destinationViewport->y : 0; |
| 22 | |
| 23 | |
| 24 | HRESULT hr = 0; |
| 25 | |
| 26 | if( m_destinationRT ) |
| 27 | { |
| 28 | if( !m_sourceViewport ) |
| 29 | { |
| 30 | Tr2TextureSubresource dest( 0 ); |
| 31 | dest.SetRect( destX, destY, destX + m_sourceRT->GetWidth(), destY + m_sourceRT->GetHeight() ); |
| 32 | |
| 33 | if( m_destinationViewport ) |
| 34 | { |
| 35 | if( m_destinationViewport->x < 0 ) |
| 36 | { |
| 37 | dest.m_box.left = 0; |
| 38 | dest.m_box.right = uint32_t( int32_t( m_sourceRT->GetWidth() ) + int32_t( m_destinationViewport->x ) ); |
| 39 | } |
| 40 | if( m_destinationViewport->y < 0 ) |
| 41 | { |
| 42 | dest.m_box.top = 0; |
| 43 | dest.m_box.bottom = uint32_t( int32_t( m_sourceRT->GetHeight() ) + int32_t( m_destinationViewport->y ) ); |
| 44 | } |
| 45 | } |
| 46 | hr = m_destinationRT->GetRenderTarget().CopySubresourceRegion( dest, *m_sourceRT, Tr2TextureSubresource( 0 ), renderContext ); |
| 47 | } |
| 48 | else |
| 49 | { |
| 50 | const auto& vp = *m_sourceViewport; |
| 51 | Tr2TextureSubresource src( 0 ); |
| 52 | src.SetRect( (uint32_t)vp.x, (uint32_t)vp.y, (uint32_t)( vp.x + vp.width ), (uint32_t)( vp.y + vp.height ) ); |
| 53 | if( vp.width <= 0 || vp.height <= 0 ) |
| 54 | { |
| 55 | return RS_OK; |
| 56 | } |
| 57 | |
| 58 | if( m_destinationViewport ) |
| 59 | { |
| 60 | if( m_destinationViewport->x < 0 ) |
| 61 | { |
| 62 | destX = 0; |
| 63 | src.m_box.right -= uint32_t( -m_destinationViewport->x ); |
| 64 | } |
| 65 | if( m_destinationViewport->y < 0 ) |
| 66 | { |
| 67 | destY = 0; |
| 68 | src.m_box.bottom -= uint32_t( -m_destinationViewport->y ); |
| 69 | } |
| 70 | } |
nothing calls this directly
no test coverage detected