windowing/windowserver/test/tdynamicres/src/wsdynamicresbase.cpp
changeset 103 2717213c588a
parent 0 5d03bc08d59c
child 116 171fae344dd4
equal deleted inserted replaced
98:bf7481649c98 103:2717213c588a
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <w32std.h>
       
    17 #include "wsdynamicresbase.h"
       
    18 #include "teflogextensions.h"
       
    19 #include "globalsettings.h"
       
    20 #include <bitdraw.h>
       
    21 #include <bitdrawinterfaceid.h>
       
    22 #include <bitdrawsurface.h>
       
    23 #include <graphics/surfaceconfiguration.h>
       
    24 #include "regionextend.h"
       
    25 
       
    26 
       
    27 #if defined(__X86GCC__)
       
    28 extern "C" TInt atexit(void (*function)(void))
       
    29 	{
       
    30 	return KErrNone;
       
    31 	}
       
    32 #endif
       
    33 
       
    34 CWsDynamicResBase::CWsDynamicResBase():
       
    35 	iUtility(this)
       
    36 	{
       
    37 	}
       
    38 
       
    39 CWsDynamicResBase::~CWsDynamicResBase()
       
    40 	{
       
    41 	}
       
    42 
       
    43 /**
       
    44 Common set up code for all tests.
       
    45 
       
    46 Creates the session and window group for further windows, plus a simple white
       
    47 background to obscure any unwanted stuff behind the test. Sets up the surface
       
    48 update session and surface manager, to work with surfaces. Creates a screen
       
    49 device for use in the tests.
       
    50 */
       
    51 void CWsDynamicResBase::SetupL()
       
    52 	{
       
    53 	SetupL(EFalse);
       
    54 	}
       
    55 void CWsDynamicResBase::SetupL(TBool aUseOtherScreenForInfo)
       
    56 	{
       
    57 	CWsDynamicResWinBase::SetupL(aUseOtherScreenForInfo);
       
    58 	
       
    59 	
       
    60 //clean-up if previous test abended
       
    61 	if (PostTestCleanupInstance().iSharedUtility)
       
    62 	{
       
    63 //Temp removed - may be causing ONB fails!
       
    64 //	if (PostTestCleanupInstance().iSharedUtility->DestroyAll())
       
    65 //		{
       
    66 //		INFO_PRINTF1(_L("Destroyed some surfaces from previous test."));
       
    67 //
       
    68 //		}
       
    69 	}
       
    70 	if (!PostTestCleanupInstance().iCleanedUpOnExit)
       
    71 	PostTestCleanupInstance().iCleanedUpOnExit=EFalse;
       
    72 	
       
    73 	if (!GCEIsSupported())
       
    74 		{
       
    75 		INFO_PRINTF1(_L("Some Setup skipped: GCE support is not loaded"));
       
    76 		return;
       
    77 		}
       
    78 
       
    79 	TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( PostTestCleanupInstance().iSharedUtility));
       
    80 	ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone);
       
    81 
       
    82 	
       
    83 	}
       
    84 
       
    85 /**
       
    86 Common tear down code for all tests.
       
    87 
       
    88 Windows, group and session created are closed. Screen device is destroyed.
       
    89 Surfaces, manager and update session are closed.
       
    90 */
       
    91 void CWsDynamicResBase::TearDownL()
       
    92 	{
       
    93 	CWsDynamicResWinBase::TearDownL();
       
    94 	delete iUtility();
       
    95 	PostTestCleanupInstance().iCleanedUpOnExit=ETrue;
       
    96 	//Pause(1000);
       
    97 	}
       
    98 /**
       
    99  * Note that this is not the ideal mechanism.
       
   100  * A derived class may thinks its TearDown is safe to do from delete, but in the class it is derived from it may not be safe
       
   101  **/
       
   102 void CWsDynamicResBase::TearDownFromDeleteL()	
       
   103 	{
       
   104 	CWsDynamicResBase::TearDownL();	
       
   105 	}
       
   106 
       
   107 //Allocating an instance of surface utility here means all test code instances will share the same instance of the utility class.
       
   108 // Owns the singleton
       
   109 /*static*/ const CWsDynamicResBase::TPostTestCleanup& CWsDynamicResBase::PostTestCleanupInstance()
       
   110 	{
       
   111 	static 
       
   112 	class RPostTestCleanup:public TPostTestCleanup
       
   113 		{
       
   114 		public:
       
   115 		RPostTestCleanup()
       
   116 			{
       
   117 			iSharedUtility=NULL;
       
   118 			iCleanedUpOnExit=ETrue;
       
   119 			}
       
   120 		~RPostTestCleanup()
       
   121 			{
       
   122 	// I want to cleanly release the surface utility, but at this point the threads have already been pulled down!
       
   123 	//		if (iSharedUtility)
       
   124 	//			delete iSharedUtility;
       
   125 			iSharedUtility=NULL;	//avoid phoenix behaviour
       
   126 			}
       
   127 		}	staticInstance;
       
   128 		return staticInstance;
       
   129 	}
       
   130 
       
   131 void	CWsDynamicResBase::TPostTestCleanup::CreateSharedUtilityL()const
       
   132 	{
       
   133 	if (iSharedUtility==NULL)
       
   134 		iSharedUtility=CSurfaceUtility::NewL();
       
   135 	}
       
   136 
       
   137 /**
       
   138 Pause for the given number of milliseconds.
       
   139 
       
   140 @param aMilliseconds	Time to wait in milliseconds.
       
   141 */
       
   142 void CWsDynamicResBase::Pause(TInt aMilliseconds)
       
   143 	{
       
   144 	User::After(TTimeIntervalMicroSeconds32(aMilliseconds * 1000));
       
   145 	}
       
   146 
       
   147 /**	Creates the normal scenario used by these tests.
       
   148  *  With a large window behind and small window in front.
       
   149  *  If the windows already exist then they are just repositioned and redrawn.
       
   150  * 	@param	aOuterRect	Position of back window
       
   151  * 	@param	aOuterColor	Background colour for back window
       
   152  * 	@param	aInnerRect	Position of front window
       
   153  * 	@param	aInnerColor	Background colour for front window
       
   154  * 
       
   155  **/
       
   156 void CWsDynamicResBase::MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor)
       
   157 	{
       
   158 	if (!iTestBack.WsHandle())
       
   159 		{
       
   160 		iTestBack=RWindow(iSession);
       
   161 		ASSERT_EQUALS_X(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   162 #ifdef  FLICKER
       
   163 		iTestBack.Activate();
       
   164 #endif
       
   165 		iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
   166 		iTestBack.SetBackgroundColor(aOuterColor);
       
   167 		iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size());
       
   168 #ifndef FLICKER
       
   169 		iTestBack.Activate();
       
   170 #endif
       
   171 		}
       
   172 	else
       
   173 		{
       
   174 		iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
   175 		iTestBack.SetBackgroundColor(aOuterColor);
       
   176 		iTestBack.SetExtent(aOuterRect.iTl,aOuterRect.Size());
       
   177 		}
       
   178 	iTestBack.BeginRedraw();
       
   179 	ActivateWithWipe(iGc,iTestBack,aOuterColor);
       
   180 	iGc->Deactivate();
       
   181 	iTestBack.EndRedraw();
       
   182 	iTestBack.SetVisible(ETrue);
       
   183 	
       
   184 	if (!iTestFront.WsHandle())
       
   185 		{
       
   186 		iTestFront=RWindow(iSession);
       
   187 		ASSERT_EQUALS_X(iTestFront.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   188 #ifdef FLICKER
       
   189 		iTestFront.Activate();
       
   190 #endif
       
   191 		iTestFront.SetRequiredDisplayMode(iDisplayMode);
       
   192 		iTestFront.SetBackgroundColor(aInnerColor);	
       
   193 		iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size());
       
   194 
       
   195 #ifndef FLICKER
       
   196 		iTestFront.Activate();
       
   197 #endif
       
   198 		}
       
   199 	else
       
   200 		{
       
   201 		iTestFront.SetRequiredDisplayMode(iDisplayMode);
       
   202 		iTestFront.SetBackgroundColor(aInnerColor);
       
   203 		iTestFront.SetExtent(aInnerRect.iTl,aInnerRect.Size());
       
   204 		}
       
   205 	
       
   206 	DrawPlainUI(iTestFront,EFalse,aInnerColor);
       
   207 	iTestFront.SetVisible(ETrue);
       
   208 	
       
   209 	}
       
   210 
       
   211 void CWsDynamicResBase::LargerTestWindow(TInt aPercentOfBack)
       
   212 	{
       
   213 	TRect newPos=iTestPos;
       
   214 	TSize backSize=iTestPos.Size();
       
   215 	newPos.Grow((aPercentOfBack-100)*backSize.iWidth/200,(aPercentOfBack-100)*backSize.iHeight/200);
       
   216 	iCenteredFrontWinRect=newPos;
       
   217 	if (iTestFront.WsHandle())
       
   218 		{
       
   219 		iTestFront.SetExtent(newPos.iTl,newPos.Size());
       
   220 		}
       
   221 	
       
   222 	}
       
   223 
       
   224 /** Destroys some or all of the test windows so the test can loop (or test the state after destruction.
       
   225  *  The windows are destroyed when the test exits normally.
       
   226  * 	Child windows are automatically killed when parent window is killed!
       
   227  * 
       
   228  **/
       
   229 void CWsDynamicResBase::DestroyTestWindowPair(TBool aKillTestBack,TBool aKillTestFront,TBool aKillTestChildren)
       
   230 	{
       
   231 	if (aKillTestBack && iTestBack.WsHandle())
       
   232 		{
       
   233 		iTestBack.Close();
       
   234 		}
       
   235 	if (aKillTestFront && iTestFront.WsHandle())
       
   236 		{
       
   237 		iTestFront.Close();
       
   238 		}
       
   239 	if (aKillTestChildren)
       
   240 		{
       
   241 		if (iTestChild.WsHandle())
       
   242 			{
       
   243 			iTestChild.Close();
       
   244 			}
       
   245 		if (iTestSecondChild.WsHandle())
       
   246 			{
       
   247 			iTestSecondChild.Close();
       
   248 			}
       
   249 		}
       
   250 	}
       
   251 /**	Creates a child window inside the front window of the usual test scenario
       
   252 *  With a large window behind and small window in front.
       
   253  *  If the windows already exist then they are just repositioned and redrawn.
       
   254  * 	@param	aOuterRect	Position of back window
       
   255  * 	@param	aOuterColor	Background colour for back window
       
   256  * 	@param	aInnerRect	Position of front window
       
   257  * 	@param	aInnerColor	Background colour for front window
       
   258  * 	@param	aChildRect	Position of child window
       
   259  * 	@param	aChildColor	Background colour for child window
       
   260  * 	@param	aSecondChildRect	Position of Second child window
       
   261  * 	@param	aSecondChildColor	Background colour for Second child window
       
   262  * 
       
   263  **/
       
   264 void CWsDynamicResBase::MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor)
       
   265 	{
       
   266 	MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor);
       
   267 
       
   268 	MakeExtraChildWindowL(iTestChild,aSecondChildRect,aSecondChildColor);
       
   269 	}
       
   270 
       
   271 /**	Creates a child window inside the front window of the usual test scenario
       
   272 *  With a large window behind and small window in front.
       
   273  *  If the windows already exist then they are just repositioned and redrawn.
       
   274  * 	@param	aOuterRect	Position of back window
       
   275  * 	@param	aOuterColor	Background colour for back window
       
   276  * 	@param	aInnerRect	Position of front window
       
   277  * 	@param	aInnerColor	Background colour for front window
       
   278  * 	@param	aChildRect	Position of child window
       
   279  * 	@param	aChildColor	Background colour for child window
       
   280  *  @param	aSecondChildRect	Position of second child window
       
   281  * 	@param	aSecondChildColor	Background colour for second child window
       
   282  * 
       
   283  **/
       
   284 void CWsDynamicResBase::CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor)
       
   285 	{
       
   286 	MakeTestWindowTripleL(aOuterRect,aOuterColor,aInnerRect,aInnerColor,aChildRect,aChildColor);
       
   287 	
       
   288 	MakeExtraChildWindowL(iTestFront,aSecondChildRect,aSecondChildColor);
       
   289 	}
       
   290 
       
   291 void CWsDynamicResBase::MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor)
       
   292 	{
       
   293 	ASSERT(aFromParent.WsHandle());
       
   294 	if (!iTestSecondChild.WsHandle())
       
   295 		{
       
   296 		iTestSecondChild=RWindow(iSession);
       
   297 		ASSERT_EQUALS_X(iTestSecondChild.Construct(aFromParent, ++iWindowHandle), KErrNone);
       
   298 		iTestSecondChild.SetRequiredDisplayMode(iDisplayMode);
       
   299 		}
       
   300 	iTestSecondChild.SetBackgroundColor(aChildColor);
       
   301 	iTestSecondChild.SetExtent(aChildRect.iTl,aChildRect.Size());
       
   302 	iTestSecondChild.Activate();
       
   303 	iTestSecondChild.BeginRedraw();
       
   304 	iGc->Activate(iCompare);
       
   305 	iGc->SetBrushColor(iBlue);
       
   306 	iGc->Clear();
       
   307 	iGc->Deactivate();
       
   308 	iTestSecondChild.EndRedraw();
       
   309 	iTestSecondChild.SetVisible(ETrue);
       
   310 	}
       
   311 
       
   312 CWsDynamicResBase::LoopingGcPtr  CWsDynamicResBase::LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor)
       
   313 	{
       
   314 	InvalidateRegion(aRegion,aWin);
       
   315 	return LoopingGcPtr(aRegion,aWin,aColor,GcForWindow(aWin));
       
   316 	}
       
   317 
       
   318 //This gets called each itteration of the while loop, and is used to step the rectangle count!
       
   319 void CWsDynamicResBase::LoopingGcPtr::operator ++()
       
   320 	{
       
   321 	iPass++;
       
   322 	if (iPass<iRegion.Count())
       
   323 		{	//Invalidate all the rectangles in the region
       
   324 		iWin.BeginRedraw(iRegion[iPass]);
       
   325 		CWsDynamicResWinBase::ActivateWithWipe(iGc,iWin,iColor);
       
   326 //		return true;
       
   327 		}
       
   328 	else
       
   329 		{
       
   330 		iGc=NULL;
       
   331 //		return false;
       
   332 		}
       
   333 	}
       
   334 
       
   335 CWindowGc*	CWsDynamicResBase::BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor)
       
   336 	{
       
   337 	return CWsDynamicResWinBase::BeginActivateWithWipe(aInvalidate,aWin,aColor);
       
   338 	}
       
   339 
       
   340 CWindowGc*	CWsDynamicResBase::BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor)
       
   341 	{
       
   342 	return CWsDynamicResWinBase::BeginActivateWithWipe(aInvalidate,aRect,aWin,aColor);
       
   343 	}
       
   344 
       
   345 CWindowGc*	CWsDynamicResBase::BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor)
       
   346 	{
       
   347 	return CWsDynamicResWinBase::BeginActivateWithWipe(aRegion,aWin,aColor);
       
   348 	}
       
   349 
       
   350 /**	Creates a child window inside the front window of the usual test scenario
       
   351 *  With a large window behind and small window in front.
       
   352  *  If the windows already exist then they are just repositioned and redrawn.
       
   353  * 	@param	aOuterRect	Position of back window
       
   354  * 	@param	aOuterColor	Background colour for back window
       
   355  * 	@param	aInnerRect	Position of front window
       
   356  * 	@param	aInnerColor	Background colour for front window
       
   357  * 	@param	aChildRect	Position of child window
       
   358  * 	@param	aChildColor	Background colour for child window
       
   359  * 
       
   360  **/
       
   361 void CWsDynamicResBase::MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor)
       
   362 	{
       
   363 	MakeTestWindowPairL(aOuterRect,aOuterColor,aInnerRect,aInnerColor);
       
   364 	ASSERT(iTestFront.WsHandle());
       
   365 	
       
   366 	if (!iTestChild.WsHandle())
       
   367 		{
       
   368 		iTestChild=RWindow(iSession);
       
   369 		ASSERT_EQUALS_X(iTestChild.Construct(iTestFront, ++iWindowHandle), KErrNone);
       
   370 		iTestChild.SetRequiredDisplayMode(iDisplayMode);
       
   371 		}
       
   372 	iTestChild.SetBackgroundColor(aChildColor);
       
   373 	iTestChild.SetExtent(aChildRect.iTl,aChildRect.Size());
       
   374 	iTestChild.Activate();
       
   375 	iTestChild.BeginRedraw();
       
   376 	iGc->Activate(iCompare);
       
   377 	iGc->SetBrushColor(iBlue);
       
   378 	iGc->Clear();
       
   379 	iGc->Deactivate();
       
   380 	iTestChild.EndRedraw();
       
   381 	iTestChild.SetVisible(ETrue);
       
   382 	}
       
   383 /**	
       
   384  * 	Generates a valid surfaceID for the current display mode.
       
   385  * 	This is then used in negative testing.
       
   386  * 
       
   387  * 
       
   388  **/
       
   389 void CWsDynamicResBase::UISurfaceL(TSurfaceId& aSurfaceId) const
       
   390 	{
       
   391 	CFbsDrawDevice* screenDevice=NULL;
       
   392 	TDisplayMode displayMode=iScreenDevice->DisplayMode();
       
   393 	screenDevice = CFbsDrawDevice::NewScreenDeviceL(TGlobalSettings::Instance().iScreen, displayMode);
       
   394 	CleanupStack::PushL(screenDevice);
       
   395 	TAny* p=NULL;
       
   396 	User::LeaveIfError(screenDevice->GetInterface(KSurfaceInterfaceID, p));
       
   397 	MSurfaceId* uiSurface = static_cast<MSurfaceId*>(p);
       
   398 	uiSurface->GetSurface(aSurfaceId);
       
   399 	CleanupStack::PopAndDestroy(screenDevice);
       
   400 	}
       
   401 
       
   402 /**
       
   403 Common set up code for creating a surface based window.
       
   404 
       
   405 Given window and surface objects and a color: creates the window and surface,
       
   406 sets the window to a default size (the same as the surface), sets the background
       
   407 to the bitwise inverse of the given color, sets the surface as the background,
       
   408 fills the surface with the color and completes a redraw to prevent an event.
       
   409 
       
   410 @param aWindow	The window object, connected to a session.
       
   411 @param aSurface	The surface object, to be initialized.
       
   412 @param aColor	The color to fill the surface with.
       
   413 */
       
   414 void CWsDynamicResBase::CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor)
       
   415 	{
       
   416 	TInt err = KErrNone;
       
   417 
       
   418 	TRAP(err, aSurface = iUtility->CreateSurfaceL(TSize(KSurfaceWidth, KSurfaceHeight), 
       
   419 			KSurfaceFormat, KSurfaceWidth * KBytesPerPixel));
       
   420 	PRINT_ON_ERROR2_L(err, _L("Failed to create surface: %d"), err);
       
   421 	ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   422 
       
   423 	aWindow.SetRequiredDisplayMode(iDisplayMode);
       
   424 	aWindow.SetExtent(TPoint(0, 0), TSize(KSurfaceWidth, KSurfaceHeight));
       
   425 	aWindow.SetBackgroundColor(TRgb(aColor.Value() ^ 0xFFFFFF));
       
   426 
       
   427 	ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(aSurface), KErrNone);
       
   428 
       
   429 	TRAP(err, iUtility->FillSurfaceL(aSurface, aColor));
       
   430 	PRINT_ON_ERROR2_L(err, _L("Failed to fill surface: %d"), err);
       
   431 	DrawUIContent(aWindow);
       
   432 	}
       
   433 
       
   434 /**
       
   435 Common set up code for resizing tests.
       
   436 
       
   437 Similar to the common surface window code, but filling the surface with a grid
       
   438 instead of a solid color. The grid lines are always black. Also, the background
       
   439 color is always blue.
       
   440 */
       
   441 void CWsDynamicResBase::ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor)
       
   442 	{
       
   443 	// Session and group created in SetUpL()
       
   444 
       
   445 	TSurfaceId surface;
       
   446 	TInt err = KErrNone;
       
   447 
       
   448 	TRAP(err, surface = iUtility->CreateSurfaceL(TSize(KSurfaceWidth, KSurfaceHeight), 
       
   449 			KSurfaceFormat, KSurfaceWidth * KBytesPerPixel));
       
   450 	PRINT_ON_ERROR2_L(err, _L("Failed to create surface: %d"), err);
       
   451 
       
   452 	ASSERT_EQUALS_X(aWindow.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   453 
       
   454 	aWindow.SetRequiredDisplayMode(iDisplayMode);
       
   455 	aWindow.SetExtent(TPoint(0, 0), TSize(KSurfaceWidth, KSurfaceHeight));
       
   456 	aWindow.SetBackgroundColor(iBlue);
       
   457 	ASSERT_EQUALS_X(aWindow.SetBackgroundSurface(surface), KErrNone);
       
   458 
       
   459 	TRAP(err, iUtility->GridFillSurfaceL(surface, aColor, TRgb(0)));
       
   460 	PRINT_ON_ERROR2_L(err, _L("Failed to grid fill surface: %d"), err);
       
   461 	DrawUIContent(aWindow);
       
   462 	}
       
   463 
       
   464 CFbsBitmap* CWsDynamicResBase::RotateBitmapLC(const CFbsBitmap* aSrcBitmap)
       
   465 	{
       
   466 	CFbsBitmap* rv=new CFbsBitmap;
       
   467 	CleanupStack::PushL(rv);
       
   468 	TSize srcSize=aSrcBitmap->SizeInPixels();
       
   469 	rv->Create(TSize(srcSize.iHeight,srcSize.iWidth),EColor16MA);
       
   470 	TRgb* linestore=new TRgb[srcSize.iHeight];
       
   471 	TPtr8 buff((unsigned char*)linestore,srcSize.iHeight*sizeof(TRgb),srcSize.iHeight*sizeof(TRgb));
       
   472 	for (TInt col=0;col<aSrcBitmap->SizeInPixels().iWidth;col++)
       
   473 		{
       
   474 		for (TInt row=0,brow=srcSize.iHeight-1;row<srcSize.iHeight;row++,brow--)
       
   475 			{
       
   476 			aSrcBitmap->GetPixel(linestore[row],TPoint(col,brow));
       
   477 			}
       
   478 		rv->SetScanLine(buff,col);
       
   479 		}
       
   480 	delete[] linestore;
       
   481 	return rv;
       
   482 	}
       
   483 
       
   484 
       
   485 //
       
   486 //
       
   487 //
       
   488 // Pattern checking. Is a given pattern still present?
       
   489 // To make life interesting, the pattern is stored backwards!
       
   490 // The pattern is fibonnacci sequence masked to byte:
       
   491 //	1	2	3	5	8	13	21	34	55	89	144	233	121
       
   492 //	98	219	61	24	85	109	194	47	241	32	17	49	66
       
   493 //	115	181	40	221	5	226	231	201	176	121	41	162
       
   494 //
       
   495 //
       
   496 void Pattern::Fill(void* aTrg,TInt aOffset,TInt aLength)
       
   497 	{
       
   498 	unsigned char* ptr=(unsigned char*)aTrg;
       
   499 	TInt a=0;
       
   500 	TInt b=1;
       
   501 	while (--aLength)
       
   502 		{
       
   503 			TInt c=a+b;
       
   504 			*(ptr+aOffset+aLength)=c&0xff;
       
   505 			a=b;
       
   506 			b=c;
       
   507 		}
       
   508 	}
       
   509 TBool Pattern::Check(void* aTrg,TInt aOffset,TInt aLength)
       
   510 	{
       
   511 	unsigned char* ptr=(unsigned char*)aTrg;
       
   512 	TInt a=0;
       
   513 	TInt b=1;
       
   514 	while (--aLength)
       
   515 		{
       
   516 			TInt c=a+b;
       
   517 			if (*(ptr+aOffset+aLength)!=c&0xff)
       
   518 				return EFalse;
       
   519 			a=b;
       
   520 			b=c;
       
   521 		}
       
   522 	return ETrue;
       
   523 	}
       
   524 TBool Pattern::CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val)
       
   525 	{
       
   526 	unsigned char* ptr=(unsigned char*)aTrg;
       
   527 	while (--aLength)
       
   528 		{
       
   529 			if (*(ptr+aOffset+aLength)!=val&0xff)
       
   530 				return EFalse;
       
   531 		}
       
   532 	return ETrue;
       
   533 	}
       
   534 
       
   535 //I have removed these only because they use TRegionExtend
       
   536 //
       
   537 //TInt	CWsDynamicResBase::RegionDiffForUiLayer(TInt aUiLayer)
       
   538 //	{
       
   539 //	EWsDebugGetUILayerConfig,		//return: TSurfaceConfig		//Index UI layer via EWsDebugArgLayerMask
       
   540 //	EWsDebugGetUILayerBase,			//return: TRect[]
       
   541 //	
       
   542 //	RRegion 	layerRegion;
       
   543 //	TInt layerRegionLen=iSession.DebugInfo(EWsDebugGetUILayerBase,iSession.ObjInd(0,aUiLayer),layerRegion);
       
   544 //	if (layerRegionLen==KErrCancel)
       
   545 //		return TRegionExtend::EExact;
       
   546 //	ASSERT_TRUE(layerRegionLen>=0);
       
   547 //	TBuf8<sizeof(TSurfaceConfiguration)> configBuf(sizeof(TSurfaceConfiguration));
       
   548 //	const TSurfaceConfiguration* config;
       
   549 //	TInt configLen=iSession.DebugInfo(EWsDebugGetUILayerConfig,iSession.ObjInd(0,aUiLayer),configBuf,config);
       
   550 //	ASSERT_TRUE(configLen>=0);
       
   551 //	TRect layerExtent;
       
   552 //	config->GetExtent(layerExtent);
       
   553 //	TInt retVal=TRegionExtend::Cast(layerRegion).TestDifference(layerExtent.Size());
       
   554 //	layerRegion.Close();
       
   555 //	return retVal;
       
   556 //	}
       
   557 //CWsDynamicResBase::FastPathMode	CWsDynamicResBase::DeduceUiFastPathMode()
       
   558 //	{
       
   559 //	TInt blendedRegionState=RegionDiffForUiLayer(0);
       
   560 //	TInt opaqueRegionState=RegionDiffForUiLayer(1);
       
   561 //	if (blendedRegionState&TRegionExtend::ENoIntersect)
       
   562 //		{
       
   563 //		if (opaqueRegionState&TRegionExtend::ENoIntersect)
       
   564 //			{
       
   565 //			return EFpExternalOpaque;			//fullscreen fast-path external surface
       
   566 //			}
       
   567 //		else
       
   568 //			if (opaqueRegionState&TRegionExtend::EAdd)
       
   569 //				{
       
   570 //				return (FastPathMode)(EFpUiOpaque|EFpUiRegions);	//windowed max-opt no blending
       
   571 //				}
       
   572 //			else
       
   573 //				{
       
   574 //				return EFpUiOpaque;		//full-screen fastpath
       
   575 //				}
       
   576 //		}
       
   577 //	else
       
   578 //		{
       
   579 //		if (opaqueRegionState&TRegionExtend::ENoIntersect)
       
   580 //			{
       
   581 //			if (blendedRegionState&TRegionExtend::EAdd)
       
   582 //				{
       
   583 //				return (FastPathMode)(EFpUiBlended|EFpUiRegions);	//windowed max-opt no opaque
       
   584 //				}
       
   585 //			else
       
   586 //				{
       
   587 //				return (EFpUiBlended);	//full-screen blended
       
   588 //				}
       
   589 //			}
       
   590 //		else
       
   591 //			{
       
   592 //			if ((blendedRegionState|opaqueRegionState)&TRegionExtend::EAdd)
       
   593 //				{
       
   594 //				return (FastPathMode)(EFpUiComplex|EFpUiRegions);	//moxed blending, opaque and external max optimisation
       
   595 //				}
       
   596 //			else
       
   597 //				{
       
   598 //				return EFpUiComplex;	//Error! blend and opaque both enabled and full-screen!
       
   599 //				}
       
   600 //			}
       
   601 //		
       
   602 //		}
       
   603 //	}