sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32test.h>
|
sl@0
|
17 |
#include <hal.h>
|
sl@0
|
18 |
#include <bitdraw.h>
|
sl@0
|
19 |
#include <bitdrawinterfaceid.h>
|
sl@0
|
20 |
#include <bitdrawsurface.h>
|
sl@0
|
21 |
#include "cdsb.h"
|
sl@0
|
22 |
#include <bitstd.h>
|
sl@0
|
23 |
#include <bitdev.h>
|
sl@0
|
24 |
#include "BMDRAW.H"
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifdef SYMBIAN_GRAPHICS_GCE
|
sl@0
|
27 |
#undef __WINS__
|
sl@0
|
28 |
#elif __WINS__
|
sl@0
|
29 |
#include "_WININC.H"
|
sl@0
|
30 |
#endif
|
sl@0
|
31 |
|
sl@0
|
32 |
#include "TDirectScreenBitmap.h"
|
sl@0
|
33 |
|
sl@0
|
34 |
enum
|
sl@0
|
35 |
{
|
sl@0
|
36 |
WAIT_TIME = 1*400000
|
sl@0
|
37 |
};
|
sl@0
|
38 |
|
sl@0
|
39 |
class CCommonInterfaces
|
sl@0
|
40 |
{
|
sl@0
|
41 |
public:
|
sl@0
|
42 |
virtual ~CCommonInterfaces();
|
sl@0
|
43 |
TBool ScreenClear();
|
sl@0
|
44 |
TBool ScreenClearPartial();
|
sl@0
|
45 |
TBool DrawColor(const TRect& aRect,const TRgb& aColour);
|
sl@0
|
46 |
CCommonInterfaces(const TRect& aRect, const TDisplayMode& aDispMode,CDirectScreenBitmap* aDSBitmap);
|
sl@0
|
47 |
void BeginDraw();
|
sl@0
|
48 |
void EndDraw(TRequestStatus& aStatus);
|
sl@0
|
49 |
void EndDraw(const TRect& aRect, TRequestStatus& aStatus);
|
sl@0
|
50 |
void Drawing(const TRect& aRect);
|
sl@0
|
51 |
void DrawColour64KPixel(TInt aX,TInt aY, const TRgb& aColour);
|
sl@0
|
52 |
|
sl@0
|
53 |
protected:
|
sl@0
|
54 |
TRect iRect;
|
sl@0
|
55 |
TDisplayMode iDispMode;
|
sl@0
|
56 |
CDirectScreenBitmap* iDSBitmap;
|
sl@0
|
57 |
TAcceleratedBitmapInfo iBitmapInfo;
|
sl@0
|
58 |
TBool iDrawingRed;
|
sl@0
|
59 |
};
|
sl@0
|
60 |
|
sl@0
|
61 |
CCommonInterfaces::CCommonInterfaces(const TRect& aRect, const TDisplayMode& aDispMode,CDirectScreenBitmap* aDSBitmap):iRect(aRect),iDispMode(aDispMode),iDSBitmap(aDSBitmap),iDrawingRed(ETrue)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
CCommonInterfaces::~CCommonInterfaces()
|
sl@0
|
66 |
{
|
sl@0
|
67 |
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
/** If the display mode of iBitmapInfo is not expected, return EFalse
|
sl@0
|
71 |
* or render to the back buffer and returns ETrue
|
sl@0
|
72 |
*/
|
sl@0
|
73 |
TBool CCommonInterfaces::DrawColor(const TRect& aRect,const TRgb& aColour)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
TRect local = TRect(aRect.iTl-iRect.iTl, aRect.Size());
|
sl@0
|
76 |
TUint16* pBuffer16;
|
sl@0
|
77 |
TUint32* pBuffer32;
|
sl@0
|
78 |
|
sl@0
|
79 |
if (iBitmapInfo.iDisplayMode != iDispMode)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
return EFalse;
|
sl@0
|
82 |
}
|
sl@0
|
83 |
for (TInt y = local.iTl.iY; y < local.iBr.iY; y++)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
for (TInt x = local.iTl.iX; x < local.iBr.iX; x++)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
switch (iDispMode)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
case EColor64K:
|
sl@0
|
90 |
pBuffer16 = (TUint16*)iBitmapInfo.iAddress;
|
sl@0
|
91 |
pBuffer16[y*iBitmapInfo.iLinePitch/2+x] = aColour._Color64K();
|
sl@0
|
92 |
break;
|
sl@0
|
93 |
case EColor16M:
|
sl@0
|
94 |
pBuffer16 = (TUint16*)iBitmapInfo.iAddress;
|
sl@0
|
95 |
pBuffer16[y*iBitmapInfo.iLinePitch/2+x] = aColour._Color64K();
|
sl@0
|
96 |
break;
|
sl@0
|
97 |
case EColor16MU:
|
sl@0
|
98 |
pBuffer32 = (TUint32*)iBitmapInfo.iAddress;
|
sl@0
|
99 |
pBuffer32[y*iBitmapInfo.iLinePitch/4+x] = aColour._Color16MU();
|
sl@0
|
100 |
break;
|
sl@0
|
101 |
case EColor16MA:
|
sl@0
|
102 |
pBuffer32 = (TUint32*)iBitmapInfo.iAddress;
|
sl@0
|
103 |
pBuffer32[y*iBitmapInfo.iLinePitch/4+x] = aColour._Color16MA();
|
sl@0
|
104 |
break;
|
sl@0
|
105 |
case EColor4K:
|
sl@0
|
106 |
pBuffer16 = (TUint16*)iBitmapInfo.iAddress;
|
sl@0
|
107 |
pBuffer16[y*iBitmapInfo.iLinePitch/2+x] = aColour._Color4K();
|
sl@0
|
108 |
break;
|
sl@0
|
109 |
case EColor16MAP:
|
sl@0
|
110 |
pBuffer32 = (TUint32*)iBitmapInfo.iAddress;
|
sl@0
|
111 |
pBuffer32[y*iBitmapInfo.iLinePitch/4+x] = aColour._Color16MAP();
|
sl@0
|
112 |
break;
|
sl@0
|
113 |
default:
|
sl@0
|
114 |
break;
|
sl@0
|
115 |
}
|
sl@0
|
116 |
}
|
sl@0
|
117 |
}
|
sl@0
|
118 |
return ETrue;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
TBool CCommonInterfaces::ScreenClear()
|
sl@0
|
122 |
{
|
sl@0
|
123 |
iDSBitmap->BeginUpdate(iBitmapInfo);
|
sl@0
|
124 |
TBool ret= DrawColor(iRect, KRgbWhite);
|
sl@0
|
125 |
if (ret)
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TRequestStatus requestStatus;
|
sl@0
|
128 |
iDSBitmap->EndUpdate(requestStatus);
|
sl@0
|
129 |
}
|
sl@0
|
130 |
return ret;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
TBool CCommonInterfaces::ScreenClearPartial()
|
sl@0
|
134 |
{
|
sl@0
|
135 |
iDSBitmap->BeginUpdate(iBitmapInfo);
|
sl@0
|
136 |
TBool ret= DrawColor(iRect, KRgbWhite);
|
sl@0
|
137 |
if (ret)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
TRequestStatus requestStatus;
|
sl@0
|
140 |
iDSBitmap->EndUpdate(iRect,requestStatus);
|
sl@0
|
141 |
}
|
sl@0
|
142 |
return ret;
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
void CCommonInterfaces::BeginDraw()
|
sl@0
|
146 |
{
|
sl@0
|
147 |
iDSBitmap->BeginUpdate(iBitmapInfo);
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
void CCommonInterfaces::EndDraw(TRequestStatus& aStatus)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
iDSBitmap->EndUpdate(aStatus);
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
void CCommonInterfaces::EndDraw(const TRect& aRect, TRequestStatus& aStatus)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
iDSBitmap->EndUpdate(aRect,aStatus);
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
|
sl@0
|
161 |
void CCommonInterfaces::Drawing(const TRect& aRect)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
if (iDrawingRed)
|
sl@0
|
164 |
{
|
sl@0
|
165 |
DrawColor(aRect,KRgbRed);
|
sl@0
|
166 |
iDrawingRed = EFalse;
|
sl@0
|
167 |
}
|
sl@0
|
168 |
else
|
sl@0
|
169 |
{
|
sl@0
|
170 |
DrawColor(aRect,KRgbBlack);
|
sl@0
|
171 |
iDrawingRed = ETrue;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
void CCommonInterfaces::DrawColour64KPixel(TInt aX,TInt aY, const TRgb& aColour)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
TUint16 *pBuffer = (TUint16*)iBitmapInfo.iAddress;
|
sl@0
|
178 |
pBuffer[aY*iBitmapInfo.iLinePitch/2+aX] = aColour._Color64K();
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
class CRendering : public CActive, public CCommonInterfaces
|
sl@0
|
182 |
{
|
sl@0
|
183 |
public:
|
sl@0
|
184 |
static CRendering* NewL(const TRect& aRect, const TDisplayMode& aDispMode, CDirectScreenBitmap* aDSBitmap,CDirectScreenBitmap::TSettingsFlags aSettings);
|
sl@0
|
185 |
void ProcessFrame();
|
sl@0
|
186 |
void EndDraw();
|
sl@0
|
187 |
virtual ~CRendering();
|
sl@0
|
188 |
protected: // from CActive
|
sl@0
|
189 |
|
sl@0
|
190 |
void DoCancel();
|
sl@0
|
191 |
void RunL();
|
sl@0
|
192 |
|
sl@0
|
193 |
private:
|
sl@0
|
194 |
|
sl@0
|
195 |
CRendering(const TRect& aRect, const TDisplayMode& aDispMode,CDirectScreenBitmap* aDSBitmap,CDirectScreenBitmap::TSettingsFlags aSettings);
|
sl@0
|
196 |
void ConstructL();
|
sl@0
|
197 |
|
sl@0
|
198 |
private:
|
sl@0
|
199 |
|
sl@0
|
200 |
TAcceleratedBitmapInfo iBitmapInfo;
|
sl@0
|
201 |
TInt iFrames;
|
sl@0
|
202 |
CDirectScreenBitmap::TSettingsFlags iSettings;
|
sl@0
|
203 |
|
sl@0
|
204 |
};
|
sl@0
|
205 |
|
sl@0
|
206 |
CRendering* CRendering::NewL(const TRect& aRect, const TDisplayMode& aDispMode,CDirectScreenBitmap* aDSBitmap, CDirectScreenBitmap::TSettingsFlags aSettings)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
CRendering * rendering = new (ELeave) CRendering(aRect, aDispMode, aDSBitmap, aSettings);
|
sl@0
|
209 |
CleanupStack::PushL(rendering);
|
sl@0
|
210 |
rendering->ConstructL();
|
sl@0
|
211 |
CleanupStack::Pop(rendering);
|
sl@0
|
212 |
return rendering;
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
CRendering::~CRendering()
|
sl@0
|
216 |
{
|
sl@0
|
217 |
// "Cancel" is a meaningless call, since the service
|
sl@0
|
218 |
// (video driver's screen update process) is not cancellable.
|
sl@0
|
219 |
// When destroying this active object, you must make sure,
|
sl@0
|
220 |
// that the last update request (CDirectScreenBitmap::EndUpdate()) is completed.
|
sl@0
|
221 |
// Assuming that LCD refresh rate is not less than 60 Hz,
|
sl@0
|
222 |
// the wait time should be more than 1/60 secs.
|
sl@0
|
223 |
// (Otherwise a stay signal comes.)
|
sl@0
|
224 |
User::After(WAIT_TIME); // to let the GCE return a valid request notification back to CDSB
|
sl@0
|
225 |
// or surface update panics with EUpdateServPanicDataIntegrity
|
sl@0
|
226 |
Cancel();
|
sl@0
|
227 |
}
|
sl@0
|
228 |
|
sl@0
|
229 |
CRendering::CRendering(const TRect& aRect, const TDisplayMode& aDispMode, CDirectScreenBitmap* aDSBitmap,CDirectScreenBitmap::TSettingsFlags aSettings)
|
sl@0
|
230 |
:CActive( CActive::EPriorityStandard ),CCommonInterfaces(aRect,aDispMode,aDSBitmap),iFrames(0),iSettings(aSettings)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
}
|
sl@0
|
233 |
|
sl@0
|
234 |
|
sl@0
|
235 |
void CRendering::ConstructL()
|
sl@0
|
236 |
{
|
sl@0
|
237 |
CActiveScheduler::Add( this );
|
sl@0
|
238 |
// clear the screen, and also check the display mode of iBitmapInfo is the same as expected
|
sl@0
|
239 |
// If not, stop creating the CRendering object.
|
sl@0
|
240 |
TBool ret = (iSettings & CDirectScreenBitmap::EIncrementalUpdate) ? ScreenClearPartial() : ScreenClear();
|
sl@0
|
241 |
if (!ret)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
User::Leave(KErrGeneral);
|
sl@0
|
244 |
}
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
void CRendering::RunL()
|
sl@0
|
248 |
{
|
sl@0
|
249 |
// Video driver finished to draw the last frame on the screen
|
sl@0
|
250 |
// You may initiate rendering the next frame from here,
|
sl@0
|
251 |
// but it would be slow, since there is a delay between CDirectScreenBitmap::EndUpdate()
|
sl@0
|
252 |
// and the completition of screen refresh by the video driver
|
sl@0
|
253 |
if (iFrames++ <200)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
ProcessFrame();
|
sl@0
|
256 |
}
|
sl@0
|
257 |
else
|
sl@0
|
258 |
{
|
sl@0
|
259 |
CActiveScheduler::Stop();
|
sl@0
|
260 |
}
|
sl@0
|
261 |
}
|
sl@0
|
262 |
|
sl@0
|
263 |
void CRendering::DoCancel()
|
sl@0
|
264 |
{
|
sl@0
|
265 |
// Cancel not implemented in service provider, so we can't do anything here
|
sl@0
|
266 |
}
|
sl@0
|
267 |
|
sl@0
|
268 |
|
sl@0
|
269 |
void CRendering::EndDraw()
|
sl@0
|
270 |
{
|
sl@0
|
271 |
if (IsActive())
|
sl@0
|
272 |
{
|
sl@0
|
273 |
Cancel();
|
sl@0
|
274 |
}
|
sl@0
|
275 |
CCommonInterfaces::EndDraw(iStatus);
|
sl@0
|
276 |
SetActive();
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
void CRendering::ProcessFrame()
|
sl@0
|
280 |
{
|
sl@0
|
281 |
BeginDraw();
|
sl@0
|
282 |
Drawing(iRect);
|
sl@0
|
283 |
EndDraw();
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
|
sl@0
|
287 |
//A largely visual test to demonstrate regional refreshing of DirectScreenBitmaps and the correct display function
|
sl@0
|
288 |
//of the Emulator.
|
sl@0
|
289 |
class CTDirectScreenBitmap : public CTGraphicsBase
|
sl@0
|
290 |
{
|
sl@0
|
291 |
public:
|
sl@0
|
292 |
~CTDirectScreenBitmap();
|
sl@0
|
293 |
void ConstructL(const TRect &aScreenRect, const CDirectScreenBitmap::TSettingsFlags aSettings,TInt aScreenNo=0);
|
sl@0
|
294 |
void Close();
|
sl@0
|
295 |
void DoRefreshCycle(void);
|
sl@0
|
296 |
void TestOrientRefresh(CFbsDrawDevice *aDev);
|
sl@0
|
297 |
void TestRefreshingWindowsL();
|
sl@0
|
298 |
void ExhaustiveTestMergeL(TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,TInt aStepSize=1,TInt aChannelControl=1);
|
sl@0
|
299 |
void ExhaustiveTestMergePerDispModeL(TDisplayMode aDrawDeviceDispMode, TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,TInt aStepSize=1,TInt aChannelControl=1,TInt aOtherChannels=0,TDisplayMode aTestMode=EColor16MA);
|
sl@0
|
300 |
void LogColourEvent(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aPreMulSrcPixelColor,TInt aNonPreMulSrcPixelColor,TReal aVal1,TReal aVal2,TReal aVal3,TRefByValue<const TDesC> aMsg,TBool aErr);
|
sl@0
|
301 |
void TestContinuousRefreshingL();
|
sl@0
|
302 |
void TestRefreshingTimeL();
|
sl@0
|
303 |
private:
|
sl@0
|
304 |
void TestRefreshingWindowsPerDisplayModeL(TDisplayMode aDisplayMode);
|
sl@0
|
305 |
void TestContinuousRefreshingPerDisplayModeL(const TDisplayMode& aDisplayMode);
|
sl@0
|
306 |
void UpdateFrame();
|
sl@0
|
307 |
void MeasureFrame(const TRect &aScreenRect);
|
sl@0
|
308 |
CDirectScreenBitmap::TSettingsFlags iSettings;
|
sl@0
|
309 |
CDirectScreenBitmap* iDirectScreenBitmap;
|
sl@0
|
310 |
TAcceleratedBitmapInfo iBitmapInfo;
|
sl@0
|
311 |
TRequestStatus iRequestStatus;
|
sl@0
|
312 |
TRect iFullRect;
|
sl@0
|
313 |
TRect iTopLeft;
|
sl@0
|
314 |
TRect iTopRight;
|
sl@0
|
315 |
TRect iBotLeft;
|
sl@0
|
316 |
TRect iBotRight;
|
sl@0
|
317 |
TRect iMiddle;
|
sl@0
|
318 |
TInt iScreenType;
|
sl@0
|
319 |
CCommonInterfaces* iInterface;
|
sl@0
|
320 |
CRendering* iRendering;
|
sl@0
|
321 |
public:
|
sl@0
|
322 |
CTDirectScreenBitmap();
|
sl@0
|
323 |
CTDirectScreenBitmap(CTestStep* aStep);
|
sl@0
|
324 |
protected:
|
sl@0
|
325 |
//from CTGraphicsStep
|
sl@0
|
326 |
virtual void RunTestCaseL(TInt aCurTestCase);
|
sl@0
|
327 |
private:
|
sl@0
|
328 |
TDisplayMode iDispMode;
|
sl@0
|
329 |
TInt iFreq; // For measuring the average time per frame
|
sl@0
|
330 |
TReal iMeasure ;
|
sl@0
|
331 |
TUint32 iTimeBefore;
|
sl@0
|
332 |
TUint32 iTimeAfter;
|
sl@0
|
333 |
|
sl@0
|
334 |
};
|
sl@0
|
335 |
|
sl@0
|
336 |
/**
|
sl@0
|
337 |
The runtime code currently contains a special case when dest starts unmultipled and ends premultiplied.
|
sl@0
|
338 |
When src alpha is 0 the dest colour is simply passed through, not converted from unmultiplied to premultiplied.
|
sl@0
|
339 |
That causes this fn to record errors, that will get ignored
|
sl@0
|
340 |
for all source mask (srcMask==0), and most values of bkgrdChannel.
|
sl@0
|
341 |
*/
|
sl@0
|
342 |
class TIgnoreSpecialCases
|
sl@0
|
343 |
{
|
sl@0
|
344 |
public:
|
sl@0
|
345 |
TIgnoreSpecialCases (TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul) ;
|
sl@0
|
346 |
bool operator()(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aSrcMask,TInt aSrcChannel);
|
sl@0
|
347 |
TInt IgnoreCount();
|
sl@0
|
348 |
TInt ExpectedIgnoreCount(TInt aFreq);
|
sl@0
|
349 |
private:
|
sl@0
|
350 |
TInt iIgnoredCount;
|
sl@0
|
351 |
TBool iDoIgnore;
|
sl@0
|
352 |
};
|
sl@0
|
353 |
|
sl@0
|
354 |
CTDirectScreenBitmap::CTDirectScreenBitmap(CTestStep* aStep) :
|
sl@0
|
355 |
CTGraphicsBase(aStep),iMeasure(0)
|
sl@0
|
356 |
{
|
sl@0
|
357 |
}
|
sl@0
|
358 |
|
sl@0
|
359 |
CTDirectScreenBitmap::~CTDirectScreenBitmap()
|
sl@0
|
360 |
{
|
sl@0
|
361 |
Close();
|
sl@0
|
362 |
}
|
sl@0
|
363 |
|
sl@0
|
364 |
//Construct the DirectScreenBitmap and sub-rects for test of the refresh.
|
sl@0
|
365 |
//Constructs a DirectScreenBitmap for EDoubleBuffer and EIncrementalUpdate
|
sl@0
|
366 |
void CTDirectScreenBitmap::ConstructL(const TRect &aScreenRect, const CDirectScreenBitmap::TSettingsFlags aSettings, TInt aScreenType)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
Close();
|
sl@0
|
369 |
iScreenType = aScreenType;
|
sl@0
|
370 |
TInt Screenno;
|
sl@0
|
371 |
if (iScreenType==CDirectScreenBitmap::EDoubleBuffer || iScreenType==CDirectScreenBitmap::EIncrementalUpdate)
|
sl@0
|
372 |
{
|
sl@0
|
373 |
Screenno=iScreenType;
|
sl@0
|
374 |
iDirectScreenBitmap = CDirectScreenBitmap::NewL(Screenno);
|
sl@0
|
375 |
}
|
sl@0
|
376 |
else
|
sl@0
|
377 |
{
|
sl@0
|
378 |
iDirectScreenBitmap = CDirectScreenBitmap::NewL();
|
sl@0
|
379 |
}
|
sl@0
|
380 |
iSettings = aSettings;
|
sl@0
|
381 |
TInt create=iDirectScreenBitmap->Create(aScreenRect, aSettings);
|
sl@0
|
382 |
if (create==KErrNone)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
iFullRect = aScreenRect;
|
sl@0
|
385 |
TPoint Pos = aScreenRect.iTl;
|
sl@0
|
386 |
TSize hSize = TSize(aScreenRect.Width()/2, aScreenRect.Height()/2);
|
sl@0
|
387 |
TSize hSizeX = TSize(aScreenRect.Width()/2, 0);
|
sl@0
|
388 |
TSize hSizeY = TSize(0, aScreenRect.Height()/2);
|
sl@0
|
389 |
TSize qSize = TSize(aScreenRect.Width()/4, aScreenRect.Height()/4);
|
sl@0
|
390 |
|
sl@0
|
391 |
iTopLeft = TRect(Pos, hSize);
|
sl@0
|
392 |
iTopRight = TRect(Pos + hSizeX, hSize);
|
sl@0
|
393 |
iBotLeft = TRect(Pos + hSizeY, hSize);
|
sl@0
|
394 |
iBotRight = TRect(Pos + hSize, hSize);
|
sl@0
|
395 |
iMiddle = TRect(Pos + hSize - qSize, hSize);
|
sl@0
|
396 |
|
sl@0
|
397 |
iInterface = new (ELeave) CCommonInterfaces(iFullRect, iDispMode, iDirectScreenBitmap);
|
sl@0
|
398 |
iRendering = CRendering::NewL(iFullRect,iDispMode,iDirectScreenBitmap,iSettings);
|
sl@0
|
399 |
}
|
sl@0
|
400 |
else
|
sl@0
|
401 |
{
|
sl@0
|
402 |
User::Leave(create);
|
sl@0
|
403 |
}
|
sl@0
|
404 |
}
|
sl@0
|
405 |
|
sl@0
|
406 |
void CTDirectScreenBitmap::Close()
|
sl@0
|
407 |
{
|
sl@0
|
408 |
User::After(WAIT_TIME);
|
sl@0
|
409 |
delete iDirectScreenBitmap;
|
sl@0
|
410 |
iDirectScreenBitmap = NULL;
|
sl@0
|
411 |
delete iInterface;
|
sl@0
|
412 |
iInterface = NULL;
|
sl@0
|
413 |
delete iRendering;
|
sl@0
|
414 |
iRendering = NULL;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
|
sl@0
|
418 |
//A refresh cycle fills a 2x2 region of RGBW rects and draws it to the screen. If the mode is incremental
|
sl@0
|
419 |
//The different colour rects are updated seperately to test the sub-region update.
|
sl@0
|
420 |
void CTDirectScreenBitmap::DoRefreshCycle(void)
|
sl@0
|
421 |
{
|
sl@0
|
422 |
if ((iSettings & CDirectScreenBitmap::EIncrementalUpdate)&&(!iInterface->ScreenClearPartial()))
|
sl@0
|
423 |
{
|
sl@0
|
424 |
INFO_PRINTF1(_L("The display mode of the iBitmapInfo is not expected"));
|
sl@0
|
425 |
}
|
sl@0
|
426 |
else if (!(iSettings & CDirectScreenBitmap::EIncrementalUpdate)&&(!iInterface->ScreenClear()))
|
sl@0
|
427 |
{
|
sl@0
|
428 |
INFO_PRINTF1(_L("The display mode of the iBitmapInfo is not expected"));
|
sl@0
|
429 |
}
|
sl@0
|
430 |
else
|
sl@0
|
431 |
{
|
sl@0
|
432 |
iInterface->BeginDraw();
|
sl@0
|
433 |
iInterface->DrawColor(iTopLeft,KRgbRed);
|
sl@0
|
434 |
iInterface->DrawColor(iTopRight,KRgbGreen);
|
sl@0
|
435 |
iInterface->DrawColor(iBotLeft,KRgbBlue);
|
sl@0
|
436 |
iInterface->DrawColor(iBotRight,KRgbBlack);
|
sl@0
|
437 |
|
sl@0
|
438 |
if (!(iSettings & CDirectScreenBitmap::EIncrementalUpdate))
|
sl@0
|
439 |
{
|
sl@0
|
440 |
iInterface->EndDraw(iRequestStatus);
|
sl@0
|
441 |
User::After(WAIT_TIME);
|
sl@0
|
442 |
}
|
sl@0
|
443 |
else
|
sl@0
|
444 |
{
|
sl@0
|
445 |
iInterface->EndDraw(iTopLeft, iRequestStatus);
|
sl@0
|
446 |
User::After(WAIT_TIME);
|
sl@0
|
447 |
iInterface->BeginDraw();
|
sl@0
|
448 |
iInterface->EndDraw(iTopRight, iRequestStatus);
|
sl@0
|
449 |
User::After(WAIT_TIME);
|
sl@0
|
450 |
iInterface->BeginDraw();
|
sl@0
|
451 |
iInterface->EndDraw(iBotLeft, iRequestStatus);
|
sl@0
|
452 |
User::After(WAIT_TIME);
|
sl@0
|
453 |
iInterface->BeginDraw();
|
sl@0
|
454 |
iInterface->EndDraw(iBotRight, iRequestStatus);
|
sl@0
|
455 |
User::After(WAIT_TIME);
|
sl@0
|
456 |
|
sl@0
|
457 |
iInterface->DrawColor(iMiddle,KRgbCyan);
|
sl@0
|
458 |
iInterface->BeginDraw();
|
sl@0
|
459 |
iInterface->EndDraw(iMiddle, iRequestStatus);
|
sl@0
|
460 |
User::After(WAIT_TIME);
|
sl@0
|
461 |
|
sl@0
|
462 |
}
|
sl@0
|
463 |
__ASSERT_DEBUG(iInterface->ScreenClear(), User::Invariant());
|
sl@0
|
464 |
}
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
//Tests the Orientation and Refresh operations
|
sl@0
|
468 |
void CTDirectScreenBitmap::TestOrientRefresh(CFbsDrawDevice *aDev)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
|
sl@0
|
471 |
MSurfaceId* surfaceIdInterface;
|
sl@0
|
472 |
if (KErrNone != aDev->GetInterface(KSurfaceInterfaceID, reinterpret_cast <TAny*&> (surfaceIdInterface)))
|
sl@0
|
473 |
{
|
sl@0
|
474 |
// GCE is off
|
sl@0
|
475 |
TBool orientations[4];
|
sl@0
|
476 |
aDev->OrientationsAvailable(orientations);
|
sl@0
|
477 |
if ((!orientations[0])&&(!orientations[1])&&(!orientations[2])&&(!orientations[3]))
|
sl@0
|
478 |
{
|
sl@0
|
479 |
INFO_PRINTF1(_L("TestOrientRefresh(): All 4 orientations not supported? (error for non-gce)"));
|
sl@0
|
480 |
}
|
sl@0
|
481 |
for (TUint i = 0; i<4; i++)
|
sl@0
|
482 |
{
|
sl@0
|
483 |
if (orientations[i])
|
sl@0
|
484 |
{
|
sl@0
|
485 |
if (aDev->SetOrientation((CFbsDrawDevice::TOrientation)i))
|
sl@0
|
486 |
{
|
sl@0
|
487 |
DoRefreshCycle();
|
sl@0
|
488 |
}
|
sl@0
|
489 |
else
|
sl@0
|
490 |
{
|
sl@0
|
491 |
TEST(EFalse);
|
sl@0
|
492 |
}
|
sl@0
|
493 |
}
|
sl@0
|
494 |
}
|
sl@0
|
495 |
aDev->SetOrientation((CFbsDrawDevice::TOrientation)0);
|
sl@0
|
496 |
}
|
sl@0
|
497 |
else
|
sl@0
|
498 |
{
|
sl@0
|
499 |
//GCE is on
|
sl@0
|
500 |
TInt orientationAvailable = surfaceIdInterface->DeviceOrientationsAvailable();
|
sl@0
|
501 |
for (TUint32 i = (TUint32)EDeviceOrientationNormal; i <= (TUint32)EDeviceOrientation270CW; i *= 2)
|
sl@0
|
502 |
{
|
sl@0
|
503 |
if (orientationAvailable&i)
|
sl@0
|
504 |
{
|
sl@0
|
505 |
surfaceIdInterface->SetDeviceOrientation((TDeviceOrientation)i);
|
sl@0
|
506 |
DoRefreshCycle();
|
sl@0
|
507 |
}
|
sl@0
|
508 |
}
|
sl@0
|
509 |
surfaceIdInterface->SetDeviceOrientation(EDeviceOrientationNormal);
|
sl@0
|
510 |
}
|
sl@0
|
511 |
}
|
sl@0
|
512 |
|
sl@0
|
513 |
|
sl@0
|
514 |
/**
|
sl@0
|
515 |
@SYMTestCaseID GRAPHICS-CTDirectScreenBitmap-TestRefreshingWindowsL-0001
|
sl@0
|
516 |
@SYMDEF PDEF103006
|
sl@0
|
517 |
@SYMTestCaseDesc Test orientation and Tests refreshing windows for various display modes
|
sl@0
|
518 |
on all type of screens( full screen non-incremental, full screen double buffer, full screen incremental,
|
sl@0
|
519 |
sub-region non incremental, sub region double-buffer, sub region incremental).
|
sl@0
|
520 |
@SYMTestPriority Critical
|
sl@0
|
521 |
@SYMTestStatus Implemented
|
sl@0
|
522 |
@SYMTestActions Create a screen device for all type of screens. Set and test screen orientation
|
sl@0
|
523 |
and finally test refreshing windows.
|
sl@0
|
524 |
@SYMTestExpectedResults
|
sl@0
|
525 |
The orientation and windows refresh test shall succeed on all screen type for various display mode
|
sl@0
|
526 |
**/
|
sl@0
|
527 |
void CTDirectScreenBitmap::TestRefreshingWindowsL()
|
sl@0
|
528 |
{
|
sl@0
|
529 |
TestRefreshingWindowsPerDisplayModeL(EColor64K);
|
sl@0
|
530 |
TestRefreshingWindowsPerDisplayModeL(EColor16M);
|
sl@0
|
531 |
TestRefreshingWindowsPerDisplayModeL(EColor16MU);
|
sl@0
|
532 |
TestRefreshingWindowsPerDisplayModeL(EColor16MA);
|
sl@0
|
533 |
TestRefreshingWindowsPerDisplayModeL(EColor4K);
|
sl@0
|
534 |
TestRefreshingWindowsPerDisplayModeL(EColor16MAP);
|
sl@0
|
535 |
}
|
sl@0
|
536 |
|
sl@0
|
537 |
/**
|
sl@0
|
538 |
Perform TestRefreshingWindowsL test as describe above for individual display mode type.
|
sl@0
|
539 |
@param aDisplayMode : relate to the window color mode to be displayed
|
sl@0
|
540 |
**/
|
sl@0
|
541 |
void CTDirectScreenBitmap::TestRefreshingWindowsPerDisplayModeL(TDisplayMode aDisplayMode)
|
sl@0
|
542 |
{
|
sl@0
|
543 |
CFbsDrawDevice *pDev = NULL;
|
sl@0
|
544 |
iDispMode = aDisplayMode;
|
sl@0
|
545 |
|
sl@0
|
546 |
TRAPD(err,pDev = CFbsDrawDevice::NewScreenDeviceL(0, aDisplayMode));
|
sl@0
|
547 |
if (err)
|
sl@0
|
548 |
{
|
sl@0
|
549 |
INFO_PRINTF2(_L("Note: Failed to create screen device for display mode %i - not supported on this config?"),aDisplayMode);
|
sl@0
|
550 |
|
sl@0
|
551 |
}
|
sl@0
|
552 |
else
|
sl@0
|
553 |
{
|
sl@0
|
554 |
INFO_PRINTF2(_L("Testing RefreshingWindows for display mode %i"),aDisplayMode);
|
sl@0
|
555 |
CleanupDeletePushL(pDev);
|
sl@0
|
556 |
pDev->InitScreen();
|
sl@0
|
557 |
|
sl@0
|
558 |
TSize screenSize = pDev->SizeInPixels();
|
sl@0
|
559 |
TRect directRect;
|
sl@0
|
560 |
|
sl@0
|
561 |
directRect = TRect(TPoint(), screenSize);
|
sl@0
|
562 |
//Full screen non-incremental run
|
sl@0
|
563 |
INFO_PRINTF1(_L("Full screen non-incremental"));
|
sl@0
|
564 |
TRAPD(err,ConstructL(directRect, CDirectScreenBitmap::ENone));
|
sl@0
|
565 |
if (err)
|
sl@0
|
566 |
{
|
sl@0
|
567 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
568 |
}
|
sl@0
|
569 |
else
|
sl@0
|
570 |
{
|
sl@0
|
571 |
TestOrientRefresh(pDev);
|
sl@0
|
572 |
}
|
sl@0
|
573 |
|
sl@0
|
574 |
//Full screen double buffer
|
sl@0
|
575 |
INFO_PRINTF1(_L("Full screen double-buffer"));
|
sl@0
|
576 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EDoubleBuffer,1));
|
sl@0
|
577 |
if (err)
|
sl@0
|
578 |
{
|
sl@0
|
579 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
580 |
}
|
sl@0
|
581 |
else
|
sl@0
|
582 |
{
|
sl@0
|
583 |
TestOrientRefresh(pDev);
|
sl@0
|
584 |
}
|
sl@0
|
585 |
|
sl@0
|
586 |
//Full screen incremental run
|
sl@0
|
587 |
INFO_PRINTF1(_L("Full screen incremental"));
|
sl@0
|
588 |
TRAP(err,ConstructL(directRect, CDirectScreenBitmap::EIncrementalUpdate,2));
|
sl@0
|
589 |
if (err)
|
sl@0
|
590 |
{
|
sl@0
|
591 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
592 |
}
|
sl@0
|
593 |
else
|
sl@0
|
594 |
{
|
sl@0
|
595 |
TestOrientRefresh(pDev);
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
//Quarter screen non-incremental run
|
sl@0
|
599 |
INFO_PRINTF1(_L("Sub region non-incremental"));
|
sl@0
|
600 |
directRect = TRect(TPoint(screenSize.iWidth/2, screenSize.iHeight/2), TSize(screenSize.iWidth/2, screenSize.iHeight/2));
|
sl@0
|
601 |
TRAP(err, ConstructL(directRect, CDirectScreenBitmap::ENone));
|
sl@0
|
602 |
if (err)
|
sl@0
|
603 |
{
|
sl@0
|
604 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
605 |
}
|
sl@0
|
606 |
else
|
sl@0
|
607 |
{
|
sl@0
|
608 |
TestOrientRefresh(pDev);
|
sl@0
|
609 |
}
|
sl@0
|
610 |
|
sl@0
|
611 |
//Quarter screen double buffer
|
sl@0
|
612 |
INFO_PRINTF1(_L("Sub region double-buffer"));
|
sl@0
|
613 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EDoubleBuffer,1));
|
sl@0
|
614 |
if (err)
|
sl@0
|
615 |
{
|
sl@0
|
616 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
617 |
}
|
sl@0
|
618 |
else
|
sl@0
|
619 |
{
|
sl@0
|
620 |
TestOrientRefresh(pDev);
|
sl@0
|
621 |
}
|
sl@0
|
622 |
|
sl@0
|
623 |
//Quarter screen incremental run
|
sl@0
|
624 |
INFO_PRINTF1(_L("Sub region incremental"));
|
sl@0
|
625 |
TRAP(err,ConstructL(directRect, CDirectScreenBitmap::EIncrementalUpdate,2));
|
sl@0
|
626 |
if (err)
|
sl@0
|
627 |
{
|
sl@0
|
628 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
629 |
}
|
sl@0
|
630 |
else
|
sl@0
|
631 |
{
|
sl@0
|
632 |
TestOrientRefresh(pDev);
|
sl@0
|
633 |
}
|
sl@0
|
634 |
|
sl@0
|
635 |
CleanupStack::PopAndDestroy(pDev);
|
sl@0
|
636 |
}
|
sl@0
|
637 |
}
|
sl@0
|
638 |
|
sl@0
|
639 |
void CTDirectScreenBitmap::TestContinuousRefreshingL()
|
sl@0
|
640 |
{
|
sl@0
|
641 |
TestContinuousRefreshingPerDisplayModeL(EColor64K);
|
sl@0
|
642 |
TestContinuousRefreshingPerDisplayModeL(EColor16M);
|
sl@0
|
643 |
TestContinuousRefreshingPerDisplayModeL(EColor16MU);
|
sl@0
|
644 |
TestContinuousRefreshingPerDisplayModeL(EColor16MA);
|
sl@0
|
645 |
TestContinuousRefreshingPerDisplayModeL(EColor4K);
|
sl@0
|
646 |
TestContinuousRefreshingPerDisplayModeL(EColor16MAP);
|
sl@0
|
647 |
}
|
sl@0
|
648 |
|
sl@0
|
649 |
void CTDirectScreenBitmap::TestContinuousRefreshingPerDisplayModeL(const TDisplayMode& aDisplayMode)
|
sl@0
|
650 |
{
|
sl@0
|
651 |
|
sl@0
|
652 |
CFbsDrawDevice *pDev = NULL;
|
sl@0
|
653 |
iDispMode = aDisplayMode;
|
sl@0
|
654 |
|
sl@0
|
655 |
TRAPD(err,pDev = CFbsDrawDevice::NewScreenDeviceL(0, aDisplayMode));
|
sl@0
|
656 |
if (err)
|
sl@0
|
657 |
{
|
sl@0
|
658 |
INFO_PRINTF2(_L("Note: Failed to create screen device for display mode %i - not supported on this config?"),iDispMode);
|
sl@0
|
659 |
|
sl@0
|
660 |
}
|
sl@0
|
661 |
else
|
sl@0
|
662 |
{
|
sl@0
|
663 |
INFO_PRINTF2(_L("Testing Continuous Refreshing for display mode %i"),iDispMode);
|
sl@0
|
664 |
CleanupDeletePushL(pDev);
|
sl@0
|
665 |
User::LeaveIfError(pDev->InitScreen());
|
sl@0
|
666 |
|
sl@0
|
667 |
TSize screenSize = pDev->SizeInPixels();
|
sl@0
|
668 |
TRect directRect;
|
sl@0
|
669 |
|
sl@0
|
670 |
// Quarter screen ENone
|
sl@0
|
671 |
INFO_PRINTF1(_L("Consecutively update frames at left bottom corner and setting ENone"));
|
sl@0
|
672 |
directRect = TRect(TPoint(0, screenSize.iHeight/2), TSize(screenSize.iWidth/2, screenSize.iHeight/2));
|
sl@0
|
673 |
TRAPD(err,ConstructL(directRect, CDirectScreenBitmap::ENone));
|
sl@0
|
674 |
if (err)
|
sl@0
|
675 |
{
|
sl@0
|
676 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
677 |
}
|
sl@0
|
678 |
else
|
sl@0
|
679 |
{
|
sl@0
|
680 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
681 |
UpdateFrame();
|
sl@0
|
682 |
}
|
sl@0
|
683 |
// Quarter screen EDoubleBuffer
|
sl@0
|
684 |
INFO_PRINTF1(_L("Consecutively update frames at up right corner and setting EDoubleBuffer"));
|
sl@0
|
685 |
directRect = TRect(TPoint(screenSize.iWidth/2, 0), TSize(screenSize.iWidth/2, screenSize.iHeight/2));
|
sl@0
|
686 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EDoubleBuffer,1));
|
sl@0
|
687 |
if (err)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
690 |
}
|
sl@0
|
691 |
else
|
sl@0
|
692 |
{
|
sl@0
|
693 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
694 |
UpdateFrame();
|
sl@0
|
695 |
}
|
sl@0
|
696 |
// Quarter screen EIncremental
|
sl@0
|
697 |
INFO_PRINTF1(_L("Consecutively update frames at right bottom corner and setting EIncremental"));
|
sl@0
|
698 |
directRect = TRect(TPoint(screenSize.iWidth/2, screenSize.iHeight/2), TSize(screenSize.iWidth/2, screenSize.iHeight/2));
|
sl@0
|
699 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EIncrementalUpdate,2));
|
sl@0
|
700 |
if (err)
|
sl@0
|
701 |
{
|
sl@0
|
702 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
703 |
}
|
sl@0
|
704 |
else
|
sl@0
|
705 |
{
|
sl@0
|
706 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
707 |
UpdateFrame();
|
sl@0
|
708 |
}
|
sl@0
|
709 |
|
sl@0
|
710 |
// Full screen EIncremental
|
sl@0
|
711 |
INFO_PRINTF1(_L("Consecutively update frames at full screen and setting EIncremental"));
|
sl@0
|
712 |
directRect = TRect(TPoint(0,0), screenSize);
|
sl@0
|
713 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EIncrementalUpdate,2));
|
sl@0
|
714 |
if (err)
|
sl@0
|
715 |
{
|
sl@0
|
716 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
717 |
}
|
sl@0
|
718 |
else
|
sl@0
|
719 |
{
|
sl@0
|
720 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
721 |
UpdateFrame();
|
sl@0
|
722 |
}
|
sl@0
|
723 |
|
sl@0
|
724 |
// Full screen ENone
|
sl@0
|
725 |
INFO_PRINTF1(_L("Consecutively update frames at full screen and setting ENone"));
|
sl@0
|
726 |
directRect = TRect(TPoint(0,0), screenSize);
|
sl@0
|
727 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::ENone));
|
sl@0
|
728 |
if (err)
|
sl@0
|
729 |
{
|
sl@0
|
730 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
731 |
}
|
sl@0
|
732 |
else
|
sl@0
|
733 |
{
|
sl@0
|
734 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
735 |
UpdateFrame();
|
sl@0
|
736 |
}
|
sl@0
|
737 |
|
sl@0
|
738 |
// Full screen EDoubleBuffering
|
sl@0
|
739 |
INFO_PRINTF1(_L("Consecutively update frames at full screen and setting EDoubleBuffering"));
|
sl@0
|
740 |
directRect = TRect(TPoint(0,0), screenSize);
|
sl@0
|
741 |
TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EDoubleBuffer,1));
|
sl@0
|
742 |
if (err)
|
sl@0
|
743 |
{
|
sl@0
|
744 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
745 |
}
|
sl@0
|
746 |
else
|
sl@0
|
747 |
{
|
sl@0
|
748 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
749 |
UpdateFrame();
|
sl@0
|
750 |
}
|
sl@0
|
751 |
CleanupStack::PopAndDestroy(pDev);
|
sl@0
|
752 |
}
|
sl@0
|
753 |
}
|
sl@0
|
754 |
|
sl@0
|
755 |
void CTDirectScreenBitmap::UpdateFrame()
|
sl@0
|
756 |
{
|
sl@0
|
757 |
iRendering->ProcessFrame();
|
sl@0
|
758 |
CActiveScheduler::Start();
|
sl@0
|
759 |
}
|
sl@0
|
760 |
|
sl@0
|
761 |
void CTDirectScreenBitmap::MeasureFrame(const TRect &aScreenRect)
|
sl@0
|
762 |
{
|
sl@0
|
763 |
TInt count = 0;
|
sl@0
|
764 |
iMeasure = 0;
|
sl@0
|
765 |
while (count++<200)
|
sl@0
|
766 |
{
|
sl@0
|
767 |
__ASSERT_DEBUG(iInterface->ScreenClear(), User::Invariant());
|
sl@0
|
768 |
iInterface->BeginDraw();
|
sl@0
|
769 |
iInterface->Drawing(aScreenRect);
|
sl@0
|
770 |
TRequestStatus status;
|
sl@0
|
771 |
iTimeBefore = User::FastCounter();
|
sl@0
|
772 |
iInterface->EndDraw(status);
|
sl@0
|
773 |
iTimeAfter = User::FastCounter();
|
sl@0
|
774 |
iMeasure += 1000 * ((TReal)(iTimeAfter - iTimeBefore)) / ((TReal) iFreq);
|
sl@0
|
775 |
}
|
sl@0
|
776 |
}
|
sl@0
|
777 |
|
sl@0
|
778 |
void CTDirectScreenBitmap::TestRefreshingTimeL()
|
sl@0
|
779 |
{
|
sl@0
|
780 |
// As other display modes have been tested in other test cases
|
sl@0
|
781 |
// Only EColor16MAP is tested here
|
sl@0
|
782 |
CFbsDrawDevice *pDev = NULL;
|
sl@0
|
783 |
TDisplayMode aDisplayMode = EColor16MAP;
|
sl@0
|
784 |
iDispMode = aDisplayMode;
|
sl@0
|
785 |
|
sl@0
|
786 |
TRAPD(err,pDev = CFbsDrawDevice::NewScreenDeviceL(0, aDisplayMode));
|
sl@0
|
787 |
if (err)
|
sl@0
|
788 |
{
|
sl@0
|
789 |
INFO_PRINTF2(_L("Note: Failed to create screen device for display mode %i - not supported on this config?"),iDispMode);
|
sl@0
|
790 |
}
|
sl@0
|
791 |
else
|
sl@0
|
792 |
{
|
sl@0
|
793 |
INFO_PRINTF2(_L("Testing Continuous Refreshing for display mode %i"),iDispMode);
|
sl@0
|
794 |
CleanupDeletePushL(pDev);
|
sl@0
|
795 |
User::LeaveIfError(pDev->InitScreen());
|
sl@0
|
796 |
TSize screenSize = pDev->SizeInPixels();
|
sl@0
|
797 |
TRect directRect;
|
sl@0
|
798 |
|
sl@0
|
799 |
// Quarter screen ENone
|
sl@0
|
800 |
INFO_PRINTF1(_L("Consecutively update frames at left bottom corner and setting ENone"));
|
sl@0
|
801 |
directRect = TRect(TPoint(0, screenSize.iHeight/2), TSize(screenSize.iWidth/2, screenSize.iHeight/2));
|
sl@0
|
802 |
TRAPD(err,ConstructL(directRect, CDirectScreenBitmap::ENone));
|
sl@0
|
803 |
if (err)
|
sl@0
|
804 |
{
|
sl@0
|
805 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
806 |
}
|
sl@0
|
807 |
else
|
sl@0
|
808 |
{
|
sl@0
|
809 |
// use the same iDirectScreenBitmap as CTDirectScreenBitmap
|
sl@0
|
810 |
User::LeaveIfError(HAL::Get(HALData::EFastCounterFrequency, iFreq));
|
sl@0
|
811 |
|
sl@0
|
812 |
MeasureFrame(directRect);
|
sl@0
|
813 |
|
sl@0
|
814 |
INFO_PRINTF2(_L("The total time to render 200 frames is %f"),iMeasure);
|
sl@0
|
815 |
|
sl@0
|
816 |
}
|
sl@0
|
817 |
CleanupStack::PopAndDestroy(pDev);
|
sl@0
|
818 |
|
sl@0
|
819 |
}
|
sl@0
|
820 |
}
|
sl@0
|
821 |
|
sl@0
|
822 |
// TIgnoreSpecialCases
|
sl@0
|
823 |
/**
|
sl@0
|
824 |
The runtime code currently contains a special case when dest starts unmultipled and ends premultiplied.
|
sl@0
|
825 |
When src alpha is 0 the dest colour is simply passed through, not converted from unmultiplied to premultiplied.
|
sl@0
|
826 |
That causes this fn to record errors, that will get ignored for all Source Mask (srcMask==0), and most values of background channel(bkgrdChannel).
|
sl@0
|
827 |
*/
|
sl@0
|
828 |
TIgnoreSpecialCases ::TIgnoreSpecialCases (TBool /*aInSrcPreMul*/,TBool aInDestPreMul,TBool aOutDestPreMul)
|
sl@0
|
829 |
{
|
sl@0
|
830 |
iDoIgnore=(!aInDestPreMul && aOutDestPreMul);
|
sl@0
|
831 |
iIgnoredCount=0;
|
sl@0
|
832 |
}
|
sl@0
|
833 |
|
sl@0
|
834 |
/**
|
sl@0
|
835 |
The function returns true if the error should be ignored and keeps the count of the no. of errors ignored.
|
sl@0
|
836 |
*/
|
sl@0
|
837 |
bool TIgnoreSpecialCases ::operator()(TInt /*aPreMulDestPixColor*/,TInt /*aNonPreMulDestPixColor*/,TInt aSrcMask,TInt /*aSrcChannel*/)
|
sl@0
|
838 |
{
|
sl@0
|
839 |
if (!iDoIgnore || aSrcMask!=0)
|
sl@0
|
840 |
{
|
sl@0
|
841 |
return EFalse;
|
sl@0
|
842 |
}
|
sl@0
|
843 |
iIgnoredCount++;
|
sl@0
|
844 |
return ETrue;
|
sl@0
|
845 |
}
|
sl@0
|
846 |
|
sl@0
|
847 |
/**
|
sl@0
|
848 |
The function returns the no. of errors ignored.
|
sl@0
|
849 |
*/
|
sl@0
|
850 |
TInt TIgnoreSpecialCases ::IgnoreCount()
|
sl@0
|
851 |
{
|
sl@0
|
852 |
return iIgnoredCount;
|
sl@0
|
853 |
}
|
sl@0
|
854 |
|
sl@0
|
855 |
/**
|
sl@0
|
856 |
If the special-case is generating ignored errors then it should generate at least this many
|
sl@0
|
857 |
If not generating errors then the count should be zero. Any other value should be noted to the log.
|
sl@0
|
858 |
*/
|
sl@0
|
859 |
TInt TIgnoreSpecialCases ::ExpectedIgnoreCount(TInt aFreq)
|
sl@0
|
860 |
{
|
sl@0
|
861 |
TInt samples=240/aFreq;
|
sl@0
|
862 |
return samples*samples*200*2; //This is an approximation.
|
sl@0
|
863 |
}
|
sl@0
|
864 |
|
sl@0
|
865 |
/**
|
sl@0
|
866 |
This function is used to write to the log file
|
sl@0
|
867 |
@param aNonPreMulDestPixColor non pre multiplied destination pixel colour
|
sl@0
|
868 |
@param aPreMulSrcPixelColor pre multiplied source pixel colour
|
sl@0
|
869 |
@param aNonPreMulSrcPixelColor non pre multiplied source pixel colour
|
sl@0
|
870 |
@param aVal1 it contains the value of the first variable of the message to be displayed
|
sl@0
|
871 |
@param aVal2 it contains the value of the second variable of the message to be displayed
|
sl@0
|
872 |
@param aVal3 it contains the value of the third variable of the message to be displayed
|
sl@0
|
873 |
@param aMsg it contains the message to be printed to the log file
|
sl@0
|
874 |
@param aErr if true then the test case fails, if false test passes. log is printed in both the case. TEST does not abort, just reports test case failure
|
sl@0
|
875 |
*/
|
sl@0
|
876 |
void CTDirectScreenBitmap::LogColourEvent(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aPreMulSrcPixelColor,TInt aNonPreMulSrcPixelColor,TReal aVal1,TReal aVal2,TReal aVal3,TRefByValue<const TDesC> aMsg,TBool aErr)
|
sl@0
|
877 |
{
|
sl@0
|
878 |
TEST(aErr==EFalse); // if aErr=True, then the previous test step failed.
|
sl@0
|
879 |
INFO_PRINTF4(aMsg,aVal1,aVal2,aVal3);
|
sl@0
|
880 |
if (aNonPreMulSrcPixelColor<0)
|
sl@0
|
881 |
{
|
sl@0
|
882 |
INFO_PRINTF4(_L("Processing source colours for MDest=%i, CDest=%i, MSrc=%i"),aPreMulDestPixColor,aNonPreMulDestPixColor,aPreMulSrcPixelColor);
|
sl@0
|
883 |
}
|
sl@0
|
884 |
else
|
sl@0
|
885 |
{
|
sl@0
|
886 |
INFO_PRINTF5(_L("Processing colour set MDest=%i, CDest=%i, MSrc=%i, CSrc=%i"),aPreMulDestPixColor,aNonPreMulDestPixColor,aPreMulSrcPixelColor,aNonPreMulSrcPixelColor);
|
sl@0
|
887 |
}
|
sl@0
|
888 |
}
|
sl@0
|
889 |
|
sl@0
|
890 |
/**
|
sl@0
|
891 |
@SYMTestCaseID GRAPHICS-CTDirectScreenBitmap-ExhaustiveTestMergeL-0001
|
sl@0
|
892 |
@SYMDEF PDEF099416
|
sl@0
|
893 |
@SYMTestCaseDesc Test that the alpha merge methods work accurately
|
sl@0
|
894 |
@SYMTestPriority High
|
sl@0
|
895 |
@SYMTestStatus Implemented
|
sl@0
|
896 |
@SYMTestActions Create an alpha capable bitmap and throw sample values at the merge function
|
sl@0
|
897 |
@SYMTestExpectedResults
|
sl@0
|
898 |
1a) The merge resultant alpha values do not wrap through 256
|
sl@0
|
899 |
1b) The merge resultant alpha values closely match an equivalent floating-point calculation
|
sl@0
|
900 |
2a) The merge resultant colours do not wrap through 256
|
sl@0
|
901 |
2b) The merge resultant colours do not exceed the resultant alpha if premultiplied output is expected
|
sl@0
|
902 |
2c) The merge resultant colours closely match an equivalent floating-point calculation
|
sl@0
|
903 |
|
sl@0
|
904 |
Exhaustive test of Blend function for every pixel value. Tests combinations of source and destination
|
sl@0
|
905 |
colour and alpha for a particular colour channel (0=red, 1= green, 2=blue). This method emulates the merge
|
sl@0
|
906 |
operation in floating piont and compares the result with the real merge function. Generally the method is
|
sl@0
|
907 |
intended to error-test premultiplied or non-multiplied, or permutations, based on the flags aInSrcPreMul,
|
sl@0
|
908 |
aInDestPreMul,aOutDestPreMul.
|
sl@0
|
909 |
@param aInSrcPreMul if true the source pixel colour will be clipped and treated as premultiplied
|
sl@0
|
910 |
@param aInDestPreMul if true the destination pixel colour will be clipped and treated as premultiplied
|
sl@0
|
911 |
@param aOutDestPreMul if true the calculated pixel colour will be clipped and treated as premultiplied
|
sl@0
|
912 |
@param aStepSize specifies how many brightness levels are skipped. 1,3,5,15,17 are good values
|
sl@0
|
913 |
@param aChannelControl which channel is controlled (0=red, 1= green, 2=blue)
|
sl@0
|
914 |
@param aOtherChannels value used for other channels. In PM modes this will be clipped to the mask value
|
sl@0
|
915 |
@param aTestMode mode of bitmap device. I presume it is consistant with the PreMul flags above
|
sl@0
|
916 |
**/
|
sl@0
|
917 |
void CTDirectScreenBitmap::ExhaustiveTestMergeL(TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,
|
sl@0
|
918 |
TInt aStepSize,TInt aChannelControl)
|
sl@0
|
919 |
{
|
sl@0
|
920 |
ExhaustiveTestMergePerDispModeL(EColor64K,aInSrcPreMul,aInDestPreMul, aOutDestPreMul, aStepSize,aChannelControl);
|
sl@0
|
921 |
ExhaustiveTestMergePerDispModeL(EColor4K,aInSrcPreMul,aInDestPreMul, aOutDestPreMul, aStepSize,aChannelControl);
|
sl@0
|
922 |
ExhaustiveTestMergePerDispModeL(EColor16M,aInSrcPreMul,aInDestPreMul, aOutDestPreMul, aStepSize,aChannelControl);
|
sl@0
|
923 |
ExhaustiveTestMergePerDispModeL(EColor16MU,aInSrcPreMul,aInDestPreMul, aOutDestPreMul, aStepSize,aChannelControl);
|
sl@0
|
924 |
ExhaustiveTestMergePerDispModeL(EColor16MA,aInSrcPreMul,aInDestPreMul, aOutDestPreMul, aStepSize,aChannelControl);
|
sl@0
|
925 |
ExhaustiveTestMergePerDispModeL(EColor16MAP,aInSrcPreMul,aInDestPreMul, aOutDestPreMul, aStepSize,aChannelControl);
|
sl@0
|
926 |
}
|
sl@0
|
927 |
|
sl@0
|
928 |
|
sl@0
|
929 |
|
sl@0
|
930 |
void CTDirectScreenBitmap::ExhaustiveTestMergePerDispModeL(TDisplayMode aDrawDeviceDispMode, TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,
|
sl@0
|
931 |
TInt aStepSize,TInt aChannelControl,TInt aOtherChannels,
|
sl@0
|
932 |
TDisplayMode aTestMode)
|
sl@0
|
933 |
{
|
sl@0
|
934 |
CFbsDrawDevice *pDev = NULL;
|
sl@0
|
935 |
iDispMode = aDrawDeviceDispMode;
|
sl@0
|
936 |
TRAPD(err,pDev = CFbsDrawDevice::NewScreenDeviceL(0,aDrawDeviceDispMode));
|
sl@0
|
937 |
if (err !=KErrNone)
|
sl@0
|
938 |
{
|
sl@0
|
939 |
INFO_PRINTF2(_L("Note: Failed to create screen device for display mode %i - not supported on this config?"),iDispMode);
|
sl@0
|
940 |
}
|
sl@0
|
941 |
else
|
sl@0
|
942 |
{
|
sl@0
|
943 |
INFO_PRINTF2(_L("Test Exhaustive Merge for display mode %i "),iDispMode);
|
sl@0
|
944 |
User::LeaveIfError(pDev->InitScreen());
|
sl@0
|
945 |
pDev->SetAutoUpdate(ETrue);
|
sl@0
|
946 |
TSize screenSize = pDev->SizeInPixels();
|
sl@0
|
947 |
|
sl@0
|
948 |
//Full screen non-incremental run
|
sl@0
|
949 |
TRect directRect(TPoint(0, 0), screenSize);
|
sl@0
|
950 |
INFO_PRINTF1(_L("PDEF099416: Test of pixel merge over full colour and alpha range"));
|
sl@0
|
951 |
|
sl@0
|
952 |
TRAPD(err, ConstructL(directRect, CDirectScreenBitmap::ENone));
|
sl@0
|
953 |
if (err)
|
sl@0
|
954 |
{
|
sl@0
|
955 |
delete pDev;
|
sl@0
|
956 |
INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created"));
|
sl@0
|
957 |
}
|
sl@0
|
958 |
else
|
sl@0
|
959 |
{
|
sl@0
|
960 |
if (!iInterface->ScreenClear())
|
sl@0
|
961 |
{
|
sl@0
|
962 |
INFO_PRINTF1(_L("The display mode of the iBitmapInfo is not expected"));
|
sl@0
|
963 |
delete pDev;
|
sl@0
|
964 |
return;
|
sl@0
|
965 |
}
|
sl@0
|
966 |
else
|
sl@0
|
967 |
{
|
sl@0
|
968 |
TSize bitmapSize(256,1);
|
sl@0
|
969 |
TUint32 bitmapMem[256];
|
sl@0
|
970 |
TUint32 srcLine[256];
|
sl@0
|
971 |
CFbsDrawDevice* bmd = CFbsDrawDevice::NewBitmapDeviceL(bitmapSize, aTestMode, CFbsBitmap::ScanLineLength(256, aTestMode));
|
sl@0
|
972 |
CleanupStack::PushL(bmd);
|
sl@0
|
973 |
//initialize
|
sl@0
|
974 |
bmd->SetAutoUpdate(EFalse);
|
sl@0
|
975 |
bmd->SetBits(bitmapMem);
|
sl@0
|
976 |
//Eveything printed to the screen is just to show the error levels graphically.
|
sl@0
|
977 |
//Patterns are very interesting sometimes
|
sl@0
|
978 |
if (screenSize.iHeight>200 && screenSize.iWidth>600)
|
sl@0
|
979 |
{
|
sl@0
|
980 |
iInterface->BeginDraw();
|
sl@0
|
981 |
iInterface->DrawColor(TRect(260,0,290,30),TRgb(255,0,0));
|
sl@0
|
982 |
iInterface->DrawColor(TRect(260,30,290,60),TRgb(100,0,0));
|
sl@0
|
983 |
iInterface->DrawColor(TRect(260,60,290,90),TRgb(100,0,0));
|
sl@0
|
984 |
iInterface->DrawColor(TRect(260,100,290,130),TRgb(0,255,0));
|
sl@0
|
985 |
iInterface->DrawColor(TRect(260,130,290,160),TRgb(0,200,0));
|
sl@0
|
986 |
iInterface->DrawColor(TRect(260,160,290,190),TRgb(0,100,0));
|
sl@0
|
987 |
iInterface->DrawColor(TRect(560,100,590,130),TRgb(0,0,255));
|
sl@0
|
988 |
iInterface->DrawColor(TRect(560,130,590,160),TRgb(0,0,200));
|
sl@0
|
989 |
iInterface->DrawColor(TRect(560,160,590,190),TRgb(0,0,100));
|
sl@0
|
990 |
iInterface->EndDraw(iRequestStatus);
|
sl@0
|
991 |
}
|
sl@0
|
992 |
//const
|
sl@0
|
993 |
TInt channelMask;
|
sl@0
|
994 |
if (aChannelControl<1)
|
sl@0
|
995 |
{
|
sl@0
|
996 |
channelMask=0x0000FF;
|
sl@0
|
997 |
}
|
sl@0
|
998 |
else
|
sl@0
|
999 |
{
|
sl@0
|
1000 |
if(aChannelControl==1)
|
sl@0
|
1001 |
{
|
sl@0
|
1002 |
channelMask=0x00FF00;
|
sl@0
|
1003 |
}
|
sl@0
|
1004 |
else
|
sl@0
|
1005 |
{
|
sl@0
|
1006 |
channelMask=0xFF0000;
|
sl@0
|
1007 |
}
|
sl@0
|
1008 |
}
|
sl@0
|
1009 |
const TInt otherMask=0xFFFFFF^channelMask;
|
sl@0
|
1010 |
const TInt channelMul=channelMask&0x01010101;
|
sl@0
|
1011 |
const TInt addFactor=aOtherChannels & otherMask; //Use to set the other colour channels with a fixed test value
|
sl@0
|
1012 |
TInt passFlag=0;
|
sl@0
|
1013 |
|
sl@0
|
1014 |
INFO_PRINTF3(_L("AddFactor pass: channel %i others %x "),aChannelControl,addFactor);
|
sl@0
|
1015 |
passFlag=passFlag^0x8000;
|
sl@0
|
1016 |
const TReal KIgnore=0.00000001;//0.3;
|
sl@0
|
1017 |
const TReal KGross=1.51;
|
sl@0
|
1018 |
const TReal KMultiplyErrorBrightness=200.0;
|
sl@0
|
1019 |
TReal errMax=20;
|
sl@0
|
1020 |
TReal errAMax256=0;
|
sl@0
|
1021 |
TReal totErrCol=0;
|
sl@0
|
1022 |
TReal totErrAlpha=0;
|
sl@0
|
1023 |
TReal zeroErrCol=0;
|
sl@0
|
1024 |
TReal zeroErrAlpha=0;
|
sl@0
|
1025 |
TInt countAlphas=0;
|
sl@0
|
1026 |
TInt countColours=0;
|
sl@0
|
1027 |
const TInt stepFactor=aStepSize; //1, 3, 5, 15, 17; //This has a ^3 effect on speed
|
sl@0
|
1028 |
TIgnoreSpecialCases ignoreSpecialCases(aInSrcPreMul,aInDestPreMul,aOutDestPreMul);
|
sl@0
|
1029 |
//bkgrdMask is background mask/alpha input value
|
sl@0
|
1030 |
|
sl@0
|
1031 |
for (TInt bkgrdMask=0;bkgrdMask<256;bkgrdMask+=stepFactor)
|
sl@0
|
1032 |
{
|
sl@0
|
1033 |
TInt logLine=-1;
|
sl@0
|
1034 |
iInterface->BeginDraw();
|
sl@0
|
1035 |
iInterface->DrawColour64KPixel(270+bkgrdMask/screenSize.iHeight,bkgrdMask%screenSize.iHeight, TRgb(addFactor|passFlag));
|
sl@0
|
1036 |
TInt maxChannels=256;
|
sl@0
|
1037 |
if (aInDestPreMul)
|
sl@0
|
1038 |
{
|
sl@0
|
1039 |
maxChannels=bkgrdMask+1;
|
sl@0
|
1040 |
}
|
sl@0
|
1041 |
TInt clippedother=((addFactor-((bkgrdMask*0x010101)&otherMask))>>8)&otherMask;
|
sl@0
|
1042 |
//clippedother is now 0x00FF00FF or 0x00000000 (or 0x00FF0000 or 0x000000FF)
|
sl@0
|
1043 |
clippedother=(addFactor&(clippedother^otherMask))|(((bkgrdMask*0x010101)&clippedother));
|
sl@0
|
1044 |
//bkgrdChannel is background channel input value. In PM it is 0...bkgrdMask. In NP it is 0...255
|
sl@0
|
1045 |
for (TInt bkgrdChannel=0,colour=(bkgrdMask<<24)|clippedother,stepChannel=stepFactor*channelMul;bkgrdChannel<maxChannels;bkgrdChannel+=stepFactor,colour+=stepChannel)
|
sl@0
|
1046 |
{
|
sl@0
|
1047 |
TInt failsPerPass=10;
|
sl@0
|
1048 |
logLine++;
|
sl@0
|
1049 |
if (logLine>=screenSize.iHeight)
|
sl@0
|
1050 |
{
|
sl@0
|
1051 |
logLine=0;
|
sl@0
|
1052 |
}
|
sl@0
|
1053 |
//srcMask is the source mask/alpha
|
sl@0
|
1054 |
for (TInt srcMask=0;srcMask<256;srcMask+=stepFactor) //0 and 255 are special cases, but need testing anyway!
|
sl@0
|
1055 |
{
|
sl@0
|
1056 |
TInt maxChannels=256; //nested
|
sl@0
|
1057 |
if (aInSrcPreMul)
|
sl@0
|
1058 |
{
|
sl@0
|
1059 |
maxChannels=srcMask+1; //In PM-PM source colour passes through unchanged, so skip the tests
|
sl@0
|
1060 |
}
|
sl@0
|
1061 |
bmd->WriteRgbMulti(0,0,maxChannels,1,TRgb(colour,bkgrdMask),CGraphicsContext::EDrawModeWriteAlpha);
|
sl@0
|
1062 |
TInt clippedother=((addFactor-((srcMask*0x010101)&otherMask))>>8)&otherMask;
|
sl@0
|
1063 |
//clippedother is now 0x00FF00FF or 0x00000000 (or 0x00FF0000 or 0x000000FF)
|
sl@0
|
1064 |
clippedother=(addFactor&(clippedother^otherMask))|(((srcMask*0x010101)&clippedother));
|
sl@0
|
1065 |
|
sl@0
|
1066 |
//srcChannel1 is the source channel input value. In PM it is 0...srcMask. In NP it is 0...255
|
sl@0
|
1067 |
for (TInt srcChannel1=0,C=(srcMask<<24)+clippedother;srcChannel1<maxChannels;srcChannel1++,C+=channelMul)
|
sl@0
|
1068 |
{
|
sl@0
|
1069 |
srcLine[srcChannel1]=C;
|
sl@0
|
1070 |
}
|
sl@0
|
1071 |
bmd->WriteLine(0,0,maxChannels,srcLine,CGraphicsContext::EDrawModePEN);
|
sl@0
|
1072 |
TReal errPos=0;
|
sl@0
|
1073 |
TReal errNeg=0;
|
sl@0
|
1074 |
TReal errGross=0;
|
sl@0
|
1075 |
TReal errAPos=0;
|
sl@0
|
1076 |
TReal errANeg=0;
|
sl@0
|
1077 |
TReal errAGross=0;
|
sl@0
|
1078 |
//source multiplier factor for alpha that can then be used to optimise non-multiplied input calculations.
|
sl@0
|
1079 |
TReal srcMultiplier=srcMask/255.0;
|
sl@0
|
1080 |
//destination/background multiplier factor for alpha that can then be used to optimise non-multiplied input calculations.
|
sl@0
|
1081 |
TReal destMultiplier=(bkgrdMask/255.0)*(1.0-srcMultiplier);
|
sl@0
|
1082 |
//alphaPixelValue is the alpha pixel value as generated from the library code under test
|
sl@0
|
1083 |
TUint alphaPixelValue=bmd->ReadPixel(0,0).Alpha();
|
sl@0
|
1084 |
//alphaDiff is the difference in alpha between pixel and float calcuation, i.e. the error. This can be less than 1 level of brightness, i.e. insignificant.
|
sl@0
|
1085 |
TReal alphaDiff=0.0;
|
sl@0
|
1086 |
//pre-mul mode does not effect the alpha calculation
|
sl@0
|
1087 |
//alphaOutputValue is a floating-point calculation of the alpha output value using 255.0 as the scaling factor.
|
sl@0
|
1088 |
TReal alphaOutputValue=(srcMultiplier+destMultiplier)*255.0;
|
sl@0
|
1089 |
alphaDiff=alphaOutputValue-alphaPixelValue;
|
sl@0
|
1090 |
zeroErrAlpha+=alphaDiff;
|
sl@0
|
1091 |
if (alphaDiff>KIgnore || alphaDiff<-KIgnore)
|
sl@0
|
1092 |
{
|
sl@0
|
1093 |
if (alphaDiff>0)
|
sl@0
|
1094 |
{
|
sl@0
|
1095 |
if (alphaDiff>KGross)
|
sl@0
|
1096 |
{
|
sl@0
|
1097 |
if (--failsPerPass>0)
|
sl@0
|
1098 |
LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,alphaOutputValue,alphaPixelValue,alphaDiff,_L("Big Alpha error: expected %f, got %f"),ETrue);
|
sl@0
|
1099 |
errAGross+=(alphaDiff-KIgnore)*KMultiplyErrorBrightness;
|
sl@0
|
1100 |
}
|
sl@0
|
1101 |
else
|
sl@0
|
1102 |
{
|
sl@0
|
1103 |
errAPos+=(alphaDiff-KIgnore)*KMultiplyErrorBrightness;
|
sl@0
|
1104 |
}
|
sl@0
|
1105 |
totErrAlpha+=alphaDiff;
|
sl@0
|
1106 |
}
|
sl@0
|
1107 |
else
|
sl@0
|
1108 |
{
|
sl@0
|
1109 |
if(alphaDiff<-KGross)
|
sl@0
|
1110 |
{
|
sl@0
|
1111 |
if (--failsPerPass>0)
|
sl@0
|
1112 |
LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,alphaOutputValue,alphaPixelValue,alphaDiff,_L("Big Alpha error: expected %f, got %f"),ETrue);
|
sl@0
|
1113 |
errAGross-=(alphaDiff+KIgnore)*KMultiplyErrorBrightness;
|
sl@0
|
1114 |
}
|
sl@0
|
1115 |
else
|
sl@0
|
1116 |
{
|
sl@0
|
1117 |
errANeg-=(alphaDiff+KIgnore)*KMultiplyErrorBrightness;
|
sl@0
|
1118 |
}
|
sl@0
|
1119 |
totErrAlpha-=alphaDiff;
|
sl@0
|
1120 |
}
|
sl@0
|
1121 |
}
|
sl@0
|
1122 |
TInt errA= STATIC_CAST(TInt,(errAPos-errANeg));
|
sl@0
|
1123 |
countAlphas++;
|
sl@0
|
1124 |
countColours+=maxChannels;
|
sl@0
|
1125 |
//The other channel values should not change while the tested channel is modulated...
|
sl@0
|
1126 |
//So I grab it's value for the zero case to compare.
|
sl@0
|
1127 |
TUint otherChannels0=bmd->ReadPixel(0,0).Color16MA()&(otherMask|0xff000000);
|
sl@0
|
1128 |
|
sl@0
|
1129 |
//srcChannel is the source channel input value. In PM it is 0...srcMask. In NP it is 0...255
|
sl@0
|
1130 |
for (TInt srcChannel=0;srcChannel<maxChannels;srcChannel++)
|
sl@0
|
1131 |
{
|
sl@0
|
1132 |
//channelOutputValue is a floating-point calculation of the channel output value using 255.0 as the scaling factor.
|
sl@0
|
1133 |
TReal channelOutputValue;
|
sl@0
|
1134 |
if (aInSrcPreMul)
|
sl@0
|
1135 |
{
|
sl@0
|
1136 |
channelOutputValue=srcChannel;
|
sl@0
|
1137 |
}
|
sl@0
|
1138 |
else
|
sl@0
|
1139 |
{
|
sl@0
|
1140 |
channelOutputValue=srcChannel*srcMultiplier;
|
sl@0
|
1141 |
}
|
sl@0
|
1142 |
|
sl@0
|
1143 |
if (aInDestPreMul)
|
sl@0
|
1144 |
{
|
sl@0
|
1145 |
channelOutputValue+=bkgrdChannel*(1.0-srcMultiplier);
|
sl@0
|
1146 |
}
|
sl@0
|
1147 |
else
|
sl@0
|
1148 |
{
|
sl@0
|
1149 |
channelOutputValue+=bkgrdChannel*destMultiplier;
|
sl@0
|
1150 |
}
|
sl@0
|
1151 |
|
sl@0
|
1152 |
if (!aOutDestPreMul)
|
sl@0
|
1153 |
{
|
sl@0
|
1154 |
if ((srcMultiplier+destMultiplier)!=0)
|
sl@0
|
1155 |
{
|
sl@0
|
1156 |
channelOutputValue=channelOutputValue/(srcMultiplier+destMultiplier);
|
sl@0
|
1157 |
}
|
sl@0
|
1158 |
}
|
sl@0
|
1159 |
TUint readPixel=bmd->ReadPixel(srcChannel,0).Color16MA();
|
sl@0
|
1160 |
//channelPixelValue is the channel pixel value as generated from the library code under test
|
sl@0
|
1161 |
TUint channelPixelValue=(readPixel&channelMask)/channelMul;
|
sl@0
|
1162 |
if (aOutDestPreMul)
|
sl@0
|
1163 |
{
|
sl@0
|
1164 |
if (channelPixelValue>alphaPixelValue)
|
sl@0
|
1165 |
{
|
sl@0
|
1166 |
if (!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel))
|
sl@0
|
1167 |
{
|
sl@0
|
1168 |
if (--failsPerPass>0)
|
sl@0
|
1169 |
{
|
sl@0
|
1170 |
LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,alphaPixelValue,channelOutputValue,channelPixelValue,_L("Output multiplied colour exceeds alpha %f: expected %f got %f"),!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel));
|
sl@0
|
1171 |
|
sl@0
|
1172 |
}
|
sl@0
|
1173 |
}
|
sl@0
|
1174 |
errGross+=10; //output value out of range - bright red spot!
|
sl@0
|
1175 |
}
|
sl@0
|
1176 |
}
|
sl@0
|
1177 |
TUint otherChannels=readPixel&(otherMask|0xff000000);
|
sl@0
|
1178 |
if (otherChannels!=otherChannels0)
|
sl@0
|
1179 |
{ //Other channels should all be constant here!
|
sl@0
|
1180 |
LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,otherChannels0,otherChannels,0,_L("Output for other channels changed when modulating test channel only - Inter-channel leakage? srcChannel=0 value = %f, this value = %f"),ETrue);
|
sl@0
|
1181 |
}
|
sl@0
|
1182 |
//channelDiff is the difference in channel between pixel and float calcuation, i.e. the error. This can be less than 1 level of brightness, i.e. insignificant.
|
sl@0
|
1183 |
TReal channelDiff=channelOutputValue-channelPixelValue;
|
sl@0
|
1184 |
zeroErrCol+=channelDiff;
|
sl@0
|
1185 |
|
sl@0
|
1186 |
if (channelDiff>KIgnore || channelDiff<-KIgnore)
|
sl@0
|
1187 |
if (channelDiff>0)
|
sl@0
|
1188 |
{
|
sl@0
|
1189 |
if (channelDiff>KGross)
|
sl@0
|
1190 |
{
|
sl@0
|
1191 |
if (!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel))
|
sl@0
|
1192 |
{
|
sl@0
|
1193 |
if (--failsPerPass>0)
|
sl@0
|
1194 |
{
|
sl@0
|
1195 |
LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,channelOutputValue,channelPixelValue,channelDiff,_L("Big Colour error: expected %f, got %f"),!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel));
|
sl@0
|
1196 |
}
|
sl@0
|
1197 |
}
|
sl@0
|
1198 |
errGross+=channelDiff-KIgnore;
|
sl@0
|
1199 |
}
|
sl@0
|
1200 |
else
|
sl@0
|
1201 |
{
|
sl@0
|
1202 |
errPos+=channelDiff-KIgnore;
|
sl@0
|
1203 |
}
|
sl@0
|
1204 |
totErrCol+=channelDiff;
|
sl@0
|
1205 |
}
|
sl@0
|
1206 |
else
|
sl@0
|
1207 |
{
|
sl@0
|
1208 |
if (channelDiff<-KGross)
|
sl@0
|
1209 |
{
|
sl@0
|
1210 |
if (!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel))
|
sl@0
|
1211 |
{
|
sl@0
|
1212 |
if (--failsPerPass>0)
|
sl@0
|
1213 |
{
|
sl@0
|
1214 |
LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,srcChannel,channelOutputValue,channelPixelValue,channelDiff,_L("Big Colour error: expected %f, got %f"),!ignoreSpecialCases(bkgrdMask,bkgrdChannel,srcMask,srcChannel));
|
sl@0
|
1215 |
}
|
sl@0
|
1216 |
}
|
sl@0
|
1217 |
errGross-=channelDiff+KIgnore;
|
sl@0
|
1218 |
}
|
sl@0
|
1219 |
else
|
sl@0
|
1220 |
{
|
sl@0
|
1221 |
errNeg-=channelDiff+KIgnore;
|
sl@0
|
1222 |
}
|
sl@0
|
1223 |
|
sl@0
|
1224 |
totErrCol-=channelDiff;
|
sl@0
|
1225 |
}
|
sl@0
|
1226 |
}
|
sl@0
|
1227 |
|
sl@0
|
1228 |
TReal err=errPos-errNeg;
|
sl@0
|
1229 |
errGross+=errAGross;
|
sl@0
|
1230 |
if (errA>errAMax256)
|
sl@0
|
1231 |
{
|
sl@0
|
1232 |
//LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,errA,0,0,_L("Row alpha error level increase, now: %f"),EFalse);
|
sl@0
|
1233 |
errAMax256=errA;
|
sl@0
|
1234 |
}
|
sl@0
|
1235 |
errPos=Min(TReal(255),(errPos*KMultiplyErrorBrightness/TReal(maxChannels)));
|
sl@0
|
1236 |
errNeg=Min(TReal(255),(errNeg*KMultiplyErrorBrightness/TReal(maxChannels)));
|
sl@0
|
1237 |
TReal err256=Min(TReal(255),err*KMultiplyErrorBrightness/TReal(maxChannels));
|
sl@0
|
1238 |
if (err256>errMax)
|
sl@0
|
1239 |
{
|
sl@0
|
1240 |
//LogColourEvent(bkgrdMask,bkgrdChannel,srcMask,-1,err256,err,0,_L("Row colour error level increase, per call now: %f value for row: %f"),EFalse);
|
sl@0
|
1241 |
errMax=err256;
|
sl@0
|
1242 |
}
|
sl@0
|
1243 |
|
sl@0
|
1244 |
errAPos=Min(TReal(255),(errAPos));
|
sl@0
|
1245 |
errANeg=Min(TReal(255),(errANeg));
|
sl@0
|
1246 |
errA=Min(255,errA);
|
sl@0
|
1247 |
if (errGross>10)
|
sl@0
|
1248 |
{
|
sl@0
|
1249 |
errGross=TReal(255);
|
sl@0
|
1250 |
}
|
sl@0
|
1251 |
else
|
sl@0
|
1252 |
{
|
sl@0
|
1253 |
errGross*=TReal(20);
|
sl@0
|
1254 |
}
|
sl@0
|
1255 |
TRect pix(TPoint(),TSize(1,1));
|
sl@0
|
1256 |
if (screenSize.iWidth>260)
|
sl@0
|
1257 |
{
|
sl@0
|
1258 |
iInterface->DrawColour64KPixel(srcMask,logLine, TRgb(STATIC_CAST(TInt,errGross),STATIC_CAST(TInt,errNeg),STATIC_CAST(TInt,errPos)));
|
sl@0
|
1259 |
}
|
sl@0
|
1260 |
if (screenSize.iWidth>360)
|
sl@0
|
1261 |
{
|
sl@0
|
1262 |
iInterface->DrawColour64KPixel(srcMask+300,logLine, TRgb(STATIC_CAST(TInt,errGross),STATIC_CAST(TInt,errNeg),STATIC_CAST(TInt,errPos)));
|
sl@0
|
1263 |
}
|
sl@0
|
1264 |
}
|
sl@0
|
1265 |
|
sl@0
|
1266 |
if (failsPerPass<0)
|
sl@0
|
1267 |
{ //note that this count may be out by 1...
|
sl@0
|
1268 |
INFO_PRINTF2(_L("Additional %i errors not reported in this pass."),-failsPerPass);
|
sl@0
|
1269 |
}
|
sl@0
|
1270 |
}
|
sl@0
|
1271 |
|
sl@0
|
1272 |
iInterface->EndDraw(iRequestStatus);
|
sl@0
|
1273 |
}
|
sl@0
|
1274 |
|
sl@0
|
1275 |
if (ignoreSpecialCases.IgnoreCount() && ignoreSpecialCases.IgnoreCount()<ignoreSpecialCases.ExpectedIgnoreCount(aStepSize))
|
sl@0
|
1276 |
{
|
sl@0
|
1277 |
TEST(ignoreSpecialCases.IgnoreCount()<ignoreSpecialCases.ExpectedIgnoreCount(aStepSize));
|
sl@0
|
1278 |
INFO_PRINTF3(_L("There were less ignored special-case errors than exepected (but more than zero): Expected: 0 or %i, got %i"),
|
sl@0
|
1279 |
ignoreSpecialCases.ExpectedIgnoreCount(aStepSize),ignoreSpecialCases.IgnoreCount()
|
sl@0
|
1280 |
);
|
sl@0
|
1281 |
}
|
sl@0
|
1282 |
INFO_PRINTF4(_L("Highest error rows (normalised @%f per row): Alpha: %f, Colour: %f "),KMultiplyErrorBrightness,errMax,errAMax256);
|
sl@0
|
1283 |
INFO_PRINTF4(_L("Alpha: Samples: %i, total abs= %f, total signed=%f (should be 0)"),countAlphas,totErrAlpha,zeroErrAlpha);
|
sl@0
|
1284 |
INFO_PRINTF4(_L("Colour: Samples: %i, total abs= %f, total signed=%f (should be 0)"),countColours,totErrCol,zeroErrCol);
|
sl@0
|
1285 |
|
sl@0
|
1286 |
CleanupStack::PopAndDestroy(bmd);
|
sl@0
|
1287 |
delete pDev;
|
sl@0
|
1288 |
}
|
sl@0
|
1289 |
|
sl@0
|
1290 |
}
|
sl@0
|
1291 |
}
|
sl@0
|
1292 |
}
|
sl@0
|
1293 |
|
sl@0
|
1294 |
void CTDirectScreenBitmap::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
1295 |
{
|
sl@0
|
1296 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
1297 |
switch(aCurTestCase)
|
sl@0
|
1298 |
{
|
sl@0
|
1299 |
case 1:
|
sl@0
|
1300 |
INFO_PRINTF1(_L("INC0594703 : TestRefreshingWindowsL"));
|
sl@0
|
1301 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-CTDirectScreenBitmap-TestRefreshingWindowsL-0001"));
|
sl@0
|
1302 |
TestRefreshingWindowsL();
|
sl@0
|
1303 |
break;
|
sl@0
|
1304 |
case 2:
|
sl@0
|
1305 |
INFO_PRINTF1(_L("Test Continuous Refreshing Frames"));
|
sl@0
|
1306 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-CTDirectScreenBitmap-TestRefreshingWindowsL-0001"));
|
sl@0
|
1307 |
TestContinuousRefreshingL();
|
sl@0
|
1308 |
break;
|
sl@0
|
1309 |
case 3:
|
sl@0
|
1310 |
INFO_PRINTF1(_L("Exhaustive merge test"));
|
sl@0
|
1311 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-CTDirectScreenBitmap-ExhaustiveTestMergeL-0001"));
|
sl@0
|
1312 |
ExhaustiveTestMergeL(EFalse,EFalse,ETrue,5,0);
|
sl@0
|
1313 |
((CTDirectScreenBitmapStep*)iStep)->RecordTestResultL();
|
sl@0
|
1314 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-CTDirectScreenBitmap-ExhaustiveTestMergeL-0001"));
|
sl@0
|
1315 |
ExhaustiveTestMergeL(EFalse,EFalse,ETrue,5,1);
|
sl@0
|
1316 |
((CTDirectScreenBitmapStep*)iStep)->RecordTestResultL();
|
sl@0
|
1317 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-CTDirectScreenBitmap-ExhaustiveTestMergeL-0001"));
|
sl@0
|
1318 |
ExhaustiveTestMergeL(EFalse,EFalse,ETrue,5,2);
|
sl@0
|
1319 |
((CTDirectScreenBitmapStep*)iStep)->RecordTestResultL();
|
sl@0
|
1320 |
break;
|
sl@0
|
1321 |
case 4:
|
sl@0
|
1322 |
INFO_PRINTF1(_L("Test refreshing time"));
|
sl@0
|
1323 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(_L(" GRAPHICS-CTDirectScreenBitmap-TestRefreshingWindowsL-0001"));
|
sl@0
|
1324 |
TestRefreshingTimeL();
|
sl@0
|
1325 |
break;
|
sl@0
|
1326 |
default:
|
sl@0
|
1327 |
((CTDirectScreenBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
1328 |
((CTDirectScreenBitmapStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
1329 |
TestComplete();
|
sl@0
|
1330 |
break;
|
sl@0
|
1331 |
}
|
sl@0
|
1332 |
((CTDirectScreenBitmapStep*)iStep)->RecordTestResultL();
|
sl@0
|
1333 |
}
|
sl@0
|
1334 |
|
sl@0
|
1335 |
//--------------
|
sl@0
|
1336 |
__CONSTRUCT_STEP__(DirectScreenBitmap)
|
sl@0
|
1337 |
|
sl@0
|
1338 |
void CTDirectScreenBitmapStep::TestSetupL()
|
sl@0
|
1339 |
{
|
sl@0
|
1340 |
TInt temp = 0;
|
sl@0
|
1341 |
User::LeaveIfError(HAL::Get(HALData::EDisplayColors, temp));//force HAL memory allocation
|
sl@0
|
1342 |
}
|