xbmc
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(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 
89  static void SettingOptionsRenderMethodsFiller(const std::shared_ptr<const CSetting>& setting,
90  std::vector<IntegerSettingOption>& list,
91  int& current,
92  void* data);
93 
94  void SetVideoSettings(const CVideoSettings &settings);
95 
96  // Gets debug info from render buffer
97  virtual DEBUG_INFO_VIDEO GetDebugInfo(int idx) { return {}; }
98 
99  virtual CRenderCapture* GetRenderCapture() { return nullptr; }
100 
101 protected:
102  void CalcDestRect(float offsetX,
103  float offsetY,
104  float width,
105  float height,
106  float inputFrameRatio,
107  float zoomAmount,
108  float verticalShift,
109  CRect& destRect);
110  void CalcNormalRenderRect(float offsetX, float offsetY, float width, float height,
111  float inputFrameRatio, float zoomAmount, float verticalShift);
112  void CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height);
113  virtual void ManageRenderArea();
114  virtual void ReorderDrawPoints();
115  virtual EShaderFormat GetShaderFormat();
116  void MarkDirty();
117 
118  //@todo drop those
119  void saveRotatedCoords();//saves the current state of m_rotatedDestCoords
120  void syncDestRectToRotatedPoints();//sync any changes of m_destRect to m_rotatedDestCoords
121  void restoreRotatedCoords();//restore the current state of m_rotatedDestCoords from saveRotatedCoords
122 
123  unsigned int m_sourceWidth = 720;
124  unsigned int m_sourceHeight = 480;
125  float m_sourceFrameRatio = 1.0f;
126  float m_fps = 0.0f;
127 
128  unsigned int m_renderOrientation = 0; // orientation of the video in degrees counter clockwise
129  // for drawing the texture with glVertex4f (holds all 4 corner points of the destination rect
130  // with correct orientation based on m_renderOrientation
131  // 0 - top left, 1 - top right, 2 - bottom right, 3 - bottom left
132  CPoint m_rotatedDestCoords[4];
133  CPoint m_savedRotatedDestCoords[4];//saved points from saveRotatedCoords call
134 
135  CRect m_destRect;
136  CRect m_sourceRect;
137  CRect m_viewRect;
138 
139  // rendering flags
140  unsigned m_iFlags = 0;
141  AVPixelFormat m_format = AV_PIX_FMT_NONE;
142 
143  CVideoSettings m_videoSettings;
144 };
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:48
Definition: settings.py:1
Definition: DebugInfo.h:21
Definition: DVDVideoCodec.h:36
Definition: BaseRenderer.h:48
Definition: VideoSettings.h:194