os/graphics/windowing/windowserver/nonnga/CLIENT/RDirect.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2000-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
// Client side classes for handling direct screen access
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include <e32base.h>
sl@0
    20
#include "../SERVER/w32cmd.h"
sl@0
    21
#include "CLIENT.H"
sl@0
    22
#include "w32comm.h"
sl@0
    23
#include <e32msgqueue.h>
sl@0
    24
sl@0
    25
NONSHARABLE_CLASS(CDsaMsgQueue) : public CActive
sl@0
    26
{
sl@0
    27
	public:
sl@0
    28
		CDsaMsgQueue();
sl@0
    29
		~CDsaMsgQueue();
sl@0
    30
		void Request(TRequestStatus* aClientRequest);
sl@0
    31
		TBool Started() { return iStarted;}
sl@0
    32
		TBool Completed();
sl@0
    33
		void OpenRecQueue(TInt aHandle);
sl@0
    34
		void OpenSendQueue(TInt aHandle);
sl@0
    35
		TInt Send(TInt aData);
sl@0
    36
		RMsgQueueBase& SendQueue() {return iSendQueue; }
sl@0
    37
		RMsgQueueBase& Queue() { return iRecQueue; }
sl@0
    38
		TRequestStatus* Status() { return &iStatus; }
sl@0
    39
		TBool RequestStarted() { return iStarted;}
sl@0
    40
	private:
sl@0
    41
		void DoCancel();
sl@0
    42
		void RunL();
sl@0
    43
		void Listen();
sl@0
    44
		
sl@0
    45
	private:
sl@0
    46
		RMsgQueueBase iRecQueue;
sl@0
    47
		RMsgQueueBase iSendQueue;
sl@0
    48
		TRequestStatus* iClientRequest;
sl@0
    49
		TBool iStarted;
sl@0
    50
		RThread* iServer;
sl@0
    51
};
sl@0
    52
sl@0
    53
//
sl@0
    54
CDsaMsgQueue::CDsaMsgQueue() : CActive(RDirectScreenAccess::EPriorityVeryHigh)
sl@0
    55
	{
sl@0
    56
	CActiveScheduler::Add(this);
sl@0
    57
	}
sl@0
    58
sl@0
    59
CDsaMsgQueue::~CDsaMsgQueue()
sl@0
    60
	{
sl@0
    61
	Cancel();
sl@0
    62
	iRecQueue.Close();
sl@0
    63
	iSendQueue.Close();
sl@0
    64
	}
sl@0
    65
sl@0
    66
TInt CDsaMsgQueue::Send(TInt aData)
sl@0
    67
	{
sl@0
    68
	return iSendQueue.Send(&aData,sizeof(TInt));
sl@0
    69
	}
sl@0
    70
sl@0
    71
void CDsaMsgQueue::OpenRecQueue(TInt aHandle)
sl@0
    72
	{
sl@0
    73
	iRecQueue.SetHandle(aHandle);
sl@0
    74
// With RmessagePtr2 compelete using an RHandle the returned handle is already duplicated
sl@0
    75
	}
sl@0
    76
sl@0
    77
void CDsaMsgQueue::OpenSendQueue(TInt aHandle)
sl@0
    78
	{
sl@0
    79
	iSendQueue.SetHandle(aHandle);
sl@0
    80
// With RmessagePtr2 compelete using an RHandle the returned handle is already duplicated
sl@0
    81
	}
sl@0
    82
sl@0
    83
void CDsaMsgQueue::DoCancel()
sl@0
    84
	{
sl@0
    85
	iRecQueue.CancelDataAvailable();
sl@0
    86
	TInt ret = KErrNone;
sl@0
    87
	do
sl@0
    88
		{
sl@0
    89
		TInt data = 0;
sl@0
    90
		ret = iRecQueue.Receive(&data,sizeof(TInt));
sl@0
    91
		}while(ret == KErrNone);
sl@0
    92
	if(iClientRequest)
sl@0
    93
		{
sl@0
    94
		RThread().RequestComplete(iClientRequest,KErrCancel);
sl@0
    95
		}
sl@0
    96
	}
sl@0
    97
	
sl@0
    98
void CDsaMsgQueue::RunL()
sl@0
    99
	{
sl@0
   100
	// get the data from the msg queue
sl@0
   101
	TInt reason = 0;
sl@0
   102
	iRecQueue.Receive(&reason,sizeof(TInt));
sl@0
   103
	
sl@0
   104
	if(iClientRequest)
sl@0
   105
		{
sl@0
   106
		// if there is an outstanding client request, complete and pass on the abort reason
sl@0
   107
		User::RequestComplete(iClientRequest,reason);
sl@0
   108
		iClientRequest = NULL;
sl@0
   109
		}
sl@0
   110
	}
