os/graphics/graphicstest/uibench/src/tredrawing.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-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
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code 
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "tredrawing.h"
sl@0
    23
sl@0
    24
const TInt KIconSeparationInPixels = 18;
sl@0
    25
const TInt KIconSizePlusSeparation = 34;
sl@0
    26
sl@0
    27
// Test bitmap files
sl@0
    28
_LIT(KAlphaTestBitmap,"z:\\system\\data\\uibench_24bit.mbm");
sl@0
    29
_LIT(K12BitBitmap, "z:\\system\\data\\uibench_12bit.mbm");
sl@0
    30
_LIT(K16x16Icon,"z:\\system\\data\\16x16icon.mbm");
sl@0
    31
sl@0
    32
const TInt KIterationsToTest = 500;
sl@0
    33
sl@0
    34
//
sl@0
    35
// CRedrawingTest
sl@0
    36
//
sl@0
    37
CRedrawingTest::CRedrawingTest()
sl@0
    38
	{
sl@0
    39
	SetTestStepName(KRedrawingTest);
sl@0
    40
	}
sl@0
    41
	
sl@0
    42
CRedrawingTest::~CRedrawingTest()
sl@0
    43
	{
sl@0
    44
	delete iWsClient;		
sl@0
    45
	}	
sl@0
    46
sl@0
    47
inline CTProfiler& CRedrawingTest::Profiler() const
sl@0
    48
    {
sl@0
    49
    return *iProfiler;
sl@0
    50
    }
sl@0
    51
sl@0
    52
/**
sl@0
    53
Override of base class virtual
sl@0
    54
sl@0
    55
@return - TVerdict code
sl@0
    56
*/
sl@0
    57
TVerdict CRedrawingTest::doTestStepPreambleL()
sl@0
    58
	{	
sl@0
    59
	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();	
sl@0
    60
	SetScreenModeL(EColor16MU);
sl@0
    61
	return TestStepResult();
sl@0
    62
	}
sl@0
    63
	
sl@0
    64
TVerdict CRedrawingTest::doTestStepL()
sl@0
    65
	{
sl@0
    66
/**
sl@0
    67
@SYMTestCaseID GRAPHICS-UI-BENCH-0060
sl@0
    68
@SYMTestType UT
sl@0
    69
@SYMTestPriority Critical
sl@0
    70
@SYMDEF DEF100017
sl@0
    71
@SYMTestCaseDesc Measures performance of redraws with bitblt
sl@0
    72
@SYMTestActions
sl@0
    73
1. Create a background window with an opaque bitmap.
sl@0
    74
2. Create two test windows both transparent with bitmaps bitblt masked to the windows.
sl@0
    75
3. Repeatly swap the order of the two test windows in a loop and measure the average performance after many iterations.
sl@0
    76
sl@0
    77
@SYMTestExpectedResults
sl@0
    78
Measure the performance of swapping the windows so that front window goes behind the back window.
sl@0
    79
*/	
sl@0
    80
	SetTestStepID(_L("GRAPHICS-UI-BENCH-0060"));
sl@0
    81
	RunRedrawWindowTestCaseL(_L("Redraw-Bitblt"), ETwoWindowBitblt);
sl@0
    82
	RecordTestResultL();
sl@0
    83
	
sl@0
    84
/**
sl@0
    85
@SYMTestCaseID GRAPHICS-UI-BENCH-0061
sl@0
    86
@SYMTestType UT
sl@0
    87
@SYMTestPriority Critical
sl@0
    88
@SYMDEF DEF100017
sl@0
    89
@SYMTestCaseDesc Measures performance of redraws with bitblt masked
sl@0
    90
@SYMTestActions
sl@0
    91
1. Create a background window with an opaque bitmap.
sl@0
    92
2. Create two test windows both transparent with bitmaps bitblt masked to the windows.
sl@0
    93
3. Repeatly swap the order of the two test windows in a loop and measure the average performance after many iterations.
sl@0
    94
sl@0
    95
@SYMTestExpectedResults
sl@0
    96
Measure the performance of swapping the windows so that front window goes behind the back window.
sl@0
    97
*/	
sl@0
    98
	SetTestStepID(_L("GRAPHICS-UI-BENCH-0061"));
sl@0
    99
	RunRedrawWindowTestCaseL(_L("Redraw-BitbltMasked"), ETwoWindowBitbltMasked);
sl@0
   100
	RecordTestResultL();
sl@0
   101
sl@0
   102
/**
sl@0
   103
@SYMTestCaseID GRAPHICS-UI-BENCH-0062
sl@0
   104
@SYMTestType UT
sl@0
   105
@SYMTestPriority Critical
sl@0
   106
@SYMDEF DEF100017
sl@0
   107
@SYMTestCaseDesc Measures performance of redraws of window with many small bitmaps
sl@0
   108
sl@0
   109
@SYMTestActions
sl@0
   110
1. Create a background window with an opaque bitmap.
sl@0
   111
2. Create two test windows both transparent with many small bitmaps bitblt to the windows.
sl@0
   112
3. Repeatly invalidate a small region of the window in a loop and measure performance.
sl@0
   113
sl@0
   114
@SYMTestExpectedResults
sl@0
   115
Measure the performance of invalidating a small region of the window.
sl@0
   116
*/	
sl@0
   117
	SetTestStepID(_L("GRAPHICS-UI-BENCH-0062"));
sl@0
   118
	RunRedrawWindowTestCaseL(_L("Redraw-ManyBitmapsBitblt"), ETwoWindowManyBitmapsBitblt);
sl@0
   119
	RecordTestResultL();
sl@0
   120
		
sl@0
   121
	return TestStepResult();
sl@0
   122
	}
