| 308 | } |
| 309 | |
| 310 | bool 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 | |
| 353 | bool Tr2AtlasTexture::LockBufferAndMargin( void*& data, unsigned& pitch, unsigned& margin ) |
| 354 | { |
no test coverage detected