sl@0
   111
sl@0
   112
void CDsaMsgQueue::Listen()
sl@0
   113
	{
sl@0
   114
	if(!IsActive())
sl@0
   115
		{
sl@0
   116
		SetActive();	
sl@0
   117
		iRecQueue.NotifyDataAvailable(iStatus);
sl@0
   118
		}
sl@0
   119
	}
sl@0
   120
sl@0
   121
void CDsaMsgQueue::Request(TRequestStatus* aClientRequest)
sl@0
   122
	{
sl@0
   123
	__ASSERT_ALWAYS(!IsActive(),User::Invariant());
sl@0
   124
	iClientRequest = aClientRequest;
sl@0
   125
	iStarted = ETrue;
sl@0
   126
	Listen();
sl@0
   127
	}
sl@0
   128
sl@0
   129
TBool CDsaMsgQueue::Completed()
sl@0
   130
	{
sl@0
   131
	if(iStarted)
sl@0
   132
		{
sl@0
   133
		Send(KErrNone);
sl@0
   134
		iStarted = EFalse;
sl@0
   135
		return ETrue;
sl@0
   136
		}
sl@0
   137
	return EFalse;
sl@0
   138
	}
sl@0
   139
	
sl@0
   140
//
sl@0
   141
// RDirectScreenAccess
sl@0
   142
//
sl@0
   143
sl@0
   144
EXPORT_C RDirectScreenAccess::RDirectScreenAccess()
sl@0
   145
/** Default constructor.
sl@0
   146
sl@0
   147
Developers should use the other constructor overload instead. */
sl@0
   148
	{
sl@0
   149
	}
sl@0
   150
sl@0
   151
EXPORT_C RDirectScreenAccess::RDirectScreenAccess(RWsSession& aWs) : MWsClientClass(aWs.iBuffer), iWs(&aWs), iMsgQueue(NULL)
sl@0
   152
/** C++ constructor with a connected window server session.
sl@0
   153
sl@0
   154
Construct() must be called to complete construction.
sl@0
   155
sl@0
   156
@param aWs Connected session with the window server. */
sl@0
   157
	{
sl@0
   158
	}
sl@0
   159
sl@0
   160
EXPORT_C TInt RDirectScreenAccess::Construct()
sl@0
   161
/** Second phase constructor.
sl@0
   162
sl@0
   163
Creates the server side resource and initialises the client's handle to it.
sl@0
   164
sl@0
   165
This function always causes a flush of the window server buffer.
sl@0
   166
sl@0
   167
@return KErrNone if successful, otherwise one of the system wide error codes. 
sl@0
   168
@panic TW32Panic 17 in debug builds if called on an already constructed object.*/
sl@0
   169
	{
sl@0
   170
	__ASSERT_DEBUG(iWsHandle == KNullHandle, Panic(EW32PanicGraphicDoubleConstruction));
sl@0
   171
	TInt ret = KErrNone;
sl@0
   172
	if ((ret = iBuffer->WriteReplyWs(EWsClOpCreateDirectScreenAccess)) >= 0)
sl@0
   173
		{
sl@0
   174
		iWsHandle = ret;
sl@0
   175
		TRAP(ret,iMsgQueue = new (ELeave)CDsaMsgQueue);
sl@0
   176
		if(ret == KErrNone)
sl@0
   177
			{
sl@0
   178
			// the servers send queue is the client receive queue
sl@0
   179
			TInt h = WriteReply(EWsDirectOpGetSendQueue);
sl@0
   180
			iMsgQueue->OpenRecQueue(h);	
sl@0
   181
		
sl@0
   182
			// servers receive queue is the clients send queue
sl@0
   183
			h = WriteReply(EWsDirectOpGetRecQueue);
sl@0
   184
			iMsgQueue->OpenSendQueue(h);	
sl@0
   185
			}
sl@0
   186
		else
sl@0
   187
			{
sl@0
   188
			Close();
sl@0
   189
			}
sl@0
   190
		}
sl@0
   191
	return(ret);
sl@0
   192
	}
sl@0
   193
sl@0
   194
EXPORT_C TInt RDirectScreenAccess::Construct(TBool /*aRegionTrackingOnly*/)
sl@0
   195
