os/graphics/graphicscomposition/openwfcompositionengine/composition/include/wfcstructs.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/* Copyright (c) 2009 The Khronos Group Inc.
sl@0
     2
 * Portions copyright (c) 2009-2010  Nokia Corporation and/or its subsidiary(-ies)
sl@0
     3
 *
sl@0
     4
 * Permission is hereby granted, free of charge, to any person obtaining a
sl@0
     5
 * copy of this software and/or associated documentation files (the
sl@0
     6
 * "Materials"), to deal in the Materials without restriction, including
sl@0
     7
 * without limitation the rights to use, copy, modify, merge, publish,
sl@0
     8
 * distribute, sublicense, and/or sell copies of the Materials, and to
sl@0
     9
 * permit persons to whom the Materials are furnished to do so, subject to
sl@0
    10
 * the following conditions:
sl@0
    11
 *
sl@0
    12
 * The above copyright notice and this permission notice shall be included
sl@0
    13
 * in all copies or substantial portions of the Materials.
sl@0
    14
 *
sl@0
    15
 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
sl@0
    16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
sl@0
    17
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
sl@0
    18
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
sl@0
    19
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
sl@0
    20
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
sl@0
    21
 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
sl@0
    22
 */
sl@0
    23
sl@0
    24
sl@0
    25
/*! \ingroup wfc
sl@0
    26
 *  \file wfcstructs.h
sl@0
    27
 *
sl@0
    28
 *  \brief Composition SI data structures
sl@0
    29
 */
sl@0
    30
sl@0
    31
#ifndef WFCSTRUCTS_H_
sl@0
    32
#define WFCSTRUCTS_H_
sl@0
    33
sl@0
    34
#include "WF/wfc.h"
sl@0
    35
sl@0
    36
#include "owftypes.h"
sl@0
    37
#include "owfimage.h"
sl@0
    38
#include "owfattributes.h"
sl@0
    39
#include "owfmessagequeue.h"
sl@0
    40
#include "owfthread.h"
sl@0
    41
#include "owfmutex.h"
sl@0
    42
#include "owfarray.h"
sl@0
    43
#include "owfpool.h"
sl@0
    44
#include "owflinkedlist.h"
sl@0
    45
#include "owfdisplaycontextgeneral.h"
sl@0
    46
sl@0
    47
#ifdef __cplusplus
sl@0
    48
