PageRenderTime 34ms CodeModel.GetById 11ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 1ms

/xbmc/cores/VideoRenderers/OverlayRenderer.h

http://github.com/xbmc/xbmc
C++ Header | 132 lines | 88 code | 24 blank | 20 comment | 0 complexity | c7fa62d61abc15d51407369fc160d896 MD5 | raw file
  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
 29class CDVDOverlay;
 30class CDVDOverlayImage;
 31class CDVDOverlaySpu;
 32class CDVDOverlaySSA;
 33
 34namespace 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_RELATIVE
 69    } m_pos;
 70
 71    float m_x;
 72    float m_y;
 73    float m_width;
 74    float m_height;
 75
 76  protected:
 77    long m_references;
 78  };
 79
 80  class COverlayMainThread
 81      : public COverlay
 82  {
 83  public:
 84    virtual ~COverlayMainThread() {}
 85    virtual long Release();
 86  };
 87
 88
 89  class CRenderer
 90  {
 91  public:
 92     CRenderer();
 93    ~CRenderer();
 94
 95    void AddOverlay(CDVDOverlay* o, double pts, int index);
 96    void AddOverlay(COverlay*    o, double pts, int index);
 97    void AddCleanup(COverlay*    o);
 98    void Render(int idx);
 99    void Flush();
100    void Release(int idx);
101
102  protected:
103
104    struct SElement
105    {
106      SElement()
107      {
108        overlay_dvd = NULL;
109        overlay     = NULL;
110        pts         = 0.0;
111      }
112      double pts;
113      CDVDOverlay* overlay_dvd;
114      COverlay*    overlay;
115    };
116
117    typedef std::vector<COverlay*>  COverlayV;
118    typedef std::vector<SElement>   SElementV;
119
120    void      Render(COverlay* o);
121    COverlay* Convert(CDVDOverlay* o, double pts);
122    COverlay* Convert(CDVDOverlaySSA* o, double pts);
123
124    void      Release(COverlayV& list);
125    void      Release(SElementV& list);
126
127    CCriticalSection m_section;
128    SElementV        m_buffers[NUM_BUFFERS];
129
130    COverlayV        m_cleanup;
131  };
132}