SgDriver Class Reference

class SgDriver

Set of static functions in the Graphics Resource API.

Public Member Functions
IMPORT_C voidAllocMarkEnd(TInt)
IMPORT_C voidAllocMarkStart()
IMPORT_C voidClose()
IMPORT_C TIntOpen()
IMPORT_C TIntResourceCount()
IMPORT_C voidSetAllocFail(RAllocator::TAllocFail, TInt)

Member Functions Documentation

AllocMarkEnd(TInt)

IMPORT_C voidAllocMarkEnd(TIntaCount)[static]

Parameters

TInt aCount

AllocMarkStart()

IMPORT_C voidAllocMarkStart()[static]

Close()

IMPORT_C voidClose()[static]

Closes the Graphics Resource driver in the context of the calling process.

This function must be called by a process when finished using the Graphics Resource API. It decrements the process-local open count and, when the count becomes zero, it carries out termination tasks needed to release the internal resources allocated for the calling process.

Each call to Close() must correspond to a prior successful call to Open(). Note that, in a multi-threaded process, it is not generally safe to call Close() regardless of whether the corresponding call to Open() succeeded or failed, since too many calls to Close() from a thread could have an unexpected effect on all the other threads in the process. The following example demonstrates how to open and close the Graphics Resource driver safely from a worker thread.

	// Open Graphics Resource driver
	TBool isDriverOpen = EFalse;
	if (SgDriver::Open() == KErrNone)
		{
		isDriverOpen = ETrue;
		}
	// Do some work in this thread
	DoThreadWork();
	// Close Graphics Resource driver
	if (isDriverOpen)
		{
		SgDriver::Close();
		}
Pre-condition
If the process-local open count is one then there are no open handles to graphics resources in the calling process.
Post-condition
The process-local open count is decremented by one if greater than zero. If the count becomes zero, then the calling process is not able to use the Graphics Resource API any longer.
panic
SGRES 1 in debug builds if there still are any open handles to graphics resources in the calling process when the process termination tasks are carried out.
SgDriver::Open()

Open()

IMPORT_C TIntOpen()[static]

Opens the Graphics Resource driver in the context of the calling process.

This function must be called by any process using the Graphics Resource API before any other function in the API. When finished the process should call Close(). If Open() has already been called from the same process then calling it again just increments a process-local open count. Each successful call to Open() must be balanced by a corresponding call to Close() later on.

Note that, in a multi-threaded process, it is not necessary for each thread to call this function. A possible strategy is therefore for the main thread to call SgDriver::Open() at the beginning and SgDriver::Close() at the end, while the rest of the threads do not call either of these but simply use the Graphics Resource API.

Pre-condition
None.
Post-condition
The Graphics Resource driver is initialised for use in the context of the calling process and the process-local open count is incremented by one.
SgDriver::Close()

ResourceCount()

IMPORT_C TIntResourceCount()[static]

SetAllocFail(RAllocator::TAllocFail, TInt)

IMPORT_C voidSetAllocFail(RAllocator::TAllocFailaType,
TIntaRate
)[static]

Parameters

RAllocator::TAllocFail aType
TInt aRate