os/graphics/graphicscomposition/openwfsupport/src/contentupdateproxy.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicscomposition/openwfsupport/src/contentupdateproxy.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,191 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// contentupdateproxy.cpp
    1.18 +// Proxy object for receiving SUS surface content update notifications and rerouting them to nativestream 
    1.19 +//
    1.20 +
    1.21 +
    1.22 +#include <e32def.h>
    1.23 +#include <graphics/suerror.h>
    1.24 +#include "streammap.h"
    1.25 +#include "surfacestream.h"
    1.26 +#include "contentupdateproxy.h"
    1.27 +
    1.28 +CExtensionContainer* CContentUpdateProxy::NewL(TInt aScreenNum, COpenWfcStreamMap*	aSingleton,TInt aInternalVersion,TInt aPriority)
    1.29 +	{
    1.30 +	CContentUpdateProxy* pInstance = new(ELeave) CContentUpdateProxy();
    1.31 +	CleanupStack::PushL(pInstance);
    1.32 +	pInstance->ConstructL(aScreenNum,aSingleton,aInternalVersion,aPriority);
    1.33 +	CleanupStack::Pop(pInstance);
    1.34 +	return pInstance;
    1.35 +	}
    1.36 +void CContentUpdateProxy::ConstructL(TInt aScreenNum, COpenWfcStreamMap*	aSingleton,TInt aInternalVersion,TInt aPriority)
    1.37 +	{
    1.38 +	iScreenNum=aScreenNum;
    1.39 +	iSingleton=aSingleton;
    1.40 +	iInternalVersion=aInternalVersion;
    1.41 +	iPriority=aPriority;
    1.42 +	}
    1.43 +CContentUpdateProxy::CContentUpdateProxy():
    1.44 +iHeap(User::Heap())
    1.45 +	{
    1.46 +	}
    1.47 +CContentUpdateProxy::~CContentUpdateProxy()
    1.48 +	{
    1.49 +	
    1.50 +	}
    1.51 +
    1.52 +TInt CContentUpdateProxy::Extension_(TUint aExtensionId, TAny*& aRetPtr, TAny* a1)
    1.53 +	{
    1.54 +	switch (aExtensionId)
    1.55 +		{
    1.56 +		case MCompositionSurfaceUpdate::ETypeId:
    1.57 +			{
    1.58 +			aRetPtr=static_cast<MCompositionSurfaceUpdate*>(this);
    1.59 +			return KErrNone;
    1.60 +			}
    1.61 +		default:
    1.62 +			{
    1.63 +			return CExtensionContainer::Extension_(aExtensionId,aRetPtr,a1);
    1.64 +			}
    1.65 +		}
    1.66 +	}
    1.67 +
    1.68 +TInt CContentUpdateProxy::ApiVersion()
    1.69 +	{
    1.70 +	return KContentUpdateProxyVersion;
    1.71 +	}
    1.72 +
    1.73 +TVersion CContentUpdateProxy::InternalVersion()
    1.74 +	{
    1.75 +	return TVersion(iInternalVersion>>24,(iInternalVersion>>16)&0xff,iInternalVersion&0xffff);
    1.76 +	}
    1.77 +
    1.78 +void CContentUpdateProxy::ContentUpdated      
    1.79 +	(	const TSurfaceId&  aSurface,     		TInt		aBuffer,
    1.80 +		const TRegion*     aRegion,
    1.81 +		TRequestStatus*    aStatusConsumed,
    1.82 +		TRequestStatus*    aStatusDisplayed,	TUint32*	aTimeStamp,
    1.83 +		TRequestStatus*    aStatusDispXTimes,	TInt*		aDisplayedXTimes)
    1.84 +	{
    1.85 +    NFLOG(("### CContentUpdateProxy srf(0x%x:0x%x:0x%x:0x%x),"
    1.86 +            "\n\t\t buff(%d),\n\t\t rg(0x%x),\n\t\t rsConsumed(0x%x),\n\t\t rsDsp(0x%x),\n\t\t ts(0x%x),"
    1.87 +            "\n\t\t rsDXT(0x%x),\n\t\t dXT(%d)", 
    1.88 +            aSurface.iInternal[0], aSurface.iInternal[1], aSurface.iInternal[2], aSurface.iInternal[3],
    1.89 +            aBuffer, aRegion, aStatusConsumed, aStatusDisplayed, aTimeStamp, aStatusDispXTimes, aDisplayedXTimes ? *aDisplayedXTimes: 0));
    1.90 +    
    1.91 +    COpenWfcStreamMap* stream = NULL;
    1.92 +    TRAPD(err,stream = &COpenWfcStreamMap::InstanceL());
    1.93 +    if (err != KErrNone)
    1.94 +        {
    1.95 +        NFLOG(("### ERROR - EARLY EXIT * CContentUpdateProxy::ContentUpdated()"));
    1.96 +        // cancel notifications
    1.97 +        CompleteStatus(
    1.98 +                aStatusConsumed,
    1.99 +                aStatusDisplayed,
   1.100 +                aStatusDispXTimes,
   1.101 +                err);
   1.102 +        return;
   1.103 +        }
   1.104 +    RHeap* oldHeap = NULL;
   1.105 +	if (&iHeap != &(User::Heap()))
   1.106 +	    {
   1.107 +	    oldHeap = User::SwitchHeap(stream->GetMainHeap());
   1.108 +	    }
   1.109 +	CSurfaceStream* ns = NULL;
   1.110 +	ns = stream->Find(aSurface);
   1.111 +
   1.112 +	if (ns)
   1.113 +		{
   1.114 +		RegisterNotifications(*ns,
   1.115 +                              aBuffer,
   1.116 +                              aStatusDisplayed, aTimeStamp,
   1.117 +                              aStatusDispXTimes, aDisplayedXTimes,
   1.118 +                              aStatusConsumed, aRegion);
   1.119 +		
   1.120 +		ns->ReleaseReference();
   1.121 +		}
   1.122 +	else
   1.123 +	    {
   1.124 +	    // cancel notifications
   1.125 +	    CompleteStatus(aStatusConsumed,
   1.126 +	            aStatusDisplayed,
   1.127 +	            aStatusDispXTimes,
   1.128 +	            KErrSurfaceNotRegistered);
   1.129 +	    }
   1.130 +	if (oldHeap)
   1.131 +	    {
   1.132 +	    (void)User::SwitchHeap(oldHeap);
   1.133 +	    }
   1.134 +    NFLOG(("### EXIT * CContentUpdateProxy::ContentUpdated()"));
   1.135 +	}
   1.136 +
   1.137 +void CContentUpdateProxy::CompleteStatus(
   1.138 +        TRequestStatus*    aStatusConsumed,
   1.139 +        TRequestStatus*    aStatusDisplayed,
   1.140 +        TRequestStatus*    aStatusDispXTimes,
   1.141 +        TInt aReason)
   1.142 +    {
   1.143 +    if (aStatusConsumed)
   1.144 +        {
   1.145 +        User::RequestComplete(aStatusConsumed, aReason);
   1.146 +        }
   1.147 +    if (aStatusDisplayed)
   1.148 +        {
   1.149 +        User::RequestComplete(aStatusDisplayed, aReason);
   1.150 +        }
   1.151 +    if (aStatusDispXTimes)
   1.152 +        {
   1.153 +        User::RequestComplete(aStatusDispXTimes, aReason);
   1.154 +        }
   1.155 +    }
   1.156 +
   1.157 +void CContentUpdateProxy::RegisterNotifications(CSurfaceStream& aNs,
   1.158 +                                                 TInt            aBuffer,
   1.159 +                                                 TRequestStatus* aStatusDisplayed, TUint32* aTimeStamp,
   1.160 +                                                 TRequestStatus* aStatusDispXTimes, TInt* aDisplayedXTimes,
   1.161 +                                                 TRequestStatus* aStatusConsumed, const TRegion* aRegion)
   1.162 +    {
   1.163 +    if (KErrNone != aNs.CheckBufferNumber(aBuffer, aStatusDisplayed, aStatusDispXTimes, aStatusConsumed))
   1.164 +        {
   1.165 +        return;
   1.166 +        }
   1.167 +    
   1.168 +    TInt updateFlag = 0;
   1.169 +    if (aStatusConsumed)
   1.170 +        {
   1.171 +        *aStatusConsumed = KRequestPending;
   1.172 +        updateFlag |= ESOWF_EventAvailable;
   1.173 +        }
   1.174 +    if (aStatusDisplayed)
   1.175 +        {
   1.176 +        *aStatusDisplayed = KRequestPending;
   1.177 +        updateFlag |= ESOWF_EventDisplayed;
   1.178 +        }
   1.179 +    if (aStatusDispXTimes)
   1.180 +        {
   1.181 +        *aStatusDispXTimes = KRequestPending;
   1.182 +        updateFlag |= ESOWF_EventDisplayedX;
   1.183 +        }
   1.184 +    
   1.185 +    aNs.SetNewNotifications(aBuffer, 
   1.186 +                            aStatusDisplayed, 
   1.187 +                            aTimeStamp, 
   1.188 +                            aStatusDispXTimes, 
   1.189 +                            aDisplayedXTimes, 
   1.190 +                            aStatusConsumed, 
   1.191 +                            aRegion,
   1.192 +                            iScreenNum);
   1.193 +    }
   1.194 +