os/graphics/windowing/windowserverplugins/openwfc/inc/elementwrapper.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.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // A class which wraps OpenWF element related functionality.
    15 
    16 //
    17 
    18 #ifndef ELEMENTWRAPPER_H_
    19 #define ELEMENTWRAPPER_H_
    20 
    21 #include "openwfcwrapper.h"
    22 #include <graphics/wselement.h>
    23 #include <graphics/surface.h>
    24 #include <WF/wfc.h>
    25 
    26 #if defined(ENABLE_LI_LOGGING)
    27 #define LILOG(X)  RDebug::Printf X
    28 #else
    29 #define LILOG(X)
    30 #endif
    31 
    32 #define OWF_SURFACE_WIDTH  (768) /* needs to be > 640 + 2 to allow S60 nHD config to work */
    33 #define OWF_SURFACE_HEIGHT (768) /* needs to be > 640 + 2 to allow S60 nHD config to work */
    34 
    35 NONSHARABLE_CLASS(CElementWrapper) : public CBase, public MWsElement
    36     {
    37 public:  
    38     enum TOwfUpdates
    39         {   //All setters should set EUpdate_PostIllegalUpdate
    40         EUpdate_None                        = 0,
    41 
    42         EUpdate_DESTINATION_RECTANGLE       = 0x00000001,
    43         EUpdate_SOURCE                      = 0x00000002,
    44         EUpdate_SOURCE_RECTANGLE            = 0x00000004,
    45         EUpdate_SOURCE_FLIP                 = 0x00000008,
    46         EUpdate_SOURCE_ROTATION             = 0x00000010,
    47         EUpdate_SOURCE_SCALE_FILTER         = 0x00000020,  //No client-side code yet to drive this
    48         EUpdate_TRANSPARENCY_TYPES          = 0x00000040,
    49         EUpdate_GLOBAL_ALPHA                = 0x00000080,
    50         EUpdate_MASK                        = 0x00000100,  //No client-side code yet to drive this
    51         EUpdate_DESTINATION_CLIP_RECTANGLE  = EUpdate_DESTINATION_RECTANGLE|EUpdate_SOURCE_RECTANGLE,
    52 
    53         EUpdate_SOURCE_GEOMETRY_SET         = EUpdate_SOURCE_RECTANGLE|EUpdate_SOURCE_FLIP|EUpdate_SOURCE_ROTATION,
    54         EUpdate_ALL_ATTRIBS                 = 0x000fffff,
    55         EUpdate_AttributesIllegal           = 0x00100000,   //If set then the owf scene will not be updated because it would be illegal.
    56         EUpdate_SettingValid                = 0x00200000,
    57 
    58         EUpdate_Insert                      = 0x01000000,
    59         EUpdate_Remove                      = 0x02000000,
    60         EUpdate_Destroy                     = 0x04000000,
    61         EUpdate_SceneCommited               = 0x10000000,
    62         };    
    63 
    64 public: // from MWsElement  
    65     const TSurfaceId& ConnectedSurface() const;
    66     TInt ConnectSurface(const TSurfaceId& aSurface);
    67 
    68     TInt SetSourceRectangle(const TRect& aSrc);
    69     TInt GetSourceRectangle(TRect& aSrc);
    70     
    71     TInt SetSourceFlipping(const TBool aFlip);
    72     TBool SourceFlipping() const;
    73     
    74     MWsElement* ElementAbove();
    75     MWsElement* ElementBelow();
    76 
    77     TInt SetGlobalAlpha(const TInt aAlpha);
    78     void GlobalAlpha(TInt& aAlpha) const;
    79 
    80     TInt SetSourceRotation(const TElementRotation aElementRotation);
    81     MWsElement::TElementRotation SourceRotation() const;
    82     
    83     TInt SetTargetRendererFlags(const TUint32& aTargetRendererFlags);
    84     TInt SetRenderStageFlags(const TUint32& aRenderStageFlags);
    85     void GetTargetRendererFlags(TUint32& aTargetRendererFlags) const;
    86     void GetRenderStageFlags(TUint32& aRenderStageFlags) const;
    87 
    88     TInt SetDestinationRectangle(const TRect& aDest);
    89     TInt GetDestinationRectangle(TRect& aDest) const;
    90     TInt SetDestinationClippingRect(const TRect& aDestClipRect);
    91     TInt GetDestinationClippingRect(TRect& aDestClipRect) const;
    92     
    93 public:
    94     static CElementWrapper* NewL(COpenWfcWrapper& aCOpenWfcWrapper, CElementWrapper*& aCleanupPrevRef);
    95     CElementWrapper(COpenWfcWrapper& aOpenWfcWrapper);
    96     ~CElementWrapper();
    97     void ConstructL(CElementWrapper*& aCleanupPrevRef);
    98     void RemoveAfter(CElementWrapper** apBelow);
    99     void InsertAfter(CElementWrapper*& aRefBelow, CElementWrapper* aBelow, TOwfUpdates aUpdateFlag);
   100     CElementWrapper** RefsMyElementBelow();
   101     CElementWrapper*& MyElementAbove();
   102     COpenWfcWrapper& Owner()const { return iOpenWfcWrapper;}
   103     TBool FlushSceneChanges();
   104     WFCElement Element(){ return iElement;};
   105     TOwfUpdates UpdateFlags()const {return static_cast<TOwfUpdates>(iUpdateFlags);}
   106     TInt ReplicateElements(WFCContext aContext, WFCElement& aPreviousTargetElement, const TPoint& aOffset);
   107 
   108 protected:
   109     void SetEltDestinationRectangle(WFCElement aElement)const;
   110     void SetEltDestinationRectangle(WFCElement aElement, const TPoint& aOffset)const;
   111     void SetEltSource(WFCElement aElement)const;
   112     void SetEltSourceComposed();
   113     void SetEltSourceRectangle(WFCElement aElement);
   114     void SetEltSourceFlip(WFCElement aElement)const;
   115     void SetEltTransparencyTypes(WFCElement aElement)const;
   116     void FlushAttributeChanges(WFCElement aElement, TInt aUpdateFlags);
   117     TBool IsNewElementLegal()const;
   118     
   119 private: //methods
   120     TBool UnsetSurface(TSurfaceId& aSurface);
   121     static TInt WfcRotation(MWsElement::TElementRotation aRotation);
   122     void HelpStreamGetHeader(khronos_int32_t* width, khronos_int32_t* height )const;
   123     TRect SetSourceDestRect(const TRect& aDestElementRect, const TRect& aDestElementClippedRect,const TRect& aSrcOriginalElementRect,const TBool& aElementFlip,const MWsElement::TElementRotation& aElementRotation) const;
   124     TInt SurfaceInfo(const TSurfaceId& aSurface, RSurfaceManager::TInfoBuf& aInfo);
   125 
   126 
   127 private: //data
   128     TUint                         iUpdateFlags;
   129     COpenWfcWrapper&              iOpenWfcWrapper;
   130     TSurfaceId                    iComposedSurfaceId;
   131     TSurfaceId                    iSurfaceId;
   132     TSize                         iSurfaceSize;
   133     TRect                         iSourcRect; 
   134     TRect                         iDestinationRect;
   135     TRect                         iDestinationClippingRect;
   136     TInt                          iGlobalAlpha;
   137     TBool                         iFlipped;
   138     MWsElement::TElementRotation  iRotation;
   139     TUint32                       iTargetRendererFlags;
   140     TUint32                       iRenderStageFlags;
   141     WFCElement                    iElement;
   142     CElementWrapper*              iElementAbove;     //used to maintain the scene list
   143     CElementWrapper*              iElementBelow;     //used to maintain the scene list
   144     CElementWrapper**             iCleanupPrevRef;    //used to clean up the context on exit
   145     CElementWrapper*              iCleanupNext;       //used to clean up the context on exit
   146     };
   147 
   148 #endif /* ELEMENTWRAPPER_H_ */