1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
124 TBool ret= DrawColor(iRect, KRgbWhite); |
124 TBool ret= DrawColor(iRect, KRgbWhite); |
125 if (ret) |
125 if (ret) |
126 { |
126 { |
127 TRequestStatus requestStatus; |
127 TRequestStatus requestStatus; |
128 iDSBitmap->EndUpdate(requestStatus); |
128 iDSBitmap->EndUpdate(requestStatus); |
|
129 User::WaitForRequest(requestStatus); |
129 } |
130 } |
130 return ret; |
131 return ret; |
131 } |
132 } |
132 |
133 |
133 TBool CCommonInterfaces::ScreenClearPartial() |
134 TBool CCommonInterfaces::ScreenClearPartial() |
136 TBool ret= DrawColor(iRect, KRgbWhite); |
137 TBool ret= DrawColor(iRect, KRgbWhite); |
137 if (ret) |
138 if (ret) |
138 { |
139 { |
139 TRequestStatus requestStatus; |
140 TRequestStatus requestStatus; |
140 iDSBitmap->EndUpdate(iRect,requestStatus); |
141 iDSBitmap->EndUpdate(iRect,requestStatus); |
|
142 User::WaitForRequest(requestStatus); |
141 } |
143 } |
142 return ret; |
144 return ret; |
143 } |
145 } |
144 |
146 |
145 void CCommonInterfaces::BeginDraw() |
147 void CCommonInterfaces::BeginDraw() |
284 } |
286 } |
285 |
287 |
286 |
288 |
287 //A largely visual test to demonstrate regional refreshing of DirectScreenBitmaps and the correct display function |
289 //A largely visual test to demonstrate regional refreshing of DirectScreenBitmaps and the correct display function |
288 //of the Emulator. |
290 //of the Emulator. |
289 class CTDirectScreenBitmap : public CTGraphicsBase |
291 class CTDirectScreenBitmap : public CTGraphicsBase, public MDirectScreenAccess |
290 { |
292 { |
291 public: |
293 public: |
292 ~CTDirectScreenBitmap(); |
294 ~CTDirectScreenBitmap(); |
293 void ConstructL(const TRect &aScreenRect, const CDirectScreenBitmap::TSettingsFlags aSettings,TInt aScreenNo=0); |
295 void ConstructL(const TRect &aScreenRect, const CDirectScreenBitmap::TSettingsFlags aSettings,TInt aScreenNo=0); |
294 void Close(); |
296 void Close(); |
298 void ExhaustiveTestMergeL(TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,TInt aStepSize=1,TInt aChannelControl=1); |
300 void ExhaustiveTestMergeL(TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,TInt aStepSize=1,TInt aChannelControl=1); |
299 void ExhaustiveTestMergePerDispModeL(TDisplayMode aDrawDeviceDispMode, TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,TInt aStepSize=1,TInt aChannelControl=1,TInt aOtherChannels=0,TDisplayMode aTestMode=EColor16MA); |
301 void ExhaustiveTestMergePerDispModeL(TDisplayMode aDrawDeviceDispMode, TBool aInSrcPreMul,TBool aInDestPreMul,TBool aOutDestPreMul,TInt aStepSize=1,TInt aChannelControl=1,TInt aOtherChannels=0,TDisplayMode aTestMode=EColor16MA); |
300 void LogColourEvent(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aPreMulSrcPixelColor,TInt aNonPreMulSrcPixelColor,TReal aVal1,TReal aVal2,TReal aVal3,TRefByValue<const TDesC> aMsg,TBool aErr); |
302 void LogColourEvent(TInt aPreMulDestPixColor,TInt aNonPreMulDestPixColor,TInt aPreMulSrcPixelColor,TInt aNonPreMulSrcPixelColor,TReal aVal1,TReal aVal2,TReal aVal3,TRefByValue<const TDesC> aMsg,TBool aErr); |
301 void TestContinuousRefreshingL(); |
303 void TestContinuousRefreshingL(); |
302 void TestRefreshingTimeL(); |
304 void TestRefreshingTimeL(); |
|
305 |
|
306 void Restart(RDirectScreenAccess::TTerminationReasons aReason); |
|
307 void AbortNow(RDirectScreenAccess::TTerminationReasons aReason); |
303 private: |
308 private: |
304 void TestRefreshingWindowsPerDisplayModeL(TDisplayMode aDisplayMode); |
309 void TestRefreshingWindowsPerDisplayModeL(TDisplayMode aDisplayMode); |
305 void TestContinuousRefreshingPerDisplayModeL(const TDisplayMode& aDisplayMode); |
310 void TestContinuousRefreshingPerDisplayModeL(const TDisplayMode& aDisplayMode); |
306 void UpdateFrame(); |
311 void UpdateFrame(); |
307 void MeasureFrame(const TRect &aScreenRect); |
312 void MeasureFrame(const TRect &aScreenRect); |
328 TDisplayMode iDispMode; |
333 TDisplayMode iDispMode; |
329 TInt iFreq; // For measuring the average time per frame |
334 TInt iFreq; // For measuring the average time per frame |
330 TReal iMeasure ; |
335 TReal iMeasure ; |
331 TUint32 iTimeBefore; |
336 TUint32 iTimeBefore; |
332 TUint32 iTimeAfter; |
337 TUint32 iTimeAfter; |
|
338 RWsSession iSession; |
|
339 CWsScreenDevice* iScreenDevice; |
|
340 RWindow* iWin; |
|
341 RWindowGroup* iWinGroup; |
|
342 CDirectScreenAccess* iDSA; |
|
343 TInt iWindowHandle; |
333 |
344 |
334 }; |
345 }; |
335 |
346 |
336 /** |
347 /** |
337 The runtime code currently contains a special case when dest starts unmultipled and ends premultiplied. |
348 The runtime code currently contains a special case when dest starts unmultipled and ends premultiplied. |
350 TInt iIgnoredCount; |
361 TInt iIgnoredCount; |
351 TBool iDoIgnore; |
362 TBool iDoIgnore; |
352 }; |
363 }; |
353 |
364 |
354 CTDirectScreenBitmap::CTDirectScreenBitmap(CTestStep* aStep) : |
365 CTDirectScreenBitmap::CTDirectScreenBitmap(CTestStep* aStep) : |
355 CTGraphicsBase(aStep),iMeasure(0) |
366 CTGraphicsBase(aStep),iMeasure(0), iSession() |
356 { |
367 { |
357 } |
368 } |
358 |
369 |
359 CTDirectScreenBitmap::~CTDirectScreenBitmap() |
370 CTDirectScreenBitmap::~CTDirectScreenBitmap() |
360 { |
371 { |
361 Close(); |
372 Close(); |
362 } |
373 } |
|
374 |
|
375 void CTDirectScreenBitmap::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) |
|
376 { |
|
377 iDSA->StartL(); |
|
378 CFbsBitGc* gc = iDSA->Gc(); |
|
379 RRegion* region = iDSA->DrawingRegion(); |
|
380 gc->SetClippingRegion(region); |
|
381 } |
|
382 |
|
383 void CTDirectScreenBitmap::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/) |
|
384 { |
|
385 } |
363 |
386 |
364 //Construct the DirectScreenBitmap and sub-rects for test of the refresh. |
387 //Construct the DirectScreenBitmap and sub-rects for test of the refresh. |
365 //Constructs a DirectScreenBitmap for EDoubleBuffer and EIncrementalUpdate |
388 //Constructs a DirectScreenBitmap for EDoubleBuffer and EIncrementalUpdate |
366 void CTDirectScreenBitmap::ConstructL(const TRect &aScreenRect, const CDirectScreenBitmap::TSettingsFlags aSettings, TInt aScreenType) |
389 void CTDirectScreenBitmap::ConstructL(const TRect &aScreenRect, const CDirectScreenBitmap::TSettingsFlags aSettings, TInt aScreenType) |
367 { |
390 { |
375 } |
398 } |
376 else |
399 else |
377 { |
400 { |
378 iDirectScreenBitmap = CDirectScreenBitmap::NewL(); |
401 iDirectScreenBitmap = CDirectScreenBitmap::NewL(); |
379 } |
402 } |
|
403 iSession.Connect(); |
|
404 iScreenDevice = new (ELeave) CWsScreenDevice(iSession); |
|
405 iScreenDevice->Construct(); |
|
406 |
|
407 iWinGroup = new (ELeave) RWindowGroup(iSession); |
|
408 iWinGroup->Construct(++iWindowHandle, iScreenDevice); |
|
409 iWin = new (ELeave) RWindow(iSession); |
|
410 iWin->Construct(*iWinGroup, ++iWindowHandle); |
|
411 iWin->SetExtent(TPoint(0,0), aScreenRect.Size()); |
|
412 iWin->SetPosition(aScreenRect.iTl); |
|
413 iWin->Activate(); |
|
414 iWin->BeginRedraw(); |
|
415 iWin->EndRedraw(); |
|
416 iDSA = CDirectScreenAccess::NewL(iSession, *iScreenDevice, *iWin, *this); |
|
417 iSession.Flush(); |
|
418 iDSA->StartL(); |
|
419 |
|
420 CFbsBitGc* gc = iDSA->Gc(); |
|
421 RRegion* region = iDSA->DrawingRegion(); |
|
422 gc->SetClippingRegion(region); |
|
423 |
380 iSettings = aSettings; |
424 iSettings = aSettings; |
381 TInt create=iDirectScreenBitmap->Create(aScreenRect, aSettings); |
425 TInt create=iDirectScreenBitmap->Create(aScreenRect, aSettings); |
382 if (create==KErrNone) |
426 if (create==KErrNone) |
383 { |
427 { |
384 iFullRect = aScreenRect; |
428 iFullRect = aScreenRect; |
436 iInterface->DrawColor(iBotRight,KRgbBlack); |
493 iInterface->DrawColor(iBotRight,KRgbBlack); |
437 |
494 |
438 if (!(iSettings & CDirectScreenBitmap::EIncrementalUpdate)) |
495 if (!(iSettings & CDirectScreenBitmap::EIncrementalUpdate)) |
439 { |
496 { |
440 iInterface->EndDraw(iRequestStatus); |
497 iInterface->EndDraw(iRequestStatus); |
441 User::After(WAIT_TIME); |
498 User::WaitForRequest(iRequestStatus); |
442 } |
499 } |
443 else |
500 else |
444 { |
501 { |
445 iInterface->EndDraw(iTopLeft, iRequestStatus); |
502 iInterface->EndDraw(iTopLeft, iRequestStatus); |
446 User::After(WAIT_TIME); |
503 User::WaitForRequest(iRequestStatus); |
447 iInterface->BeginDraw(); |
504 iInterface->BeginDraw(); |
448 iInterface->EndDraw(iTopRight, iRequestStatus); |
505 iInterface->EndDraw(iTopRight, iRequestStatus); |
449 User::After(WAIT_TIME); |
506 User::WaitForRequest(iRequestStatus); |
450 iInterface->BeginDraw(); |
507 iInterface->BeginDraw(); |
451 iInterface->EndDraw(iBotLeft, iRequestStatus); |
508 iInterface->EndDraw(iBotLeft, iRequestStatus); |
452 User::After(WAIT_TIME); |
509 User::WaitForRequest(iRequestStatus); |
453 iInterface->BeginDraw(); |
510 iInterface->BeginDraw(); |
454 iInterface->EndDraw(iBotRight, iRequestStatus); |
511 iInterface->EndDraw(iBotRight, iRequestStatus); |
455 User::After(WAIT_TIME); |
512 User::WaitForRequest(iRequestStatus); |
456 |
513 |
457 iInterface->DrawColor(iMiddle,KRgbCyan); |
514 iInterface->DrawColor(iMiddle,KRgbCyan); |
458 iInterface->BeginDraw(); |
515 iInterface->BeginDraw(); |
459 iInterface->EndDraw(iMiddle, iRequestStatus); |
516 iInterface->EndDraw(iMiddle, iRequestStatus); |
460 User::After(WAIT_TIME); |
517 User::WaitForRequest(iRequestStatus); |
461 |
518 |
462 } |
519 } |
463 __ASSERT_DEBUG(iInterface->ScreenClear(), User::Invariant()); |
520 __ASSERT_DEBUG(iInterface->ScreenClear(), User::Invariant()); |
464 } |
521 } |
465 } |
522 } |