| 865 | } |
| 866 | |
| 867 | void Tr2TextureAtlas::PaintEmptyArea( Tr2TextureAtlasArea* area ) |
| 868 | { |
| 869 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 870 | |
| 871 | if( !area || !m_paintEmptyAreas || !m_texture.IsValid() ) |
| 872 | { |
| 873 | return; |
| 874 | } |
| 875 | |
| 876 | if( m_texture.GetType() != TEX_TYPE_2D || |
| 877 | m_format != PIXEL_FORMAT_B8G8R8A8_UNORM ) |
| 878 | { |
| 879 | return; |
| 880 | } |
| 881 | |
| 882 | const bool isValidArea = |
| 883 | area->rect.left >= 0 && |
| 884 | area->rect.top >= 0 && |
| 885 | area->rect.right >= 0 && |
| 886 | area->rect.bottom >= 0 && |
| 887 | area->rect.right >= area->rect.left && |
| 888 | area->rect.bottom >= area->rect.top && |
| 889 | uint32_t( area->rect.right ) <= m_texture.GetWidth() && |
| 890 | uint32_t( area->rect.bottom ) <= m_texture.GetHeight(); |
| 891 | |
| 892 | CCP_ASSERT( isValidArea ); |
| 893 | if( !isValidArea ) |
| 894 | { |
| 895 | return; |
| 896 | } |
| 897 | |
| 898 | |
| 899 | void* rgba = nullptr; |
| 900 | uint32_t pitch = 0; |
| 901 | CR_RETURN( m_texture.MapForWriting( Tr2TextureSubresource( 0 ), rgba, pitch, renderContext ) ); |
| 902 | ON_BLOCK_EXIT( [&] { m_texture.UnmapForWriting( renderContext ); } ); |
| 903 | |
| 904 | uint8_t* dst = (uint8_t*)rgba; |
| 905 | |
| 906 | static unsigned int s_fillValue = 0; |
| 907 | s_fillValue += 0xabcdef; |
| 908 | s_fillValue &= 0xffffff; |
| 909 | |
| 910 | const uint32_t width = uint32_t( area->rect.right - area->rect.left ); |
| 911 | const uint32_t height = uint32_t( area->rect.bottom - area->rect.top ); |
| 912 | |
| 913 | if( IsCompressedFormat( m_format ) ) |
| 914 | { |
| 915 | const uint32_t blockSize = GetBlockByteSize( m_format ); |
| 916 | |
| 917 | const uint32_t blocksX = width / 4; |
| 918 | |
| 919 | // Have to copy one line at a time since the target area is not linearly laid out. |
| 920 | for( uint32_t line = 0; line < height; line += 4 ) |
| 921 | { |
| 922 | uint32_t* p = (uint32_t*)dst; |
| 923 | for( uint32_t i = 0; i < blocksX * blockSize / 4; ++i ) |
| 924 | { |
nothing calls this directly
no test coverage detected