sl@0
   123
sl@0
   124
/**
sl@0
   125
This method runs the actual test case given the test name and test case Enum
sl@0
   126
sl@0
   127
@param aTestName is the test case name to be displayed in the log file - must be unique for each test case
sl@0
   128
@param aTestCase the test case to run
sl@0
   129
*/
sl@0
   130
void CRedrawingTest::RunRedrawWindowTestCaseL(const TDesC& aTestName, TRedrawTestCase aTestCase)
sl@0
   131
	{
sl@0
   132
	iWsClient = new(ELeave) CWsClient(*this, aTestCase);
sl@0
   133
	iProfiler->StartTimer();
sl@0
   134
	iWsClient->ConstructL();	
sl@0
   135
	CActiveScheduler::Start(); 	// Starts the active schedule that starts the test
sl@0
   136
	iProfiler->MarkResultSetL();			// Returns here once the test has completed.
sl@0
   137
	iProfiler->ResultsAnalysisAverageByIterations(aTestName, 0, 0, ScreenDevice()->BitmapDevice().DisplayMode(), KIterationsToTest);
sl@0
   138
	delete iWsClient;
sl@0
   139
	iWsClient=NULL;
sl@0
   140
	}
sl@0
   141
sl@0
   142
//
sl@0
   143
// CWsRedrawer
sl@0
   144
//
sl@0
   145
CWsRedrawer::CWsRedrawer() : CActive(CActive::EPriorityLow)
sl@0
   146
    {
sl@0
   147
    }
sl@0
   148
sl@0
   149
void CWsRedrawer::ConstructL(CWsClient* aClient)
sl@0
   150
    {
sl@0
   151
    iClient = aClient;
sl@0
   152
    CActiveScheduler::Add(this);
sl@0
   153
    IssueRequest();
sl@0
   154
    }
sl@0
   155
sl@0
   156
CWsRedrawer::~CWsRedrawer()
sl@0
   157
    {
sl@0
   158
    Cancel();
sl@0
   159
    }
sl@0
   160
sl@0
   161
void CWsRedrawer::IssueRequest()
sl@0
   162
    {
sl@0
   163
    iClient->WsSession().RedrawReady(&iStatus);
sl@0
   164
    SetActive();
sl@0
   165
    }
sl@0
   166
sl@0
   167
void CWsRedrawer::DoCancel()
sl@0
   168
    {
sl@0
   169
    iClient->WsSession().RedrawReadyCancel();
sl@0
   170
    }
sl@0
   171
sl@0
   172
