FIX: [droid] set "remote as keyboard" default to true
[vuplus_xbmc] / xbmc / cores / VideoRenderers / OverlayRenderer.h
1 /*
2  *      Initial code sponsored by: Voddler Inc (voddler.com)
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
22 #pragma once
23
24 #include "threads/CriticalSection.h"
25 #include "BaseRenderer.h"
26
27 #include <vector>
28
29 class CDVDOverlay;
30 class CDVDOverlayImage;
31 class CDVDOverlaySpu;
32 class CDVDOverlaySSA;
33
34 namespace OVERLAY {
35
36   struct SRenderState
37   {
38     float x;
39     float y;
40     float width;
41     float height;
42   };
43
44   class COverlay
45   {
46   public:
47              COverlay();
48     virtual ~COverlay();
49
50     virtual COverlay* Acquire();
51     virtual long      Release();
52     virtual void      Render(SRenderState& state) = 0;
53
54     enum EType
55     { TYPE_NONE
56     , TYPE_TEXTURE
57     , TYPE_GUITEXT
58     } m_type;
59
60     enum EAlign
61     { ALIGN_SCREEN
62     , ALIGN_VIDEO
63     , ALIGN_SUBTITLE
64     } m_align;
65
66     enum EPosition
67     { POSITION_ABSOLUTE
68     , POSITION_ABSOLUTE_SCREEN
69     , POSITION_RELATIVE
70     } m_pos;
71
72     float m_x;
73     float m_y;
74     float m_width;
75     float m_height;
76
77   protected:
78     long m_references;
79   };
80
81   class COverlayMainThread
82       : public COverlay
83   {
84   public:
85     virtual ~COverlayMainThread() {}
86     virtual long Release();
87   };
88
89
90   class CRenderer
91   {
92   public:
93      CRenderer();
94     ~CRenderer();
95
96     void AddOverlay(CDVDOverlay* o, double pts, int index);
97     void AddOverlay(COverlay*    o, double pts, int index);
98     void AddCleanup(COverlay*    o);
99     void Render(int idx);
100     void Flush();
101     void Release(int idx);
102
103   protected:
104
105     struct SElement
106     {
107       SElement()
108       {
109         overlay_dvd = NULL;
110         overlay     = NULL;
111         pts         = 0.0;
112       }
113       double pts;
114       CDVDOverlay* overlay_dvd;
115       COverlay*    overlay;
116     };
117
118     typedef std::vector<COverlay*>  COverlayV;
119     typedef std::vector<SElement>   SElementV;
120
121     void      Render(COverlay* o);
122     COverlay* Convert(CDVDOverlay* o, double pts);
123     COverlay* Convert(CDVDOverlaySSA* o, double pts);
124
125     void      Release(COverlayV& list);
126     void      Release(SElementV& list);
127
128     CCriticalSection m_section;
129     SElementV        m_buffers[NUM_BUFFERS];
130
131     COverlayV        m_cleanup;
132   };
133 }