3abf421e0253b3dc43f755a4706524757d9cfd4a
[platform/upstream/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapiwindow_priv.h
1 /*
2  *  gstvaapiwindow_priv.h - VA window 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-2013 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_WINDOW_PRIV_H
26 #define GST_VAAPI_WINDOW_PRIV_H
27
28 #include "gstvaapiobject_priv.h"
29
30 G_BEGIN_DECLS
31
32 #define GST_VAAPI_WINDOW_CLASS(klass) \
33     ((GstVaapiWindowClass *)(klass))
34
35 #define GST_VAAPI_WINDOW_GET_CLASS(obj) \
36     GST_VAAPI_WINDOW_CLASS(GST_VAAPI_OBJECT_GET_CLASS(obj))
37
38 /* GstVaapiWindowClass hooks */
39 typedef gboolean  (*GstVaapiWindowCreateFunc)  (GstVaapiWindow *window,
40     guint *width, guint *height);
41 typedef gboolean  (*GstVaapiWindowShowFunc)    (GstVaapiWindow *window);
42 typedef gboolean  (*GstVaapiWindowHideFunc)    (GstVaapiWindow *window);
43 typedef gboolean  (*GstVaapiWindowGetGeometryFunc)(GstVaapiWindow *window,
44     gint *px, gint *py, guint *pwidth, guint *pheight);
45 typedef gboolean  (*GstVaapiWindowSetFullscreenFunc)(GstVaapiWindow *window,
46     gboolean fullscreen);
47 typedef gboolean  (*GstVaapiWindowResizeFunc)  (GstVaapiWindow *window,
48     guint width, guint height);
49 typedef gboolean  (*GstVaapiWindowRenderFunc)  (GstVaapiWindow *window,
50     GstVaapiSurface *surface, const GstVaapiRectangle *src_rect,
51     const GstVaapiRectangle *dst_rect, guint flags);
52 typedef gboolean  (*GstVaapiWindowRenderPixmapFunc)(GstVaapiWindow *window,
53     GstVaapiPixmap *pixmap, const GstVaapiRectangle *src_rect,
54     const GstVaapiRectangle *dst_rect);
55
56 /**
57  * GstVaapiWindow:
58  *
59  * Base class for system-dependent windows.
60  */
61 struct _GstVaapiWindow {
62     /*< private >*/
63     GstVaapiObject parent_instance;
64
65     /*< protected >*/
66     guint               width;
67     guint               height;
68     guint               display_width;
69     guint               display_height;
70     guint               use_foreign_window      : 1;
71     guint               is_fullscreen           : 1;
72     guint               check_geometry          : 1;
73 };
74
75 /**
76  * GstVaapiWindowClass:
77  * @create: virtual function to create a window with width and height
78  * @show: virtual function to show (map) a window
79  * @hide: virtual function to hide (unmap) a window
80  * @get_geometry: virtual function to get the current window geometry
81  * @set_fullscreen: virtual function to change window fullscreen state
82  * @resize: virtual function to resize a window
83  * @render: virtual function to render a #GstVaapiSurface into a window
84  *
85  * Base class for system-dependent windows.
86  */
87 struct _GstVaapiWindowClass {
88     /*< private >*/
89     GstVaapiObjectClass parent_class;
90
91     /*< protected >*/
92     GstVaapiWindowCreateFunc            create;
93     GstVaapiWindowShowFunc              show;
94     GstVaapiWindowHideFunc              hide;
95     GstVaapiWindowGetGeometryFunc       get_geometry;
96     GstVaapiWindowSetFullscreenFunc     set_fullscreen;
97     GstVaapiWindowResizeFunc            resize;
98     GstVaapiWindowRenderFunc            render;
99     GstVaapiWindowRenderPixmapFunc      render_pixmap;
100 };
101
102 GstVaapiWindow *
103 gst_vaapi_window_new(const GstVaapiWindowClass *window_class,
104     GstVaapiDisplay *display, guint width, guint height);
105
106 GstVaapiWindow *
107 gst_vaapi_window_new_from_native(const GstVaapiWindowClass *window_class,
108     GstVaapiDisplay *display, gpointer native_window);
109
110 /* Inline reference counting for core libgstvaapi library */
111 #ifdef IN_LIBGSTVAAPI_CORE
112 #define gst_vaapi_window_ref_internal(window) \
113     ((gpointer)gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(window)))
114
115 #define gst_vaapi_window_unref_internal(window) \
116     gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(window))
117
118 #define gst_vaapi_window_replace_internal(old_window_ptr, new_window) \
119     gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_window_ptr), \
120         GST_VAAPI_MINI_OBJECT(new_window))
121
122 #undef  gst_vaapi_window_ref
123 #define gst_vaapi_window_ref(window) \
124     gst_vaapi_window_ref_internal((window))
125
126 #undef  gst_vaapi_window_unref
127 #define gst_vaapi_window_unref(window) \
128     gst_vaapi_window_unref_internal((window))
129
130 #undef  gst_vaapi_window_replace
131 #define gst_vaapi_window_replace(old_window_ptr, new_window) \
132     gst_vaapi_window_replace_internal((old_window_ptr), (new_window))
133 #endif
134
135 G_END_DECLS
136
137 #endif /* GST_VAAPI_WINDOW_PRIV_H */