void CWsRedrawer::RunL()
sl@0
   173
    {
sl@0
   174
    // find out what needs to be done
sl@0
   175
    TWsRedrawEvent redrawEvent;
sl@0
   176
    iClient->WsSession().GetRedraw(redrawEvent); // get event
sl@0
   177
    CWindow* window=(CWindow*)(redrawEvent.Handle()); // get window
sl@0
   178
    if (window)
sl@0
   179
        {
sl@0
   180
        TRect rect=redrawEvent.Rect(); // and rectangle that needs redrawing
sl@0
   181
        // now do drawing
sl@0
   182
        iClient->Gc().Activate(window->Window());
sl@0
   183
        window->Window().BeginRedraw(rect);
sl@0
   184
        window->Draw(rect);
sl@0
   185
        window->Window().EndRedraw();
sl@0
   186
        iClient->Gc().Deactivate();
sl@0
   187
        }
sl@0
   188
    // maintain outstanding request
sl@0
   189
    IssueRequest();
sl@0
   190
    }
sl@0
   191
sl@0
   192
//
sl@0
   193
// CWindow
sl@0
   194
//
sl@0
   195
CWindow::CWindow(CWsClient* aClient, TRedrawTestCase aTestCase)
sl@0
   196
    : iClient(aClient), iTestCase(aTestCase)
sl@0
   197
    {
sl@0
   198
    }
sl@0
   199
sl@0
   200
void CWindow::ConstructL (const TRect& aRect, CWindow* aParent)
sl@0
   201
    {
sl@0
   202
    // If a parent window was specified, use it; if not, use the window group
sl@0
   203
    // (aParent defaults to 0).
sl@0
   204
    RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->WindowGroup());
sl@0
   205
    iWindow=RWindow(iClient->WsSession()); // use app's session to window server
sl@0
   206
    User::LeaveIfError(iWindow.Construct(*parent,(TUint32)this));
sl@0
   207
    iRect = aRect;
sl@0
   208
    iWindow.SetExtent(iRect.iTl, iRect.Size()); // set extent relative to group coords    
sl@0
   209
    }
sl@0
   210
sl@0
   211
CWindow::~CWindow()
sl@0
   212
    {
sl@0
   213
    iWindow.Close();
sl@0
   214
    }
sl@0
   215
sl@0
   216
RWindow& CWindow::Window()
sl@0
   217
    {
sl@0
   218
    return iWindow;
sl@0
   219
    }
sl@0
   220
sl@0
   221
void CWindow::Activate()
sl@0
   222
	{
sl@0
   223
	iWindow.Activate();
sl@0
   224
	}
sl@0
   225
sl@0
   226
CWindowGc& CWindow::SystemGc()
sl@0
   227
    {
sl@0
   228
    return iClient->Gc();
sl@0
   229
    }
sl@0
   230
sl@0
   231
//
sl@0
   232
// CMainWindow
sl@0
   233
//
sl@0
   234
CMainWindow::CMainWindow(CWsClient* aClient, TRedrawTestCase aTestCase) : CWindow (aClient, aTestCase)
sl@0
   235
    {
sl@0
   236
    }
sl@0
   237
sl@0
   238
void CMainWindow::ConstructL(const TRect& aRect, CWindow* aParent)
sl@0
   239
	{	
sl@0
   240
	CWindow::ConstructL(aRect,aParent);
sl@0
   241
	iBitmapImage = iClient->TestSuite().LoadBitmapL(KAlphaTestBitmap,0);
sl@0
   242
	}
sl@0
   243
sl@0
   244
CMainWindow::~CMainWindow()
sl@0
   245
    {
sl@0
   246
    delete iBitmapImage;
sl@0
   247
    }
sl@0
   248
sl@0
   249
void CMainWindow::Draw(const TRect& aRect)
sl@0
   250
    {    
sl@0
   251
    CWindowGc& gc=SystemGc();
sl@0
   252
    gc.SetClippingRect(aRect);
sl@0
   253
    gc.BitBlt(TPoint(0,0), iBitmapImage);
sl@0
   254
    }
sl@0
   255
sl@0
   256
//
sl@0
   257
// CTestWindow
sl@0
   258
//
sl@0
   259
CTestWindow::CTestWindow(CWsClient* aClient, TRedrawTestCase aTestCase) : CWindow (aClient, aTestCase)
sl@0
   260
    {
sl@0
   261
    }
sl@0
   262
