diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 19a9cd8..d0cecf4 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -65,6 +65,14 @@ void ReloadableMedia::Update(float dt) if(LoadedComponent) { + + // video needs to run a frame to start getting size info + if(GetBaseViewInfo()->GetImageHeight() == 0 && GetBaseViewInfo()->GetImageWidth() == 0) + { + GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth()); + GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight()); + } + LoadedComponent->Update(dt); } @@ -147,6 +155,8 @@ void ReloadableMedia::ReloadTexture() if(LoadedComponent) { LoadedComponent->AllocateGraphicsMemory(); + GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth()); + GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight()); found = true; } } diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.cpp b/RetroFE/Source/Graphics/Component/VideoComponent.cpp index c5da5ea..000339d 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.cpp +++ b/RetroFE/Source/Graphics/Component/VideoComponent.cpp @@ -45,6 +45,13 @@ void VideoComponent::Update(float dt) if(IsPlaying) { VideoInst->Update(dt); + + // video needs to run a frame to start getting size info + if(GetBaseViewInfo()->GetImageHeight() == 0 && GetBaseViewInfo()->GetImageWidth() == 0) + { + GetBaseViewInfo()->SetImageHeight(static_cast(VideoInst->GetHeight())); + GetBaseViewInfo()->SetImageWidth(static_cast(VideoInst->GetWidth())); + } } Component::Update(dt); @@ -69,6 +76,15 @@ void VideoComponent::FreeGraphicsMemory() Component::FreeGraphicsMemory(); } +void VideoComponent::LaunchEnter() +{ + FreeGraphicsMemory(); +} +void VideoComponent::LaunchExit() +{ + AllocateGraphicsMemory(); +} + void VideoComponent::Draw() { ViewInfo *info = GetBaseViewInfo(); diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.h b/RetroFE/Source/Graphics/Component/VideoComponent.h index c4073ab..a46631b 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.h +++ b/RetroFE/Source/Graphics/Component/VideoComponent.h @@ -30,14 +30,8 @@ public: void Draw(); void FreeGraphicsMemory(); void AllocateGraphicsMemory(); - void LaunchEnter() - { - FreeGraphicsMemory(); - } - void LaunchExit() - { - AllocateGraphicsMemory(); - } + void LaunchEnter(); + void LaunchExit(); private: std::string VideoFile; diff --git a/RetroFE/Source/Video/GStreamerVideo.cpp b/RetroFE/Source/Video/GStreamerVideo.cpp index 69145d9..16f3437 100644 --- a/RetroFE/Source/Video/GStreamerVideo.cpp +++ b/RetroFE/Source/Video/GStreamerVideo.cpp @@ -323,9 +323,20 @@ void GStreamerVideo::FreeElements() gst_object_unref(Playbin); Playbin = NULL; } - } + +int GStreamerVideo::GetHeight() +{ + return static_cast(Height); +} + +int GStreamerVideo::GetWidth() +{ + return static_cast(Width); +} + + void GStreamerVideo::Draw() { FrameReady = false; diff --git a/RetroFE/Source/Video/GStreamerVideo.h b/RetroFE/Source/Video/GStreamerVideo.h index 2918c6e..101fef3 100644 --- a/RetroFE/Source/Video/GStreamerVideo.h +++ b/RetroFE/Source/Video/GStreamerVideo.h @@ -38,6 +38,8 @@ public: void Draw(); void SetNumLoops(int n); void FreeElements(); + int GetHeight(); + int GetWidth(); private: static void ProcessNewBuffer (GstElement *fakesink, GstBuffer *buf, GstPad *pad, gpointer data); diff --git a/RetroFE/Source/Video/IVideo.h b/RetroFE/Source/Video/IVideo.h index ad4126e..5dface7 100644 --- a/RetroFE/Source/Video/IVideo.h +++ b/RetroFE/Source/Video/IVideo.h @@ -29,4 +29,6 @@ public: virtual SDL_Texture *GetTexture() const = 0; virtual void Update(float dt) = 0; virtual void Draw() = 0; + virtual int GetHeight() = 0; + virtual int GetWidth() = 0; };