/** Second phase constructor.
sl@0
   196
This is not supported in WSERV non NGA. It's available just when NGA is present.*/
sl@0
   197
	{
sl@0
   198
	return KErrNotSupported;
sl@0
   199
	}
sl@0
   200
sl@0
   201
EXPORT_C TInt RDirectScreenAccess::Request(RRegion*& aRegion,TRequestStatus& aStatus,const RWindowBase& aWindow)
sl@0
   202
/** Issues a request to the window server for permission to perform direct screen 
sl@0
   203
access on a window.
sl@0
   204
sl@0
   205
Direct access to the screen may be refused due to lack of memory or if the 
sl@0
   206
target window is completely obscured.
sl@0
   207
sl@0
   208
If direct access is allowed, the function passes back a clipping region which 
sl@0
   209
is the part of the screen the caller can draw to. 
sl@0
   210
sl@0
   211
When direct screen access must stop, for instance because a dialog is to be 
sl@0
   212
displayed in front of the region where direct screen access is taking place, 
sl@0
   213
the window server completes the request. The recommended way to check for 
sl@0
   214
this is for aStatus to be the request status of an active object that will 
sl@0
   215
be run when the request completes, i.e. if Request() returns KErrNone, call 
sl@0
   216
SetActive(), and in the object's RunL(), you should immediately abort direct 
sl@0
   217
screen access.
sl@0
   218
sl@0
   219
While the DSA is in operation, it is strongly advised that the client should 
sl@0
   220
not make any call to WSERV that will affect the visible area of the window in 
sl@0
   221
which the DSA is taking place. 
sl@0
   222
sl@0
   223
When WSERV tells the client that it needs to abort its DSA, it waits to receive
sl@0
   224
the acknowledgment from the client that it has done so. However, it doesn't wait 
sl@0
   225
for ever, since the client may have entered some long running calculation or even
sl@0
   226
an infinite loop. So WSERV also waits on a timer: if the timer expires before the
sl@0
   227
client acknowledges, then WSERV continues; if, later on, WSERV gets notification
sl@0
   228
from the client that it has aborted the DSA, then WSERV will invalidate the region
sl@0
   229
in which the DSA was taking place, just in case there had been a conflict between
sl@0
   230
the DSA and another client.
sl@0
   231
sl@0
   232
sl@0
   233
This function always causes a flush of the window server buffer.
sl@0
   234
sl@0
   235
@param aRegion On return, the clipping region that the caller can draw to. 
sl@0
   236
NULL if the function was not successful.
sl@0
   237
If the target window is invisible or completely covered by other windows
sl@0
   238
then the region will be empty.
sl@0
   239
@param aStatus A request status that is set to a completion code by the window 
sl@0
   240
server when direct screen access must stop.
sl@0
   241
@param aWindow The window that you want to perform the direct screen access 
sl@0
   242
on. There must not already be direct access on this window or a panic occurs.
sl@0
   243
@return KErrNone if the request was successful, KErrNone with empty region if 
sl@0
   244
none of the window is currently visible, otherwise one of the system wide error codes,
sl@0
   245
e.g. KErrNoMemory if out of memory. */
sl@0
   246
	{
sl@0
   247
	__ASSERT_ALWAYS(iMsgQueue,Panic(EW32PanicDirectMisuse));
sl@0
   248
sl@0
   249
	aRegion = NULL;
sl@0
   250
sl@0
   251
	// Allocate the memory for the RRegion here so it is simple to back out
sl@0
   252
	// in case of failure
sl@0
   253
	TAny* regionMem = User::Alloc (sizeof (RRegion));
sl@0
   254
	if (!regionMem)
sl@0
   255
		{
sl@0
   256
		return KErrNoMemory;
sl@0
   257
		}
sl@0
   258
sl@0
   259
	TInt ret = WriteReplyInt(aWindow.WsHandle(),EWsDirectOpRequest);
sl@0
   260
	if (ret<KErrNone)
sl@0
   261
		{
sl@0
   262
		User::Free (regionMem);
sl@0
   263
		return ret;
sl@0
   264
		}
sl@0
   265
	TRect* rectList = NULL;
sl@0
   266
	TRect* newRectList;
sl@0
   267
	TInt numRect;
sl@0
   268
sl@0
   269
	do
sl@0
   270
		{
sl@0
   271
		numRect = ret;
sl@0
   272
		newRectList = STATIC_CAST(TRect*,User::ReAlloc(rectList,numRect*sizeof(TRect)));
sl@0
   273
		if (!newRectList)
sl@0
   274
			{
sl@0
   275
			Write(EWsDirectOpInitFailed);
sl@0
   276
			User::Free (regionMem);
sl@0
   277
			delete rectList;
sl@0
   278
			return KErrNoMemory;
sl@0
   279
			}
sl@0
   280
		rectList = newRectList;
sl@0
   281
		TPtr8 ptr(REINTERPRET_CAST(TUint8*,rectList),ret*sizeof(TRect));
sl@0
   282
		ret = WriteReplyIntP(ret,&ptr,EWsDirectOpGetRegion);
sl@0
   283
		} while(ret >=0 && ret != KMaxTInt);
sl@0
   284
	if (ret<0)
sl@0
   285
		{
sl@0
   286
		User::Free (regionMem);
sl@0
   287
		delete rectList;
sl@0
   288
		return ret;
sl@0
   289
		}
sl@0
   290
sl@0
   291
	aRegion = new (regionMem) RRegion (numRect, rectList);
sl@0
   292
	aStatus = KRequestPending;
sl@0
   293
	iMsgQueue->Request(&aStatus);
sl@0
   294
	iWs->DirectAcessActivation(ETrue);
sl@0
   295
	return KErrNone;
sl@0
   296
	}
