|
1 /* Copyright (c) 2009 The Khronos Group Inc. |
|
2 * |
|
3 * Permission is hereby granted, free of charge, to any person obtaining a |
|
4 * copy of this software and/or associated documentation files (the |
|
5 * "Materials"), to deal in the Materials without restriction, including |
|
6 * without limitation the rights to use, copy, modify, merge, publish, |
|
7 * distribute, sublicense, and/or sell copies of the Materials, and to |
|
8 * permit persons to whom the Materials are furnished to do so, subject to |
|
9 * the following conditions: |
|
10 * |
|
11 * The above copyright notice and this permission notice shall be included |
|
12 * in all copies or substantial portions of the Materials. |
|
13 * |
|
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 */ |
|
22 |
|
23 /*! \ingroup wfc |
|
24 * \file wfccontext.h |
|
25 * |
|
26 * \brief Context handling interface |
|
27 */ |
|
28 #ifndef WFCCONTEXT_H_ |
|
29 #define WFCCONTEXT_H_ |
|
30 |
|
31 #include "WF/wfc.h" |
|
32 #include "wfcstructs.h" |
|
33 #include "wfcdevice.h" |
|
34 #include "owfscreen.h" |
|
35 |
|
36 #ifdef __cplusplus |
|
37 extern "C" |
|
38 { |
|
39 #endif |
|
40 |
|
41 #define MAX_SOURCE_WIDTH OWF_SURFACE_WIDTH |
|
42 #define MAX_SOURCE_HEIGHT OWF_SURFACE_HEIGHT |
|
43 /*! |
|
44 Initialize context attributes |
|
45 \return ATTR_ERROR_NONE if attributes have been properly initialised. |
|
46 */ |
|
47 OWF_API_CALL OWF_ATTRIBUTE_LIST_STATUS |
|
48 WFC_Context_InitializeAttributes(WFC_CONTEXT* context, |
|
49 WFCContextType type); |
|
50 |
|
51 /*! |
|
52 * \brief Create new context on device |
|
53 * |
|
54 * \param device Device on which the context should be created |
|
55 * \param type Context type (on- or off-screen) |
|
56 * |
|
57 * \return New context object or NULL in case of failure |
|
58 */ |
|
59 OWF_API_CALL WFC_CONTEXT* |
|
60 WFC_Context_Create(WFC_DEVICE* device, |
|
61 WFCNativeStreamType stream, |
|
62 WFCContextType type, |
|
63 WFCint screenNum); |
|
64 /*! |
|
65 * \brief Releases the resources associated with the context. |
|
66 * Some of these resources hold reference-counts on the context, |
|
67 * so this must be called BEFORE the main attempt to destroy the context. |
|
68 * |
|
69 * \param type Context type (on- or off-screen) |
|
70 */ |
|
71 OWF_API_CALL void |
|
72 WFC_Context_Shutdown(WFC_CONTEXT* context); |
|
73 |
|
74 /*! |
|
75 * \brief Setup context rendering target |
|
76 * |
|
77 * \param context Context |
|
78 * \param stream Target stream to use for rendering |
|
79 */ |
|
80 OWF_API_CALL void |
|
81 WFC_Context_SetTargetStream(WFC_CONTEXT* context, |
|
82 OWFNativeStreamType stream); |
|
83 |
|
84 /*! |
|
85 * \brief Checks if the given stream would be valid as an off-screen context target. |
|
86 * Checks that the format can be rendered TO. |
|
87 * Also checks that the image size is acceptable (within the scratch buffers). |
|
88 * This is called before the context is created so is effectively a "static" context method. |
|
89 * |
|
90 * \param stream Target stream to use for rendering |
|
91 */ |
|
92 OWF_API_CALL WFCboolean |
|
93 WFC_Context_IsValidTargetStream(OWFNativeStreamType stream); |
|
94 /*! |
|
95 * \brief Checks that the image size is acceptable (within the scratch buffers). |
|
96 * This is called before the source is created. |
|
97 * |
|
98 * \param stream source stream to use for rendering. |
|
99 */ |
|
100 OWF_API_CALL WFCboolean |
|
101 WFC_Context_IsValidSourceStream(OWFNativeStreamType stream); |
|
102 /*! |
|
103 * \brief Destroy all masks in context |
|
104 * |
|
105 * \param context Context |
|
106 */ |
|
107 OWF_API_CALL void |
|
108 WFC_Context_DestroyMasks(WFC_CONTEXT* context); |
|
109 |
|
110 /*! |
|
111 * \brief Destroy all context sources |
|
112 */ |
|
113 OWF_API_CALL void |
|
114 WFC_Context_DestroySources(WFC_CONTEXT* context); |
|
115 |
|
116 /*! |
|
117 * \brief Destroy all context elements |
|
118 * |
|
119 * \param context Context object |
|
120 */ |
|
121 OWF_API_CALL void |
|
122 WFC_Context_DestroyElements(WFC_CONTEXT* context); |
|
123 |
|
124 /*! |
|
125 * \brief Find element from current scene |
|
126 * |
|
127 * \param context Context object |
|
128 * \param element Element to find |
|
129 * |
|
130 * \return Element object or NULL if element hasn't been inserted |
|
131 * into current scene. |
|
132 */ |
|
133 OWF_API_CALL WFC_ELEMENT* |
|
134 WFC_Context_FindElement(WFC_CONTEXT* context, |
|
135 WFCElement element); |
|
136 |
|
137 /*! |
|
138 * \brief Activate/deactivate auto-composition on context |
|
139 * |
|
140 * \param context Context |
|
141 * \param act Auto-composition enable/disable |
|
142 */ |
|
143 OWF_API_CALL void |
|
144 WFC_Context_Activate(WFC_CONTEXT* context, |
|
145 WFCboolean act); |
|
146 |
|
147 /*! |
|
148 * \brief Insert composition request to command stream |
|
149 * |
|
150 * \param device |
|
151 * \param context |
|
152 * \param wait WFD_TRUE if executed synchronously |
|
153 */ |
|
154 OWF_API_CALL WFCboolean |
|
155 WFC_Context_InvokeComposition(WFC_DEVICE* device, |
|
156 WFC_CONTEXT* context, |
|
157 WFCboolean wait); |
|
158 |
|
159 /*! |
|
160 * |
|
161 * \brief Insert commit request to command stream |
|
162 * |
|
163 * \param device |
|
164 * \param context |
|
165 * \param wait WFD_TRUE if executed synchronously |
|
166 */ |
|
167 OWF_API_CALL WFCErrorCode |
|
168 WFC_Context_InvokeCommit(WFC_DEVICE* device, |
|
169 WFC_CONTEXT* context, |
|
170 WFCboolean wait); |
|
171 |
|
172 /*! |
|
173 * \brief Insert fence token to context's command stream |
|
174 * |
|
175 * \param dpy |
|
176 * \param context |
|
177 * \param sync |
|
178 */ |
|
179 OWF_API_CALL void |
|
180 WFC_Context_InsertFence(WFC_CONTEXT* context, |
|
181 WFCEGLDisplay dpy, |
|
182 WFCEGLSync sync); |
|
183 |
|
184 /*! |
|
185 * \brief Create element |
|
186 * |
|
187 * \param context |
|
188 */ |
|
189 OWF_API_CALL WFC_ELEMENT* |
|
190 WFC_Context_CreateElement(WFC_CONTEXT* context); |
|
191 |
|
192 /*! \brief Destroy element |
|
193 * \param context |
|
194 * \param element |
|
195 */ |
|
196 OWF_API_CALL WFCErrorCode |
|
197 WFC_Context_DestroyElement(WFC_CONTEXT* context, WFCElement element); |
|
198 |
|
199 /*! |
|
200 * \brief IncreaseClientElementCount |
|
201 * |
|
202 * \param context |
|
203 * \return positive increased current element count; negative or zero indicating the count can't be increased |
|
204 */ |
|
205 OWF_API_CALL WFCint |
|
206 WFC_Context_IncreaseClientElementCount(WFC_CONTEXT* context); |
|
207 |
|
208 /*! |
|
209 * \brief DecreaseClientElementCount |
|
210 * |
|
211 * \param context |
|
212 * \return positive or zero decreased current element count; negative indicating the count can't be decreased - p0robably already zero |
|
213 */ |
|
214 OWF_API_CALL WFCint |
|
215 WFC_Context_DecreaseClientElementCount(WFC_CONTEXT* context); |
|
216 |
|
217 /*! |
|
218 * \brief Insert element into context's scene |
|
219 * |
|
220 * \param context |
|
221 * \param element |
|
222 * \param subordinate |
|
223 * |
|
224 * \return WFCErrorCode |
|
225 */ |
|
226 OWF_API_CALL WFCErrorCode |
|
227 WFC_Context_InsertElement(WFC_CONTEXT* context, |
|
228 WFCElement element, |
|
229 WFCElement subordinate); |
|
230 |
|
231 /*! |
|
232 * \brief Remove element from context's scene |
|
233 * |
|
234 * \param context |
|
235 * \param element |
|
236 * |
|
237 * \return WFCErrorCode |
|
238 */ |
|
239 OWF_API_CALL WFCErrorCode |
|
240 WFC_Context_RemoveElement(WFC_CONTEXT* context, |
|
241 WFCElement element); |
|
242 |
|
243 /*! |
|
244 * \brief Fetch the handle of the element that is above the given element. |
|
245 * |
|
246 * \param context |
|
247 * \param element |
|
248 * |
|
249 * \return Error code. On return, the location pointed by result |
|
250 * will contain handle of the element above OR WFC_INVALID_HANDLE, |
|
251 * if no element is above given element. |
|
252 */ |
|
253 OWF_API_CALL WFCErrorCode |
|
254 WFC_Context_GetElementAbove(WFC_CONTEXT* context, |
|
255 WFCElement element, |
|
256 WFCElement* result); |
|
257 |
|
258 /*! |
|
259 * \brief Fetch the handle of the element that is below the given element. |
|
260 * |
|
261 * \param context |
|
262 * \param element |
|
263 * |
|
264 * \return Error code. On return, the location pointed by result |
|
265 * will contain handle of the element below OR WFC_INVALID_HANDLE, |
|
266 * if no element is below given element. |
|
267 */ |
|
268 OWF_API_CALL WFCErrorCode |
|
269 WFC_Context_GetElementBelow(WFC_CONTEXT* context, |
|
270 WFCElement element, |
|
271 WFCElement* result); |
|
272 |
|
273 /*! |
|
274 * \brief Get context attribute value |
|
275 * |
|
276 * \param context |
|
277 * \param attrib |
|
278 * \param value |
|
279 * |
|
280 * \return WFCErrorCode |
|
281 */ |
|
282 OWF_API_CALL WFCErrorCode |
|
283 WFC_Context_GetAttribi(WFC_CONTEXT* context, |
|
284 WFCContextAttrib attrib, |
|
285 WFCint* value); |
|
286 |
|
287 /*! |
|
288 * \brief Set context attribute value |
|
289 * |
|
290 * \param context |
|
291 * \param attrib |
|
292 * \param value |
|
293 * |
|
294 * \return WFCErrorCode |
|
295 */ |
|
296 OWF_API_CALL WFCErrorCode |
|
297 WFC_Context_SetAttribi(WFC_CONTEXT* context, |
|
298 WFCContextAttrib attrib, |
|
299 WFCint value); |
|
300 |
|
301 /*! |
|
302 * \brief Get context attribute value |
|
303 * |
|
304 * \param context |
|
305 * \param attrib |
|
306 * \param value |
|
307 * |
|
308 * \return WFCErrorCode |
|
309 */ |
|
310 OWF_API_CALL WFCErrorCode |
|
311 WFC_Context_GetAttribfv(WFC_CONTEXT* context, |
|
312 WFCContextAttrib attrib, |
|
313 WFCint count, |
|
314 WFCfloat* values); |
|
315 |
|
316 /*! |
|
317 * \brief Set context attribute value |
|
318 * |
|
319 * \param context |
|
320 * \param attrib |
|
321 * \param value |
|
322 * |
|
323 * \return WFCErrorCode |
|
324 */ |
|
325 OWF_API_CALL WFCErrorCode |
|
326 WFC_Context_SetAttribfv(WFC_CONTEXT* context, |
|
327 WFCContextAttrib attrib, |
|
328 WFCint count, |
|
329 const WFCfloat* values); |
|
330 |
|
331 |
|
332 /*! |
|
333 * \brief Stream content notification callback |
|
334 * |
|
335 * \param stream Handle of the stream |
|
336 * \param event Stream event type |
|
337 * \param data Context |
|
338 */ |
|
339 OWF_API_CALL void |
|
340 WFC_Context_SourceStreamUpdated(OWFNativeStreamType stream, |
|
341 OWFint event, |
|
342 void* data, |
|
343 void* param); |
|
344 |
|
345 /*! |
|
346 * \brief Check if context is currently activated |
|
347 * |
|
348 * \param context |
|
349 */ |
|
350 |
|
351 OWF_API_CALL WFCboolean |
|
352 WFC_Context_Active(WFC_CONTEXT* context); |
|
353 |
|
354 #ifdef __cplusplus |
|
355 } |
|
356 #endif |
|
357 |
|
358 #endif /*WFCCONTEXT_H_*/ |