mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-13 02:08:52 +01:00
Not specifying height/width uses videos native size.
This commit is contained in:
parent
a81b1bc5ad
commit
a4c29eeb7b
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<float>(VideoInst->GetHeight()));
|
||||
GetBaseViewInfo()->SetImageWidth(static_cast<float>(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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -323,9 +323,20 @@ void GStreamerVideo::FreeElements()
|
||||
gst_object_unref(Playbin);
|
||||
Playbin = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int GStreamerVideo::GetHeight()
|
||||
{
|
||||
return static_cast<int>(Height);
|
||||
}
|
||||
|
||||
int GStreamerVideo::GetWidth()
|
||||
{
|
||||
return static_cast<int>(Width);
|
||||
}
|
||||
|
||||
|
||||
void GStreamerVideo::Draw()
|
||||
{
|
||||
FrameReady = false;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user