sl@0
   297
sl@0
   298
EXPORT_C void RDirectScreenAccess::Completed()
sl@0
   299
/** Indicates to the window server that you have responded to the completion of 
sl@0
   300
the request status passed to Request(), by stopping direct screen access. */
sl@0
   301
	{
sl@0
   302
	__ASSERT_ALWAYS(iMsgQueue->Started(),Panic(EW32PanicDirectMisuse));
sl@0
   303
	if(iMsgQueue->Completed())
sl@0
   304
		{
sl@0
   305
		iWs->DirectAcessActivation(EFalse);
sl@0
   306
		}
sl@0
   307
	}
sl@0
   308
sl@0
   309
EXPORT_C void RDirectScreenAccess::Cancel()
sl@0
   310
/** Indicates to the window server that you have finished performing direct screen 
sl@0
   311
access. */
sl@0
   312
	{
sl@0
   313
	if(iMsgQueue->Started())
sl@0
   314
		{
sl@0
   315
		Completed();
sl@0
   316
		}
sl@0
   317
	TInt ret = WriteReply(EWsDirectOpCancel);
sl@0
   318
	if(ret != 0) // the server is sending us some data.
sl@0
   319
		{
sl@0
   320
		iMsgQueue->Queue().CancelDataAvailable();
sl@0
   321
		TInt data = 0;
sl@0
   322
		iMsgQueue->Queue().ReceiveBlocking(&data,sizeof(TInt));
sl@0
   323
		}
sl@0
   324
	iMsgQueue->Cancel();
sl@0
   325
	}
sl@0
   326
sl@0
   327
EXPORT_C void RDirectScreenAccess::Close()
sl@0
   328
/** Calls Completed() then deletes the server side resource and sets the client's 
sl@0
   329
handle to it to NULL. */
sl@0
   330
	{
sl@0
   331
	if (iBuffer && iWsHandle)
sl@0
   332
		{
sl@0
   333
		if(iMsgQueue && iMsgQueue->Started())
sl@0
   334
			{
sl@0
   335
			Completed();
sl@0
   336
			}
sl@0
   337
		Write(EWsDirectOpFree);
sl@0
   338
		delete iMsgQueue;
sl@0
   339
		iMsgQueue = NULL;
sl@0
   340
		}
sl@0
   341
	iWsHandle = NULL;
sl@0
   342
	}
sl@0
   343
sl@0
   344
//
sl@0
   345
// CDirectScreenAccess
sl@0
   346
//
sl@0
   347
sl@0
   348
EXPORT_C CDirectScreenAccess* CDirectScreenAccess::NewL(RWsSession& aWs,CWsScreenDevice& aScreenDevice,RWindowBase& aWin,MDirectScreenAccess& aAbort)
sl@0
   349
