| 351 | } |
| 352 | |
| 353 | bool Tr2AtlasTexture::LockBufferAndMargin( void*& data, unsigned& pitch, unsigned& margin ) |
| 354 | { |
| 355 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 356 | |
| 357 | Tr2TextureAL* texture = nullptr; |
| 358 | if( m_textureAtlas && m_atlasArea ) |
| 359 | { |
| 360 | texture = m_textureAtlas->GetTexture(); |
| 361 | } |
| 362 | else if( m_texture.IsValid() ) |
| 363 | { |
| 364 | texture = &m_texture; |
| 365 | } |
| 366 | |
| 367 | if( !m_textureAtlas || !m_atlasArea || m_isLocked || !texture || !texture->IsValid() ) |
| 368 | { |
| 369 | margin = 0; |
| 370 | return LockBuffer( data, pitch ); |
| 371 | } |
| 372 | |
| 373 | margin = m_textureAtlas->GetMargin(); |
| 374 | long hr = texture->MapForWriting( |
| 375 | Tr2TextureSubresource( 0 ).SetRect( uint32_t( m_x - margin ), uint32_t( m_y - margin ), uint32_t( m_x + m_width + margin ), uint32_t( m_y + m_height + margin ) ), |
| 376 | data, |
| 377 | pitch, |
| 378 | renderContext ) |
| 379 | .GetResult(); |
| 380 | |
| 381 | if( FAILED( hr ) ) |
| 382 | { |
| 383 | CCP_LOGERR( "Tr2AtlasTexture::LockBufferAndMargin failed - another atlas texture may be locked already (HR: %08lx)", hr ); |
| 384 | return false; |
| 385 | } |
| 386 | |
| 387 | m_isLocked = true; |
| 388 | |
| 389 | return true; |
| 390 | } |
| 391 | |
| 392 | void Tr2AtlasTexture::UnlockBuffer() |
| 393 | { |
no test coverage detected