sl@0
|
1 |
// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
//
|
sl@0
|
3 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
sl@0
|
4 |
// copy of this software and/or associated documentation files (the
|
sl@0
|
5 |
// "Materials"), to deal in the Materials without restriction, including
|
sl@0
|
6 |
// without limitation the rights to use, copy, modify, merge, publish,
|
sl@0
|
7 |
// distribute, sublicense, and/or sell copies of the Materials, and to
|
sl@0
|
8 |
// permit persons to whom the Materials are furnished to do so, subject to
|
sl@0
|
9 |
// the following conditions:
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// The above copyright notice and this permission notice shall be included
|
sl@0
|
12 |
// in all copies or substantial portions of the Materials.
|
sl@0
|
13 |
//
|
sl@0
|
14 |
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
sl@0
|
15 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
sl@0
|
16 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
sl@0
|
17 |
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
sl@0
|
18 |
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
sl@0
|
19 |
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
sl@0
|
20 |
// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
sl@0
|
21 |
//
|
sl@0
|
22 |
// Description:
|
sl@0
|
23 |
// Display Adaptation Interface Implementation for Display channel
|
sl@0
|
24 |
//
|
sl@0
|
25 |
//
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "openwfc_ri_displaychannel.h"
|
sl@0
|
28 |
#include <e32debug.h>
|
sl@0
|
29 |
#include <hal.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
_LIT(KDisplayChannelLdd, "display0.ldd");
|
sl@0
|
32 |
const TUint32 KDefaultScreenNumber = 0;
|
sl@0
|
33 |
|
sl@0
|
34 |
#ifdef _DEBUG
|
sl@0
|
35 |
void Panic(TInt aPanic)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
_LIT(KPanic, "DA-DC");
|
sl@0
|
38 |
User::Panic(KPanic, aPanic);
|
sl@0
|
39 |
}
|
sl@0
|
40 |
#endif
|
sl@0
|
41 |
|
sl@0
|
42 |
EXPORT_C COpenWFC_RI_Display* COpenWFC_RI_Display::NewL(TUint aScreen)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
return COpenWFC_RI_DisplayChannel::NewL(aScreen);
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
EXPORT_C TUint32 COpenWFC_RI_Display::DefaultScreenNumber()
|
sl@0
|
48 |
{
|
sl@0
|
49 |
return KDefaultScreenNumber;
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
COpenWFC_RI_DisplayChannel::COpenWFC_RI_DisplayChannel(TUint aScreen):
|
sl@0
|
53 |
iScreenNumber(aScreen),
|
sl@0
|
54 |
iCurrentSceneStream(SYMBIAN_INVALID_HANDLE)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
COpenWFC_RI_DisplayChannel* COpenWFC_RI_DisplayChannel::NewL(TUint aScreen)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
COpenWFC_RI_DisplayChannel* screenContext = new(ELeave) COpenWFC_RI_DisplayChannel(aScreen);
|
sl@0
|
61 |
CleanupStack::PushL(screenContext);
|
sl@0
|
62 |
screenContext->ConstructL();
|
sl@0
|
63 |
CleanupStack::Pop(screenContext);
|
sl@0
|
64 |
return screenContext;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
COpenWFC_RI_DisplayChannel::~COpenWFC_RI_DisplayChannel()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
TInt count = iCompositionBuffer.Count();
|
sl@0
|
70 |
for(TInt ii = 0; ii < count; ++ii)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
TBufferAddress* addr = iCompositionBuffer[ii];
|
sl@0
|
73 |
if (addr)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
addr->iChunk.Close();
|
sl@0
|
76 |
delete addr;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
}
|
sl@0
|
79 |
iCompositionBuffer.Close();
|
sl@0
|
80 |
// We do not need to use this boolean
|
sl@0
|
81 |
TBool unused;
|
sl@0
|
82 |
// Reset the initial rotation for next time.
|
sl@0
|
83 |
iDispChan.SetRotation(iDefaultRotation, unused);
|
sl@0
|
84 |
iDispChan.Close();
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
void COpenWFC_RI_DisplayChannel::ConstructL()
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TInt err = User::LoadLogicalDevice(KDisplayChannelLdd);
|
sl@0
|
90 |
if (err != KErrNone && err != KErrAlreadyExists)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
User::Leave(err);
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
User::LeaveIfError(iDispChan.Open(iScreenNumber));
|
sl@0
|
96 |
//#ifdef __WINS__
|
sl@0
|
97 |
iScreenInfo.iDefaultRotation = EScreenRotate0;
|
sl@0
|
98 |
iDefaultRotation = RDisplayChannel::ERotationNormal;
|
sl@0
|
99 |
iRotationOffset = 0;
|
sl@0
|
100 |
//#else
|
sl@0
|
101 |
// iScreenInfo.iDefaultRotation = EScreenRotate270;
|
sl@0
|
102 |
// iDefaultRotation = RDisplayChannel::ERotation270CW;
|
sl@0
|
103 |
// iRotationOffset = 3;
|
sl@0
|
104 |
//#endif
|
sl@0
|
105 |
RDisplayChannel::TDisplayRotation rotation = iDispChan.CurrentRotation();
|
sl@0
|
106 |
switch (rotation)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
case RDisplayChannel::ERotationNormal:
|
sl@0
|
109 |
iScreenInfo.iCurrentRotation = EScreenRotate0;
|
sl@0
|
110 |
break;
|
sl@0
|
111 |
case RDisplayChannel::ERotation90CW:
|
sl@0
|
112 |
iScreenInfo.iCurrentRotation = EScreenRotate90;
|
sl@0
|
113 |
break;
|
sl@0
|
114 |
case RDisplayChannel::ERotation180:
|
sl@0
|
115 |
iScreenInfo.iCurrentRotation = EScreenRotate180;
|
sl@0
|
116 |
break;
|
sl@0
|
117 |
case RDisplayChannel::ERotation270CW:
|
sl@0
|
118 |
iScreenInfo.iCurrentRotation = EScreenRotate270;
|
sl@0
|
119 |
break;
|
sl@0
|
120 |
default:
|
sl@0
|
121 |
RDebug::Printf("COpenWFC_RI_DisplayChannel::ConstructL() unsupported rotation %d", rotation);
|
sl@0
|
122 |
User::Leave(KErrNotSupported);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
iNewRotation = iScreenInfo.iCurrentRotation;
|
sl@0
|
126 |
TPckgBuf<RDisplayChannel::TDisplayInfo> pkgInfo;
|
sl@0
|
127 |
iDispChan.GetDisplayInfo(pkgInfo);
|
sl@0
|
128 |
RDisplayChannel::TDisplayInfo info = pkgInfo();
|
sl@0
|
129 |
/* Note that in theory other formats could be supported for composition
|
sl@0
|
130 |
* (eg EUidPixelFormatARGB_8888 | EUidPixelFormatARGB_8888_PRE )
|
sl@0
|
131 |
* So long as the background colour is opaque then the final composed image should end up opaque,
|
sl@0
|
132 |
* so compatible with alpha modes.
|
sl@0
|
133 |
* However, it would give problems for fastpathing, where alpha byte should be ignored,
|
sl@0
|
134 |
* probably fastpath would need to be disabled.
|
sl@0
|
135 |
* At present we only care about PlatSim,
|
sl@0
|
136 |
* and it is unlikely that any platform will NOT support xrgb32,
|
sl@0
|
137 |
* so it is better to assert the capabilities match than think about this hypothetical case too hard.
|
sl@0
|
138 |
*/
|
sl@0
|
139 |
if (info.iPixelFormat != EUidPixelFormatXRGB_8888)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
RDebug::Printf("COpenWFC_RI_DisplayChannel::ConstructL() unsupported pixel format 0x%08.8x", info.iPixelFormat);
|
sl@0
|
142 |
User::Leave(KErrNotSupported);
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
iScreenInfo.iPixelFormat = EUidPixelFormatXRGB_8888;
|
sl@0
|
146 |
iScreenInfo.iSupportedRotations = info.iAvailableRotations;
|
sl@0
|
147 |
|
sl@0
|
148 |
TInt bytesPerPixel = 4;
|
sl@0
|
149 |
if((info.iBitsPerPixel != 24) && (info.iBitsPerPixel != 32))
|
sl@0
|
150 |
{
|
sl@0
|
151 |
RDebug::Printf("COpenWFC_RI_DisplayChannel::ConstructL()unexpected bpp value %d", info.iBitsPerPixel);
|
sl@0
|
152 |
}
|
sl@0
|
153 |
|
sl@0
|
154 |
iScreenInfo.iBytesPerPixel = bytesPerPixel;
|
sl@0
|
155 |
|
sl@0
|
156 |
if (iRotationOffset & 1)
|
sl@0
|
157 |
{
|
sl@0
|
158 |
// Either 90 or 270 degree rotation, so reverse the normal and flipped
|
sl@0
|
159 |
// sizes (which relate to zero degrees rotation).
|
sl@0
|
160 |
iScreenInfo.iNormalWidth = info.iFlipped.iWidth;
|
sl@0
|
161 |
iScreenInfo.iNormalHeight = info.iFlipped.iHeight;
|
sl@0
|
162 |
iScreenInfo.iNormalStride = info.iFlipped.iOffsetBetweenLines;
|
sl@0
|
163 |
iScreenInfo.iFlippedWidth = info.iNormal.iWidth;
|
sl@0
|
164 |
iScreenInfo.iFlippedHeight = info.iNormal.iHeight;
|
sl@0
|
165 |
iScreenInfo.iFlippedStride = info.iNormal.iOffsetBetweenLines;
|
sl@0
|
166 |
}
|
sl@0
|
167 |
else
|
sl@0
|
168 |
{
|
sl@0
|
169 |
iScreenInfo.iNormalWidth = info.iNormal.iWidth;
|
sl@0
|
170 |
iScreenInfo.iNormalHeight = info.iNormal.iHeight;
|
sl@0
|
171 |
iScreenInfo.iNormalStride = info.iNormal.iOffsetBetweenLines;
|
sl@0
|
172 |
iScreenInfo.iFlippedWidth = info.iFlipped.iWidth;
|
sl@0
|
173 |
iScreenInfo.iFlippedHeight = info.iFlipped.iHeight;
|
sl@0
|
174 |
iScreenInfo.iFlippedStride = info.iFlipped.iOffsetBetweenLines;
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
if (iScreenInfo.iNormalStride < 0)
|
sl@0
|
178 |
{
|
sl@0
|
179 |
iScreenInfo.iNormalStride = bytesPerPixel * iScreenInfo.iNormalWidth;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
if (iScreenInfo.iFlippedStride < 0)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
iScreenInfo.iFlippedStride = bytesPerPixel * iScreenInfo.iFlippedWidth;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
for(TInt i = 0; i < info.iNumCompositionBuffers; ++i)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
iCompositionBuffer.AppendL(NULL);
|
sl@0
|
189 |
TBufferAddress* address = new(ELeave) TBufferAddress;
|
sl@0
|
190 |
iCompositionBuffer[i] = address;
|
sl@0
|
191 |
User::LeaveIfError(iDispChan.GetCompositionBufferInfo(i, address->iChunk, address->iOffset));
|
sl@0
|
192 |
address->iAddress = address->iChunk.Base() + address->iOffset;
|
sl@0
|
193 |
}
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
TInt COpenWFC_RI_Display::GetAttributeSize(TUint aAttributeId)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
switch (aAttributeId)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
case EScreenAttributeImplementationVersion:
|
sl@0
|
201 |
case EScreenAttributePixelFormat:
|
sl@0
|
202 |
case EScreenAttributeBytesPerPixel:
|
sl@0
|
203 |
case EScreenAttributeSupportedRotation:
|
sl@0
|
204 |
case EScreenAttributeNormalWidth:
|
sl@0
|
205 |
case EScreenAttributeNormalHeight:
|
sl@0
|
206 |
case EScreenAttributeNormalStride:
|
sl@0
|
207 |
case EScreenAttributeFlippedWidth:
|
sl@0
|
208 |
case EScreenAttributeFlippedHeight:
|
sl@0
|
209 |
case EScreenAttributeFlippedStride:
|
sl@0
|
210 |
case EScreenAttributeDefaultRotation:
|
sl@0
|
211 |
case EScreenAttributeCurrentRotation:
|
sl@0
|
212 |
return sizeof(TUint32);
|
sl@0
|
213 |
|
sl@0
|
214 |
case EScreenAttributeScreenGeometry:
|
sl@0
|
215 |
return sizeof(TScreenGeometryAttribute);
|
sl@0
|
216 |
|
sl@0
|
217 |
default:
|
sl@0
|
218 |
return 0;
|
sl@0
|
219 |
}
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
TInt COpenWFC_RI_DisplayChannel::GetAttribute(TInt aAttributeId, TAny* aAttribute, TInt aAttributeSize)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
TInt parameterSize = GetAttributeSize(aAttributeId);
|
sl@0
|
225 |
|
sl@0
|
226 |
if (aAttribute == NULL)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
return KErrArgument;
|
sl@0
|
229 |
}
|
sl@0
|
230 |
|
sl@0
|
231 |
if (parameterSize == 0)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
return KErrNotSupported;
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
if (aAttributeSize != parameterSize)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
return KErrArgument;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
switch (aAttributeId)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
case EScreenAttributeImplementationVersion:
|
sl@0
|
244 |
*((TUint32*)aAttribute) = KImplementationVersion;
|
sl@0
|
245 |
break;
|
sl@0
|
246 |
case EScreenAttributePixelFormat:
|
sl@0
|
247 |
*((TUint32*)aAttribute) = iScreenInfo.iPixelFormat;
|
sl@0
|
248 |
break;
|
sl@0
|
249 |
case EScreenAttributeBytesPerPixel:
|
sl@0
|
250 |
*((TUint32*)aAttribute) = iScreenInfo.iBytesPerPixel;
|
sl@0
|
251 |
break;
|
sl@0
|
252 |
case EScreenAttributeSupportedRotation:
|
sl@0
|
253 |
*((TUint32*)aAttribute) = iScreenInfo.iSupportedRotations;
|
sl@0
|
254 |
break;
|
sl@0
|
255 |
case EScreenAttributeNormalWidth:
|
sl@0
|
256 |
*((TUint32*)aAttribute) = iScreenInfo.iNormalWidth;
|
sl@0
|
257 |
break;
|
sl@0
|
258 |
case EScreenAttributeNormalHeight:
|
sl@0
|
259 |
*((TUint32*)aAttribute) = iScreenInfo.iNormalHeight;
|
sl@0
|
260 |
break;
|
sl@0
|
261 |
case EScreenAttributeNormalStride:
|
sl@0
|
262 |
*((TUint32*)aAttribute) = iScreenInfo.iNormalStride;
|
sl@0
|
263 |
break;
|
sl@0
|
264 |
case EScreenAttributeFlippedWidth:
|
sl@0
|
265 |
*((TUint32*)aAttribute) = iScreenInfo.iFlippedWidth;
|
sl@0
|
266 |
break;
|
sl@0
|
267 |
case EScreenAttributeFlippedHeight:
|
sl@0
|
268 |
*((TUint32*)aAttribute) = iScreenInfo.iFlippedHeight;
|
sl@0
|
269 |
break;
|
sl@0
|
270 |
case EScreenAttributeFlippedStride:
|
sl@0
|
271 |
*((TUint32*)aAttribute) = iScreenInfo.iFlippedStride;
|
sl@0
|
272 |
break;
|
sl@0
|
273 |
case EScreenAttributeDefaultRotation:
|
sl@0
|
274 |
*((TUint32*)aAttribute) = iScreenInfo.iDefaultRotation;
|
sl@0
|
275 |
break;
|
sl@0
|
276 |
case EScreenAttributeCurrentRotation:
|
sl@0
|
277 |
*((TUint32*)aAttribute) = iScreenInfo.iCurrentRotation;
|
sl@0
|
278 |
break;
|
sl@0
|
279 |
case EScreenAttributeScreenGeometry:
|
sl@0
|
280 |
*((TScreenGeometryAttribute*)aAttribute) = iScreenInfo;
|
sl@0
|
281 |
break;
|
sl@0
|
282 |
default:
|
sl@0
|
283 |
return KErrNotSupported;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
return KErrNone;
|
sl@0
|
287 |
}
|
sl@0
|
288 |
|
sl@0
|
289 |
|
sl@0
|
290 |
TInt COpenWFC_RI_DisplayChannel::SetAttribute(TInt aAttributeId, TAny* aAttribute, TInt aAttributeSize)
|
sl@0
|
291 |
{
|
sl@0
|
292 |
// the only parameter we can modify is the current rotation
|
sl@0
|
293 |
TInt parameterSize = GetAttributeSize(aAttributeId);
|
sl@0
|
294 |
|
sl@0
|
295 |
if (aAttributeSize != parameterSize || aAttribute == NULL)
|
sl@0
|
296 |
{
|
sl@0
|
297 |
return KErrArgument;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
|
sl@0
|
300 |
switch (aAttributeId)
|
sl@0
|
301 |
{
|
sl@0
|
302 |
case EScreenAttributeCurrentRotation:
|
sl@0
|
303 |
iNewRotation = static_cast<TScreenRotation>(*((TUint32*)aAttribute));
|
sl@0
|
304 |
break;
|
sl@0
|
305 |
default:
|
sl@0
|
306 |
return KErrNotSupported;
|
sl@0
|
307 |
}
|
sl@0
|
308 |
return KErrNone;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
|
sl@0
|
312 |
TInt COpenWFC_RI_DisplayChannel::CommitAttribute()
|
sl@0
|
313 |
{
|
sl@0
|
314 |
// For DisplayChannel the new screen attributes must be applied
|
sl@0
|
315 |
// at the same time with the composition.
|
sl@0
|
316 |
if (iScreenInfo.iCurrentRotation != iNewRotation)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
TInt totalRotation;
|
sl@0
|
319 |
RDisplayChannel::TDisplayRotation dcRotation;
|
sl@0
|
320 |
|
sl@0
|
321 |
// Change the rotation to a numeric index from zero
|
sl@0
|
322 |
switch (iNewRotation)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
case EScreenRotate90:
|
sl@0
|
325 |
totalRotation = 1;
|
sl@0
|
326 |
break;
|
sl@0
|
327 |
case EScreenRotate180:
|
sl@0
|
328 |
totalRotation = 2;
|
sl@0
|
329 |
break;
|
sl@0
|
330 |
case EScreenRotate270:
|
sl@0
|
331 |
totalRotation = 3;
|
sl@0
|
332 |
break;
|
sl@0
|
333 |
case EScreenRotate0:
|
sl@0
|
334 |
default:
|
sl@0
|
335 |
__ASSERT_DEBUG(iNewRotation == EScreenRotate0, Panic(__LINE__));
|
sl@0
|
336 |
totalRotation = 0;
|
sl@0
|
337 |
break;
|
sl@0
|
338 |
}
|
sl@0
|
339 |
|
sl@0
|
340 |
// Add the initial rotation of the device and wrap to get final one.
|
sl@0
|
341 |
totalRotation = (totalRotation + iRotationOffset) % 4;
|
sl@0
|
342 |
|
sl@0
|
343 |
// Now change the final rotation to the display channel rotation
|
sl@0
|
344 |
switch (totalRotation)
|
sl@0
|
345 |
{
|
sl@0
|
346 |
case 1:
|
sl@0
|
347 |
dcRotation = RDisplayChannel::ERotation90CW;
|
sl@0
|
348 |
break;
|
sl@0
|
349 |
case 2:
|
sl@0
|
350 |
dcRotation = RDisplayChannel::ERotation180;
|
sl@0
|
351 |
break;
|
sl@0
|
352 |
case 3:
|
sl@0
|
353 |
dcRotation = RDisplayChannel::ERotation270CW;
|
sl@0
|
354 |
break;
|
sl@0
|
355 |
case 0:
|
sl@0
|
356 |
default:
|
sl@0
|
357 |
__ASSERT_DEBUG(totalRotation == 0, Panic(__LINE__));
|
sl@0
|
358 |
dcRotation = RDisplayChannel::ERotationNormal;
|
sl@0
|
359 |
break;
|
sl@0
|
360 |
}
|
sl@0
|
361 |
|
sl@0
|
362 |
if (!(iScreenInfo.iSupportedRotations & dcRotation))
|
sl@0
|
363 |
{
|
sl@0
|
364 |
return KErrNotSupported;
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
// We do not need to use this boolean
|
sl@0
|
368 |
TBool displayConfigChanged;
|
sl@0
|
369 |
TInt err = iDispChan.SetRotation(dcRotation, displayConfigChanged);
|
sl@0
|
370 |
__ASSERT_DEBUG(err == KErrNone, Panic(__LINE__));
|
sl@0
|
371 |
if (err == KErrNone)
|
sl@0
|
372 |
{
|
sl@0
|
373 |
iScreenInfo.iCurrentRotation = iNewRotation;
|
sl@0
|
374 |
}
|
sl@0
|
375 |
else
|
sl@0
|
376 |
{
|
sl@0
|
377 |
return err;
|
sl@0
|
378 |
}
|
sl@0
|
379 |
}
|
sl@0
|
380 |
return KErrNone;
|
sl@0
|
381 |
}
|
sl@0
|
382 |
|
sl@0
|
383 |
TInt COpenWFC_RI_DisplayChannel::SetLayerSurface(TInt aLayer, SymbianStreamType aStream,TInt* aNonTrivialAttribs)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
// display channel interface can be seen as mono-layered
|
sl@0
|
386 |
if (aLayer != 0)
|
sl@0
|
387 |
{
|
sl@0
|
388 |
return KErrArgument;
|
sl@0
|
389 |
}
|
sl@0
|
390 |
if (aNonTrivialAttribs && *aNonTrivialAttribs)
|
sl@0
|
391 |
{
|
sl@0
|
392 |
return KErrNotSupported;
|
sl@0
|
393 |
}
|
sl@0
|
394 |
TBool acceptable=ETrue;
|
sl@0
|
395 |
khronos_int32_t format,pixSize;
|
sl@0
|
396 |
SymbianStreamGetHeader(aStream,NULL,NULL,NULL,&format,&pixSize);
|
sl@0
|
397 |
if (format!=EUidPixelFormatARGB_8888 && format!=EUidPixelFormatARGB_8888_PRE && format!=EUidPixelFormatXRGB_8888)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
acceptable=EFalse;
|
sl@0
|
400 |
}
|
sl@0
|
401 |
|
sl@0
|
402 |
if (!acceptable)
|
sl@0
|
403 |
{
|
sl@0
|
404 |
return KErrNotSupported;
|
sl@0
|
405 |
}
|
sl@0
|
406 |
|
sl@0
|
407 |
iCurrentSceneStream = aStream;
|
sl@0
|
408 |
return KErrNone;
|
sl@0
|
409 |
}
|
sl@0
|
410 |
|
sl@0
|
411 |
TInt COpenWFC_RI_DisplayChannel::SetTopLayerSurface(SymbianStreamType aStream,TInt* aNonTrivialAttribs)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
return SetLayerSurface(KTopMostLayer, aStream,aNonTrivialAttribs);
|
sl@0
|
414 |
}
|
sl@0
|
415 |
|
sl@0
|
416 |
TInt COpenWFC_RI_DisplayChannel::UpdateDisplay()
|
sl@0
|
417 |
{
|
sl@0
|
418 |
// The solution is suboptimal because a blit is used insteat of posting a user buffer
|
sl@0
|
419 |
// The solution is more simpler and because the emulator is to be phased-out soon,
|
sl@0
|
420 |
// there is no much incentive in complicating the code
|
sl@0
|
421 |
TInt err;
|
sl@0
|
422 |
|
sl@0
|
423 |
TUint bufferIndex;
|
sl@0
|
424 |
TRequestStatus status;
|
sl@0
|
425 |
iDispChan.GetCompositionBuffer(bufferIndex, status);
|
sl@0
|
426 |
User::WaitForRequest(status);
|
sl@0
|
427 |
|
sl@0
|
428 |
err = status.Int();
|
sl@0
|
429 |
if (err != KErrNone || bufferIndex >= iCompositionBuffer.Count())
|
sl@0
|
430 |
{
|
sl@0
|
431 |
return KErrGeneral;
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
TUint8* firstPixelAddr = iCompositionBuffer[bufferIndex]->iAddress;
|
sl@0
|
435 |
|
sl@0
|
436 |
// Only 32 or 16bpp supported and assume stride == width * pixel size
|
sl@0
|
437 |
TInt size = 0;
|
sl@0
|
438 |
if (iNewRotation == EScreenRotate0 || iNewRotation == EScreenRotate180)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
size = iScreenInfo.iNormalHeight * iScreenInfo.iNormalStride;
|
sl@0
|
441 |
}
|
sl@0
|
442 |
else
|
sl@0
|
443 |
{
|
sl@0
|
444 |
size = iScreenInfo.iFlippedHeight * iScreenInfo.iFlippedStride;
|
sl@0
|
445 |
}
|
sl@0
|
446 |
SymbianStreamBuffer frontBuffer;
|
sl@0
|
447 |
SymbianStreamAcquireReadBuffer(iCurrentSceneStream, &frontBuffer);
|
sl@0
|
448 |
void* pixelDataPtr = NULL;
|
sl@0
|
449 |
SymbianStreamGetBufferPointer(iCurrentSceneStream, frontBuffer,&pixelDataPtr);
|
sl@0
|
450 |
Mem::Move(firstPixelAddr, pixelDataPtr, size);
|
sl@0
|
451 |
RDisplayChannel::TPostCount postCount;
|
sl@0
|
452 |
err = iDispChan.PostCompositionBuffer(NULL, postCount);
|
sl@0
|
453 |
if (err == KErrNone)
|
sl@0
|
454 |
{
|
sl@0
|
455 |
// This will throttle composition more than necessary,
|
sl@0
|
456 |
// since it will wait until buffer is being displayed
|
sl@0
|
457 |
iDispChan.WaitForPost(postCount, status);
|
sl@0
|
458 |
User::WaitForRequest(status);
|
sl@0
|
459 |
err = status.Int();
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
SymbianStreamReleaseReadBuffer(iCurrentSceneStream, frontBuffer);
|
sl@0
|
463 |
|
sl@0
|
464 |
return err;
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|