/** Allocates and constructs the object and adds it to the current active scheduler.
sl@0
   350
sl@0
   351
This function always causes a flush of the window server buffer.
sl@0
   352
sl@0
   353
@param aWs A session with the window server.
sl@0
   354
@param aScreenDevice Specifies the characteristics of the screen device to 
sl@0
   355
draw to.
sl@0
   356
@param aWin The window to draw to directly.
sl@0
   357
@param aAbort Defines an AbortNow() and a Restart() function which are both 
sl@0
   358
called on aborting, as part of the RunL(). Restart() is called from an idle 
sl@0
   359
time active object (CIdle).
sl@0
   360
@return The newly constructed object. */
sl@0
   361
	{
sl@0
   362
	CDirectScreenAccess* self = new(ELeave) CDirectScreenAccess(aWs,&aScreenDevice,aWin,aAbort);
sl@0
   363
	CleanupStack::PushL(self);
sl@0
   364
	self->ConstructL(aWs,EFalse); //this EFalse has no meaning here, it is used just to comply with the changes in NGA code
sl@0
   365
	CleanupStack::Pop(self);
sl@0
   366
	return self;
sl@0
   367
	}
sl@0
   368
sl@0
   369
EXPORT_C CDirectScreenAccess* CDirectScreenAccess::NewL(RWsSession& /*aWs*/,CWsScreenDevice&/* aScreenDevice*/,RWindowBase&/* aWin*/,MDirectScreenAccess&/*aAbort*/,TBool /*aRegionTrackingOnly*/)
sl@0
   370
/** This is not supported in WSERV non NGA. It's available just when NGA is present.*/
sl@0
   371
	{
sl@0
   372
	User::Leave(KErrNotSupported);
sl@0
   373
	return NULL;
sl@0
   374
	}
sl@0
   375
sl@0
   376
CDirectScreenAccess::~CDirectScreenAccess()
sl@0
   377
	{
sl@0
   378
	__ASSERT_ALWAYS(!iAborting,Panic(EW32PanicDirectMisuse));
sl@0
   379
	Cancel();
sl@0
   380
	delete iGc;
sl@0
   381
	delete iScreenDevice;
sl@0
   382
	if (iDrawingRegion)
sl@0
   383
		iDrawingRegion->Destroy();
sl@0
   384
	iDirectAccess.Close();
sl@0
   385
	delete iRestart;
sl@0
   386
	}
sl@0
   387
sl@0
   388
void CDirectScreenAccess::ConstructL(RWsSession& aWs,TBool /*aRegionTrackingOnly*/)
sl@0
   389
	{
sl@0
   390
	iScreenNumber = iWsScreenDevice->GetScreenNumber();
sl@0
   391
	
sl@0
   392
	User::LeaveIfError(iDirectAccess.Construct());
sl@0
   393
	iRestart = CIdle::NewL(RDirectScreenAccess::EPriorityVeryHigh-5);
sl@0
   394
	CActiveScheduler::Add(this);
sl@0
   395
	if (aWs.GetColorModeList(NULL)>1)
sl@0
   396
		iFlags |= EDirectCheckModeChange;
sl@0
   397
	if (iWsScreenDevice->NumScreenModes() == 1)
sl@0
   398
		{
sl@0
   399
		if (iWsScreenDevice->GetRotationsList(0,NULL) == 1)
sl@0
   400
			return;
sl@0
   401
		}
sl@0
   402
	iFlags |= EDirectCheckSizeModeChange;
sl@0
   403
	}
sl@0
   404
sl@0
   405
void CDirectScreenAccess::CreateScreenObjectsL(TDisplayMode aCurrentMode)
sl@0
   406
	{
sl@0
   407
	delete iScreenDevice;
sl@0
   408
	iScreenDevice = NULL;
sl@0
   409
	
sl@0
   410
	iScreenDevice = CFbsScreenDevice::NewL(iScreenNumber,aCurrentMode);
sl@0
   411
	
sl@0
   412
	if (iGc)
sl@0
   413
		iGc->Activate(iScreenDevice);
sl@0
   414
	else
sl@0
   415
		{
sl@0
   416
		User::LeaveIfError(iScreenDevice->CreateContext(iGc));
sl@0
   417
		if (!(iFlags&EDirectCheckSizeModeChange))
sl@0
   418
			UpdateSizeAndRotation(iGc);
sl@0
   419
		}
sl@0
   420
	}
sl@0
   421
sl@0
   422
EXPORT_C void CDirectScreenAccess::StartL()
sl@0
   423