sl@0
   263
void CTestWindow::ConstructL(const TRect& aRect, CWindow* aParent)
sl@0
   264
	{	
sl@0
   265
	CWindow::ConstructL(aRect,aParent);
sl@0
   266
	// Load all bitmaps
sl@0
   267
	iBitmapImage = iClient->TestSuite().LoadBitmapL(KAlphaTestBitmap,0);
sl@0
   268
	iBitmap12bit = iClient->TestSuite().LoadBitmapL(K12BitBitmap, 0);
sl@0
   269
	iAlpha8bitMask = iClient->TestSuite().CopyIntoNewBitmapL(iBitmap12bit, EGray256);
sl@0
   270
	i16x16Icon = iClient->TestSuite().LoadBitmapL(K16x16Icon, 0);	
sl@0
   271
	i16x16IconMonochrome = iClient->TestSuite().LoadBitmapL(K16x16Icon, 1);	
sl@0
   272
	}
sl@0
   273
sl@0
   274
CTestWindow::~CTestWindow()
sl@0
   275
    {
sl@0
   276
    delete iBitmapImage;
sl@0
   277
    delete iBitmap12bit;
sl@0
   278
    delete iAlpha8bitMask;
sl@0
   279
    delete i16x16Icon;
sl@0
   280
    delete i16x16IconMonochrome;
sl@0
   281
    iWindow.Close();
sl@0
   282
    }
sl@0
   283
sl@0
   284
void CTestWindow::Draw(const TRect& aRect)
sl@0
   285
    {
sl@0
   286
    CWindowGc& gc=SystemGc();
sl@0
   287
    gc.SetClippingRect(aRect);
sl@0
   288
    
sl@0
   289
    // -*-* Add new test cases here for drawing to test window
sl@0
   290
    switch(iTestCase)
sl@0
   291
    	{
sl@0
   292
    	case ETwoWindowBitblt:     		    		
sl@0
   293
    		gc.BitBlt(TPoint(0,0), iBitmapImage);
sl@0
   294
    		break;
sl@0
   295
    	
sl@0
   296
    	case ETwoWindowBitbltMasked:
sl@0
   297
    		{
sl@0
   298
    		TRect cropTo(0,0,300,300);
sl@0
   299
    		gc.BitBltMasked(TPoint(0,0), iBitmapImage, cropTo, iAlpha8bitMask, EFalse);
sl@0
   300
    		break;
sl@0
   301
    		}
sl@0
   302
    		
sl@0
   303
    	case ETwoWindowManyBitmapsBitblt:
sl@0
   304
			{			
sl@0
   305
			// Draw a matrix of bitmaps in the window
sl@0
   306
			for (TInt y=10;y>=0;--y)
sl@0
   307
				{				
sl@0
   308
				for (TInt x=10;x>=0;--x)
sl@0
   309
					{
sl@0
   310
					if (!iBitmapFlag)
sl@0
   311
						gc.BitBlt(TPoint(x*KIconSeparationInPixels, y*KIconSeparationInPixels), i16x16Icon);
sl@0
   312
					else
sl@0
   313
						gc.BitBlt(TPoint(x*KIconSeparationInPixels, y*KIconSeparationInPixels), i16x16IconMonochrome);
sl@0
   314
					}
sl@0
   315
				}
sl@0
   316
			iBitmapFlag=!iBitmapFlag;
sl@0
   317
			break;
sl@0
   318
			}    		
sl@0
   319
    		
sl@0
   320
    	}
sl@0
   321
    
sl@0
   322
    }
sl@0
   323
sl@0
   324
/** 
sl@0
   325
Create an application initiated draw by drawing doign a bitblt in a small area of the window
sl@0
   326
*/
sl@0
   327
