4 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
25 #include "guilib/Resolution.h"
26 #include "guilib/Geometry.h"
27 #include "RenderFormats.h"
28 #include "RenderFeatures.h"
36 typedef struct YV12Image
38 uint8_t* plane[MAX_PLANES];
39 int planesize[MAX_PLANES];
40 unsigned stride[MAX_PLANES];
45 unsigned cshift_x; /* this is the chroma shift used */
47 unsigned bpp; /* bytes per pixel */
60 RENDER_METHOD_AUTO = 0,
63 RENDER_METHOD_SOFTWARE,
67 RENDER_OVERLAYS = 99 // to retain compatibility
70 typedef void (*RenderUpdateCallBackFn)(const void *ctx, const CRect &SrcRect, const CRect &DestRect);
71 typedef void (*RenderFeaturesCallBackFn)(const void *ctx, Features &renderFeatures);
73 struct DVDVideoPicture;
79 virtual ~CBaseRenderer();
81 void SetViewMode(int viewMode);
82 RESOLUTION GetResolution() const;
83 void GetVideoRect(CRect &source, CRect &dest);
84 float GetAspectRatio() const;
86 virtual bool AddVideoPicture(DVDVideoPicture* picture, int index) { return false; }
87 virtual void Flush() {};
90 * Returns number of references a single buffer can retain when rendering a single frame
92 virtual unsigned int GetProcessorSize() { return 0; }
93 virtual unsigned int GetMaxBufferSize() { return 0; }
94 virtual void SetBufferSize(int numBuffers) { }
95 virtual void ReleaseBuffer(int idx) { }
97 virtual bool Supports(ERENDERFEATURE feature) { return false; }
99 // Supported pixel formats, can be called before configure
100 std::vector<ERenderFormat> SupportedFormats() { return std::vector<ERenderFormat>(); }
102 virtual void RegisterRenderUpdateCallBack(const void *ctx, RenderUpdateCallBackFn fn);
103 virtual void RegisterRenderFeaturesCallBack(const void *ctx, RenderFeaturesCallBackFn fn);
105 static void SettingOptionsRenderMethodsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t);
108 void ChooseBestResolution(float fps);
109 bool FindResolutionFromOverride(float fps, float& weight, bool fallback);
110 void FindResolutionFromFpsMatch(float fps, float& weight);
111 RESOLUTION FindClosestResolution(float fps, float multiplier, RESOLUTION current, float& weight);
112 static float RefreshWeight(float refresh, float fps);
113 void CalcNormalDisplayRect(float offsetX, float offsetY, float screenWidth, float screenHeight, float inputFrameRatio, float zoomAmount, float verticalShift);
114 void CalculateFrameAspectRatio(unsigned int desired_width, unsigned int desired_height);
115 void ManageDisplay();
117 virtual void ReorderDrawPoints();//might be overwritten (by egl e.x.)
118 void saveRotatedCoords();//saves the current state of m_rotatedDestCoords
119 void syncDestRectToRotatedPoints();//sync any changes of m_destRect to m_rotatedDestCoords
120 void restoreRotatedCoords();//restore the current state of m_rotatedDestCoords from saveRotatedCoords
123 RESOLUTION m_resolution; // the resolution we're running in
124 unsigned int m_sourceWidth;
125 unsigned int m_sourceHeight;
126 float m_sourceFrameRatio;
129 unsigned int m_renderOrientation; // orientation of the video in degress counter clockwise
130 unsigned int m_oldRenderOrientation; // orientation of the previous frame
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
138 CRect m_oldDestRect; // destrect of the previous frame
144 const void* m_RenderUpdateCallBackCtx;
145 RenderUpdateCallBackFn m_RenderUpdateCallBackFn;
147 const void* m_RenderFeaturesCallBackCtx;
148 RenderFeaturesCallBackFn m_RenderFeaturesCallBackFn;