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

Method LockBuffer

trinity/Tr2AtlasTexture.cpp:310–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310bool Tr2AtlasTexture::LockBuffer( void*& pData, unsigned int& pitch )
311{
312 USE_MAIN_THREAD_RENDER_CONTEXT();
313
314 Tr2TextureAL* texture = nullptr;
315 if( m_textureAtlas && m_atlasArea )
316 {
317 texture = m_textureAtlas->GetTexture();
318 }
319 else if( m_texture.IsValid() )
320 {
321 texture = &m_texture;
322 }
323
324 if( !texture || !texture->IsValid() )
325 {
326 return false;
327 }
328
329 if( m_isLocked )
330 {
331 CCP_LOGERR( "Tr2AtlasTexture::LockBuffer failed - texture is already locked" );
332 return false;
333 }
334
335 long hr = texture->MapForWriting(
336 Tr2TextureSubresource( 0 ).SetRect( uint32_t( m_x ), uint32_t( m_y ), uint32_t( m_x + m_width ), uint32_t( m_y + m_height ) ),
337 pData,
338 pitch,
339 renderContext )
340 .GetResult();
341
342 if( FAILED( hr ) )
343 {
344 CCP_LOGERR( "Tr2AtlasTexture::LockBuffer failed - another atlas texture may be locked already (HR: %08lx)", hr );
345 return false;
346 }
347
348 m_isLocked = true;
349
350 return true;
351}
352
353bool Tr2AtlasTexture::LockBufferAndMargin( void*& data, unsigned& pitch, unsigned& margin )
354{

Callers 5

PyLockBufferFunction · 0.80
DrawToAtlasTextureMethod · 0.80
OnPrepareResourcesMethod · 0.80
FlashDefaultTextureMethod · 0.80

Calls 6

SetRectMethod · 0.80
GetTextureMethod · 0.45
IsValidMethod · 0.45
GetResultMethod · 0.45
MapForWritingMethod · 0.45

Tested by

no test coverage detected