void CTestWindow::AppInitiatedDraw()
sl@0
   328
	{
sl@0
   329
	TRect rect(KIconSeparationInPixels,KIconSeparationInPixels,KIconSizePlusSeparation,KIconSizePlusSeparation);
sl@0
   330
	CWindowGc& gc=SystemGc();
sl@0
   331
	gc.Activate(iWindow);
sl@0
   332
	iWindow.BeginRedraw(rect);
sl@0
   333
	if (!iBitmapFlag)
sl@0
   334
		gc.BitBlt(TPoint(KIconSeparationInPixels,KIconSeparationInPixels), i16x16IconMonochrome);
sl@0
   335
	else
sl@0
   336
		gc.BitBlt(TPoint(KIconSeparationInPixels,KIconSeparationInPixels), i16x16Icon);
sl@0
   337
	iWindow.EndRedraw();
sl@0
   338
	gc.Deactivate();
sl@0
   339
	iBitmapFlag=!iBitmapFlag;
sl@0
   340
	}
sl@0
   341
sl@0
   342
//
sl@0
   343
// CWsClient
sl@0
   344
//
sl@0
   345
CWsClient::CWsClient(CRedrawingTest& aTestSuite, TRedrawTestCase aTestCase) : CActive(CActive::EPriorityHigh), iTestCase(aTestCase), iTestSuite(aTestSuite)
sl@0
   346
    {
sl@0
   347
    }
sl@0
   348
sl@0
   349
void CWsClient::ConstructL()
sl@0
   350
    {    
sl@0
   351
    CActiveScheduler::Add(this);
sl@0
   352
    
sl@0
   353
    // Connect to windows server
sl@0
   354
    User::LeaveIfError(iWs.Connect());
sl@0
   355
    
sl@0
   356
    // construct our one and only window group
sl@0
   357
    iGroup=RWindowGroup(iWs);
sl@0
   358
    User::LeaveIfError(iGroup.Construct(2,ETrue)); // meaningless handle; enable focus
sl@0
   359
    
sl@0
   360
    // construct screen device and graphics context
sl@0
   361
    iScreen=new (ELeave) CWsScreenDevice(iWs); // make device for this session
sl@0
   362
    User::LeaveIfError(iScreen->Construct()); // and complete its construction
sl@0
   363
    User::LeaveIfError(iScreen->CreateContext(iGc)); // create graphics context
sl@0
   364
    
sl@0
   365
    iRect = TRect(0,0,iScreen->SizeInPixels().iWidth, iScreen->SizeInPixels().iHeight);
sl@0
   366
    
sl@0
   367
    // construct redrawer
sl@0
   368
    iRedrawer=new (ELeave) CWsRedrawer;
sl@0
   369
    iRedrawer->ConstructL(this);
sl@0
   370
    
sl@0
   371
    // construct main window
sl@0
   372
    ConstructMainWindowL();
sl@0
   373
    
sl@0
   374
    // request first event and start scheduler
sl@0
   375
    IssueRequest();
sl@0
   376
    }
sl@0
   377
sl@0
   378
CWsClient::~CWsClient()
sl@0
   379
    {
sl@0
   380
    Cancel();
sl@0
   381
    delete iGc;
sl@0
   382
    delete iScreen;
sl@0
   383
    delete iRedrawer;
sl@0
   384
    delete iMainWindow;
sl@0
   385
    delete iTestWindow;
sl@0
   386
    delete iTestWindow2;
sl@0
   387
	delete iTestActive;	
sl@0
   388
	
sl@0
   389
    iGroup.Close();
sl@0
   390
    iWs.Close();
sl@0
   391
    }
sl@0
   392
sl@0
   393
void CWsClient::IssueRequest()
sl@0
   394
    {
sl@0
   395
    iWs.EventReady(&iStatus); // request an event for standard events. i.e. All events except redraws and pointer priority key events
sl@0
   396
    SetActive();
sl@0
   397
    }
sl@0
   398
sl@0
   399
void CWsClient::DoCancel()
sl@0
   400
    {
sl@0
   401
    iWs.EventReadyCancel(); // cancel event request
sl@0
   402
    }
sl@0
   403
sl@0
   404
