sl@0: /* Copyright (c) 2009 The Khronos Group Inc. sl@0: * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies) sl@0: * sl@0: * Permission is hereby granted, free of charge, to any person obtaining a sl@0: * copy of this software and/or associated documentation files (the sl@0: * "Materials"), to deal in the Materials without restriction, including sl@0: * without limitation the rights to use, copy, modify, merge, publish, sl@0: * distribute, sublicense, and/or sell copies of the Materials, and to sl@0: * permit persons to whom the Materials are furnished to do so, subject to sl@0: * the following conditions: sl@0: * sl@0: * The above copyright notice and this permission notice shall be included sl@0: * in all copies or substantial portions of the Materials. sl@0: * sl@0: * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, sl@0: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF sl@0: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. sl@0: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY sl@0: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, sl@0: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE sl@0: * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. sl@0: */ sl@0: sl@0: sl@0: /*! \ingroup wfc sl@0: * \file wfcstructs.h sl@0: * sl@0: * \brief Composition SI data structures sl@0: */ sl@0: sl@0: #ifndef WFCSTRUCTS_H_ sl@0: #define WFCSTRUCTS_H_ sl@0: sl@0: #include "WF/wfc.h" sl@0: sl@0: #include "owftypes.h" sl@0: #include "owfimage.h" sl@0: #include "owfattributes.h" sl@0: #include "owfmessagequeue.h" sl@0: #include "owfthread.h" sl@0: #include "owfmutex.h" sl@0: #include "owfarray.h" sl@0: #include "owfpool.h" sl@0: #include "owflinkedlist.h" sl@0: #include "owfdisplaycontextgeneral.h" sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" sl@0: { sl@0: #endif sl@0: sl@0: struct WFC_CONTEXT_; sl@0: sl@0: sl@0: typedef struct WFC_DEVICE_ { sl@0: WFCDevice deviceId; sl@0: WFCHandle handle; sl@0: WFCErrorCode latestUnreadError; sl@0: OWF_ARRAY contexts; sl@0: OWF_ARRAY providers; sl@0: OWF_ARRAY elements; sl@0: OWF_MUTEX mutex; sl@0: } WFC_DEVICE; sl@0: sl@0: typedef struct PHYSICAL_DEVICE_ { sl@0: OWF_ARRAY iDeviceInstanceArray; sl@0: OWFint gDeviceHandleID; sl@0: } PHYSICAL_DEVICE; sl@0: sl@0: typedef struct { sl@0: OWFNativeStreamBuffer targetBuffer; sl@0: /* */ sl@0: void* targetPixels; sl@0: /* Mapped to the external format target image buffer each frame */ sl@0: OWF_IMAGE* targetImage; sl@0: /* Mapped to the internal format target image to compose to */ sl@0: OWF_IMAGE* internalTargetImage; sl@0: sl@0: /* The unrotated target buffer */ sl@0: OWF_IMAGE_INST unrotatedTargetImage; sl@0: /* The rotated version of the target buffer for hardware rotation, sl@0: * or a de-rotated version of the internal buffer into another scratch buffer for software rotation sl@0: */ sl@0: OWF_IMAGE_INST rotatedTargetImage; sl@0: /* The internal target buffer composed to for 0 and 180 degree rotation */ sl@0: OWF_IMAGE_INST unrotatedInternalTargetImage; sl@0: /* The internal target buffer composed to for 90 and 270 degree rotation */ sl@0: OWF_IMAGE_INST rotatedInternalTargetImage; sl@0: } WFC_CONTEXT_STATE; sl@0: sl@0: /*! sl@0: Scratch buffers needed: sl@0: 1 for cropped source image sl@0: 1 for cropped mask image sl@0: 1 for scaled element image sl@0: 1 for mask sl@0: */ sl@0: #define SCRATCH_BUFFER_COUNT 5 sl@0: sl@0: typedef struct { sl@0: /*! elements, ordered by depth; starting from bottom */ sl@0: struct WFC_CONTEXT_* context; sl@0: OWF_NODE* elements; sl@0: } WFC_SCENE; sl@0: sl@0: sl@0: /*! sl@0: Element's composition state parameters. sl@0: */ sl@0: typedef struct { sl@0: /*! original source image and mask image - inputs to the first stage */ sl@0: OWF_IMAGE* originalSourceImage; sl@0: OWF_IMAGE* originalMaskImage; sl@0: sl@0: /*! converted source image - sl@0: results of the first stage in the sl@0: composition */ sl@0: OWF_IMAGE_INST convertedSourceImage; sl@0: sl@0: /*! cropped source image - result of cropping stage */ sl@0: OWF_IMAGE_INST croppedSourceImage; sl@0: sl@0: /*! mirrored source intermediate image - temp buffer used in mirroring stage */ sl@0: OWF_IMAGE_INST rotatedSourceIntermediateImage; sl@0: sl@0: /*! mirrored source image - result of mirroring stage */ sl@0: OWF_IMAGE_INST flippedSourceImage; sl@0: sl@0: /*! rotated source image - result of rotation stage */ sl@0: OWF_IMAGE_INST rotatedSourceImage; sl@0: sl@0: /*! these are the "final size" (i.e. destination sl@0: size) versions of the previous. used in sl@0: the blending stage */ sl@0: OWF_IMAGE_INST scaledSourceImage; sl@0: OWF_RECTANGLE scaledSrcRect; sl@0: OWF_IMAGE_INST maskImage; sl@0: sl@0: sl@0: /*! support for blending operation */ sl@0: OWF_BLEND_INFO blendInfo; sl@0: sl@0: sl@0: /*! source and target extents */ sl@0: WFCfloat sourceRect[4]; sl@0: WFCfloat destinationRect[4]; sl@0: OWF_RECTANGLE dstRect; sl@0: sl@0: /*! source fp viewport */ sl@0: WFCfloat transformedSourceRect[4]; sl@0: sl@0: /*! oversized integer crop */ sl@0: OWF_RECTANGLE oversizedCropRect; sl@0: sl@0: /* Other attributes copied from element */ sl@0: OWFsubpixel globalAlpha; sl@0: WFCScaleFilter sourceScaleFilter; sl@0: WFCbitfield transparencyTypes; sl@0: /*! rotation method */ sl@0: WFCRotation rotation; sl@0: /*! flipping */ sl@0: WFCboolean sourceFlip; sl@0: sl@0: } WFC_ELEMENT_STATE; sl@0: sl@0: typedef enum sl@0: { sl@0: WFC_IMAGE_SOURCE, sl@0: WFC_IMAGE_MASK sl@0: } WFC_IMAGE_PROVIDER_TYPE; sl@0: sl@0: typedef struct sl@0: { sl@0: OWFNativeStreamBuffer buffer; sl@0: OWFint lockCount; sl@0: OWF_IMAGE_INST image; sl@0: sl@0: } WFC_LOCK_STREAM; sl@0: sl@0: typedef struct sl@0: { sl@0: WFCHandle handle; sl@0: WFC_IMAGE_PROVIDER_TYPE type; sl@0: OWFNativeStreamType streamHandle; sl@0: void* owner; sl@0: WFCint contentUpdated; sl@0: WFCint contentVisible; sl@0: WFCint composed; sl@0: WFCint visited; sl@0: WFC_LOCK_STREAM lockedStream; sl@0: sl@0: } WFC_IMAGE_PROVIDER; sl@0: sl@0: typedef struct { sl@0: WFCElement handle; sl@0: WFC_DEVICE* device; sl@0: struct WFC_CONTEXT_* context; sl@0: /*! element attributes */ sl@0: WFCfloat srcRect[4]; sl@0: WFCfloat dstRect[4]; sl@0: WFCboolean sourceFlip; sl@0: WFCRotation sourceRotation; sl@0: WFCScaleFilter sourceScaleFilter; sl@0: WFCbitfield transparencyTypes; sl@0: WFCfloat globalAlpha; sl@0: WFCMask maskHandle; sl@0: WFCSource sourceHandle; sl@0: sl@0: /*! client scene and composed scene dereferenced image providers */ sl@0: WFC_IMAGE_PROVIDER* mask; sl@0: WFC_IMAGE_PROVIDER* source; sl@0: WFC_IMAGE_PROVIDER* cachedMask; sl@0: WFC_IMAGE_PROVIDER* cachedSource; sl@0: sl@0: /*! shared element? (must not be destroyed by a scene) */ sl@0: WFCboolean shared; sl@0: sl@0: /*! set in WFC_Element_BeginComposition to indicate whether sl@0: the element should be included in composition */ sl@0: WFCboolean skipCompose; sl@0: /*! Set in WFC_Element_BeginComposition to indicate whether sl@0: * the mask stream should be included in composition */ sl@0: WFCboolean maskComposed; sl@0: } WFC_ELEMENT; sl@0: sl@0: typedef enum sl@0: { sl@0: WFC_CONTEXT_STATE_PASSIVE, sl@0: WFC_CONTEXT_STATE_ACTIVATING, sl@0: WFC_CONTEXT_STATE_ACTIVE, sl@0: WFC_CONTEXT_STATE_DEACTIVATING sl@0: } WFC_CONTEXT_ACTIVATION_STATE; sl@0: sl@0: typedef EGLint (*TFPtrEglPrivateSignalSyncNok) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); sl@0: #define INITIAL_CONTEXT_SERIAL_NUMBER 0 sl@0: typedef struct WFC_CONTEXT_ { sl@0: WFCContext handle; sl@0: WFC_DEVICE* device; sl@0: sl@0: /*! work-in-progress scene */ sl@0: WFC_SCENE* workScene; sl@0: WFC_SCENE* committedScene; sl@0: WFC_SCENE* snapshotScene; sl@0: sl@0: /*! pools for resource allocation */ sl@0: OWF_POOL* scenePool; sl@0: OWF_POOL* nodePool; sl@0: OWF_POOL* elementPool; sl@0: sl@0: /*! screen number for on-screen contexts */ sl@0: WFCint screenNumber; sl@0: sl@0: /*! scratch buffers used in composition to store per-element sl@0: intermediate results */ sl@0: void* scratchBuffer[SCRATCH_BUFFER_COUNT]; sl@0: sl@0: /*! onscreen/offscreen write stream */ sl@0: OWFNativeStreamType stream; sl@0: WFCContextType type; sl@0: WFCint targetWidth; sl@0: WFCint targetHeight; sl@0: WFCRotation rotation; sl@0: OWFuint32 backgroundColor; sl@0: WFCElement lowestElement; sl@0: OWF_ATTRIBUTE_LIST attributes; sl@0: WFCint clientElementCount; sl@0: sl@0: /*! timing & synchronization */ sl@0: OWF_MESSAGE_QUEUE composerQueue; sl@0: OWF_THREAD composerThread; sl@0: WFC_CONTEXT_ACTIVATION_STATE activationState; sl@0: OWF_SEMAPHORE compositionSemaphore; sl@0: OWF_SEMAPHORE commitSemaphore; sl@0: OWF_MUTEX updateFlagMutex; sl@0: OWF_MUTEX sceneMutex; sl@0: WFCint sourceUpdateCount; sl@0: sl@0: WFC_CONTEXT_STATE state; sl@0: OWF_DISPCTX displayContext; sl@0: sl@0: WFCEGLDisplay nextSyncObjectDisplay; sl@0: WFC_ELEMENT_STATE prototypeElementState; sl@0: TFPtrEglPrivateSignalSyncNok eglPrivateSignalSync; sl@0: } WFC_CONTEXT; sl@0: sl@0: sl@0: #define IMAGE_PROVIDER(x) ((WFC_IMAGE_PROVIDER*)(x)) sl@0: #define ELEMENT(x) ((WFC_ELEMENT*)(x)) sl@0: #define CONTEXT(x) ((WFC_CONTEXT*)(x)) sl@0: #define DEVICE(x) ((WFC_DEVICE*)(x)) sl@0: #define SCENE(x) ((WFC_SCENE*)(x)) sl@0: #define STREAM(x) ((OWF_STREAM*)(x)) sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: #endif /*STRUCTS_H_*/ sl@0: