sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Graphics Resource - logical device driver internal functionality
sl@0: //
sl@0: 
sl@0: #ifndef SGDEVICEIMPL_H
sl@0: #define SGDEVICEIMPL_H
sl@0: 
sl@0: #include <kernel/kernel.h>
sl@0: #include <sgresource/sgdevice.h>
sl@0: 
sl@0: enum TSgDevicePanicReason
sl@0: 	{
sl@0: 	ESgPanicMetaDataSizeTooBig = 1,
sl@0: 	ESgPanicDataSizeNegative = 2
sl@0: 	};
sl@0: 
sl@0: void Panic(TSgDevicePanicReason aReason);
sl@0: 
sl@0: class DSgDevice: public DLogicalDevice
sl@0: 	{
sl@0: public:
sl@0: 	// From DLogicalDevice
sl@0: 	TInt Install();
sl@0: 	void GetCaps(TDes8& aDes) const;
sl@0: 	TInt Create(DLogicalChannelBase*& aChannel);
sl@0: 	};
sl@0: 
sl@0: class DSgResource;
sl@0: 
sl@0: class DSgChannel: public DLogicalChannelBase
sl@0: 	{
sl@0: public:
sl@0: 	~DSgChannel();
sl@0: 	// From DLogicalChannelBase
sl@0: 	TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVersion);
sl@0: 	TInt Request(TInt aFunction, TAny* a1, TAny* a2);
sl@0: private:
sl@0: 	TInt CreateResource(TUint32 aAttribs, const TDesC8& aMetaData, TInt aDataSize, TUint64& aId);
sl@0: 	TInt OpenResource(TUint64 aId);
sl@0: 	TInt CloseResource(TUint64 aId);
sl@0: 	TUint32 ResourceAttributes(TUint64 aId) const;
sl@0: 	TInt GetResourceMetaData(TUint64 aId, TDes8& aMetaData) const;
sl@0: 	TAny* ResourceDataAddress(TUint64 aId) const;
sl@0: 	TInt ResourceDataSize(TUint64 aId) const;
sl@0: 	TInt GlobalResourceCount() const;
sl@0: 	TInt LocalGraphicsMemoryUsed() const;
sl@0: 	TInt GlobalGraphicsMemoryUsed() const;
sl@0: private:
sl@0: 	class TResourceListItem
sl@0: 		{
sl@0: 	public:
sl@0: 		TResourceListItem(DSgResource* aResource, TInt aChunkHandle);
sl@0: 	public:
sl@0: 		DSgResource* iResource;
sl@0: 		TInt iChunkHandle;
sl@0: 		};
sl@0: private:
sl@0: 	static TInt Compare(const TUint64* aId, const TResourceListItem& aResourceListItem);
sl@0: 	static TInt Compare(const TResourceListItem& aResourceListItem1, const TResourceListItem& aResourceListItem2);
sl@0: private:
sl@0: 	DMutex* iMutex;
sl@0: 	RArray<TResourceListItem> iResources;
sl@0: 	};
sl@0: 
sl@0: #endif // SGDEVICEIMPL_H