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