FSlateShaderResourceProxy* FSlateRHIResourceManager::GetShaderResource( const FSlateBrush& InBrush ) { check( IsThreadSafeForSlateRendering() ); FSlateShaderResourceProxy* Texture = NULL; if( !InBrush.IsDynamicallyLoaded() && !InBrush.HasUObject() ) { Texture = ResourceMap.FindRef( InBrush.GetResourceName() ); } else if (InBrush.GetResourceObject() && InBrush.GetResourceObject()->IsA<UMaterialInterface>()) { Texture = GetMaterialResource(InBrush); } else if( InBrush.IsDynamicallyLoaded() || ( InBrush.HasUObject() ) ) { if( InBrush.HasUObject() && InBrush.GetResourceObject() == nullptr ) { // Hack for loading via the deprecated path LoadUObjectForBrush( InBrush ); } Texture = FindOrCreateDynamicTextureResource( InBrush ); } return Texture; }
FSlateShaderResourceProxy* FSlateRHIResourceManager::GetTexture( const FSlateBrush& InBrush ) { check( IsThreadSafeForSlateRendering() ); FSlateShaderResourceProxy* Texture = NULL; if( !InBrush.IsDynamicallyLoaded() && !InBrush.HasUObject() ) { Texture = ResourceMap.FindRef( InBrush.GetResourceName() ); } else if( InBrush.IsDynamicallyLoaded() || ( InBrush.HasUObject() ) ) { Texture = GetDynamicTextureResource( InBrush ); } return Texture; }
/** * Loads a UTexture2D from a package and stores it in the cache * * @param TextureName The name of the texture to load */ bool FSlateRHIResourceManager::LoadTexture( const FName& TextureName, const FString& ResourcePath, uint32& Width, uint32& Height, TArray<uint8>& DecodedImage ) { check( IsThreadSafeForSlateRendering() ); bool bSucceeded = true; uint32 BytesPerPixel = 4; TArray<uint8> RawFileData; if( FFileHelper::LoadFileToArray( RawFileData, *ResourcePath ) ) { IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>( FName("ImageWrapper") ); IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper( EImageFormat::PNG ); if ( ImageWrapper.IsValid() && ImageWrapper->SetCompressed( RawFileData.GetData(), RawFileData.Num() ) ) { Width = ImageWrapper->GetWidth(); Height = ImageWrapper->GetHeight(); const TArray<uint8>* RawData = NULL; if (ImageWrapper->GetRaw( ERGBFormat::BGRA, 8, RawData)) { DecodedImage.AddUninitialized( Width*Height*BytesPerPixel ); DecodedImage = *RawData; } else { UE_LOG(LogSlate, Log, TEXT("Invalid texture format for Slate resource only RGBA and RGB pngs are supported: %s"), *TextureName.ToString() ); bSucceeded = false; } } else { UE_LOG(LogSlate, Log, TEXT("Only pngs are supported in Slate")); bSucceeded = false; } } else { UE_LOG(LogSlate, Log, TEXT("Could not find file for Slate resource: %s"), *TextureName.ToString() ); bSucceeded = false; } return bSucceeded; }
bool FSlateRenderer::IsViewportFullscreen( const SWindow& Window ) const { check( IsThreadSafeForSlateRendering() ); bool bFullscreen = false; if (FPlatformProperties::SupportsWindowedMode()) { if( GIsEditor) { bFullscreen = false; } else { bFullscreen = Window.GetWindowMode() == EWindowMode::Fullscreen; } } else { bFullscreen = true; } return bFullscreen; }
FSlateShaderResource* FSceneViewport::GetViewportRenderTargetTexture() const { check(IsThreadSafeForSlateRendering()); return (BufferedSlateHandles.Num() != 0) ? BufferedSlateHandles[CurrentBufferedTargetIndex] : nullptr; }