Called on background thread
| 570 | |
| 571 | // Called on background thread |
| 572 | BlueAsyncRes::LoadingResult TriTextureRes::DoLoad() |
| 573 | { |
| 574 | CCP_STATS_ZONE( __FUNCTION__ ); |
| 575 | |
| 576 | BeTimer t; |
| 577 | |
| 578 | m_originalMemoryUse = 0; |
| 579 | |
| 580 | if( m_isTextureLoadDisabled ) |
| 581 | { |
| 582 | return LR_FAILED; |
| 583 | } |
| 584 | |
| 585 | // check if this is a cube map texture or not |
| 586 | if( m_path.find( L"_cube" ) != m_path.npos ) |
| 587 | { |
| 588 | m_type = TEX_TYPE_CUBE; |
| 589 | } |
| 590 | else if( m_path.find( L"_volume" ) != m_path.npos ) |
| 591 | { |
| 592 | m_type = TEX_TYPE_3D; |
| 593 | } |
| 594 | else |
| 595 | { |
| 596 | m_type = TEX_TYPE_2D; |
| 597 | } |
| 598 | |
| 599 | if( m_loadedBitmap && m_lodEnabled ) |
| 600 | { |
| 601 | Tr2TextureLodManager::Instance().CpuTextureDestroyed( *m_loadedBitmap ); |
| 602 | } |
| 603 | |
| 604 | CcpThreadSleep( s_diskLatencySimulation ); |
| 605 | |
| 606 | m_loadedBitmap.reset( CCP_NEW( "TriTextureRes::m_loadedBitmap" ) ImageIO::HostBitmap ); |
| 607 | CCP_ASSERT( m_loadedBitmap != nullptr ); |
| 608 | |
| 609 | ImageIO::Result result; |
| 610 | auto mipSkip = m_requestedLoadMip + ComputeMipSkipCount(); |
| 611 | ImageIO::LoadParameters params( m_path.c_str(), mipSkip, m_mipLevelMaxCount ); |
| 612 | result = ImageIO::ReadImage( *m_dataStream, params, *m_loadedBitmap, &m_metadata ); |
| 613 | |
| 614 | if( !result ) |
| 615 | { |
| 616 | CCP_LOGERR( "Tr2ImageHandler failed to load texture '%S': %s", GetPath(), result.GetErrorMessage().c_str() ); |
| 617 | m_loadedBitmap.reset(); |
| 618 | } |
| 619 | else if( IsTga( GetPath() ) ) |
| 620 | { |
| 621 | if( !m_loadedBitmap->GenerateMipMaps() ) |
| 622 | { |
| 623 | CCP_LOGERR( "Tr2ImageHandler failed to generate mipmaps for texture '%S'", GetPath() ); |
| 624 | m_loadedBitmap.reset(); |
| 625 | } |
| 626 | } |
| 627 | if( result ) |
| 628 | { |
| 629 | m_loadedBitmap->GetAverageColor( m_averageColor.r, m_averageColor.g, m_averageColor.b, m_averageColor.a ); |
nothing calls this directly
no test coverage detected