MCPcopy Create free account
hub / github.com/carbonengine/trinity / Execute

Method Execute

trinity/RenderJob/TriStepCopyRenderTarget.cpp:13–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13TriStepResult 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 }

Callers

nothing calls this directly

Calls 7

SetRectMethod · 0.80
GetRenderTargetMethod · 0.80
GetWidthMethod · 0.45
GetHeightMethod · 0.45
CopySubresourceRegionMethod · 0.45
GetTextureMethod · 0.45

Tested by

no test coverage detected