void CWsClient::ConstructMainWindowL()
sl@0
   405
    {	                
sl@0
   406
    iTestActive = new(ELeave)CWsClient::CRedrawingTestActive(*this);    
sl@0
   407
	iTestActive->ConstructL();
sl@0
   408
sl@0
   409
	// -*-* Add new windows for test cases here
sl@0
   410
	switch (iTestCase)	
sl@0
   411
		{
sl@0
   412
		case ETwoWindowBitblt:
sl@0
   413
		case ETwoWindowBitbltMasked:
sl@0
   414
			{
sl@0
   415
			// Create the main background window with a bitmap image. This window is not transparent.
sl@0
   416
		    iMainWindow=new (ELeave) CMainWindow(this, iTestCase);
sl@0
   417
		    iMainWindow->ConstructL(iRect);
sl@0
   418
		    iMainWindow->Activate();
sl@0
   419
		        
sl@0
   420
			// Create the first test window. This window is transparent.
sl@0
   421
		    iTestWindow = new(ELeave) CTestWindow(this, iTestCase);
sl@0
   422
		    iTestWindow->ConstructL(TRect (TPoint (10, 10), TSize (200, 200)), iMainWindow);
sl@0
   423
		    TInt ret = iTestWindow->Window().SetTransparencyFactor(TRgb(0xbbbbbb,128));
sl@0
   424
		    User::LeaveIfError(ret);
sl@0
   425
		    iTestWindow->Activate();    
sl@0
   426
		    
sl@0
   427
		    // Create the second test window. This window is also transparent.
sl@0
   428
		    iTestWindow2 = new(ELeave) CTestWindow(this, iTestCase);
sl@0
   429
		    iTestWindow2->ConstructL(TRect (TPoint (30, 30), TSize (250, 200)), iMainWindow);	    
sl@0
   430
		    ret = iTestWindow2->Window().SetTransparencyFactor(TRgb(0xddaa55,200));
sl@0
   431
		    User::LeaveIfError(ret);    
sl@0
   432
		    iTestWindow2->Activate();
sl@0
   433
		    break;
sl@0
   434
			}
sl@0
   435
			
sl@0
   436
		case ETwoWindowManyBitmapsBitblt:
sl@0
   437
			{
sl@0
   438
			// Create the main background window with a bitmap image. This window is not transparent.
sl@0
   439
		    iMainWindow=new (ELeave) CMainWindow(this, iTestCase);
sl@0
   440
		    iMainWindow->ConstructL(iRect);
sl@0
   441
		    iMainWindow->Activate();
sl@0
   442
sl@0
   443
			// Create the first test window. This window is transparent.
sl@0
   444
		    iTestWindow = new(ELeave) CTestWindow(this, iTestCase);
sl@0
   445
		    iTestWindow->ConstructL(TRect (TPoint (10, 10), TSize (200, 200)), iMainWindow);
sl@0
   446
		    TInt ret = iTestWindow->Window().SetTransparencyFactor(TRgb(0xbbbbbb,128));
sl@0
   447
		    User::LeaveIfError(ret);
sl@0
   448
		    iTestWindow->Activate(); 
sl@0
   449
		    
sl@0
   450
			// Create the second test window. This window is also transparent.
sl@0
   451
		    iTestWindow2 = new(ELeave) CTestWindow(this, iTestCase);
sl@0
   452
		    iTestWindow2->ConstructL(TRect (TPoint (10, 10), TSize (250, 200)), iMainWindow);	    
sl@0
   453
		    ret = iTestWindow2->Window().SetTransparencyFactor(TRgb(0xddaa55,200));
sl@0
   454
		    User::LeaveIfError(ret);    
sl@0
   455
		    iTestWindow2->Activate();   				
sl@0
   456
			}
sl@0
   457
			break;
sl@0
   458
		}
sl@0
   459
    }
sl@0
   460
sl@0
   461
// Handle standard events from the window server.
sl@0
   462
// Standard events include all events except redraws and priority key events.
sl@0
   463
void CWsClient::RunL()
sl@0
   464
	{
sl@0
   465
	}
sl@0
   466
sl@0
   467
//
sl@0
   468
// CWsClient::CRedrawingTestActive inner class
sl@0
   469
// Set to low priority to avoid starving other active objects from being executed.
sl@0
   470
//
sl@0
   471
CWsClient::CRedrawingTestActive::CRedrawingTestActive(CWsClient& aClient) : CActive(CActive::EPriorityLow), iClient(aClient)
sl@0
   472
	{	
sl@0
   473
	CActiveScheduler::Add(this);
sl@0
   474
	}
sl@0
   475
	
sl@0
   476
