1 /*
2  *  gstvaapitexture_priv.h - VA texture abstraction (private definitions)
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2012-2014 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24 
25 #ifndef GST_VAAPI_TEXTURE_PRIV_H
26 #define GST_VAAPI_TEXTURE_PRIV_H
27 
28 #include "gstvaapiobject_priv.h"
29 
30 G_BEGIN_DECLS
31 
32 #define GST_VAAPI_TEXTURE_CLASS(klass) \
33   ((GstVaapiTextureClass *)(klass))
34 
35 #define GST_VAAPI_TEXTURE_GET_CLASS(obj) \
36   GST_VAAPI_TEXTURE_CLASS (GST_VAAPI_OBJECT_GET_CLASS (obj))
37 
38 /**
39  * GST_VAAPI_TEXTURE_ID:
40  * @texture: a #GstVaapiTexture
41  *
42  * Macro that evaluates to the GL texture id associated with the @texture
43  */
44 #undef  GST_VAAPI_TEXTURE_ID
45 #define GST_VAAPI_TEXTURE_ID(texture) \
46   (GST_VAAPI_OBJECT_ID (texture))
47 
48 /**
49  * GST_VAAPI_TEXTURE_TARGET:
50  * @texture: a #GstVaapiTexture
51  *
52  * Macro that evaluates to the GL texture target associated with the @texture
53  */
54 #undef  GST_VAAPI_TEXTURE_TARGET
55 #define GST_VAAPI_TEXTURE_TARGET(texture) \
56   (GST_VAAPI_TEXTURE (texture)->gl_target)
57 
58 /**
59  * GST_VAAPI_TEXTURE_FORMAT:
60  * @texture: a #GstVaapiTexture
61  *
62  * Macro that evaluates to the GL texture format associated with the @texture
63  */
64 #undef  GST_VAAPI_TEXTURE_FORMAT
65 #define GST_VAAPI_TEXTURE_FORMAT(texture) \
66   (GST_VAAPI_TEXTURE (texture)->gl_format)
67 
68 /**
69  * GST_VAAPI_TEXTURE_WIDTH:
70  * @texture: a #GstVaapiTexture
71  *
72  * Macro that evaluates to the GL texture width associated with the @texture
73  */
74 #undef  GST_VAAPI_TEXTURE_WIDTH
75 #define GST_VAAPI_TEXTURE_WIDTH(texture) \
76   (GST_VAAPI_TEXTURE (texture)->width)
77 
78 /**
79  * GST_VAAPI_TEXTURE_HEIGHT:
80  * @texture: a #GstVaapiTexture
81  *
82  * Macro that evaluates to the GL texture height associated with the @texture
83  */
84 #undef  GST_VAAPI_TEXTURE_HEIGHT
85 #define GST_VAAPI_TEXTURE_HEIGHT(texture) \
86   (GST_VAAPI_TEXTURE (texture)->height)
87 
88 #define GST_VAAPI_TEXTURE_FLAGS         GST_VAAPI_MINI_OBJECT_FLAGS
89 #define GST_VAAPI_TEXTURE_FLAG_IS_SET   GST_VAAPI_MINI_OBJECT_FLAG_IS_SET
90 #define GST_VAAPI_TEXTURE_FLAG_SET      GST_VAAPI_MINI_OBJECT_FLAG_SET
91 #define GST_VAAPI_TEXTURE_FLAG_UNSET    GST_VAAPI_MINI_OBJECT_FLAG_UNSET
92 
93 /* GstVaapiTextureClass hooks */
94 typedef gboolean (*GstVaapiTextureAllocateFunc) (GstVaapiTexture * texture);
95 typedef gboolean (*GstVaapiTexturePutSurfaceFunc) (GstVaapiTexture * texture,
96     GstVaapiSurface * surface, const GstVaapiRectangle * crop_rect,
97     guint flags);
98 
99 typedef struct _GstVaapiTextureClass GstVaapiTextureClass;
100 
101 /**
102  * GstVaapiTexture:
103  *
104  * Base class for API-dependent textures.
105  */
106 struct _GstVaapiTexture {
107   /*< private >*/
108   GstVaapiObject parent_instance;
109 
110   /*< protected >*/
111   guint gl_target;
112   guint gl_format;
113   guint width;
114   guint height;
115   guint is_wrapped:1;
116 };
117 
118 /**
119  * GstVaapiTextureClass:
120  * @put_surface: virtual function to render a #GstVaapiSurface into a texture
121  *
122  * Base class for API-dependent textures.
123  */
124 struct _GstVaapiTextureClass {
125   /*< private >*/
126   GstVaapiObjectClass parent_class;
127 
128   /*< protected >*/
129   GstVaapiTextureAllocateFunc allocate;
130   GstVaapiTexturePutSurfaceFunc put_surface;
131 };
132 
133 GstVaapiTexture *
134 gst_vaapi_texture_new_internal (const GstVaapiTextureClass * klass,
135     GstVaapiDisplay * display, GstVaapiID id, guint target, guint format,
136     guint width, guint height);
137 
138 G_END_DECLS
139 
140 #endif /* GST_VAAPI_TEXTURE_PRIV_H */
141