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 Updater
|
sl@0
|
24 |
//
|
sl@0
|
25 |
//
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "openwfc_ri_displayupdater.h"
|
sl@0
|
28 |
#include <e32debug.h>
|
sl@0
|
29 |
#include <hal.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
#if defined(ENABLE_LOGGING)
|
sl@0
|
32 |
#define LOG(X) RDebug::Printf X
|
sl@0
|
33 |
#else
|
sl@0
|
34 |
#define LOG(X)
|
sl@0
|
35 |
#endif
|
sl@0
|
36 |
|
sl@0
|
37 |
// #define LOG_DISPLAY_PROPERTIES
|
sl@0
|
38 |
|
sl@0
|
39 |
const TUint32 KDefaultScreenNumber = 0;
|
sl@0
|
40 |
|
sl@0
|
41 |
#ifdef _DEBUG
|
sl@0
|
42 |
void Panic(TInt aPanic)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
_LIT(KPanic, "DA-DU");
|
sl@0
|
45 |
User::Panic(KPanic, aPanic);
|
sl@0
|
46 |
}
|
sl@0
|
47 |
#endif
|
sl@0
|
48 |
|
sl@0
|
49 |
EXPORT_C COpenWFC_RI_Display* COpenWFC_RI_Display::NewL(TUint aScreen)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
return COpenWFC_RI_DisplayUpdater::NewL(aScreen);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
EXPORT_C TUint32 COpenWFC_RI_Display::DefaultScreenNumber()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
return KDefaultScreenNumber;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
COpenWFC_RI_DisplayUpdater::COpenWFC_RI_DisplayUpdater(TUint aScreen):
|
sl@0
|
60 |
iScreenNumber(aScreen),
|
sl@0
|
61 |
iDisplayUpdater(NULL),
|
sl@0
|
62 |
iCurrentSceneStream(SYMBIAN_INVALID_HANDLE),
|
sl@0
|
63 |
iCurrentReadBuffer(SYMBIAN_INVALID_HANDLE),
|
sl@0
|
64 |
iNextSceneStream(SYMBIAN_INVALID_HANDLE),
|
sl@0
|
65 |
iNextReadBuffer(SYMBIAN_INVALID_HANDLE)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
COpenWFC_RI_DisplayUpdater* COpenWFC_RI_DisplayUpdater::NewL(TUint aScreen)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::NewL(%d)", aScreen));
|
sl@0
|
72 |
COpenWFC_RI_DisplayUpdater* screenContext = new(ELeave) COpenWFC_RI_DisplayUpdater(aScreen);
|
sl@0
|
73 |
CleanupStack::PushL(screenContext);
|
sl@0
|
74 |
screenContext->ConstructL();
|
sl@0
|
75 |
CleanupStack::Pop(screenContext);
|
sl@0
|
76 |
LOG((" --- COpenWFC_RI_DisplayUpdater::NewL(%d) : 0x%X", aScreen, screenContext));
|
sl@0
|
77 |
return screenContext;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater()
|
sl@0
|
81 |
{
|
sl@0
|
82 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater(%d)", iScreenNumber));
|
sl@0
|
83 |
if (iDisplayUpdater)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
TDisplayViewSettings viewSettings; // DEFAULT
|
sl@0
|
86 |
TBufferInfo bufferInfo; // DEFAULT
|
sl@0
|
87 |
TInt err = KErrNone;
|
sl@0
|
88 |
|
sl@0
|
89 |
// Set to default view to release layer
|
sl@0
|
90 |
err = iDisplayUpdater->SetView(KTopMostLayer, viewSettings, bufferInfo);
|
sl@0
|
91 |
if (err != KErrNone)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater()ERROR: Display update set view failed %d", err));
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
TRequestStatus completedWhenReady = KRequestPending;
|
sl@0
|
97 |
LOG(("\n +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() FLUSHING *******\n"));
|
sl@0
|
98 |
iDisplayUpdater->Flush(completedWhenReady);
|
sl@0
|
99 |
LOG(("\n +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() AFTER FLUSHING ******* 2\n"));
|
sl@0
|
100 |
User::WaitForRequest(completedWhenReady);
|
sl@0
|
101 |
LOG(("\n +++ COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() FLUSHING:REQUEST COMPLETED %d*******\n", completedWhenReady.Int()));
|
sl@0
|
102 |
|
sl@0
|
103 |
if (iCurrentSceneStream != SYMBIAN_INVALID_HANDLE && iCurrentReadBuffer != SYMBIAN_INVALID_HANDLE)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
SymbianStreamReleaseReadBuffer(iCurrentSceneStream, iCurrentReadBuffer);
|
sl@0
|
106 |
}
|
sl@0
|
107 |
if (iNextSceneStream != SYMBIAN_INVALID_HANDLE && iNextReadBuffer != SYMBIAN_INVALID_HANDLE)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
SymbianStreamReleaseReadBuffer(iNextSceneStream, iNextReadBuffer);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
}
|
sl@0
|
112 |
delete iDisplayUpdater;
|
sl@0
|
113 |
iSurfaceManager.Close();
|
sl@0
|
114 |
LOG((" --- COpenWFC_RI_DisplayUpdater::~COpenWFC_RI_DisplayUpdater() completed"));
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
void COpenWFC_RI_DisplayUpdater::ConstructL()
|
sl@0
|
118 |
{
|
sl@0
|
119 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::ConstructL"));
|
sl@0
|
120 |
User::LeaveIfError(iSurfaceManager.Open());
|
sl@0
|
121 |
iDisplayUpdater = CDisplayUpdater::NewL(iScreenNumber);
|
sl@0
|
122 |
iScreenInfo.iDefaultRotation = EScreenRotate0;
|
sl@0
|
123 |
iDefaultRotation = ERotate0Deg;
|
sl@0
|
124 |
iCurrentRotation = ERotate0Deg;
|
sl@0
|
125 |
iRotationOffset = 0;
|
sl@0
|
126 |
iScreenInfo.iCurrentRotation = EScreenRotate0;
|
sl@0
|
127 |
iNewRotation = iScreenInfo.iCurrentRotation;
|
sl@0
|
128 |
|
sl@0
|
129 |
TDisplayDrvInfo displayInfo;
|
sl@0
|
130 |
iDisplayUpdater->GetDisplayProperties(displayInfo);
|
sl@0
|
131 |
|
sl@0
|
132 |
#if defined(LOG_DISPLAY_PROPERTIES)
|
sl@0
|
133 |
LOG((" ??? Display resolution (%d,%d)", displayInfo.iPanelResolution.iWidth, displayInfo.iPanelResolution.iHeight));
|
sl@0
|
134 |
LOG((" ??? Display twips (%d,%d)", displayInfo.iPanelTwips.iWidth, displayInfo.iPanelTwips.iHeight));
|
sl@0
|
135 |
LOG((" ??? Display refresh rate %dHz", displayInfo.iPanelRefreshRateHz));
|
sl@0
|
136 |
LOG((" ??? Display %d internal composition buffers", (TInt)displayInfo.iNumberOfBuffers));
|
sl@0
|
137 |
LOG((" ??? Display pixel formats: 0x%08.8X", (TInt)displayInfo.iSupportedFormats));
|
sl@0
|
138 |
LOG((" ??? Display pixel aspect ratio %d/%d", (TInt)displayInfo.iPixelAspectRNumerator, (TInt)displayInfo.iPixelAspectRDenominator));
|
sl@0
|
139 |
LOG((" ??? Display supported per-layer rotations: 0x%08.8X", (TInt)displayInfo.iSupportedPerLayerRotations));
|
sl@0
|
140 |
LOG((" ??? Display rotation works with: 0x%08.8X", (TInt)displayInfo.iRotationWorksWithTheseFeatures));
|
sl@0
|
141 |
LOG((" ??? Display scaling works with: 0x%08.8X", (TInt)displayInfo.iScalingWorksWithTheseFeatures));
|
sl@0
|
142 |
LOG((" ??? Display minimum scaling: 100/%d", (TInt)displayInfo.iScalingMinDenominator));
|
sl@0
|
143 |
LOG((" ??? Display maximum scaling: %d/100", (TInt)displayInfo.iScalingMaxNumerator));
|
sl@0
|
144 |
LOG((" ??? Display maximum overlays: %d", (TInt)displayInfo.iNumberOfOverlays));
|
sl@0
|
145 |
LOG((" ??? Display colour space: 0x%08.8X", (TInt)displayInfo.iDestinationColorSpace));
|
sl@0
|
146 |
LOG((" ??? Display colour coords: (%d,%d)R (%d,%d)G (%d,%d)B (%d,%d)W",
|
sl@0
|
147 |
displayInfo.iDestinationColorCoordinates.iRed.iX, displayInfo.iDestinationColorCoordinates.iRed.iY,
|
sl@0
|
148 |
displayInfo.iDestinationColorCoordinates.iGreen.iX, displayInfo.iDestinationColorCoordinates.iGreen.iY,
|
sl@0
|
149 |
displayInfo.iDestinationColorCoordinates.iBlue.iX, displayInfo.iDestinationColorCoordinates.iBlue.iY,
|
sl@0
|
150 |
displayInfo.iDestinationColorCoordinates.iWhite.iX, displayInfo.iDestinationColorCoordinates.iWhite.iY));
|
sl@0
|
151 |
LOG((" ??? Display direct buffer display: %d", (TInt)displayInfo.iGivenBufferWorksAsFrameBuffer));
|
sl@0
|
152 |
LOG((" ??? Display variable resolution: %d", (TInt)displayInfo.iVariableResolution));
|
sl@0
|
153 |
LOG((" ??? Display draw overscan: %d", (TInt)displayInfo.iOverscanToBeDrawn));
|
sl@0
|
154 |
LOG((" ??? Display is on: %d", (TInt)displayInfo.iDisplayOn));
|
sl@0
|
155 |
#endif
|
sl@0
|
156 |
|
sl@0
|
157 |
TInt supportedFormats = displayInfo.iSupportedFormats;
|
sl@0
|
158 |
/* Note that in theory other formats could be supported for composition
|
sl@0
|
159 |
* (eg EPixelFormatARgb8888Le | EPixelFormatARgb8888LeP )
|
sl@0
|
160 |
* So long as the background colour is opaque then the final compiosed image should end up opaque,
|
sl@0
|
161 |
* so compatible with alpha modes.
|
sl@0
|
162 |
* However, it would give problems for fastpathing, where alpha byte should be ignored,
|
sl@0
|
163 |
* probably fastpath would need to be disabled.
|
sl@0
|
164 |
* At present we only care about PlatSim,
|
sl@0
|
165 |
* and it is unlikely that any platform will NOT support xrgb32,
|
sl@0
|
166 |
* so it is better to assert the capabilities match than think about this hypothetical case too hard.
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
if (supportedFormats & (EPixelFormatXRgb8888Le ))
|
sl@0
|
169 |
{
|
sl@0
|
170 |
iScreenInfo.iPixelFormat = EUidPixelFormatXRGB_8888;
|
sl@0
|
171 |
iScreenInfo.iBytesPerPixel = 4;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
else
|
sl@0
|
174 |
{
|
sl@0
|
175 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::ConstructL() unsupported pixel formats 0x%08.8x", supportedFormats));
|
sl@0
|
176 |
User::Leave(KErrNotSupported);
|
sl@0
|
177 |
}
|
sl@0
|
178 |
|
sl@0
|
179 |
iScreenInfo.iPixelFormat = EUidPixelFormatXRGB_8888;
|
sl@0
|
180 |
if (displayInfo.iRotationWorksWithTheseFeatures & EFeatureExternalBuf)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
iScreenInfo.iSupportedRotations = displayInfo.iSupportedPerLayerRotations & 0x0f;
|
sl@0
|
183 |
}
|
sl@0
|
184 |
else
|
sl@0
|
185 |
{
|
sl@0
|
186 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::ConstructL() fixed output rotation"));
|
sl@0
|
187 |
iScreenInfo.iSupportedRotations = (TInt32)ERotate0Deg;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
iScreenInfo.iNormalWidth = displayInfo.iPanelResolution.iWidth;
|
sl@0
|
191 |
iScreenInfo.iNormalHeight = displayInfo.iPanelResolution.iHeight;
|
sl@0
|
192 |
iScreenInfo.iFlippedWidth = iScreenInfo.iNormalHeight;
|
sl@0
|
193 |
iScreenInfo.iFlippedHeight = iScreenInfo.iNormalWidth;
|
sl@0
|
194 |
|
sl@0
|
195 |
iScreenInfo.iNormalStride = iScreenInfo.iBytesPerPixel * iScreenInfo.iNormalWidth;
|
sl@0
|
196 |
iScreenInfo.iFlippedStride = iScreenInfo.iBytesPerPixel * iScreenInfo.iFlippedWidth;
|
sl@0
|
197 |
LOG((" --- COpenWFC_RI_DisplayUpdater::ConstructL"));
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
TInt COpenWFC_RI_Display::GetAttributeSize(TUint aAttributeId)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d)", aAttributeId));
|
sl@0
|
203 |
switch (aAttributeId)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
case EScreenAttributeImplementationVersion:
|
sl@0
|
206 |
case EScreenAttributePixelFormat:
|
sl@0
|
207 |
case EScreenAttributeBytesPerPixel:
|
sl@0
|
208 |
case EScreenAttributeSupportedRotation:
|
sl@0
|
209 |
case EScreenAttributeNormalWidth:
|
sl@0
|
210 |
case EScreenAttributeNormalHeight:
|
sl@0
|
211 |
case EScreenAttributeNormalStride:
|
sl@0
|
212 |
case EScreenAttributeFlippedWidth:
|
sl@0
|
213 |
case EScreenAttributeFlippedHeight:
|
sl@0
|
214 |
case EScreenAttributeFlippedStride:
|
sl@0
|
215 |
case EScreenAttributeDefaultRotation:
|
sl@0
|
216 |
case EScreenAttributeCurrentRotation:
|
sl@0
|
217 |
LOG((" --- COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d) = 4", aAttributeId));
|
sl@0
|
218 |
return sizeof(TUint32);
|
sl@0
|
219 |
|
sl@0
|
220 |
case EScreenAttributeScreenGeometry:
|
sl@0
|
221 |
LOG((" --- COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d) = %d", aAttributeId, sizeof(TScreenGeometryAttribute)));
|
sl@0
|
222 |
return sizeof(TScreenGeometryAttribute);
|
sl@0
|
223 |
|
sl@0
|
224 |
default:
|
sl@0
|
225 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttributeSize(%d) UNKNOWN", aAttributeId));
|
sl@0
|
226 |
return 0;
|
sl@0
|
227 |
}
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
TInt COpenWFC_RI_DisplayUpdater::GetAttribute(TInt aAttributeId, TAny* aAttribute, TInt aAttributeSize)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::GetAttribute(%d, 0x%X, %d)", aAttributeId, aAttribute, aAttributeSize));
|
sl@0
|
233 |
TInt parameterSize = GetAttributeSize(aAttributeId);
|
sl@0
|
234 |
|
sl@0
|
235 |
if (aAttribute == NULL)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() aAttribute NULL ptr"));
|
sl@0
|
238 |
return KErrArgument;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
if (parameterSize == 0)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() Not Supported parameter aAttributeId"));
|
sl@0
|
244 |
return KErrNotSupported;
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
if (aAttributeSize != parameterSize)
|
sl@0
|
248 |
{
|
sl@0
|
249 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() aAttributeSize wrong size"));
|
sl@0
|
250 |
return KErrArgument;
|
sl@0
|
251 |
}
|
sl@0
|
252 |
|
sl@0
|
253 |
switch (aAttributeId)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
case EScreenAttributeImplementationVersion:
|
sl@0
|
256 |
*((TUint32*)aAttribute) = KImplementationVersion;
|
sl@0
|
257 |
break;
|
sl@0
|
258 |
case EScreenAttributePixelFormat:
|
sl@0
|
259 |
*((TUint32*)aAttribute) = iScreenInfo.iPixelFormat;
|
sl@0
|
260 |
break;
|
sl@0
|
261 |
case EScreenAttributeBytesPerPixel:
|
sl@0
|
262 |
*((TUint32*)aAttribute) = iScreenInfo.iBytesPerPixel;
|
sl@0
|
263 |
break;
|
sl@0
|
264 |
case EScreenAttributeSupportedRotation:
|
sl@0
|
265 |
*((TUint32*)aAttribute) = iScreenInfo.iSupportedRotations;
|
sl@0
|
266 |
break;
|
sl@0
|
267 |
case EScreenAttributeNormalWidth:
|
sl@0
|
268 |
*((TUint32*)aAttribute) = iScreenInfo.iNormalWidth;
|
sl@0
|
269 |
break;
|
sl@0
|
270 |
case EScreenAttributeNormalHeight:
|
sl@0
|
271 |
*((TUint32*)aAttribute) = iScreenInfo.iNormalHeight;
|
sl@0
|
272 |
break;
|
sl@0
|
273 |
case EScreenAttributeNormalStride:
|
sl@0
|
274 |
*((TUint32*)aAttribute) = iScreenInfo.iNormalStride;
|
sl@0
|
275 |
break;
|
sl@0
|
276 |
case EScreenAttributeFlippedWidth:
|
sl@0
|
277 |
*((TUint32*)aAttribute) = iScreenInfo.iFlippedWidth;
|
sl@0
|
278 |
break;
|
sl@0
|
279 |
case EScreenAttributeFlippedHeight:
|
sl@0
|
280 |
*((TUint32*)aAttribute) = iScreenInfo.iFlippedHeight;
|
sl@0
|
281 |
break;
|
sl@0
|
282 |
case EScreenAttributeFlippedStride:
|
sl@0
|
283 |
*((TUint32*)aAttribute) = iScreenInfo.iFlippedStride;
|
sl@0
|
284 |
break;
|
sl@0
|
285 |
case EScreenAttributeDefaultRotation:
|
sl@0
|
286 |
*((TUint32*)aAttribute) = iScreenInfo.iDefaultRotation;
|
sl@0
|
287 |
break;
|
sl@0
|
288 |
case EScreenAttributeCurrentRotation:
|
sl@0
|
289 |
*((TUint32*)aAttribute) = iScreenInfo.iCurrentRotation;
|
sl@0
|
290 |
break;
|
sl@0
|
291 |
case EScreenAttributeScreenGeometry:
|
sl@0
|
292 |
*((TScreenGeometryAttribute*)aAttribute) = iScreenInfo;
|
sl@0
|
293 |
break;
|
sl@0
|
294 |
default:
|
sl@0
|
295 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::GetAttribute() attribute unrecognised"));
|
sl@0
|
296 |
return KErrNotSupported;
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
LOG((" --- COpenWFC_RI_DisplayUpdater::GetAttribute() = %d", *((TUint32*)aAttribute)));
|
sl@0
|
300 |
return KErrNone;
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
|
sl@0
|
304 |
TInt COpenWFC_RI_DisplayUpdater::SetAttribute(TInt aAttributeId, TAny* aAttribute, TInt aAttributeSize)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::SetAttribute(%d, 0x%X, %d)", aAttributeId, aAttribute, aAttributeSize));
|
sl@0
|
307 |
// the only parameter we can modify is the current rotation
|
sl@0
|
308 |
TInt parameterSize = GetAttributeSize(aAttributeId);
|
sl@0
|
309 |
|
sl@0
|
310 |
if (aAttributeSize != parameterSize || aAttribute == NULL)
|
sl@0
|
311 |
{
|
sl@0
|
312 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetAttribute() Invalid parameter"));
|
sl@0
|
313 |
return KErrArgument;
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
switch (aAttributeId)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
case EScreenAttributeCurrentRotation:
|
sl@0
|
319 |
iNewRotation = static_cast<TScreenRotation>(*((TUint32*)aAttribute));
|
sl@0
|
320 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::SetAttribute(CurrentRotation, %d)", (TInt)iNewRotation));
|
sl@0
|
321 |
break;
|
sl@0
|
322 |
default:
|
sl@0
|
323 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetAttribute() Invalid attribute"));
|
sl@0
|
324 |
return KErrNotSupported;
|
sl@0
|
325 |
}
|
sl@0
|
326 |
LOG((" --- COpenWFC_RI_DisplayUpdater::SetAttribute()"));
|
sl@0
|
327 |
return KErrNone;
|
sl@0
|
328 |
}
|
sl@0
|
329 |
|
sl@0
|
330 |
|
sl@0
|
331 |
TInt COpenWFC_RI_DisplayUpdater::CommitAttribute()
|
sl@0
|
332 |
{
|
sl@0
|
333 |
LOG((" +++ COpenWFC_RI_DisplayUpdater::CommitAttribute"));
|
sl@0
|
334 |
// Hardware rotation is not demonstrated on PlatSim
|
sl@0
|
335 |
__ASSERT_DEBUG(iScreenInfo.iCurrentRotation == iNewRotation, Panic(__LINE__));
|
sl@0
|
336 |
return KErrNone;
|
sl@0
|
337 |
}
|
sl@0
|
338 |
|
sl@0
|
339 |
TInt COpenWFC_RI_DisplayUpdater::SetLayerSurface(TInt aLayer, SymbianStreamType aStream, TInt* aNonTrivialAttribs)
|
sl@0
|
340 |
{
|
sl@0
|
341 |
// display channel interface can be seen as mono-layered
|
sl@0
|
342 |
if (aLayer != 0)
|
sl@0
|
343 |
{
|
sl@0
|
344 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : non-zero layer not supported"));
|
sl@0
|
345 |
return KErrArgument;
|
sl@0
|
346 |
}
|
sl@0
|
347 |
|
sl@0
|
348 |
if (aNonTrivialAttribs && *aNonTrivialAttribs)
|
sl@0
|
349 |
{
|
sl@0
|
350 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Non-trivial attributes not accepted."));
|
sl@0
|
351 |
return KErrNotSupported;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
if (aStream!=iNextSceneStream)
|
sl@0
|
355 |
{ //If, in future non-trivial attributes are supported then this condition is inadequate
|
sl@0
|
356 |
SymbianStreamBuffer nextReadBuffer=NULL;
|
sl@0
|
357 |
//Scene stream has changed - re-validate and set up for new info
|
sl@0
|
358 |
TInt err=SymbianStreamAcquireReadBuffer(aStream,&nextReadBuffer);
|
sl@0
|
359 |
if (err<KErrNone)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Falied to access stream properties"));
|
sl@0
|
362 |
return err;
|
sl@0
|
363 |
}
|
sl@0
|
364 |
const TSurfaceId* surfaceId;
|
sl@0
|
365 |
khronos_int32_t index;
|
sl@0
|
366 |
err= SymbianStreamGetBufferId(aStream,nextReadBuffer,&index,&surfaceId);
|
sl@0
|
367 |
if (err<KErrNone)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Falied to access stream properties"));
|
sl@0
|
370 |
SymbianStreamReleaseReadBuffer(aStream, nextReadBuffer);
|
sl@0
|
371 |
return err;
|
sl@0
|
372 |
}
|
sl@0
|
373 |
RSurfaceManager::TInfoBuf surfaceInfo;
|
sl@0
|
374 |
iSurfaceManager.SurfaceInfo(*surfaceId,surfaceInfo);
|
sl@0
|
375 |
TBool acceptable=ETrue;
|
sl@0
|
376 |
if (!surfaceInfo().iContiguous)
|
sl@0
|
377 |
{
|
sl@0
|
378 |
acceptable=EFalse;
|
sl@0
|
379 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream 0x%08x iContiguous not accepted ",aStream));
|
sl@0
|
380 |
}
|
sl@0
|
381 |
khronos_int32_t format=surfaceInfo().iPixelFormat;
|
sl@0
|
382 |
if (format!=EUidPixelFormatARGB_8888 && format!=EUidPixelFormatARGB_8888_PRE && format!=EUidPixelFormatXRGB_8888)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
acceptable=EFalse;
|
sl@0
|
385 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream 0x%08x iPixelFormat 0x%08x not accepted ",aStream,surfaceInfo().iPixelFormat));
|
sl@0
|
386 |
}
|
sl@0
|
387 |
|
sl@0
|
388 |
if (!acceptable)
|
sl@0
|
389 |
{
|
sl@0
|
390 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream 0x%08x properties not accepted ",aStream));
|
sl@0
|
391 |
SymbianStreamReleaseReadBuffer(aStream, nextReadBuffer);
|
sl@0
|
392 |
return KErrNotSupported;
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
//Note that if we early-return before this point the previous top stream should still be locked for use.
|
sl@0
|
396 |
|
sl@0
|
397 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream changed 0x%08x --> 0x%08x ",iNextSceneStream,aStream));
|
sl@0
|
398 |
if (iNextSceneStream != SYMBIAN_INVALID_HANDLE && iNextReadBuffer != SYMBIAN_INVALID_HANDLE)
|
sl@0
|
399 |
{
|
sl@0
|
400 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : double-call to SetLayerSurface. First discarded."));
|
sl@0
|
401 |
SymbianStreamReleaseReadBuffer(iNextSceneStream, iNextReadBuffer);
|
sl@0
|
402 |
}
|
sl@0
|
403 |
iNextReadBuffer=nextReadBuffer;
|
sl@0
|
404 |
iNextSceneStream=aStream;
|
sl@0
|
405 |
}
|
sl@0
|
406 |
else
|
sl@0
|
407 |
{
|
sl@0
|
408 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::SetLayerSurface : Stream still 0x%08x",aStream));
|
sl@0
|
409 |
}
|
sl@0
|
410 |
return KErrNone;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
|
sl@0
|
413 |
TInt COpenWFC_RI_DisplayUpdater::SetTopLayerSurface(SymbianStreamType aStream, TInt* aNonTrivialAttribs)
|
sl@0
|
414 |
{
|
sl@0
|
415 |
return SetLayerSurface(KTopMostLayer, aStream, aNonTrivialAttribs);
|
sl@0
|
416 |
}
|
sl@0
|
417 |
|
sl@0
|
418 |
TInt COpenWFC_RI_DisplayUpdater::UpdateDisplay()
|
sl@0
|
419 |
{
|
sl@0
|
420 |
TInt err = KErrNone;
|
sl@0
|
421 |
|
sl@0
|
422 |
SymbianStreamBuffer readBuffer = iNextReadBuffer;
|
sl@0
|
423 |
iNextReadBuffer = SYMBIAN_INVALID_HANDLE;
|
sl@0
|
424 |
if (!iNextSceneStream)
|
sl@0
|
425 |
{
|
sl@0
|
426 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay() ASSERT: No top layer has been set!"));
|
sl@0
|
427 |
return KErrNotReady;
|
sl@0
|
428 |
}
|
sl@0
|
429 |
if (readBuffer == SYMBIAN_INVALID_HANDLE)
|
sl@0
|
430 |
{
|
sl@0
|
431 |
if ((err = SymbianStreamAcquireReadBuffer(iNextSceneStream, &readBuffer)) != KErrNone)
|
sl@0
|
432 |
{ //AcquireReadBuffer "Can't fail" in theory, but just incase....
|
sl@0
|
433 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay() Acquire failed: %d", err));
|
sl@0
|
434 |
return err;
|
sl@0
|
435 |
}
|
sl@0
|
436 |
}
|
sl@0
|
437 |
TBufferInfo bufferInfo;
|
sl@0
|
438 |
khronos_int32_t width, height, stride;
|
sl@0
|
439 |
SymbianStreamGetHeader(iNextSceneStream, &width, &height, &stride, NULL, NULL);
|
sl@0
|
440 |
bufferInfo.iBufferWidth = (TInt16)width;
|
sl@0
|
441 |
bufferInfo.iBufferHeight = (TInt16)height;
|
sl@0
|
442 |
bufferInfo.iStride = (TInt16)stride;
|
sl@0
|
443 |
bufferInfo.iBufferFormat = EPixelFormatXRgb8888Le;
|
sl@0
|
444 |
bufferInfo.iLinearAddress = 0;
|
sl@0
|
445 |
err = SymbianStreamGetBufferPointer(iNextSceneStream, readBuffer,&bufferInfo.iLinearAddress);
|
sl@0
|
446 |
if (err == KErrNone)
|
sl@0
|
447 |
{
|
sl@0
|
448 |
err = SymbianStreamGetChunkHandle(iNextSceneStream, &bufferInfo.iBufferRChunkHandle);
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
if (err != KErrNone)
|
sl@0
|
452 |
{
|
sl@0
|
453 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay() error %d getting stream data", err));
|
sl@0
|
454 |
SymbianStreamReleaseReadBuffer(iNextSceneStream, readBuffer);
|
sl@0
|
455 |
return err;
|
sl@0
|
456 |
}
|
sl@0
|
457 |
|
sl@0
|
458 |
TRect displayRect;
|
sl@0
|
459 |
displayRect.SetRect(TPoint(0, 0), TSize(bufferInfo.iBufferWidth, bufferInfo.iBufferHeight ));
|
sl@0
|
460 |
|
sl@0
|
461 |
TDisplayViewSettings viewSettings; // Default
|
sl@0
|
462 |
viewSettings.iSourceScissor = displayRect;
|
sl@0
|
463 |
viewSettings.iDestinationScaledRect = displayRect;
|
sl@0
|
464 |
viewSettings.iLayerRotation = ERotate0Deg;
|
sl@0
|
465 |
viewSettings.iUsageHint = EPurposeUi;
|
sl@0
|
466 |
viewSettings.iTearingFree = ETrue;
|
sl@0
|
467 |
|
sl@0
|
468 |
LOG((" $$$*** bufferInfo.iBufferWidth %d", bufferInfo.iBufferWidth));
|
sl@0
|
469 |
LOG((" $$$*** bufferInfo.iBufferHeight %d", bufferInfo.iBufferHeight));
|
sl@0
|
470 |
LOG((" $$$*** bufferInfo.iStride %d", bufferInfo.iStride));
|
sl@0
|
471 |
LOG((" $$$*** bufferInfo.iBufferFormat %d", bufferInfo.iBufferFormat));
|
sl@0
|
472 |
LOG((" $$$*** bufferInfo.iLinearAddress %08x", bufferInfo.iLinearAddress));
|
sl@0
|
473 |
LOG((" $$$*** bufferInfo.iBufferRChunkHandle %d", bufferInfo.iBufferRChunkHandle));
|
sl@0
|
474 |
|
sl@0
|
475 |
LOG((" $$$*** viewSettings iSourceScissor width %d", viewSettings.iSourceScissor.Width()));
|
sl@0
|
476 |
LOG((" $$$*** viewSettings iSourceScissor height %d", viewSettings.iSourceScissor.Height()));
|
sl@0
|
477 |
LOG((" $$$*** viewSettings iDestinationScaledRect width %d", viewSettings.iDestinationScaledRect.Width()));
|
sl@0
|
478 |
LOG((" $$$*** viewSettings iDestinationScaledRect height %d", viewSettings.iDestinationScaledRect.Height()));
|
sl@0
|
479 |
LOG((" $$$*** viewSettings iLayerRotation %d", viewSettings.iLayerRotation));
|
sl@0
|
480 |
LOG((" $$$*** viewSettings iUsageHint %d", viewSettings.iUsageHint));
|
sl@0
|
481 |
LOG((" $$$*** viewSettings iTearingFree %d", viewSettings.iTearingFree));
|
sl@0
|
482 |
|
sl@0
|
483 |
TRequestStatus completedWhenReady = KRequestPending;
|
sl@0
|
484 |
viewSettings.iLayerRotation = iCurrentRotation;
|
sl@0
|
485 |
|
sl@0
|
486 |
err = iDisplayUpdater->SetView(KTopMostLayer, viewSettings, bufferInfo);
|
sl@0
|
487 |
|
sl@0
|
488 |
if (err != KErrNone)
|
sl@0
|
489 |
{
|
sl@0
|
490 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay()ERROR: Display update set view failed %d", err));
|
sl@0
|
491 |
}
|
sl@0
|
492 |
else
|
sl@0
|
493 |
{
|
sl@0
|
494 |
err = iDisplayUpdater->SetBuffer(KTopMostLayer, displayRect, bufferInfo );
|
sl@0
|
495 |
if (err != KErrNone)
|
sl@0
|
496 |
{
|
sl@0
|
497 |
LOG((" !!! COpenWFC_RI_DisplayUpdater::UpdateDisplay()ERROR: Display Update set buffer failed %d", err));
|
sl@0
|
498 |
}
|
sl@0
|
499 |
}
|
sl@0
|
500 |
|
sl@0
|
501 |
////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
502 |
iDisplayUpdater->Flush(completedWhenReady);
|
sl@0
|
503 |
|
sl@0
|
504 |
/* The TRequestStatus& aCompletedWhenReady parameter is signalled
|
sl@0
|
505 |
* either when the buffer has been copied,
|
sl@0
|
506 |
* or it is streaming the first pixel to the display
|
sl@0
|
507 |
* In either case this indicates that the previous buffer is no longer required.
|
sl@0
|
508 |
* By waiting here we guarantee that the previous iCurrentReadBuffer is no longer required,
|
sl@0
|
509 |
* but here are more intelligent ways to wait, I am sure!
|
sl@0
|
510 |
*/
|
sl@0
|
511 |
User::WaitForRequest(completedWhenReady);
|
sl@0
|
512 |
if (iCurrentReadBuffer != SYMBIAN_INVALID_HANDLE)
|
sl@0
|
513 |
{
|
sl@0
|
514 |
// Release the previous update's read buffer.
|
sl@0
|
515 |
/* This ensures that a lock is held on the displayed buffer until the next commit/compose
|
sl@0
|
516 |
* This is correct behaviour for streaming direct to the display, but is actually not
|
sl@0
|
517 |
* necessary if the display makes its own copy.
|
sl@0
|
518 |
* However, PlatSim currently supports only the latter, and we think the former is important,
|
sl@0
|
519 |
* so this implementation allows us to validate that the behaviour is correct in direct streaming.
|
sl@0
|
520 |
*/
|
sl@0
|
521 |
SymbianStreamReleaseReadBuffer(iCurrentSceneStream, iCurrentReadBuffer);
|
sl@0
|
522 |
}
|
sl@0
|
523 |
iCurrentReadBuffer = readBuffer;
|
sl@0
|
524 |
iCurrentSceneStream = iNextSceneStream;
|
sl@0
|
525 |
return err;
|
sl@0
|
526 |
}
|
sl@0
|
527 |
|