CWsClient::CRedrawingTestActive::~CRedrawingTestActive()
sl@0
   477
	{
sl@0
   478
	Cancel();
sl@0
   479
	}
sl@0
   480
	
sl@0
   481
void CWsClient::CRedrawingTestActive::ConstructL()
sl@0
   482
	{
sl@0
   483
	iClient.iTestSuite.Profiler().InitResults();
sl@0
   484
	// Start active object and run tests
sl@0
   485
	RequestComplete();
sl@0
   486
	}
sl@0
   487
sl@0
   488
void CWsClient::CRedrawingTestActive::DoCancel()
sl@0
   489
	{
sl@0
   490
	TRequestStatus* status = &iStatus;
sl@0
   491
	User::RequestComplete(status, KErrCancel);
sl@0
   492
	}
sl@0
   493
	
sl@0
   494
void CWsClient::CRedrawingTestActive::RequestComplete()
sl@0
   495
	{		
sl@0
   496
	SetActive();
sl@0
   497
    TRequestStatus* status = &iStatus;
sl@0
   498
    User::RequestComplete(status, KErrNone);
sl@0
   499
	}
sl@0
   500
sl@0
   501
/**
sl@0
   502
The test iterates KIterationsToTest times, after which the active scheduler is stopped
sl@0
   503
which passes control back to CRedrawingTest.
sl@0
   504
*/	
sl@0
   505
void CWsClient::CRedrawingTestActive::RunL()
sl@0
   506
	{
sl@0
   507
	TInt status = iStatus.Int();
sl@0
   508
	if (status==KErrNone)	
sl@0
   509
		{	
sl@0
   510
		switch(iClient.iTestCase)
sl@0
   511
			{
sl@0
   512
			// -*-* Add test cases here
sl@0
   513
			case ETwoWindowBitblt:
sl@0
   514
			case ETwoWindowBitbltMasked:
sl@0
   515
				TestTwoWindowsBitBlt();
sl@0
   516
				break;
sl@0
   517
			case ETwoWindowManyBitmapsBitblt:
sl@0
   518
				TestInvalidateSmallArea();
sl@0
   519
				break;
sl@0
   520
			}
sl@0
   521
	
sl@0
   522
		if (++iIterationCount > KIterationsToTest)	// If we reached last iteration then stop the active scheduler
sl@0
   523
			{		
sl@0
   524
			CActiveScheduler::Stop();
sl@0
   525
			}
sl@0
   526
		}		
sl@0
   527
	RequestComplete();
sl@0
   528
	}
sl@0
   529
sl@0
   530
/**
sl@0
   531
This flips the window ordinals around each time it is called
sl@0
   532
*/
sl@0
   533
void CWsClient::CRedrawingTestActive::TestTwoWindowsBitBlt()
sl@0
   534
	{
sl@0
   535
	if (iFlipWindow)
sl@0
   536
		{		
sl@0
   537
		iClient.iTestWindow->Window().SetOrdinalPosition(0);
sl@0
   538
		iClient.iTestWindow2->Window().SetOrdinalPosition(1);
sl@0
   539
		iFlipWindow=EFalse;
sl@0
   540
		} 
sl@0
   541
	else 
sl@0
   542
		{
sl@0
   543
		iClient.iTestWindow->Window().SetOrdinalPosition(1);
sl@0
   544
		iClient.iTestWindow2->Window().SetOrdinalPosition(0);		
sl@0
   545
		iFlipWindow=ETrue;
sl@0
   546
		}
sl@0
   547
	iClient.iWs.Flush();
sl@0
   548
	}
sl@0
   549
sl@0
   550
/**
sl@0
   551
This invalidates a small area of the window and causes an appication initiated draw
sl@0
   552
*/
sl@0
   553
void CWsClient::CRedrawingTestActive::TestInvalidateSmallArea()
sl@0
   554
	{
sl@0
   555
	iClient.iTestWindow->Window().Invalidate(TRect(KIconSeparationInPixels,KIconSeparationInPixels,KIconSizePlusSeparation,KIconSizePlusSeparation));
sl@0
   556
	// Application inititated draw
sl@0
   557
	iClient.iTestWindow->AppInitiatedDraw();
sl@0
   558
	
sl@0
   559
	iClient.iWs.Flush();
sl@0
   560
	}