kodi
BaseRenderer.h
1 /*
2  * Copyright (C) 2005-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 "DebugInfo.h"
12 #include "RenderCapture.h"
13 #include "RenderInfo.h"
14 #include "VideoShaders/ShaderFormats.h"
15 #include "cores/IPlayer.h"
16 #include "cores/VideoPlayer/Buffers/VideoBuffer.h"
17 #include "utils/Geometry.h"
18 
19 #include <utility>
20 #include <vector>
21 
22 #define MAX_FIELDS 3
23 #define NUM_BUFFERS 6
24 
25 class CSetting;
27 
28 enum EFIELDSYNC
29 {
30  FS_NONE,
31  FS_TOP,
32  FS_BOT
33 };
34 
35 // Render Methods
36 enum RenderMethods
37 {
38  RENDER_METHOD_AUTO = 0,
39  RENDER_METHOD_GLSL,
40  RENDER_METHOD_SOFTWARE,
41  RENDER_METHOD_D3D_PS,
42  RENDER_METHOD_DXVA,
43  RENDER_OVERLAYS = 99 // to retain compatibility
44 };
45 
46 struct VideoPicture;
47 
49 {
50 public:
51  CBaseRenderer();
52  virtual ~CBaseRenderer();
53 
54  // Player functions
55  virtual bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) = 0;
56  virtual bool IsConfigured() = 0;
57  virtual void AddVideoPicture(const VideoPicture &picture, int index) = 0;
58  virtual bool IsPictureHW(const VideoPicture& picture) { return false; }
59  virtual void UnInit() = 0;
60  virtual bool Flush(bool saveBuffers) { return false; }
61  virtual void SetBufferSize(int numBuffers) { }
62  virtual void ReleaseBuffer(int idx) { }
63  virtual bool NeedBuffer(int idx) { return false; }
64  virtual bool IsGuiLayer() { return true; }
65  // Render info, can be called before configure
66  virtual CRenderInfo GetRenderInfo() { return CRenderInfo(); }
67  virtual void Update() = 0;
68  virtual void RenderUpdate(int index, int index2, bool clear, unsigned int flags, unsigned int alpha) = 0;
69  virtual bool RenderCapture(int index, CRenderCapture* capture) = 0;
70  virtual bool ConfigChanged(const VideoPicture &picture) = 0;
71 
72  // Feature support
73  virtual bool SupportsMultiPassRendering() = 0;
74  virtual bool Supports(ERENDERFEATURE feature) const { return false; }
75  virtual bool Supports(ESCALINGMETHOD method) const = 0;
76 
77  virtual bool WantsDoublePass() { return false; }
78 
79  void SetViewMode(int viewMode);
80 
86  void GetVideoRect(CRect& source, CRect& dest, CRect& view) const;
87  float GetAspectRatio() const;
88  unsigned int GetOrientation() const { return m_renderOrientation; }
89 
90  static void SettingOptionsRenderMethodsFiller(const std::shared_ptr<const CSetting>& setting,
91  std::vector<IntegerSettingOption>& list,
92  int& current,
93  void* data);
94 
95  void SetVideoSettings(const CVideoSettings &settings);
96 
97  // Gets debug info from render buffer
98  virtual DEBUG_INFO_VIDEO GetDebugInfo(int idx) { return {}; }
99 
100  virtual CRenderCapture* GetRenderCapture() { return nullptr; }
101 
102 protected:
103  void CalcDestRect(float offsetX,
104  float offsetY,
105  float width,
106  float height,
107  float inputFrameRatio,
108  float zoomAmount,
109  float verticalShift,
110  CRect& destRect);
111  void CalcNormalRenderRect(float offsetX, float offsetY, float width, float height,
112  float inputFrameRatio, float zoomAmount, float verticalShift);
113  void CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height);
114  virtual void ManageRenderArea();
115  virtual void ReorderDrawPoints();
116  virtual EShaderFormat GetShaderFormat();
117  void MarkDirty();
118  void EnableAlwaysClip();
119 
120  //@todo drop those
121  void saveRotatedCoords();//saves the current state of m_rotatedDestCoords
122  void syncDestRectToRotatedPoints();//sync any changes of m_destRect to m_rotatedDestCoords
123  void restoreRotatedCoords();//restore the current state of m_rotatedDestCoords from saveRotatedCoords
124 
125  unsigned int m_sourceWidth = 720;
126  unsigned int m_sourceHeight = 480;
127  float m_sourceFrameRatio = 1.0f;
128  float m_fps = 0.0f;
129 
130  unsigned int m_renderOrientation = 0; // orientation of the video in degrees counter clockwise
131  // for drawing the texture with glVertex4f (holds all 4 corner points of the destination rect
132  // with correct orientation based on m_renderOrientation
133  // 0 - top left, 1 - top right, 2 - bottom right, 3 - bottom left
134  CPoint m_rotatedDestCoords[4];
135  CPoint m_savedRotatedDestCoords[4];//saved points from saveRotatedCoords call
136 
137  CRect m_destRect;
138  CRect m_sourceRect;
139  CRect m_viewRect;
140 
141  // rendering flags
142  unsigned m_iFlags = 0;
143  AVPixelFormat m_format = AV_PIX_FMT_NONE;
144 
145  CVideoSettings m_videoSettings;
146 
147 private:
148  bool m_alwaysClip = false;
149 };
Definition: RenderCapture.h:23
Definition: RenderInfo.h:19
Setting base class containing all the properties which are common to all settings independent of the ...
Definition: Setting.h:46
Definition: SettingDefinitions.h:66
void GetVideoRect(CRect &source, CRect &dest, CRect &view) const
Get video rectangle and view window.
Definition: BaseRenderer.cpp:46
Definition: settings.py:1
Definition: DebugInfo.h:21
Definition: DVDVideoCodec.h:36
Definition: BaseRenderer.h:48
Definition: VideoSettings.h:194