diff options
author | Anton Fedchin <anightik@gmail.com> | 2017-01-25 18:47:59 +0300 |
---|---|---|
committer | Anton Fedchin <afedchin@ruswizards.com> | 2017-01-26 22:35:29 +0300 |
commit | 489e82ad086c683d8e814dc8401dd36887d629ab (patch) | |
tree | b25af3f63173005495920f9cf0574727457709b0 | |
parent | 1c8b8d3a3787b064ff8fee96f49880c999c9f588 (diff) |
[VideoPlayer] OverlayRendererDX: "mark" overlay as invalid on destroying device in case of fatal error.
-rw-r--r-- | xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.cpp | 28 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.h | 6 |
2 files changed, 33 insertions, 1 deletions
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.cpp index d5e36af13d..1d64eb4110 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.cpp +++ b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.cpp @@ -151,12 +151,14 @@ COverlayQuadsDX::COverlayQuadsDX(ASS_Image* images, int width, int height) CLog::Log(LOGERROR, "%s - failed to create vertex buffer", __FUNCTION__); m_texture.Release(); } - + else + g_Windowing.Register(this); delete[] vt; } COverlayQuadsDX::~COverlayQuadsDX() { + g_Windowing.Unregister(this); } void COverlayQuadsDX::Render(SRenderState &state) @@ -204,8 +206,18 @@ void COverlayQuadsDX::Render(SRenderState &state) pGUIShader->RestoreBuffers(); } +void COverlayQuadsDX::OnDestroyDevice(bool fatal) +{ + // fatal means that we have no valid buffer anymore + // resetting m_count will cause no rendering + if (fatal) + m_count = 0; +} + + COverlayImageDX::~COverlayImageDX() { + g_Windowing.Unregister(this); } COverlayImageDX::COverlayImageDX(CDVDOverlayImage* o) @@ -271,6 +283,7 @@ COverlayImageDX::COverlayImageDX(CDVDOverlayImage* o) m_width = (float)o->width; m_height = (float)o->height; } + g_Windowing.Register(this); } COverlayImageDX::COverlayImageDX(CDVDOverlaySpu* o) @@ -292,6 +305,8 @@ COverlayImageDX::COverlayImageDX(CDVDOverlaySpu* o) m_y = (float)(min_y + o->y); m_width = (float)(max_x - min_x); m_height = (float)(max_y - min_y); + + g_Windowing.Register(this); } void COverlayImageDX::Load(uint32_t* rgba, int width, int height, int stride) @@ -329,6 +344,9 @@ void COverlayImageDX::Load(uint32_t* rgba, int width, int height, int stride) void COverlayImageDX::Render(SRenderState &state) { + if (m_type == TYPE_NONE) + return; + ID3D11DeviceContext* pContext = g_Windowing.Get3D11Context(); CGUIShaderDX* pGUIShader = g_Windowing.GetGUIShader(); @@ -369,4 +387,12 @@ void COverlayImageDX::Render(SRenderState &state) pGUIShader->RestoreBuffers(); } +void OVERLAY::COverlayImageDX::OnDestroyDevice(bool fatal) +{ + // fatal means that we have no valid texture and buffer anymore + // resetting m_type will cause no rendering + if (fatal) + m_type = TYPE_NONE; +} + #endif diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.h b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.h index f5fd62bf3c..23e40839bd 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.h +++ b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRendererDX.h @@ -35,12 +35,15 @@ namespace OVERLAY { class COverlayQuadsDX : public COverlay + , public ID3DResource { public: COverlayQuadsDX(ASS_Image* images, int width, int height); virtual ~COverlayQuadsDX(); void Render(SRenderState& state); + void OnCreateDevice() override {} + void OnDestroyDevice(bool fatal) override; int m_count; DWORD m_fvf; @@ -50,6 +53,7 @@ namespace OVERLAY { class COverlayImageDX : public COverlay + , public ID3DResource { public: COverlayImageDX(CDVDOverlayImage* o); @@ -58,6 +62,8 @@ namespace OVERLAY { void Load(uint32_t* rgba, int width, int height, int stride); void Render(SRenderState& state); + void OnCreateDevice() override {} + void OnDestroyDevice(bool fatal) override; DWORD m_fvf; CD3DTexture m_texture; |