PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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