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