/** Informs the window server that you are going to start direct screen access 
sl@0
   424
and sets up a graphics context with which you can draw to the screen.
sl@0
   425
sl@0
   426
It should also be called to restart direct screen access after Cancel() has 
sl@0
   427
been called to stop it. 
sl@0
   428
sl@0
   429
While the DSA is in operation, it is strongly advised that the client should 
sl@0
   430
not make any call to WSERV that will affect the visible area of the window in 
sl@0
   431
which the DSA is taking place. 
sl@0
   432
sl@0
   433
When WSERV tells the client that it needs to abort its DSA, it waits to receive
sl@0
   434
the acknowledgment from the client that it has done so. However, it doesn't wait
sl@0
   435
for ever, since the client may have entered some long running calculation or even
sl@0
   436
an infinite loop. So WSERV also waits on a timer: if the timer expires before the
sl@0
   437
client acknowledges, then WSERV continues; if, later on, WSERV gets notification
sl@0
   438
from the client that it has aborted the DSA, then WSERV will invalidate the region
sl@0
   439
in which the DSA was taking place, just in case there had been a conflict between
sl@0
   440
the DSA and another client.
sl@0
   441
sl@0
   442
sl@0
   443
This function always causes a flush of the window server buffer. */
sl@0
   444
	{
sl@0
   445
	if (iDrawingRegion)
sl@0
   446
		iDrawingRegion->Destroy();
sl@0
   447
	User::LeaveIfError(iDirectAccess.Request(iDrawingRegion,iStatus,iWindow));
sl@0
   448
	SetActive();
sl@0
   449
	if ((iFlags&EDirectCheckModeChange) || iScreenDevice == NULL)
sl@0
   450
		{
sl@0
   451
		TDisplayMode currentDisplayMode = iWsScreenDevice->DisplayMode();
sl@0
   452
		if (iScreenDevice == NULL || currentDisplayMode != iScreenDevice->DisplayMode())
sl@0
   453
			{
sl@0
   454
			TRAPD(err,CreateScreenObjectsL(currentDisplayMode));
sl@0
   455
			if (err != KErrNone)
sl@0
   456
				{
sl@0
   457
				Cancel();
sl@0
   458
				User::Leave(err);
sl@0
   459
				}
sl@0
   460
			}
sl@0
   461
		}
sl@0
   462
	if (iFlags&EDirectCheckSizeModeChange)
sl@0
   463
		UpdateSizeAndRotation(iGc);
sl@0
   464
	iGc->SetOrigin(iWindow.AbsPosition());
sl@0
   465
	iDrawingRegion->ClipRect(iScreenSize);
sl@0
   466
	iGc->SetClippingRegion(iDrawingRegion);
sl@0
   467
	}
sl@0
   468
sl@0
   469
TInt CDirectScreenAccess::Restart(TAny* aDirect)		//static
sl@0
   470
	{
sl@0
   471
	STATIC_CAST(CDirectScreenAccess*,aDirect)->Restart();
sl@0
   472
	return(KErrNone);
sl@0
   473
	}
sl@0
   474
sl@0
   475
void CDirectScreenAccess::Restart()
sl@0
   476
	{
sl@0
   477
	iAbort.Restart(iReason);
sl@0
   478
	}
sl@0
   479
sl@0
   480
void CDirectScreenAccess::UpdateSizeAndRotation(CFbsBitGc* aGc)
sl@0
   481
	{
sl@0
   482
	TPixelsAndRotation sizeAndRotation;
sl@0
   483
	iWsScreenDevice->GetDefaultScreenSizeAndRotation(sizeAndRotation);
sl@0
   484
	iScreenSize = sizeAndRotation.iPixelSize;
sl@0
   485
	TSize scale = iWsScreenDevice->GetCurrentScreenModeScale();
sl@0
   486
	iScreenDevice->SetScalingFactor(iWsScreenDevice->GetDefaultScreenModeOrigin(),scale.iWidth,scale.iHeight,1,1);
sl@0
   487
	if (aGc)
sl@0
   488
		aGc->SetOrientation(sizeAndRotation.iRotation);
sl@0
   489
	}
sl@0
   490
sl@0
   491
void CDirectScreenAccess::RunL()
sl@0
   492
	{
sl@0
   493
	iAborting = ETrue;
sl@0
   494
	iReason = REINTERPRET_CAST(RDirectScreenAccess::TTerminationReasons&,iStatus);
sl@0
   495
	iAbort.AbortNow(iReason);
sl@0
   496
	iAborting = EFalse;
sl@0
   497
	iDirectAccess.Completed();
sl@0
   498
	iRestart->Start(TCallBack(CDirectScreenAccess::Restart,this));
sl@0
   499
	}
sl@0
   500
sl@0
   501
void CDirectScreenAccess::DoCancel()
sl@0
   502
	{
sl@0
   503
	iDirectAccess.Cancel();
sl@0
   504
	}