| 1029 | } |
| 1030 | |
| 1031 | BlueStdResult TriTextureRes::CreateFromTexture( TriTextureRes* texture ) |
| 1032 | { |
| 1033 | if( this == texture ) |
| 1034 | { |
| 1035 | return BLUE_STD_RESULT_OK; |
| 1036 | } |
| 1037 | if( !texture || !texture->IsGood() || !texture->GetTexture() ) |
| 1038 | { |
| 1039 | return BlueStdResult( BLUE_STD_RESULT_VALUE_ERROR, "invalid texture" ); |
| 1040 | } |
| 1041 | if( !Tr2Renderer::IsResourceCreationAllowed() ) |
| 1042 | { |
| 1043 | return BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "resource creation is not allowed at this time" ); |
| 1044 | } |
| 1045 | |
| 1046 | DestroyOwnTexture(); |
| 1047 | |
| 1048 | auto& other = *texture->GetTexture(); |
| 1049 | auto width = other.GetWidth(); |
| 1050 | auto height = other.GetHeight(); |
| 1051 | |
| 1052 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 1053 | |
| 1054 | Tr2BitmapDimensions bd( other.GetDesc() ); |
| 1055 | |
| 1056 | CR_RETURN_VAL( m_ownTexture.Create( |
| 1057 | Tr2BitmapDimensions( width, height, other.GetTrueMipCount(), other.GetFormat() ), |
| 1058 | Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, |
| 1059 | Tr2CpuUsage::READ, |
| 1060 | renderContext ), |
| 1061 | BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "could not create a texture" ) ); |
| 1062 | |
| 1063 | CR_RETURN_VAL( |
| 1064 | m_ownTexture.CopySubresourceRegion( Tr2TextureSubresource(), other, Tr2TextureSubresource(), renderContext ), |
| 1065 | BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "could not copy a texture" ) ); |
| 1066 | m_isTextureResizable = false; |
| 1067 | return BLUE_STD_RESULT_OK; |
| 1068 | } |
| 1069 | |
| 1070 | bool TriTextureRes::Create( uint32_t width, |
| 1071 | uint32_t height, |
nothing calls this directly
no test coverage detected