1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #ifndef WFC_CLIENT_STREAM_H |
29 | #define WFC_CLIENT_STREAM_H |
30 | |
31 | #include "interface/vctypes/vc_image_types.h" |
32 | #include "interface/khronos/common/khrn_int_common.h" |
33 | #include "interface/khronos/include/WF/wfc.h" |
34 | #include "interface/khronos/wf/wfc_int.h" |
35 | #include "interface/khronos/include/EGL/eglext.h" |
36 | |
37 | //============================================================================== |
38 | //!@name Flags |
39 | //!@{ |
40 | |
41 | #define WFC_STREAM_FLAGS_NONE 0 |
42 | //!@brief Allow the server to indicate to the host when a buffer is available; for use |
43 | //! with wfc_stream_await_buffer(). |
44 | #define WFC_STREAM_FLAGS_BUF_AVAIL (1 << 0) |
45 | //! GNL - Hack up a new semaphore thing to make Android rendering wait |
46 | #define WFC_STREAM_FLAGS_ANDROID_GL_STREAM (1 << 2) |
47 | //! So the reference to the vc image in the pool can be released |
48 | #define WFC_STREAM_FLAGS_ANDROID_MM_STREAM (1 << 3) |
49 | |
50 | //! Flags needed to work with EGL |
51 | #define WFC_STREAM_FLAGS_EGL (WFC_STREAM_FLAGS_BUF_AVAIL) |
52 | |
53 | //!@} |
54 | //!@name Internal flags; do not use directly. |
55 | //!@{ |
56 | |
57 | //!@brief Allow the server to indicate to the host that a change to the source and/or |
58 | //! destination rectangles has been requested by the server. |
59 | #define WFC_STREAM_FLAGS_REQ_RECT (1 << 31) |
60 | |
61 | //!@} |
62 | //============================================================================== |
63 | |
64 | //! Type for callback from wfc_stream_create_req_rect(). |
65 | typedef void (*WFC_STREAM_REQ_RECT_CALLBACK_T) |
66 | (void *args, const WFCint dest_rect[WFC_RECT_SIZE], const WFCfloat src_rect[WFC_RECT_SIZE]); |
67 | |
68 | //============================================================================== |
69 | |
70 | //! In cases where the caller doesn't want to assign a stream number, provide one for it. |
71 | WFCNativeStreamType wfc_stream_get_next(void); |
72 | |
73 | //!@brief Create a stream, using the given stream handle (typically assigned by the |
74 | //! window manager). Return zero if OK. |
75 | uint32_t wfc_stream_create(WFCNativeStreamType stream, uint32_t flags); |
76 | |
77 | //! Create a stream, and automatically assign it a new stream number, which is returned |
78 | WFCNativeStreamType wfc_stream_create_assign_id(uint32_t flags); |
79 | |
80 | //!@brief Create a stream, using the given stream handle, which will notify the calling |
81 | //! module when the server requests a change in source and/or destination rectangle, |
82 | //! using the supplied callback. Return zero if OK. |
83 | uint32_t wfc_stream_create_req_rect |
84 | (WFCNativeStreamType stream, uint32_t flags, |
85 | WFC_STREAM_REQ_RECT_CALLBACK_T callback, void *cb_args); |
86 | |
87 | //!@brief Indicate that a source or mask is now associated with this stream, or should |
88 | //! now be removed from such an association. |
89 | //! |
90 | //!@return True if successful, false if not (invalid handle). |
91 | bool wfc_stream_register_source_or_mask(WFCNativeStreamType stream, bool add_source_or_mask); |
92 | |
93 | //!@brief Suspend until buffer is available on the server (requires |
94 | //! WFC_STREAM_FLAGS_ASYNC_SEM to have been specified on creation). |
95 | void wfc_stream_await_buffer(WFCNativeStreamType stream); |
96 | |
97 | //! Destroy a stream. |
98 | void wfc_stream_destroy(WFCNativeStreamType stream); |
99 | |
100 | //------------------------------------------------------------------------------ |
101 | //!@name Off-screen composition functions |
102 | //!@{ |
103 | |
104 | //! Create a stream for an off-screen context to output to, with the default number of buffers. |
105 | uint32_t wfc_stream_create_for_context |
106 | (WFCNativeStreamType stream, uint32_t width, uint32_t height); |
107 | |
108 | //! Create a stream for an off-screen context to output to, with a specific number of buffers. |
109 | uint32_t wfc_stream_create_for_context_nbufs |
110 | (WFCNativeStreamType stream, uint32_t width, uint32_t height, uint32_t nbufs); |
111 | |
112 | //! Returns true if this stream exists, and is in use as the output of an off-screen context. |
113 | bool wfc_stream_used_for_off_screen(WFCNativeStreamType stream); |
114 | |
115 | //!@brief Called on behalf of an off-screen context, to either set or clear the stream's |
116 | //! flag indicating that it's being used as output for that context. |
117 | void wfc_stream_register_off_screen(WFCNativeStreamType stream, bool used_for_off_screen); |
118 | |
119 | //!@} |
120 | //------------------------------------------------------------------------------ |
121 | |
122 | void wfc_stream_signal_eglimage_data(WFCNativeStreamType stream, EGLImageKHR im); |
123 | void wfc_stream_signal_eglimage_data_protected(WFCNativeStreamType stream, EGLImageKHR im, uint32_t is_protected); |
124 | void wfc_stream_release_eglimage_data(WFCNativeStreamType stream, EGLImageKHR im); |
125 | void wfc_stream_signal_mm_image_data(WFCNativeStreamType stream, uint32_t im); |
126 | |
127 | void wfc_stream_signal_raw_pixels(WFCNativeStreamType stream, uint32_t handle, |
128 | uint32_t format, uint32_t w, uint32_t h, uint32_t pitch, uint32_t vpitch); |
129 | void wfc_stream_signal_image(WFCNativeStreamType stream, |
130 | const WFC_STREAM_IMAGE_T *image); |
131 | void wfc_stream_register(WFCNativeStreamType stream); |
132 | void wfc_stream_unregister(WFCNativeStreamType stream); |
133 | |
134 | //============================================================================== |
135 | #endif /* WF_INT_STREAM_H_ */ |
136 | |