|
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 // contentupdateproxy.cpp |
|
15 // Proxy object for receiving SUS surface content update notifications and rerouting them to nativestream |
|
16 // |
|
17 |
|
18 |
|
19 #include <e32def.h> |
|
20 #include <graphics/suerror.h> |
|
21 #include "streammap.h" |
|
22 #include "surfacestream.h" |
|
23 #include "contentupdateproxy.h" |
|
24 |
|
25 CExtensionContainer* CContentUpdateProxy::NewL(TInt aScreenNum, COpenWfcStreamMap* aSingleton,TInt aInternalVersion,TInt aPriority) |
|
26 { |
|
27 CContentUpdateProxy* pInstance = new(ELeave) CContentUpdateProxy(); |
|
28 CleanupStack::PushL(pInstance); |
|
29 pInstance->ConstructL(aScreenNum,aSingleton,aInternalVersion,aPriority); |
|
30 CleanupStack::Pop(pInstance); |
|
31 return pInstance; |
|
32 } |
|
33 void CContentUpdateProxy::ConstructL(TInt aScreenNum, COpenWfcStreamMap* aSingleton,TInt aInternalVersion,TInt aPriority) |
|
34 { |
|
35 iScreenNum=aScreenNum; |
|
36 iSingleton=aSingleton; |
|
37 iInternalVersion=aInternalVersion; |
|
38 iPriority=aPriority; |
|
39 } |
|
40 CContentUpdateProxy::CContentUpdateProxy(): |
|
41 iHeap(User::Heap()) |
|
42 { |
|
43 } |
|
44 CContentUpdateProxy::~CContentUpdateProxy() |
|
45 { |
|
46 |
|
47 } |
|
48 |
|
49 TInt CContentUpdateProxy::Extension_(TUint aExtensionId, TAny*& aRetPtr, TAny* a1) |
|
50 { |
|
51 switch (aExtensionId) |
|
52 { |
|
53 case MCompositionSurfaceUpdate::ETypeId: |
|
54 { |
|
55 aRetPtr=static_cast<MCompositionSurfaceUpdate*>(this); |
|
56 return KErrNone; |
|
57 } |
|
58 default: |
|
59 { |
|
60 return CExtensionContainer::Extension_(aExtensionId,aRetPtr,a1); |
|
61 } |
|
62 } |
|
63 } |
|
64 |
|
65 TInt CContentUpdateProxy::ApiVersion() |
|
66 { |
|
67 return KContentUpdateProxyVersion; |
|
68 } |
|
69 |
|
70 TVersion CContentUpdateProxy::InternalVersion() |
|
71 { |
|
72 return TVersion(iInternalVersion>>24,(iInternalVersion>>16)&0xff,iInternalVersion&0xffff); |
|
73 } |
|
74 |
|
75 void CContentUpdateProxy::ContentUpdated |
|
76 ( const TSurfaceId& aSurface, TInt aBuffer, |
|
77 const TRegion* aRegion, |
|
78 TRequestStatus* aStatusConsumed, |
|
79 TRequestStatus* aStatusDisplayed, TUint32* aTimeStamp, |
|
80 TRequestStatus* aStatusDispXTimes, TInt* aDisplayedXTimes) |
|
81 { |
|
82 NFLOG(("### CContentUpdateProxy srf(0x%x:0x%x:0x%x:0x%x)," |
|
83 "\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)," |
|
84 "\n\t\t rsDXT(0x%x),\n\t\t dXT(%d)", |
|
85 aSurface.iInternal[0], aSurface.iInternal[1], aSurface.iInternal[2], aSurface.iInternal[3], |
|
86 aBuffer, aRegion, aStatusConsumed, aStatusDisplayed, aTimeStamp, aStatusDispXTimes, aDisplayedXTimes ? *aDisplayedXTimes: 0)); |
|
87 |
|
88 COpenWfcStreamMap* stream = NULL; |
|
89 TRAPD(err,stream = &COpenWfcStreamMap::InstanceL()); |
|
90 if (err != KErrNone) |
|
91 { |
|
92 NFLOG(("### ERROR - EARLY EXIT * CContentUpdateProxy::ContentUpdated()")); |
|
93 // cancel notifications |
|
94 CompleteStatus( |
|
95 aStatusConsumed, |
|
96 aStatusDisplayed, |
|
97 aStatusDispXTimes, |
|
98 err); |
|
99 return; |
|
100 } |
|
101 RHeap* oldHeap = NULL; |
|
102 if (&iHeap != &(User::Heap())) |
|
103 { |
|
104 oldHeap = User::SwitchHeap(stream->GetMainHeap()); |
|
105 } |
|
106 CSurfaceStream* ns = NULL; |
|
107 ns = stream->Find(aSurface); |
|
108 |
|
109 if (ns) |
|
110 { |
|
111 RegisterNotifications(*ns, |
|
112 aBuffer, |
|
113 aStatusDisplayed, aTimeStamp, |
|
114 aStatusDispXTimes, aDisplayedXTimes, |
|
115 aStatusConsumed, aRegion); |
|
116 |
|
117 ns->ReleaseReference(); |
|
118 } |
|
119 else |
|
120 { |
|
121 // cancel notifications |
|
122 CompleteStatus(aStatusConsumed, |
|
123 aStatusDisplayed, |
|
124 aStatusDispXTimes, |
|
125 KErrSurfaceNotRegistered); |
|
126 } |
|
127 if (oldHeap) |
|
128 { |
|
129 (void)User::SwitchHeap(oldHeap); |
|
130 } |
|
131 NFLOG(("### EXIT * CContentUpdateProxy::ContentUpdated()")); |
|
132 } |
|
133 |
|
134 void CContentUpdateProxy::CompleteStatus( |
|
135 TRequestStatus* aStatusConsumed, |
|
136 TRequestStatus* aStatusDisplayed, |
|
137 TRequestStatus* aStatusDispXTimes, |
|
138 TInt aReason) |
|
139 { |
|
140 if (aStatusConsumed) |
|
141 { |
|
142 User::RequestComplete(aStatusConsumed, aReason); |
|
143 } |
|
144 if (aStatusDisplayed) |
|
145 { |
|
146 User::RequestComplete(aStatusDisplayed, aReason); |
|
147 } |
|
148 if (aStatusDispXTimes) |
|
149 { |
|
150 User::RequestComplete(aStatusDispXTimes, aReason); |
|
151 } |
|
152 } |
|
153 |
|
154 void CContentUpdateProxy::RegisterNotifications(CSurfaceStream& aNs, |
|
155 TInt aBuffer, |
|
156 TRequestStatus* aStatusDisplayed, TUint32* aTimeStamp, |
|
157 TRequestStatus* aStatusDispXTimes, TInt* aDisplayedXTimes, |
|
158 TRequestStatus* aStatusConsumed, const TRegion* aRegion) |
|
159 { |
|
160 if (KErrNone != aNs.CheckBufferNumber(aBuffer, aStatusDisplayed, aStatusDispXTimes, aStatusConsumed)) |
|
161 { |
|
162 return; |
|
163 } |
|
164 |
|
165 TInt updateFlag = 0; |
|
166 if (aStatusConsumed) |
|
167 { |
|
168 *aStatusConsumed = KRequestPending; |
|
169 updateFlag |= ESOWF_EventAvailable; |
|
170 } |
|
171 if (aStatusDisplayed) |
|
172 { |
|
173 *aStatusDisplayed = KRequestPending; |
|
174 updateFlag |= ESOWF_EventDisplayed; |
|
175 } |
|
176 if (aStatusDispXTimes) |
|
177 { |
|
178 *aStatusDispXTimes = KRequestPending; |
|
179 updateFlag |= ESOWF_EventDisplayedX; |
|
180 } |
|
181 |
|
182 aNs.SetNewNotifications(aBuffer, |
|
183 aStatusDisplayed, |
|
184 aTimeStamp, |
|
185 aStatusDispXTimes, |
|
186 aDisplayedXTimes, |
|
187 aStatusConsumed, |
|
188 aRegion, |
|
189 iScreenNum); |
|
190 } |
|
191 |