---------------------------------------------------------------
| 1157 | |
| 1158 | // --------------------------------------------------------------- |
| 1159 | bool TriTextureRes::SetTexture( Tr2TextureAL& texture ) |
| 1160 | { |
| 1161 | if( m_memoryUse ) |
| 1162 | { |
| 1163 | CCP_STATS_ADD( textureResBytes, -int( m_memoryUse ) ); |
| 1164 | m_memoryUse = 0; |
| 1165 | } |
| 1166 | |
| 1167 | if( !texture.IsValid() ) |
| 1168 | { |
| 1169 | m_texture = nullptr; |
| 1170 | SetPrepared( false ); |
| 1171 | SetGood( false ); |
| 1172 | |
| 1173 | Tr2BitmapDimensions::Destroy(); |
| 1174 | |
| 1175 | m_onTextureChange(); |
| 1176 | return true; |
| 1177 | } |
| 1178 | |
| 1179 | *static_cast<Tr2BitmapDimensions*>( this ) = texture.GetDesc(); |
| 1180 | m_texture = &texture; |
| 1181 | |
| 1182 | // Estimate memory use for the resource cache. |
| 1183 | m_memoryUse = 0; |
| 1184 | auto mipCount = GetTrueMipCount(); |
| 1185 | for( uint32_t i = 0; i < mipCount; ++i ) |
| 1186 | { |
| 1187 | m_memoryUse += GetMipSize( i ); |
| 1188 | } |
| 1189 | m_memoryUse *= std::max( 1u, GetArraySize() ); |
| 1190 | CCP_STATS_ADD( textureResBytes, m_memoryUse ); |
| 1191 | |
| 1192 | SetPrepared( true ); |
| 1193 | SetGood( true ); |
| 1194 | m_onTextureChange(); |
| 1195 | return true; |
| 1196 | } |
| 1197 | |
| 1198 | // -------------------------------------------------------------------------------------- |
| 1199 | // Description: |
no test coverage detected