Gnash  0.8.11dev
VaapiSurface.h
Go to the documentation of this file.
1 // VaapiSurface.h: VA surface abstraction
2 //
3 // Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 
20 #ifndef GNASH_VAAPISURFACE_H
21 #define GNASH_VAAPISURFACE_H
22 
23 #include <vector>
24 
25 #include "vaapi_common.h"
26 #include "dsodefs.h"
27 
28 namespace gnash {
29 
30 // Forward declarations
31 class VaapiContext;
32 class VaapiSubpicture;
33 
35 struct VaapiRectangle : public VARectangle {
36  VaapiRectangle(unsigned int w = 0, unsigned int h = 0)
37  { x = 0; y = 0; width = w; height = h; }
38 
39  VaapiRectangle(int x_, int y_, unsigned int w, unsigned int h)
40  { x = x_; y = y_; width = w; height = h; }
41 };
42 
45  uintptr_t _surface;
46  unsigned int _width;
47  unsigned int _height;
48 
49 protected:
50  void reset(uintptr_t surface) { _surface = surface; }
51 
52 public:
53  VaapiSurfaceImplBase(unsigned int width, unsigned int height);
54  virtual ~VaapiSurfaceImplBase() { }
55 
57  uintptr_t surface() const { return _surface; }
58 
60  unsigned int width() const { return _width; }
61 
63  unsigned int height() const { return _height; }
64 };
65 
68 {
69  std::unique_ptr<VaapiSurfaceImplBase> _impl;
70  std::vector< std::shared_ptr<VaapiSubpicture> > _subpictures;
71 
72  friend class VaapiContext;
73  VaapiContext *_context;
74 
76  void setContext(VaapiContext *context) { _context = context; }
77 
78 public:
79  VaapiSurface(unsigned int width, unsigned int height);
80 
82  VaapiContext *getContext() const { return _context; }
83 
85  VASurfaceID get() const { return static_cast<VASurfaceID>(_impl->surface()); }
86 
88  unsigned int width() const { return _impl->width(); }
89 
91  unsigned int height() const { return _impl->height(); }
92 
94  void clear();
95 
97  bool associateSubpicture(std::shared_ptr<VaapiSubpicture> subpicture,
98  VaapiRectangle const & src_rect,
99  VaapiRectangle const & dst_rect);
100 
102  bool deassociateSubpicture(std::shared_ptr<VaapiSubpicture> subpicture);
103 };
104 
105 } // gnash namespace
106 
107 #endif // GNASH_VAAPISURFACE_H
108 
109 // local Variables:
110 // mode: C++
111 // indent-tabs-mode: nil
112 // End:
113 
gnash::VaapiImage::width
unsigned int width() const
Get image width.
Definition: VaapiImage.h:65
gnash::VaapiContext
VA context abstraction.
Definition: VaapiContext.h:51
gnash::VaapiSurfaceImplBase
VA surface base representation.
Definition: VaapiSurface.h:44
height
@ height
Definition: klash_part.cpp:329
gnash::VaapiGlobalContext
VA API global context.
Definition: VaapiGlobalContext.h:33
gnash::VaapiImage::getPitch
unsigned int getPitch(int plane) const
Get scanline pitch for the specified plane.
Definition: VaapiImage.cpp:166
gnash::VaapiSurface::width
unsigned int width() const
Get surface width.
Definition: VaapiSurface.h:88
gnash::VaapiGlobalContext::display
VADisplay display() const
Get the VA display.
Definition: VaapiGlobalContext.h:71
gnash::VaapiRectangle::VaapiRectangle
VaapiRectangle(int x_, int y_, unsigned int w, unsigned int h)
Definition: VaapiSurface.h:39
dsodefs.h
gnash::VaapiImage::unmap
bool unmap()
Unmap image data.
Definition: VaapiImage.cpp:134
gnash::VaapiSurfaceImplBase::surface
uintptr_t surface() const
Get VA surface.
Definition: VaapiSurface.h:57
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
y
std::int32_t y
Definition: BitmapData_as.cpp:435
gnash::key::i
@ i
Definition: GnashKey.h:155
_
#define _(String)
Definition: log.h:44
gnash::VaapiSurface::VaapiSurface
VaapiSurface(unsigned int width, unsigned int height)
Definition: VaapiSurface.cpp:98
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
GNASH_REPORT_FUNCTION
#define GNASH_REPORT_FUNCTION
Definition: log.h:452
gnash::VaapiGlobalContext::get
static VaapiGlobalContext * get()
Get the unique global VA context.
Definition: VaapiGlobalContext.cpp:130
gnash::VaapiImage::height
unsigned int height() const
Get image height.
Definition: VaapiImage.h:68
gnash::VaapiSurface::clear
void clear()
Clear surface with black color.
Definition: VaapiSurface.cpp:105
gnash::VaapiSurface::associateSubpicture
bool associateSubpicture(std::shared_ptr< VaapiSubpicture > subpicture, VaapiRectangle const &src_rect, VaapiRectangle const &dst_rect)
Associate subpicture to the surface.
Definition: VaapiSurface.cpp:151
gnash::key::a
@ a
Definition: GnashKey.h:147
gnash::VaapiSurfaceImplBase::~VaapiSurfaceImplBase
virtual ~VaapiSurfaceImplBase()
Definition: VaapiSurface.h:54
gnash::key::h
@ h
Definition: GnashKey.h:154
gnash::vaapi_check_status
bool vaapi_check_status(VAStatus status, const char *msg)
Check VA status for success or print out an error.
Definition: vaapi_utils.cpp:51
test.w
w
Definition: test.py:8
gnash::VaapiImage
VA image abstraction.
Definition: VaapiImage.h:41
gnash::VaapiSurfaceImplBase::width
unsigned int width() const
Get surface width.
Definition: VaapiSurface.h:60
VaapiImage.h
gnash::VaapiSurfaceImplBase::height
unsigned int height() const
Get surface height.
Definition: VaapiSurface.h:63
vaapi_common.h
gnash::VaapiSurface::getContext
VaapiContext * getContext() const
Return parent VA context.
Definition: VaapiSurface.h:82
VaapiGlobalContext.h
VaapiSurface.h
log.h
gnash::VaapiSurfaceImplBase::reset
void reset(uintptr_t surface)
Definition: VaapiSurface.h:50
gnash::VaapiSurface::get
VASurfaceID get() const
Return VA surface id.
Definition: VaapiSurface.h:85
gnash::VaapiRectangle
VA rectangle abstraction.
Definition: VaapiSurface.h:35
gnash::VaapiImage::get
VAImageID get() const
Get VA image ID.
Definition: VaapiImage.h:59
gnash::VaapiSurfaceImplBase::VaapiSurfaceImplBase
VaapiSurfaceImplBase(unsigned int width, unsigned int height)
Definition: VaapiSurface.cpp:36
gnash::VaapiRectangle::VaapiRectangle
VaapiRectangle(unsigned int w=0, unsigned int h=0)
Definition: VaapiSurface.h:36
gnash::VaapiImage::map
bool map()
Map image data.
Definition: VaapiImage.cpp:109
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::VaapiSurface
VA surface abstraction.
Definition: VaapiSurface.h:68
gnash::VaapiSurface::deassociateSubpicture
bool deassociateSubpicture(std::shared_ptr< VaapiSubpicture > subpicture)
Deassociate subpicture from the surface.
Definition: VaapiSurface.cpp:180
VAAPI_IMAGE_NV12
@ VAAPI_IMAGE_NV12
Planar YUV 4:2:0, 12-bit, 1 plane for Y and 1 plane for UV.
Definition: VaapiImageFormat.h:38
gnash::operator==
bool operator==(const event_id &a, const event_id &b)
Return whether two event_ids are equal.
Definition: event_id.h:163
width
@ width
Definition: klash_part.cpp:329
gnash::VaapiSurface::height
unsigned int height() const
Get surface height.
Definition: VaapiSurface.h:91
vaapi_utils.h
x
std::int32_t x
Definition: BitmapData_as.cpp:434
gnash::key::b
@ b
Definition: GnashKey.h:148
gnash::VaapiImage::getPlane
std::uint8_t * getPlane(int plane) const
Get pixels for the specified plane.
Definition: VaapiImage.cpp:156
gnash::fontlib::clear
void clear()
Clean up the font library.
Definition: fontlib.cpp:36
VaapiSubpicture.h
gnash::key::Y
@ Y
Definition: GnashKey.h:137