xbmc
GUIGameRenderManager.h
1 /*
2  * Copyright (C) 2017-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 "cores/GameSettings.h"
12 #include "threads/CriticalSection.h"
13 
14 #include <map>
15 #include <memory>
16 
17 namespace KODI
18 {
19 namespace GAME
20 {
21 class CDialogGameAdvancedSettings;
22 class CDialogGameVideoSelect;
23 } // namespace GAME
24 
25 namespace RETRO
26 {
27 class CGameWindowFullScreen;
28 class CGUIGameControl;
29 class CGUIGameSettingsHandle;
30 class CGUIGameVideoHandle;
31 class CGUIRenderTargetFactory;
32 class CGUIRenderHandle;
33 class CGUIRenderTarget;
34 class IGameCallback;
35 class IRenderCallback;
36 class IPlayback;
37 
70 {
71  // Classes that call into the protected interface
72  friend class CGUIGameSettingsHandle;
73  friend class CGUIGameVideoHandle;
74  friend class CGUIRenderHandle;
75 
76 public:
77  CGUIGameRenderManager() = default;
79 
87  void RegisterPlayer(CGUIRenderTargetFactory* factory,
88  IRenderCallback* callback,
89  IGameCallback* gameCallback);
90 
94  void UnregisterPlayer();
95 
103  std::shared_ptr<CGUIRenderHandle> RegisterControl(CGUIGameControl& control);
104 
112  std::shared_ptr<CGUIRenderHandle> RegisterWindow(CGameWindowFullScreen& window);
113 
122  std::shared_ptr<CGUIGameVideoHandle> RegisterDialog(GAME::CDialogGameVideoSelect& dialog);
123 
129  std::shared_ptr<CGUIGameSettingsHandle> RegisterGameSettingsDialog();
130 
131 protected:
132  // Functions exposed to friend class CGUIRenderHandle
133  void UnregisterHandle(CGUIRenderHandle* handle);
134  void Render(CGUIRenderHandle* handle);
135  void RenderEx(CGUIRenderHandle* handle);
136  void ClearBackground(CGUIRenderHandle* handle);
137  bool IsDirty(CGUIRenderHandle* handle);
138 
139  // Functions exposed to friend class CGUIGameVideoHandle
140  void UnregisterHandle(CGUIGameVideoHandle* handle) {}
141  bool IsPlayingGame();
142  bool SupportsRenderFeature(RENDERFEATURE feature);
143  bool SupportsScalingMethod(SCALINGMETHOD method);
144 
145  // Functions exposed to CGUIGameSettingsHandle
146  void UnregisterHandle(CGUIGameSettingsHandle* handle) {}
147  std::string GameClientID();
148  std::string GetPlayingGame();
149  std::string CreateSavestate(bool autosave);
150  bool UpdateSavestate(const std::string& savestatePath);
151  bool LoadSavestate(const std::string& savestatePath);
152  void FreeSavestateResources(const std::string& savestatePath);
153  void CloseOSD();
154 
155 private:
160  void UpdateRenderTargets();
161 
169  CGUIRenderTarget* CreateRenderTarget(CGUIRenderHandle* handle);
170 
171  // Render events
172  CGUIRenderTargetFactory* m_factory = nullptr;
173  std::map<CGUIRenderHandle*, std::shared_ptr<CGUIRenderTarget>> m_renderTargets;
174  CCriticalSection m_targetMutex;
175 
176  // Video properties
177  IRenderCallback* m_callback = nullptr;
178  CCriticalSection m_callbackMutex;
179 
180  // Game properties
181  IGameCallback* m_gameCallback = nullptr;
182  CCriticalSection m_gameCallbackMutex;
183 };
184 } // namespace RETRO
185 } // namespace KODI
Definition: GUIGameSettingsHandle.h:20
Definition: GUIRenderHandle.h:27
Definition: GUIGameVideoHandle.h:19
Definition: DialogGameVideoSelect.h:27
Definition: IGameCallback.h:19
Definition: GUIGameControl.h:29
A target of rendering commands.
Definition: GUIRenderTarget.h:27
Definition: IRenderCallback.h:17
Controller configuration window.
Definition: AudioDecoder.h:18
Definition: GUIRenderTargetFactory.h:20
Definition: GameWindowFullScreen.h:22
Class to safely route commands between the GUI and RetroPlayer.
Definition: GUIGameRenderManager.h:69