| 1 |
/* |
| 2 |
* Copyright (C) 2010-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 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" |
| 16 |
|
| 17 |
#include <memory> |
| 18 |
#include <string> |
| 19 |
#include <vector> |
| 20 |
|
| 21 |
#include <CoreVideo/CVOpenGLESTextureCache.h> |
| 22 |
|
| 23 |
class IDispResource; |
| 24 |
class CVideoSyncTVos; |
| 25 |
struct CADisplayLinkWrapper; |
| 26 |
|
| 27 |
class CWinSystemTVOS : public CWinSystemBase, public CRenderSystemGLES, public ITimerCallback |
| 28 |
{ |
| 29 |
public: |
| 30 |
CWinSystemTVOS(); |
| 31 |
virtual ~CWinSystemTVOS(); |
| 32 |
|
| 33 |
static void Register(); |
| 34 |
static std::unique_ptr<CWinSystemBase> CreateWinSystem(); |
| 35 |
|
| 36 |
// ITimerCallback interface |
| 37 |
virtual void OnTimeout() override {} |
| 38 |
|
| 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 |
void UpdateResolutions() override; |
| 55 |
bool CanDoWindowed() override { return false; } |
| 56 |
|
| 57 |
void ShowOSMouse(bool show) override {} |
| 58 |
bool HasCursor() override; |
| 59 |
|
| 60 |
void NotifyAppActiveChange(bool bActivated) override; |
| 61 |
|
| 62 |
bool Minimize() override; |
| 63 |
bool Restore() override; |
| 64 |
bool Hide() override; |
| 65 |
bool Show(bool raise = true) override; |
| 66 |
|
| 67 |
bool IsExtSupported(const char* extension) const override; |
| 68 |
|
| 69 |
bool BeginRender() override; |
| 70 |
bool EndRender() override; |
| 71 |
|
| 72 |
void Register(IDispResource* resource) override; |
| 73 |
void Unregister(IDispResource* resource) override; |
| 74 |
|
| 75 |
//virtual std::unique_ptr<CVideoSync> GetVideoSync(CVideoReferenceClock* clock) override; |
| 76 |
|
| 77 |
std::vector<std::string> GetConnectedOutputs() override; |
| 78 |
|
| 79 |
bool InitDisplayLink(CVideoSyncTVos* syncImpl); |
| 80 |
void DeinitDisplayLink(void); |
| 81 |
void OnAppFocusChange(bool focus); |
| 82 |
bool IsBackgrounded() const { return m_bIsBackgrounded; } |
| 83 |
CVEAGLContext GetEAGLContextObj(); |
| 84 |
|
| 85 |
// winevents override |
| 86 |
bool MessagePump() override; |
| 87 |
|
| 88 |
protected: |
| 89 |
virtual std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl() override; |
| 90 |
void PresentRenderImpl(bool rendered) override; |
| 91 |
void SetVSyncImpl(bool enable) override {} |
| 92 |
|
| 93 |
void* m_glView; // EAGLView opaque |
| 94 |
void* m_WorkingContext; // shared EAGLContext opaque |
| 95 |
bool m_bWasFullScreenBeforeMinimize; |
| 96 |
std::string m_eglext; |
| 97 |
CCriticalSection m_resourceSection; |
| 98 |
std::vector<IDispResource*> m_resources; |
| 99 |
bool m_bIsBackgrounded; |
| 100 |
CTimer m_lostDeviceTimer; |
| 101 |
|
| 102 |
private: |
| 103 |
bool GetScreenResolution(int* w, int* h, double* fps, int screenIdx); |
| 104 |
void FillInVideoModes(int screenIdx); |
| 105 |
bool SwitchToVideoMode(int width, int height, double refreshrate); |
| 106 |
CADisplayLinkWrapper* m_pDisplayLink; |
| 107 |
}; |