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