os/graphics/graphicscomposition/openwfcompositionengine/composition/include/wfcstructs.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfcompositionengine/composition/include/wfcstructs.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,299 @@
1.4 +/* Copyright (c) 2009 The Khronos Group Inc.
1.5 + * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies)
1.6 + *
1.7 + * Permission is hereby granted, free of charge, to any person obtaining a
1.8 + * copy of this software and/or associated documentation files (the
1.9 + * "Materials"), to deal in the Materials without restriction, including
1.10 + * without limitation the rights to use, copy, modify, merge, publish,
1.11 + * distribute, sublicense, and/or sell copies of the Materials, and to
1.12 + * permit persons to whom the Materials are furnished to do so, subject to
1.13 + * the following conditions:
1.14 + *
1.15 + * The above copyright notice and this permission notice shall be included
1.16 + * in all copies or substantial portions of the Materials.
1.17 + *
1.18 + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1.19 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1.20 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1.21 + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1.22 + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1.23 + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1.24 + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1.25 + */
1.26 +
1.27 +
1.28 +/*! \ingroup wfc
1.29 + * \file wfcstructs.h
1.30 + *
1.31 + * \brief Composition SI data structures
1.32 + */
1.33 +
1.34 +#ifndef WFCSTRUCTS_H_
1.35 +#define WFCSTRUCTS_H_
1.36 +
1.37 +#include "WF/wfc.h"
1.38 +
1.39 +#include "owftypes.h"
1.40 +#include "owfimage.h"
1.41 +#include "owfattributes.h"
1.42 +#include "owfmessagequeue.h"
1.43 +#include "owfthread.h"
1.44 +#include "owfmutex.h"
1.45 +#include "owfarray.h"
1.46 +#include "owfpool.h"
1.47 +#include "owflinkedlist.h"
1.48 +#include "owfdisplaycontextgeneral.h"
1.49 +
1.50 +#ifdef __cplusplus
1.51 +extern "C"
1.52 +{
1.53 +#endif
1.54 +
1.55 +struct WFC_CONTEXT_;
1.56 +
1.57 +
1.58 +typedef struct WFC_DEVICE_ {
1.59 + WFCDevice deviceId;
1.60 + WFCHandle handle;
1.61 + WFCErrorCode latestUnreadError;
1.62 + OWF_ARRAY contexts;
1.63 + OWF_ARRAY providers;
1.64 + OWF_ARRAY elements;
1.65 + OWF_MUTEX mutex;
1.66 +} WFC_DEVICE;
1.67 +
1.68 +typedef struct PHYSICAL_DEVICE_ {
1.69 + OWF_ARRAY iDeviceInstanceArray;
1.70 + OWFint gDeviceHandleID;
1.71 +} PHYSICAL_DEVICE;
1.72 +
1.73 +typedef struct {
1.74 + OWFNativeStreamBuffer targetBuffer;
1.75 + /* */
1.76 + void* targetPixels;
1.77 + /* Mapped to the external format target image buffer each frame */
1.78 + OWF_IMAGE* targetImage;
1.79 + /* Mapped to the internal format target image to compose to */
1.80 + OWF_IMAGE* internalTargetImage;
1.81 +
1.82 + /* The unrotated target buffer */
1.83 + OWF_IMAGE_INST unrotatedTargetImage;
1.84 + /* The rotated version of the target buffer for hardware rotation,
1.85 + * or a de-rotated version of the internal buffer into another scratch buffer for software rotation
1.86 + */
1.87 + OWF_IMAGE_INST rotatedTargetImage;
1.88 + /* The internal target buffer composed to for 0 and 180 degree rotation */
1.89 + OWF_IMAGE_INST unrotatedInternalTargetImage;
1.90 + /* The internal target buffer composed to for 90 and 270 degree rotation */
1.91 + OWF_IMAGE_INST rotatedInternalTargetImage;
1.92 +} WFC_CONTEXT_STATE;
1.93 +
1.94 +/*!
1.95 +Scratch buffers needed:
1.96 +1 for cropped source image
1.97 +1 for cropped mask image
1.98 +1 for scaled element image
1.99 +1 for mask
1.100 +*/
1.101 +#define SCRATCH_BUFFER_COUNT 5
1.102 +
1.103 +typedef struct {
1.104 + /*! elements, ordered by depth; starting from bottom */
1.105 + struct WFC_CONTEXT_* context;
1.106 + OWF_NODE* elements;
1.107 +} WFC_SCENE;
1.108 +
1.109 +
1.110 +/*!
1.111 + Element's composition state parameters.
1.112 + */
1.113 +typedef struct {
1.114 + /*! original source image and mask image - inputs to the first stage */
1.115 + OWF_IMAGE* originalSourceImage;
1.116 + OWF_IMAGE* originalMaskImage;
1.117 +
1.118 + /*! converted source image -
1.119 + results of the first stage in the
1.120 + composition */
1.121 + OWF_IMAGE_INST convertedSourceImage;
1.122 +
1.123 + /*! cropped source image - result of cropping stage */
1.124 + OWF_IMAGE_INST croppedSourceImage;
1.125 +
1.126 + /*! mirrored source intermediate image - temp buffer used in mirroring stage */
1.127 + OWF_IMAGE_INST rotatedSourceIntermediateImage;
1.128 +
1.129 + /*! mirrored source image - result of mirroring stage */
1.130 + OWF_IMAGE_INST flippedSourceImage;
1.131 +
1.132 + /*! rotated source image - result of rotation stage */
1.133 + OWF_IMAGE_INST rotatedSourceImage;
1.134 +
1.135 + /*! these are the "final size" (i.e. destination
1.136 + size) versions of the previous. used in
1.137 + the blending stage */
1.138 + OWF_IMAGE_INST scaledSourceImage;
1.139 + OWF_RECTANGLE scaledSrcRect;
1.140 + OWF_IMAGE_INST maskImage;
1.141 +
1.142 +
1.143 + /*! support for blending operation */
1.144 + OWF_BLEND_INFO blendInfo;
1.145 +
1.146 +
1.147 + /*! source and target extents */
1.148 + WFCfloat sourceRect[4];
1.149 + WFCfloat destinationRect[4];
1.150 + OWF_RECTANGLE dstRect;
1.151 +
1.152 + /*! source fp viewport */
1.153 + WFCfloat transformedSourceRect[4];
1.154 +
1.155 + /*! oversized integer crop */
1.156 + OWF_RECTANGLE oversizedCropRect;
1.157 +
1.158 + /* Other attributes copied from element */
1.159 + OWFsubpixel globalAlpha;
1.160 + WFCScaleFilter sourceScaleFilter;
1.161 + WFCbitfield transparencyTypes;
1.162 + /*! rotation method */
1.163 + WFCRotation rotation;
1.164 + /*! flipping */
1.165 + WFCboolean sourceFlip;
1.166 +
1.167 +} WFC_ELEMENT_STATE;
1.168 +
1.169 +typedef enum
1.170 +{
1.171 + WFC_IMAGE_SOURCE,
1.172 + WFC_IMAGE_MASK
1.173 +} WFC_IMAGE_PROVIDER_TYPE;
1.174 +
1.175 +typedef struct
1.176 +{
1.177 + OWFNativeStreamBuffer buffer;
1.178 + OWFint lockCount;
1.179 + OWF_IMAGE_INST image;
1.180 +
1.181 +} WFC_LOCK_STREAM;
1.182 +
1.183 +typedef struct
1.184 +{
1.185 + WFCHandle handle;
1.186 + WFC_IMAGE_PROVIDER_TYPE type;
1.187 + OWFNativeStreamType streamHandle;
1.188 + void* owner;
1.189 + WFCint contentUpdated;
1.190 + WFCint contentVisible;
1.191 + WFCint composed;
1.192 + WFCint visited;
1.193 + WFC_LOCK_STREAM lockedStream;
1.194 +
1.195 +} WFC_IMAGE_PROVIDER;
1.196 +
1.197 +typedef struct {
1.198 + WFCElement handle;
1.199 + WFC_DEVICE* device;
1.200 + struct WFC_CONTEXT_* context;
1.201 + /*! element attributes */
1.202 + WFCfloat srcRect[4];
1.203 + WFCfloat dstRect[4];
1.204 + WFCboolean sourceFlip;
1.205 + WFCRotation sourceRotation;
1.206 + WFCScaleFilter sourceScaleFilter;
1.207 + WFCbitfield transparencyTypes;
1.208 + WFCfloat globalAlpha;
1.209 + WFCMask maskHandle;
1.210 + WFCSource sourceHandle;
1.211 +
1.212 + /*! client scene and composed scene dereferenced image providers */
1.213 + WFC_IMAGE_PROVIDER* mask;
1.214 + WFC_IMAGE_PROVIDER* source;
1.215 + WFC_IMAGE_PROVIDER* cachedMask;
1.216 + WFC_IMAGE_PROVIDER* cachedSource;
1.217 +
1.218 + /*! shared element? (must not be destroyed by a scene) */
1.219 + WFCboolean shared;
1.220 +
1.221 + /*! set in WFC_Element_BeginComposition to indicate whether
1.222 + the element should be included in composition */
1.223 + WFCboolean skipCompose;
1.224 + /*! Set in WFC_Element_BeginComposition to indicate whether
1.225 + * the mask stream should be included in composition */
1.226 + WFCboolean maskComposed;
1.227 +} WFC_ELEMENT;
1.228 +
1.229 +typedef enum
1.230 +{
1.231 + WFC_CONTEXT_STATE_PASSIVE,
1.232 + WFC_CONTEXT_STATE_ACTIVATING,
1.233 + WFC_CONTEXT_STATE_ACTIVE,
1.234 + WFC_CONTEXT_STATE_DEACTIVATING
1.235 +} WFC_CONTEXT_ACTIVATION_STATE;
1.236 +
1.237 +typedef EGLint (*TFPtrEglPrivateSignalSyncNok) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);
1.238 +#define INITIAL_CONTEXT_SERIAL_NUMBER 0
1.239 +typedef struct WFC_CONTEXT_ {
1.240 + WFCContext handle;
1.241 + WFC_DEVICE* device;
1.242 +
1.243 + /*! work-in-progress scene */
1.244 + WFC_SCENE* workScene;
1.245 + WFC_SCENE* committedScene;
1.246 + WFC_SCENE* snapshotScene;
1.247 +
1.248 + /*! pools for resource allocation */
1.249 + OWF_POOL* scenePool;
1.250 + OWF_POOL* nodePool;
1.251 + OWF_POOL* elementPool;
1.252 +
1.253 + /*! screen number for on-screen contexts */
1.254 + WFCint screenNumber;
1.255 +
1.256 + /*! scratch buffers used in composition to store per-element
1.257 + intermediate results */
1.258 + void* scratchBuffer[SCRATCH_BUFFER_COUNT];
1.259 +
1.260 + /*! onscreen/offscreen write stream */
1.261 + OWFNativeStreamType stream;
1.262 + WFCContextType type;
1.263 + WFCint targetWidth;
1.264 + WFCint targetHeight;
1.265 + WFCRotation rotation;
1.266 + OWFuint32 backgroundColor;
1.267 + WFCElement lowestElement;
1.268 + OWF_ATTRIBUTE_LIST attributes;
1.269 + WFCint clientElementCount;
1.270 +
1.271 + /*! timing & synchronization */
1.272 + OWF_MESSAGE_QUEUE composerQueue;
1.273 + OWF_THREAD composerThread;
1.274 + WFC_CONTEXT_ACTIVATION_STATE activationState;
1.275 + OWF_SEMAPHORE compositionSemaphore;
1.276 + OWF_SEMAPHORE commitSemaphore;
1.277 + OWF_MUTEX updateFlagMutex;
1.278 + OWF_MUTEX sceneMutex;
1.279 + WFCint sourceUpdateCount;
1.280 +
1.281 + WFC_CONTEXT_STATE state;
1.282 + OWF_DISPCTX displayContext;
1.283 +
1.284 + WFCEGLDisplay nextSyncObjectDisplay;
1.285 + WFC_ELEMENT_STATE prototypeElementState;
1.286 + TFPtrEglPrivateSignalSyncNok eglPrivateSignalSync;
1.287 +} WFC_CONTEXT;
1.288 +
1.289 +
1.290 +#define IMAGE_PROVIDER(x) ((WFC_IMAGE_PROVIDER*)(x))
1.291 +#define ELEMENT(x) ((WFC_ELEMENT*)(x))
1.292 +#define CONTEXT(x) ((WFC_CONTEXT*)(x))
1.293 +#define DEVICE(x) ((WFC_DEVICE*)(x))
1.294 +#define SCENE(x) ((WFC_SCENE*)(x))
1.295 +#define STREAM(x) ((OWF_STREAM*)(x))
1.296 +
1.297 +#ifdef __cplusplus
1.298 +}
1.299 +#endif
1.300 +
1.301 +#endif /*STRUCTS_H_*/
1.302 +