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

Method SharedCopyFaceFromRenderTarget

trinity/Tr2HostBitmap.cpp:61–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61bool Tr2HostBitmap::SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::CubemapFace face, Tr2TextureAL& rtAL, const int* srcRect, int offsetX, int offsetY, Tr2RenderContext& renderContext )
62{
63 bool alphaConvert = false;
64 if( !CheckForMatch( rtAL.GetDesc(), srcRect == nullptr, alphaConvert, "CopyFromRenderTarget" ) )
65 {
66 return false;
67 }
68
69 if( !rtAL.IsValid() || IsCompressed() )
70 {
71 CCP_LOGWARN( "CopyFromRenderTarget: invalid source" );
72 return false;
73 }
74
75 int left = 0;
76 int top = 0;
77 int right = rtAL.GetWidth();
78 int bottom = rtAL.GetHeight();
79
80 if( srcRect )
81 {
82 left = max( left, srcRect[0] );
83 top = max( top, srcRect[1] );
84 right = min( right, srcRect[2] );
85 bottom = min( bottom, srcRect[3] );
86 }
87 if( offsetX < 0 )
88 {
89 left = max( left, -offsetX );
90 right = min( right, int( rtAL.GetWidth() ) + offsetX );
91 }
92 if( offsetY < 0 )
93 {
94 top = max( top, -offsetY );
95 bottom = min( bottom, int( rtAL.GetHeight() ) + offsetY );
96 }
97 offsetX += left;
98 offsetY += top;
99
100 if( left >= right ||
101 top >= bottom ||
102 int( m_width ) < offsetX ||
103 int( m_height ) < offsetY )
104 {
105 return true;
106 }
107
108 unsigned width = min( unsigned( right - left ), m_width - offsetX );
109 unsigned height = min( unsigned( bottom - top ), m_height - offsetY );
110
111 const unsigned mipCount = std::min( GetTrueMipCount(), rtAL.GetTrueMipCount() );
112
113 for( unsigned mipLevel = 0; mipLevel != mipCount; ++mipLevel )
114 {
115 const void* data;
116 unsigned srcPitch;
117 if( FAILED( rtAL.MapForReading( Tr2TextureSubresource( mipLevel ), data, srcPitch, renderContext ) ) )
118 {

Callers

nothing calls this directly

Calls 7

GetTrueMipCountMethod · 0.80
IsValidMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45
MapForReadingMethod · 0.45
UnmapForReadingMethod · 0.45

Tested by

no test coverage detected