graphicscompositionref/surfacemgrcommon/inc/surfacemanagerdriver.inl
author Gareth Stockwell <gareth.stockwell@accenture.com>
Fri, 24 Sep 2010 13:54:59 +0100
branchbug235_bringup_0
changeset 2 47632b7dfb88
parent 0 91fe342bd9c4
permissions -rwxr-xr-x
Refactoring of frame buffer references to surface buffer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     7
//
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    10
//
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    11
// Contributors:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    12
//
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    13
// Description:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    14
// Surface Manager driver
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    15
// 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    16
//
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    17
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    18
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    19
@file
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    20
@internalComponent
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    21
@prototype
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    22
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    23
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    24
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    25
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    26
The driver's name
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    27
@return The name of the driver
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    28
@internalComponent
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    29
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    30
inline const TDesC& RSurfaceManagerDriver::Name()
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    31
	{
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    32
	_LIT(KSurfaceManagerName, "surfacemanagerdriver");
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    33
	return KSurfaceManagerName;
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    34
	}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    35
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    36
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    37
The driver's version
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    38
@return The version number of the driver
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    39
@internalComponent
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    40
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    41
inline TVersion RSurfaceManagerDriver::VersionRequired()
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    42
	{
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    43
	const TInt KMajorVersionNumber=1;
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    44
	const TInt KMinorVersionNumber=0;
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    45
	const TInt KBuildVersionNumber=KE32BuildVersionNumber;
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    46
	return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    47
	}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    48
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    49
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    50
#ifndef __KERNEL_MODE__
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    51
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    52
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    53
inline TInt RSurfaceManagerDriver::GetSurfaceManagerAttrib(RSurfaceManager::TSurfaceManagerAttrib aAttrib, TInt& aValue)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    54
	{return DoControl(RSurfaceManagerDriver::EControlGetSurfaceManagerAttrib, (TAny*)&aAttrib, (TAny*)&aValue);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    55
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    56
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    57
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    58
Opens a surface. If the surface is already open in this process, this call increments the reference count for the surface for this process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    59
If the surface hasn't been opened in this process, it opens the surface in this process and sets the reference count to 1 for this process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    60
A surface will be deleted when all its reference counts are 0.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    61
@param aSurfaceId  The surface id originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    62
@pre The surface id is for an existing surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    63
@post The surface is open in this process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    64
@return KErrNone if successful otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    65
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    66
inline TInt RSurfaceManagerDriver::OpenSurface(const TSurfaceId& aSurfaceId)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    67
	{return DoControl(RSurfaceManagerDriver::EControlOpenSurface, (TAny*)&aSurfaceId);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    68
	
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    69
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    70
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    71
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    72
Creates a surface and allocates the memory for the surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    73
It does not map the surface memory into this process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    74
Sets the surface ID, aSurfaceId, to a globally unique identifier for the surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    75
The most significant byte of the 4th TUint in the TSurfaceId will be set to a value to identify the surface type.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    76
The surface will be open with a reference count of 1 in this process after a successful call to CreateSurface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    77
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    78
The creation attributes are validated as follows:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    79
		The alignment is 1,2,4, 8,16,32,64 or TPageAlignment::EPageAligned.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    80
		The offset to first buffer is correctly aligned.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    81
		The width and height are both greater than zero.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    82
		There is at least one buffer.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    83
		The calculated chunk size isn't so big that it will exceed a signed int.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    84
		The caching attribute is valid
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    85
		If the offset between the start of one buffer and the next is specified, it must be correctly aligned and at least as big as the buffer size calculated from the height and stride.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    86
		A surface hint key of zero is allowed when creating a surface, it is ignored
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    87
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    88
If offset to first buffer or offset between buffers is not aligned properly, then surface manager will do the alignment, based on surface is CPU cached or not.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    89
	-	If surface is CPU cached it will be aligned with minimum of the specified alignment 32(for alignment 1, 2, 4, 8, 16, 32) or 64.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    90
	-	If surface is not CPU cached it will be aligned based on creation attribute's alignment.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    91
For page alignment it will be rounded to page size.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    92
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    93
@param aReqs  Input parameter, specifies attributes of the surface required.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    94
@param aSurfaceId  Output parameter, the surface ID, set if the call succeeds.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    95
@pre The device driver is loaded and a channel to it has been opened.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    96
@post The surface is created and opened in the creating process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    97
@return KErrNone if it succeeds, KErrArgument if the surface attributes are incorrect,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    98
KErrNoMemory if the surface cannot be created due to out of memory,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    99
KErrOverflow if the chunk limit has been exceeded in the moving memory model, otherwise a standard Symbian error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   100
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   101
inline TInt RSurfaceManagerDriver::CreateSurface(const RSurfaceManager::TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   102
	{return DoControl(RSurfaceManagerDriver::EControlCreateSurface, (TAny*)&aReqs, (TAny*)&aSurfaceId);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   103
	
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   104
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   105
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   106
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   107
Creates a surface in the shared chunk memory specified by the user.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   108
Sets a new surface ID aSurfaceId to a globally unique identifier for the surface.  
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   109
The most significant byte of the 4th TUint in the TSurfaceId will be set to a value to identify 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   110
the surface type.  The surface will be open with a reference count of 1 in this process after a 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   111
successful call to CreateSurface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   112
The creation attributes are validated as follows:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   113
		The alignment is 1,2,4, 8,16,32,64 or page alignment.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   114
		The offset to first buffer is correctly aligned.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   115
		The width and height are both greater than zero.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   116
		There is at least one buffer.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   117
		The chunk should be a valid shared chunk of the necessary size.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   118
		If the offset between the start of one buffer and the next is specified, it must be correctly 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   119
		aligned and at least as big as the buffer size calculated from the height and stride.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   120
		A surface hint key of zero is allowed when creating a surface, it is ignored
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   121
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   122
The offset can be 0 and that means the surface manager will calculate the offset
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   123
The TSurfaceCreationAttributes members iContiguous and iCacheAttribute will not be used for already existing chunks
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   124
Also, note that surface manager will not do any rounding for offset to first buffer and offset between buffer. 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   125
Surface manager will expect exact aligned values for this buffer attributes, otherwise surface creation will fail.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   126
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   127
@param aReqs  Input parameter, specifies attributes of the surface required.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   128
@param aSurfaceId  Output parameter, the surface ID, set if the call succeeds.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   129
@param aChunkHandle  Handle of the existing shared chunk.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   130
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   131
Preconditions:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   132
@pre The device driver is loaded and a channel has been opened. A valid shared chunk should be created and 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   133
big enough for the requested size. The shared chunk type should be Shared  Kernel multiple and should be right the size,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   134
ie., the size should be calculated as Offset to first buffer + (the number of buffers * ((stride * height * pixel depth in bytes) rounded up to the specified alignment) all rounded to a page size
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   135
@post The surface manager opens the chunk.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   136
@return KErrNone if it succeeds, KErrArgument if the surface attributes are incorrect. 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   137
KErrBadHandle If the handle is of an invalid shared chunk memory
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   138
*/ 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   139
inline TInt RSurfaceManagerDriver::CreateSurface(const RSurfaceManager::TSurfaceCreationAttributesBuf& aReqs, TSurfaceId& aSurfaceId, const RChunk& aChunkHandle)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   140
	{
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   141
	TDeviceParam create((TAny*)&aSurfaceId, (TAny*)&aReqs);
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   142
	return DoControl(RSurfaceManagerDriver::EControlCreateSurfaceEx, (TAny*)&create, (TAny*)aChunkHandle.Handle());
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   143
	}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   144
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   145
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   146
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   147
Closes the surface. Decrements the reference count for the surface for the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   148
If the surface has other owners, it will not be deleted from memory.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   149
If this is the last process to close the surface, the surface will be deleted and the surface ID will become invalid.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   150
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   151
@pre The surface is open.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   152
@post The surface is closed.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   153
@return KErrNone if successful, KErrArgument if the surface ID does not refer to a surface,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   154
KErrAccessDenied if the surface is not open in the current process, otherwise a system wide
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   155
error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   156
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   157
inline TInt RSurfaceManagerDriver::CloseSurface(const TSurfaceId& aSurfaceId)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   158
	{return DoControl(RSurfaceManagerDriver::EControlCloseSurface, (TAny*)&aSurfaceId);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   159
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   160
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   161
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   162
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   163
Maps the surface into the current client process address space.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   164
The actual memory will remain mapped into the calling process for as long as the RChunk handle aHandle is open.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   165
The RChunk handle is owned by the calling thread, so will need to be duplicated if passed to other threads in the process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   166
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   167
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   168
@param aHandle  Output parameter, handle to the implementation specific Shared Chunk.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   169
@pre The surface is open.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   170
@post The surface memory will be mapped into the calling porcesses address space.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   171
@return KErrNone if successful, KErrArgument if the surface ID does not refer to a
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   172
surface, KErrAccessDenied if the surface is not open in the current process,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   173
KErrNotSupported if the surface is not mappable, KErrOverflow if the chunk limit has been
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   174
exceeded in the moving memory model, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   175
@see RChunk
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   176
@see RHandleBase::Duplicate
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   177
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   178
inline TInt RSurfaceManagerDriver::MapSurface(const TSurfaceId& aSurfaceId, RChunk& aHandle)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   179
	{return aHandle.SetReturnedHandle(DoControl(RSurfaceManagerDriver::EControlAccessSurfaceData, (TAny*)&aSurfaceId));}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   180
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   181
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   182
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   183
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   184
Returns information about a particular surface identified by its surface ID.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   185
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   186
@param aInfo  TInfoBuf to receive the information about the surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   187
@pre The surface is open in the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   188
@return KErrNone if successful, KErrArgument if the surface ID does not refer to a surface,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   189
KErrAccessDenied if the surface is not open in the current process, otherwise a system wide
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   190
error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   191
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   192
inline TInt RSurfaceManagerDriver::SurfaceInfo(const TSurfaceId& aSurfaceId, RSurfaceManager::TInfoBuf& aInfo)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   193
	{return DoControl(RSurfaceManagerDriver::EControlSurfaceInfo, (TAny*)&aSurfaceId, (TAny*)&aInfo);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   194
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   195
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   196
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   197
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   198
Opens a channel to the surface manager logical device driver. 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   199
@pre The logical device driver has been loaded
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   200
@return Returns KErrNone if successful, KErrNotFound if the driver hasn't been loaded, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   201
@see User::LoadLogicalDevice
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   202
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   203
inline TInt RSurfaceManagerDriver::Open()
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   204
	{return DoCreate(Name(),VersionRequired(),KNullUnit,NULL,NULL,EOwnerProcess);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   205
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   206
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   207
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   208
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   209
This function ensures the memory is updated consistently before and/or after triggering non CPU hardware access. 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   210
Also ensures the CPU cache and the physical memory are in a consistent state before and after non CPU hardware or DMA access
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   211
to the physical memory.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   212
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   213
@param aBuffer  The buffer number indexed from 0 within the surface whose memory region is to be flushed. 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   214
@param aOperation  Specifies the sync operation as before non CPU hardware reads or before non CPU hardware writes or after non CPU hardware
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   215
writes between physical memory of the surface and the cache contents.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   216
@pre The surface is open in the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   217
@post The surface buffer memory will be synchronized properly with cache contents.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   218
@return KErrNone if successful, KErrArgument if the surface ID is invalid or
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   219
buffer number is invalid, KErrAccessDenied if the surface is not open in this
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   220
process, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   221
*/ 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   222
inline TInt RSurfaceManagerDriver::SynchronizeCache(const TSurfaceId& aSurfaceId, TInt aBuffer, RSurfaceManager::TSyncOperation aOperation)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   223
	{
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   224
	TDeviceParam buff((TAny*)&aSurfaceId, (TAny*)aBuffer);
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   225
	return DoControl(RSurfaceManagerDriver::EControlSynchronizeCache, (TAny*)&buff, (TAny*)aOperation);
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   226
	}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   227
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   228
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   229
Get the surface hint value for the given surface ID and hint pair key.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   230
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   231
@param aHint  The hint value for the requested hint pair key.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   232
@pre The surface is open in the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   233
@pre Hint key should be a key for a hint set for this surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   234
@post The hint value will be updated in the hint pair.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   235
@return KErrNone if successful, KErrArgument if the surface ID is invalid or
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   236
invalid hint pair key used, KErrAccessDenied if the surface is not open in the
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   237
current process, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   238
*/ 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   239
inline TInt RSurfaceManagerDriver::GetSurfaceHint(const TSurfaceId& aSurfaceId, RSurfaceManager::THintPair& aHint)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   240
	{return DoControl(RSurfaceManagerDriver::EControlGetSurfaceHint, (TAny*)&aSurfaceId, (TAny*)&aHint);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   241
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   242
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   243
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   244
Set the surface hint value for the surface Id.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   245
Parameters:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   246
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   247
@param aHint  The value of the hint pair to set.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   248
@pre The surface is open in the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   249
@pre The Hint key should be a key for a hint set for this surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   250
@pre Only mutable hints can be updated.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   251
@post The hint value will be updated in the surface hint pair.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   252
@return KErrNone if successful, KErrArgument if the surface ID is invalid or if invalid
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   253
hint key used, KErrAccessDenied if the hint pair is immutable or the surface is not open
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   254
in the current process, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   255
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   256
inline TInt RSurfaceManagerDriver::SetSurfaceHint(const TSurfaceId& aSurfaceId, const RSurfaceManager::THintPair& aHint)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   257
	{return DoControl(RSurfaceManagerDriver::EControlSetSurfaceHint, (TAny*)&aSurfaceId, (TAny*)&aHint);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   258
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   259
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   260
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   261
Adds a new surface hint to the surface. This function will fail if the surface already has its maximum number of hints 
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   262
or if the hint key is a duplicate or invalid.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   263
Parameters:
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   264
@param aSurfaceId  The surface identifier originally returned when the surface was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   265
@param aHint  The value of the hint pair to add.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   266
@pre The surface is open in the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   267
@pre Atleast one free space to add a hint pair.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   268
@pre The new hint key should be unique.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   269
@post New hint pair will be added in the surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   270
@return Returns KErrNone if successful, KErrArgument if the surface ID is invalid or the
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   271
hint pair has invalid key UID, KErrAccessDenied if the surface is not open in the current
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   272
process, KErrAlreadyExists if duplicate hint key used, KErrOverflow if no space to add new
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   273
pair, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   274
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   275
inline TInt RSurfaceManagerDriver::AddSurfaceHint(const TSurfaceId& aSurfaceId, const RSurfaceManager::THintPair& aHint)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   276
	{return DoControl(RSurfaceManagerDriver::EControlAddSurfaceHint, (TAny*)&aSurfaceId, (TAny*)&aHint);}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   277
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   278
/**
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   279
Get the offset of the specified buffer from the base address of the underlying
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   280
chunk.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   281
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   282
To obtain the address of the buffer, the offset returned must be added onto the
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   283
base address of the RChunk returned in a call to MapSurface(). Note that
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   284
buffer offsets are immutable during the lifetime of the surface.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   285
@param aSurfaceId The surface identifier originally returned when the surface
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   286
was created.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   287
@param aBuffer The buffer for which the offset is requested. Indexed from 0.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   288
@param aOffset Output parameter set to the offset within the chunk.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   289
@pre The surface is open in the calling process.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   290
@return KErrNone if successful, KErrArgument if aSurfaceId or aBuffer are invalid,
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   291
KErrAccessDenied if the surface is not open in the current process, KErrNotSupported if
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   292
the surface is not mappable, otherwise a system wide error code.
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   293
*/
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   294
inline TInt RSurfaceManagerDriver::GetBufferOffset(const TSurfaceId& aSurfaceId, TInt aBuffer, TInt& aOffset)
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   295
	{
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   296
	TDeviceParam buff((TAny*)&aSurfaceId, (TAny*)aBuffer);
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   297
	return DoControl(RSurfaceManagerDriver::EControlGetBufferOffset, (TAny*)&buff, (TAny*)&aOffset);
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   298
	}
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   299
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   300
#endif //__KERNEL_MODE__
91fe342bd9c4 Provide code to deliver both syborg and reference implementations of surface manager.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   301