graphicscomposition/openwfcompositionengine/composition/include/wfcstructs.h
changeset 0 5d03bc08d59c
child 152 9f1c3fea0f87
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 
       
    24 /*! \ingroup wfc
       
    25  *  \file wfcstructs.h
       
    26  *
       
    27  *  \brief Composition SI data structures
       
    28  */
       
    29 
       
    30 #ifndef WFCSTRUCTS_H_
       
    31 #define WFCSTRUCTS_H_
       
    32 
       
    33 #include "WF/wfc.h"
       
    34 
       
    35 #include "owftypes.h"
       
    36 #include "owfimage.h"
       
    37 #include "owfattributes.h"
       
    38 #include "owfmessagequeue.h"
       
    39 #include "owfthread.h"
       
    40 #include "owfmutex.h"
       
    41 #include "owfarray.h"
       
    42 #include "owfpool.h"
       
    43 #include "owflinkedlist.h"
       
    44 #include "owfdisplaycontextgeneral.h"
       
    45 
       
    46 #ifdef __cplusplus
       
    47 extern "C"
       
    48 {
       
    49 #endif
       
    50 
       
    51 struct WFC_CONTEXT_;
       
    52 
       
    53 
       
    54 typedef struct WFC_DEVICE_ {
       
    55     WFCDevice               deviceId;
       
    56     WFCHandle               handle;
       
    57     WFCErrorCode            latestUnreadError;
       
    58     OWF_ARRAY               contexts;
       
    59     OWF_ARRAY               providers;
       
    60     OWF_ARRAY               elements;
       
    61     OWF_MUTEX               mutex;
       
    62 } WFC_DEVICE;
       
    63 
       
    64 typedef struct PHYSICAL_DEVICE_ {
       
    65             OWF_ARRAY iDeviceInstanceArray;
       
    66             OWFint gDeviceHandleID;
       
    67 } PHYSICAL_DEVICE;
       
    68 
       
    69 typedef struct {
       
    70     OWFNativeStreamBuffer   targetBuffer;
       
    71     /* */
       
    72     void*                   targetPixels;
       
    73     /* Mapped to the external format target image buffer each frame */
       
    74     OWF_IMAGE*              targetImage;
       
    75     /* Mapped to the internal format target image to compose to */
       
    76     OWF_IMAGE*              internalTargetImage;
       
    77     
       
    78     /* The unrotated target buffer */ 
       
    79     OWF_IMAGE_INST          unrotatedTargetImage;
       
    80     /* The rotated version of the target buffer for hardware rotation, 
       
    81      * or a de-rotated version of the internal buffer into another scratch buffer for software rotation
       
    82      */ 
       
    83     OWF_IMAGE_INST          rotatedTargetImage;
       
    84     /* The internal target buffer composed to for 0 and 180 degree rotation */
       
    85     OWF_IMAGE_INST          unrotatedInternalTargetImage;
       
    86     /* The internal target buffer composed to for 90 and 270 degree rotation */
       
    87     OWF_IMAGE_INST          rotatedInternalTargetImage;
       
    88 } WFC_CONTEXT_STATE;
       
    89 
       
    90 /*!
       
    91 Scratch buffers needed:
       
    92 1 for cropped source image
       
    93 1 for cropped mask image
       
    94 1 for scaled element image
       
    95 1 for mask
       
    96 */
       
    97 #define SCRATCH_BUFFER_COUNT    5
       
    98 
       
    99 typedef struct {
       
   100     /*! elements, ordered by depth; starting from bottom */
       
   101     struct WFC_CONTEXT_*    context;
       
   102     OWF_NODE*               elements;
       
   103 } WFC_SCENE;
       
   104 
       
   105 
       
   106 /*!
       
   107  Element's composition state parameters.
       
   108  */
       
   109 typedef struct {
       
   110     /*! original source image and mask image - inputs to the first stage */
       
   111     OWF_IMAGE*              originalSourceImage;
       
   112     OWF_IMAGE*              originalMaskImage;
       
   113     
       
   114     /*! converted source image -
       
   115        results of the first stage in the 
       
   116        composition */
       
   117     OWF_IMAGE_INST          convertedSourceImage;
       
   118     
       
   119     /*! cropped source image - result of cropping stage */
       
   120     OWF_IMAGE_INST          croppedSourceImage;
       
   121 
       
   122     /*! mirrored source intermediate image - temp buffer used in mirroring stage */
       
   123     OWF_IMAGE_INST          rotatedSourceIntermediateImage;
       
   124     
       
   125     /*! mirrored source image - result of mirroring stage */
       
   126     OWF_IMAGE_INST          flippedSourceImage;
       
   127     
       
   128     /*! rotated source image - result of rotation stage */
       
   129     OWF_IMAGE_INST          rotatedSourceImage;
       
   130     
       
   131     /*! these are the "final size" (i.e. destination
       
   132        size) versions of the previous. used in
       
   133        the blending stage */
       
   134     OWF_IMAGE_INST          scaledSourceImage;
       
   135     OWF_RECTANGLE           scaledSrcRect;
       
   136     OWF_IMAGE_INST          maskImage;
       
   137 
       
   138     
       
   139     /*! support for blending operation */
       
   140     OWF_BLEND_INFO          blendInfo;
       
   141     
       
   142     
       
   143     /*! source and target extents */
       
   144     WFCfloat                sourceRect[4]; 
       
   145     WFCfloat                destinationRect[4];
       
   146     OWF_RECTANGLE           dstRect;
       
   147     
       
   148     /*! source fp viewport */
       
   149     WFCfloat                transformedSourceRect[4];
       
   150     
       
   151     /*! oversized integer crop */
       
   152     OWF_RECTANGLE           oversizedCropRect;
       
   153     
       
   154     /* Other attributes copied from element */
       
   155     OWFsubpixel             globalAlpha;
       
   156     WFCScaleFilter          sourceScaleFilter;
       
   157     WFCbitfield             transparencyTypes;
       
   158     /*! rotation method */
       
   159     WFCRotation             rotation;
       
   160     /*! flipping */
       
   161     WFCboolean              sourceFlip;
       
   162 
       
   163 } WFC_ELEMENT_STATE;
       
   164 
       
   165 typedef enum
       
   166 {
       
   167     WFC_IMAGE_SOURCE,
       
   168     WFC_IMAGE_MASK
       
   169 } WFC_IMAGE_PROVIDER_TYPE;
       
   170 
       
   171 typedef struct 
       
   172 {
       
   173     OWFNativeStreamBuffer   buffer;
       
   174     OWFint                  lockCount;
       
   175     OWF_IMAGE_INST          image;
       
   176 
       
   177 } WFC_LOCK_STREAM;
       
   178 
       
   179 typedef struct
       
   180 {
       
   181     WFCHandle               handle;
       
   182     WFC_IMAGE_PROVIDER_TYPE type;
       
   183     OWFNativeStreamType     streamHandle;
       
   184     void*                   owner;
       
   185     WFCint                  contentUpdated;
       
   186     WFCint                  contentVisible;
       
   187     WFCint                  composed;
       
   188     WFCint                  visited;
       
   189     WFC_LOCK_STREAM         lockedStream;
       
   190 
       
   191 } WFC_IMAGE_PROVIDER;
       
   192 
       
   193 typedef struct {
       
   194     WFCElement              handle;
       
   195     WFC_DEVICE*             device;
       
   196     struct WFC_CONTEXT_*     context;
       
   197     /*! element attributes */
       
   198     WFCfloat                srcRect[4];
       
   199     WFCfloat                dstRect[4];
       
   200     WFCboolean              sourceFlip;
       
   201     WFCRotation             sourceRotation;
       
   202     WFCScaleFilter          sourceScaleFilter;
       
   203     WFCbitfield             transparencyTypes;
       
   204     WFCfloat                globalAlpha;
       
   205     WFCMask                 maskHandle;
       
   206     WFCSource               sourceHandle;
       
   207 
       
   208     /*! client scene and composed scene dereferenced image providers */
       
   209     WFC_IMAGE_PROVIDER*     mask;
       
   210     WFC_IMAGE_PROVIDER*     source;
       
   211     WFC_IMAGE_PROVIDER*     cachedMask;
       
   212     WFC_IMAGE_PROVIDER*     cachedSource;
       
   213 
       
   214     /*! shared element? (must not be destroyed by a scene) */
       
   215     WFCboolean              shared;
       
   216 
       
   217     /*! set in WFC_Element_BeginComposition to indicate whether
       
   218        the element should be included in composition */
       
   219     WFCboolean              skipCompose;
       
   220     /*! Set in WFC_Element_BeginComposition to indicate whether 
       
   221      * the mask stream should be included in composition */
       
   222     WFCboolean              maskComposed;
       
   223 } WFC_ELEMENT;
       
   224 
       
   225 typedef enum
       
   226 {
       
   227     WFC_CONTEXT_STATE_PASSIVE,
       
   228     WFC_CONTEXT_STATE_ACTIVATING,
       
   229     WFC_CONTEXT_STATE_ACTIVE,
       
   230     WFC_CONTEXT_STATE_DEACTIVATING
       
   231 } WFC_CONTEXT_ACTIVATION_STATE;
       
   232 
       
   233 typedef EGLint (*TFPtrEglPrivateSignalSyncNok) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
       
   234 #define INITIAL_CONTEXT_SERIAL_NUMBER 0
       
   235 typedef struct WFC_CONTEXT_ {
       
   236     WFCContext              handle;
       
   237     WFC_DEVICE*             device;
       
   238 
       
   239     /*! work-in-progress scene */
       
   240     WFC_SCENE*              workScene;
       
   241     WFC_SCENE*              committedScene;
       
   242     WFC_SCENE*              snapshotScene;
       
   243 
       
   244     /*! pools for resource allocation */
       
   245     OWF_POOL*               scenePool;
       
   246     OWF_POOL*               nodePool;
       
   247     OWF_POOL*               elementPool;
       
   248 
       
   249     /*! screen number for on-screen contexts */
       
   250     WFCint                  screenNumber;
       
   251 
       
   252     /*!  scratch buffers used in composition to store per-element
       
   253         intermediate results */
       
   254     void*                   scratchBuffer[SCRATCH_BUFFER_COUNT];
       
   255 
       
   256     /*! onscreen/offscreen write stream */
       
   257     OWFNativeStreamType     stream;
       
   258     WFCContextType          type;
       
   259     WFCint                  targetWidth;
       
   260     WFCint                  targetHeight;
       
   261     WFCRotation             rotation;
       
   262     OWFuint32               backgroundColor;
       
   263     WFCElement              lowestElement;
       
   264     OWF_ATTRIBUTE_LIST      attributes;
       
   265     WFCint                  clientElementCount;
       
   266 
       
   267     /*! timing & synchronization */
       
   268     OWF_MESSAGE_QUEUE       composerQueue;
       
   269     OWF_THREAD              composerThread;
       
   270     WFC_CONTEXT_ACTIVATION_STATE       activationState;
       
   271     OWF_SEMAPHORE           compositionSemaphore;
       
   272     OWF_SEMAPHORE           commitSemaphore;
       
   273     OWF_MUTEX               updateFlagMutex;
       
   274     OWF_MUTEX               sceneMutex;
       
   275     WFCint                  sourceUpdateCount;
       
   276    
       
   277     WFC_CONTEXT_STATE       state;
       
   278     OWF_DISPCTX             displayContext;
       
   279     
       
   280     WFCEGLDisplay           nextSyncObjectDisplay;
       
   281     WFC_ELEMENT_STATE       prototypeElementState;    
       
   282     TFPtrEglPrivateSignalSyncNok    eglPrivateSignalSync;
       
   283 } WFC_CONTEXT;
       
   284 
       
   285 typedef struct WFC_CONTENT_UPDATED_PARAM_ {
       
   286     WFCint      length;
       
   287     WFCint      id;
       
   288     WFCint      par;
       
   289     WFCint      serialNumber;
       
   290     WFCint      immediateAvailable;
       
   291     WFCint      immediateVisibility;
       
   292 } WFC_CONTENT_UPDATED_PARAM;
       
   293 
       
   294 #define IMAGE_PROVIDER(x)   ((WFC_IMAGE_PROVIDER*)(x))
       
   295 #define ELEMENT(x)          ((WFC_ELEMENT*)(x))
       
   296 #define CONTEXT(x)          ((WFC_CONTEXT*)(x))
       
   297 #define DEVICE(x)           ((WFC_DEVICE*)(x))
       
   298 #define SCENE(x)            ((WFC_SCENE*)(x))
       
   299 #define STREAM(x)           ((OWF_STREAM*)(x))
       
   300 
       
   301 #ifdef __cplusplus
       
   302 }
       
   303 #endif
       
   304 
       
   305 #endif /*STRUCTS_H_*/
       
   306