/xbmc/cores/VideoRenderers/BaseRenderer.h

http://github.com/xbmc/xbmc · C Header · 148 lines · 93 code · 27 blank · 28 comment · 0 complexity · ba52e719607bee2d4a9ddf25875093ae MD5 · raw file

  1. #pragma once
  2. /*
  3. * Copyright (C) 2005-2013 Team XBMC
  4. * http://xbmc.org
  5. *
  6. * This Program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This Program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with XBMC; see the file COPYING. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #include <vector>
  22. #include "guilib/Resolution.h"
  23. #include "guilib/Geometry.h"
  24. #include "RenderFormats.h"
  25. #include "RenderFeatures.h"
  26. #define MAX_PLANES 3
  27. #define MAX_FIELDS 3
  28. #define NUM_BUFFERS 3
  29. class CSetting;
  30. typedef struct YV12Image
  31. {
  32. uint8_t* plane[MAX_PLANES];
  33. int planesize[MAX_PLANES];
  34. unsigned stride[MAX_PLANES];
  35. unsigned width;
  36. unsigned height;
  37. unsigned flags;
  38. unsigned cshift_x; /* this is the chroma shift used */
  39. unsigned cshift_y;
  40. unsigned bpp; /* bytes per pixel */
  41. } YV12Image;
  42. enum EFIELDSYNC
  43. {
  44. FS_NONE,
  45. FS_TOP,
  46. FS_BOT
  47. };
  48. // Render Methods
  49. enum RenderMethods
  50. {
  51. RENDER_METHOD_AUTO = 0,
  52. RENDER_METHOD_ARB,
  53. RENDER_METHOD_GLSL,
  54. RENDER_METHOD_SOFTWARE,
  55. RENDER_METHOD_D3D_PS,
  56. RENDER_METHOD_DXVA,
  57. RENDER_OVERLAYS = 99 // to retain compatibility
  58. };
  59. typedef void (*RenderUpdateCallBackFn)(const void *ctx, const CRect &SrcRect, const CRect &DestRect);
  60. typedef void (*RenderFeaturesCallBackFn)(const void *ctx, Features &renderFeatures);
  61. struct DVDVideoPicture;
  62. class CBaseRenderer
  63. {
  64. public:
  65. CBaseRenderer();
  66. virtual ~CBaseRenderer();
  67. void SetViewMode(int viewMode);
  68. RESOLUTION GetResolution() const;
  69. void GetVideoRect(CRect &source, CRect &dest);
  70. float GetAspectRatio() const;
  71. virtual bool AddVideoPicture(DVDVideoPicture* picture, int index) { return false; }
  72. virtual void Flush() {};
  73. /**
  74. * Returns number of references a single buffer can retain when rendering a single frame
  75. */
  76. virtual unsigned int GetProcessorSize() { return 0; }
  77. virtual unsigned int GetMaxBufferSize() { return 0; }
  78. virtual void SetBufferSize(int numBuffers) { }
  79. virtual void ReleaseBuffer(int idx) { }
  80. virtual bool Supports(ERENDERFEATURE feature) { return false; }
  81. // Supported pixel formats, can be called before configure
  82. std::vector<ERenderFormat> SupportedFormats() { return std::vector<ERenderFormat>(); }
  83. virtual void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
  84. virtual void RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn);
  85. static void SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current);
  86. protected:
  87. void ChooseBestResolution(float fps);
  88. bool FindResolutionFromOverride(float fps, float& weight, bool fallback);
  89. void FindResolutionFromFpsMatch(float fps, float& weight);
  90. RESOLUTION FindClosestResolution(float fps, float multiplier, RESOLUTION current, float& weight);
  91. static float RefreshWeight(float refresh, float fps);
  92. void CalcNormalDisplayRect(float offsetX, float offsetY, float screenWidth, float screenHeight, float inputFrameRatio, float zoomAmount, float verticalShift);
  93. void CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height);
  94. void ManageDisplay();
  95. virtual void ReorderDrawPoints();//might be overwritten (by egl e.x.)
  96. void saveRotatedCoords();//saves the current state of m_rotatedDestCoords
  97. void syncDestRectToRotatedPoints();//sync any changes of m_destRect to m_rotatedDestCoords
  98. void restoreRotatedCoords();//restore the current state of m_rotatedDestCoords from saveRotatedCoords
  99. void MarkDirty();
  100. RESOLUTION m_resolution; // the resolution we're running in
  101. unsigned int m_sourceWidth;
  102. unsigned int m_sourceHeight;
  103. float m_sourceFrameRatio;
  104. float m_fps;
  105. unsigned int m_renderOrientation; // orientation of the video in degress counter clockwise
  106. unsigned int m_oldRenderOrientation; // orientation of the previous frame
  107. // for drawing the texture with glVertex4f (holds all 4 corner points of the destination rect
  108. // with correct orientation based on m_renderOrientation
  109. // 0 - top left, 1 - top right, 2 - bottom right, 3 - bottom left
  110. CPoint m_rotatedDestCoords[4];
  111. CPoint m_savedRotatedDestCoords[4];//saved points from saveRotatedCoords call
  112. CRect m_destRect;
  113. CRect m_oldDestRect; // destrect of the previous frame
  114. CRect m_sourceRect;
  115. // rendering flags
  116. unsigned m_iFlags;
  117. const void* m_RenderUpdateCallBackCtx;
  118. RenderUpdateCallBackFn m_RenderUpdateCallBackFn;
  119. const void* m_RenderFeaturesCallBackCtx;
  120. RenderFeaturesCallBackFn m_RenderFeaturesCallBackFn;
  121. };