Merge pull request #26350 from jjd-uk/estuary_media_align
[xbmc.git] / xbmc / windowing / tvos / WinSystemTVOS.h
blob9d15ec897d2fceb9b8c2ac59feca5f05f1e71558
1 /*
2 * Copyright (C) 2010-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "rendering/gles/RenderSystemGLES.h"
12 #include "threads/CriticalSection.h"
13 #include "threads/Timer.h"
14 #include "windowing/OSScreenSaver.h"
15 #include "windowing/WinSystem.h"
17 #include <memory>
18 #include <string>
19 #include <vector>
21 #include <CoreVideo/CVOpenGLESTextureCache.h>
23 class IDispResource;
24 class CVideoSyncTVos;
25 struct CADisplayLinkWrapper;
27 class CWinSystemTVOS : public CWinSystemBase, public CRenderSystemGLES, public ITimerCallback
29 public:
30 CWinSystemTVOS();
31 virtual ~CWinSystemTVOS();
33 static void Register();
34 static std::unique_ptr<CWinSystemBase> CreateWinSystem();
36 // ITimerCallback interface
37 virtual void OnTimeout() override {}
39 void MessagePush(XBMC_Event* newEvent);
40 size_t GetQueueSize();
41 void AnnounceOnLostDevice();
42 void AnnounceOnResetDevice();
43 void StartLostDeviceTimer();
44 void StopLostDeviceTimer();
45 int GetDisplayIndexFromSettings();
46 // Implementation of CWinSystemBase
47 CRenderSystemBase* GetRenderSystem() override { return this; }
48 bool InitWindowSystem() override;
49 bool DestroyWindowSystem() override;
50 bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override;
51 bool DestroyWindow() override;
52 bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override;
53 bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override;
54 int GetBufferAge() override { return 3; }
55 void UpdateResolutions() override;
56 bool CanDoWindowed() override { return false; }
58 void ShowOSMouse(bool show) override {}
59 bool HasCursor() override;
61 void NotifyAppActiveChange(bool bActivated) override;
63 bool Minimize() override;
64 bool Restore() override;
65 bool Hide() override;
66 bool Show(bool raise = true) override;
68 bool IsExtSupported(const char* extension) const override;
70 bool BeginRender() override;
71 bool EndRender() override;
73 void Register(IDispResource* resource) override;
74 void Unregister(IDispResource* resource) override;
76 //virtual std::unique_ptr<CVideoSync> GetVideoSync(CVideoReferenceClock* clock) override;
78 std::vector<std::string> GetConnectedOutputs() override;
80 bool InitDisplayLink(CVideoSyncTVos* syncImpl);
81 void DeinitDisplayLink(void);
82 void OnAppFocusChange(bool focus);
83 bool IsBackgrounded() const { return m_bIsBackgrounded; }
84 CVEAGLContext GetEAGLContextObj();
86 // winevents override
87 bool MessagePump() override;
89 protected:
90 virtual std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() override;
91 void PresentRenderImpl(bool rendered) override;
92 void SetVSyncImpl(bool enable) override {}
94 void* m_glView; // EAGLView opaque
95 void* m_WorkingContext; // shared EAGLContext opaque
96 bool m_bWasFullScreenBeforeMinimize;
97 std::string m_eglext;
98 CCriticalSection m_resourceSection;
99 std::vector<IDispResource*> m_resources;
100 bool m_bIsBackgrounded;
101 CTimer m_lostDeviceTimer;
103 private:
104 bool GetScreenResolution(int* w, int* h, double* fps, int screenIdx);
105 void FillInVideoModes(int screenIdx);
106 bool SwitchToVideoMode(int width, int height, double refreshrate);
107 CADisplayLinkWrapper* m_pDisplayLink;