extern "C"
sl@0
    49
{
sl@0
    50
#endif
sl@0
    51
sl@0
    52
struct WFC_CONTEXT_;
sl@0
    53
sl@0
    54
sl@0
    55
typedef struct WFC_DEVICE_ {
sl@0
    56
    WFCDevice               deviceId;
sl@0
    57
    WFCHandle               handle;
sl@0
    58
    WFCErrorCode            latestUnreadError;
sl@0
    59
    OWF_ARRAY               contexts;
sl@0
    60
    OWF_ARRAY               providers;
sl@0
    61
    OWF_ARRAY               elements;
sl@0
    62
    OWF_MUTEX               mutex;
sl@0
    63
} WFC_DEVICE;
sl@0
    64
sl@0
    65
typedef struct PHYSICAL_DEVICE_ {
sl@0
    66
            OWF_ARRAY iDeviceInstanceArray;
sl@0
    67
            OWFint gDeviceHandleID;
sl@0
    68
} PHYSICAL_DEVICE;
sl@0
    69
sl@0
    70
typedef struct {
sl@0
    71
    OWFNativeStreamBuffer   targetBuffer;
sl@0
    72
    /* */
sl@0
    73
    void*                   targetPixels;
sl@0
    74
    /* Mapped to the external format target image buffer each frame */
sl@0
    75
    OWF_IMAGE*              targetImage;
sl@0
    76
    /* Mapped to the internal format target image to compose to */
sl@0
    77
    OWF_IMAGE*              internalTargetImage;
sl@0
    78
    
sl@0
    79
    /* The unrotated target buffer */ 
sl@0
    80
    OWF_IMAGE_INST          unrotatedTargetImage;
sl@0
    81
    /* The rotated version of the target buffer for hardware rotation, 
sl@0
    82
     * or a de-rotated version of the internal buffer into another scratch buffer for software rotation
sl@0
    83
     */ 
sl@0
    84
    OWF_IMAGE_INST          rotatedTargetImage;
sl@0
    85
    /* The internal target buffer composed to for 0 and 180 degree rotation */
sl@0
    86
    OWF_IMAGE_INST          unrotatedInternalTargetImage;
sl@0
    87
    /* The internal target buffer composed to for 90 and 270 degree rotation */
sl@0
    88
    OWF_IMAGE_INST          rotatedInternalTargetImage;
sl@0
    89
} WFC_CONTEXT_STATE;
sl@0
    90
sl@0
    91
/*!
sl@0
    92
Scratch buffers needed:
sl@0
    93
1 for cropped source image
sl@0
    94
1 for cropped mask image
sl@0
    95
1 for scaled element image
sl@0
    96
1 for mask
sl@0
    97
*/
sl@0
    98
#define SCRATCH_BUFFER_COUNT    5
sl@0
    99
sl@0
   100
typedef struct {
sl@0
   101
    /*! elements, ordered by depth; starting from bottom */
sl@0
   102
    struct WFC_CONTEXT_*    context;
sl@0
   103
    OWF_NODE*               elements;
sl@0
   104
} WFC_SCENE;
sl@0
   105
sl@0
   106
sl@0
   107
/*!
sl@0
   108
 Element's composition state parameters.
sl@0
   109
 */
sl@0
   110
typedef struct {
sl@0
   111
    /*! original source image and mask image - inputs to the first stage */
sl@0
   112
    OWF_IMAGE*              originalSourceImage;
sl@0
   113
    OWF_IMAGE*              originalMaskImage;
sl@0
   114
    
sl@0
   115
    /*! converted source image -
sl@0
   116
       results of the first stage in the 
sl@0
   117
       composition */
sl@0
   118
    OWF_IMAGE_INST          convertedSourceImage;
sl@0
   119
    
sl@0
   120
    /*! cropped source image - result of cropping stage */
sl@0
   121
    OWF_IMAGE_INST          croppedSourceImage;
sl@0
   122
sl@0
   123
    /*! mirrored source intermediate image - temp buffer used in mirroring stage */
sl@0
   124
    OWF_IMAGE_INST          rotatedSourceIntermediateImage;
sl@0
   125
    
sl@0
   126
    /*! mirrored source image - result of mirroring stage */
sl@0
   127
    OWF_IMAGE_INST          flippedSourceImage;
sl@0
   128
    
sl@0
   129
    /*! rotated source image - result of rotation stage */
sl@0
   130
    OWF_IMAGE_INST          rotatedSourceImage;
sl@0
   131
    
sl@0
   132
    /*! these are the "final size" (i.e. destination
sl@0
   133
       size) versions of the previous. used in
sl@0
   134
       the blending stage */
sl@0
   135
    OWF_IMAGE_INST          scaledSourceImage;
sl@0
   136
    OWF_RECTANGLE           scaledSrcRect;
sl@0
   137
    OWF_IMAGE_INST          maskImage;
sl@0
   138
sl@0
   139
    
sl@0
   140
    /*! support for blending operation */
sl@0
   141
    OWF_BLEND_INFO          blendInfo;
sl@0
   142
    
sl@0
   143
    
sl@0
   144
    /*! source and target extents */
sl@0
   145
    WFCfloat                sourceRect[4]; 
sl@0
   146
    WFCfloat                destinationRect[4];
sl@0
   147
    OWF_RECTANGLE           dstRect;
sl@0
   148
    
sl@0
   149
    /*! source fp viewport */
sl@0
   150
    WFCfloat                transformedSourceRect[4];
sl@0
   151
    
sl@0
   152
    /*! oversized integer crop */
sl@0
   153
    OWF_RECTANGLE           oversizedCropRect;
sl@0
   154
    
sl@0
   155
    /* Other attributes copied from element */
sl@0
   156
    OWFsubpixel             globalAlpha;
sl@0
   157
    WFCScaleFilter          sourceScaleFilter;
sl@0
   158
    WFCbitfield             transparencyTypes;
sl@0
   159
    /*! rotation method */
sl@0
   160
    WFCRotation             rotation;
sl@0
   161
    /*! flipping */
sl@0
   162
    WFCboolean              sourceFlip;
sl@0
   163
sl@0
   164
} WFC_ELEMENT_STATE;
sl@0
   165
sl@0
   166
typedef enum
sl@0
   167
{
sl@0
   168
    WFC_IMAGE_SOURCE,
sl@0
   169
    WFC_IMAGE_MASK
sl@0
   170
} WFC_IMAGE_PROVIDER_TYPE;
sl@0
   171
sl@0
   172
typedef struct 
sl@0
   173
{
sl@0
   174
    OWFNativeStreamBuffer   buffer;
sl@0
   175
    OWFint                  lockCount;
sl@0
   176
    OWF_IMAGE_INST          image;
sl@0
   177
sl@0
   178
} WFC_LOCK_STREAM;
sl@0
   179
sl@0
   180
typedef struct
sl@0
   181
{
sl@0
   182
    WFCHandle               handle;
sl@0
   183
    WFC_IMAGE_PROVIDER_TYPE type;
sl@0
   184
    OWFNativeStreamType     streamHandle;
sl@0
   185
    void*                   owner;
sl@0
   186
    WFCint                  contentUpdated;
sl@0
   187
    WFCint                  contentVisible;
sl@0
   188
    WFCint                  composed;
sl@0
   189
    WFCint                  visited;
sl@0
   190
    WFC_LOCK_STREAM         lockedStream;
sl@0
   191
sl@0
   192
} WFC_IMAGE_PROVIDER;
sl@0
   193
sl@0
   194
typedef struct {
sl@0
   195
    WFCElement              handle;
sl@0
   196
    WFC_DEVICE*             device;
sl@0
   197
    struct WFC_CONTEXT_*     context;
sl@0
   198
    /*! element attributes */
sl@0
   199
    WFCfloat                srcRect[4];
sl@0
   200
    WFCfloat                dstRect[4];
sl@0
   201
    WFCboolean              sourceFlip;
sl@0
   202
    WFCRotation             sourceRotation;
sl@0
   203
    WFCScaleFilter          sourceScaleFilter;
sl@0
   204
    WFCbitfield             transparencyTypes;
sl@0
   205
    WFCfloat                globalAlpha;
sl@0
   206
    WFCMask                 maskHandle;
sl@0
   207
    WFCSource               sourceHandle;
sl@0
   208
sl@0
   209
    /*! client scene and composed scene dereferenced image providers */
sl@0
   210
    WFC_IMAGE_PROVIDER*     mask;
sl@0
   211
    WFC_IMAGE_PROVIDER*     source;
sl@0
   212
    WFC_IMAGE_PROVIDER*     cachedMask;
sl@0
   213
    WFC_IMAGE_PROVIDER*     cachedSource;
sl@0
   214
sl@0
   215
    /*! shared element? (must not be destroyed by a scene) */
sl@0
   216
    WFCboolean              shared;
sl@0
   217
sl@0
   218
    /*! set in WFC_Element_BeginComposition to indicate whether
sl@0
   219
       the element should be included in composition */
sl@0
   220
    WFCboolean              skipCompose;
sl@0
   221
    /*! Set in WFC_Element_BeginComposition to indicate whether 
sl@0
   222
     * the mask stream should be included in composition */
sl@0
   223
    WFCboolean              maskComposed;
sl@0
   224
} WFC_ELEMENT;
sl@0
   225
sl@0
   226
typedef enum
sl@0
   227
{
sl@0
   228
    WFC_CONTEXT_STATE_PASSIVE,
sl@0
   229
    WFC_CONTEXT_STATE_ACTIVATING,
sl@0
   230
    WFC_CONTEXT_STATE_ACTIVE,
sl@0
   231
    WFC_CONTEXT_STATE_DEACTIVATING
sl@0
   232
} WFC_CONTEXT_ACTIVATION_STATE;
sl@0
   233
sl@0
   234
typedef EGLint (*TFPtrEglPrivateSignalSyncNok) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
sl@0
   235
#define INITIAL_CONTEXT_SERIAL_NUMBER 0
sl@0
   236
typedef struct WFC_CONTEXT_ {
sl@0
   237
    WFCContext              handle;
sl@0
   238
    WFC_DEVICE*             device;
sl@0
   239
sl@0
   240
    /*! work-in-progress scene */
sl@0
   241
    WFC_SCENE*              workScene;
sl@0
   242
    WFC_SCENE*              committedScene;
sl@0
   243
    WFC_SCENE*              snapshotScene;
sl@0
   244
sl@0
   245
    /*! pools for resource allocation */
sl@0
   246
    OWF_POOL*               scenePool;
sl@0
   247
    OWF_POOL*               nodePool;
sl@0
   248
    OWF_POOL*               elementPool;
sl@0
   249
sl@0
   250
    /*! screen number for on-screen contexts */
sl@0
   251
    WFCint                  screenNumber;
sl@0
   252
sl@0
   253
    /*!  scratch buffers used in composition to store per-element
sl@0
   254
        intermediate results */
sl@0
   255
    void*                   scratchBuffer[SCRATCH_BUFFER_COUNT];
sl@0
   256
sl@0
   257
    /*! onscreen/offscreen write stream */
sl@0
   258
    OWFNativeStreamType     stream;
sl@0
   259
    WFCContextType          type;
sl@0
   260
    WFCint                  targetWidth;
sl@0
   261
    WFCint                  targetHeight;
sl@0
   262
    WFCRotation             rotation;
sl@0
   263
    OWFuint32               backgroundColor;
sl@0
   264
    WFCElement              lowestElement;
sl@0
   265
    OWF_ATTRIBUTE_LIST      attributes;
sl@0
   266
    WFCint                  clientElementCount;
sl@0
   267
sl@0
   268
    /*! timing & synchronization */
sl@0
   269
    OWF_MESSAGE_QUEUE       composerQueue;
sl@0
   270
    OWF_THREAD              composerThread;
sl@0
   271
    WFC_CONTEXT_ACTIVATION_STATE       activationState;
sl@0
   272
    OWF_SEMAPHORE           compositionSemaphore;
sl@0
   273
    OWF_SEMAPHORE           commitSemaphore;
sl@0
   274
    OWF_MUTEX               updateFlagMutex;
sl@0
   275
    OWF_MUTEX               sceneMutex;
sl@0
   276
    WFCint                  sourceUpdateCount;
sl@0
   277
   
sl@0
   278
    WFC_CONTEXT_STATE       state;
sl@0
   279
    OWF_DISPCTX             displayContext;
sl@0
   280
    
sl@0
   281
    WFCEGLDisplay           nextSyncObjectDisplay;
sl@0
   282
    WFC_ELEMENT_STATE       prototypeElementState;    
sl@0
   283
    TFPtrEglPrivateSignalSyncNok    eglPrivateSignalSync;
sl@0
   284
} WFC_CONTEXT;
sl@0
   285
sl@0
   286
sl@0
   287
#define IMAGE_PROVIDER(x)   ((WFC_IMAGE_PROVIDER*)(x))
sl@0
   288
#define ELEMENT(x)          ((WFC_ELEMENT*)(x))
sl@0
   289
#define CONTEXT(x)          ((WFC_CONTEXT*)(x))
sl@0
   290
#define DEVICE(x)           ((WFC_DEVICE*)(x))
sl@0
   291
#define SCENE(x)            ((WFC_SCENE*)(x))
sl@0
   292
#define STREAM(x)           ((OWF_STREAM*)(x))
sl@0
   293
sl@0
   294
#ifdef __cplusplus
sl@0
   295
}
sl@0
   296
#endif
sl@0
   297
sl@0
   298
#endif /*STRUCTS_H_*/
sl@0
   299