sl@0: // Copyright (c) 2008-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 - internal functionality sl@0: // sl@0: sl@0: #ifndef SGDRIVER_H sl@0: #define SGDRIVER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "sgdevice.h" sl@0: sl@0: const TUid KSgResourceLibraryUid = {0x102872C5}; sl@0: sl@0: const TInt KSgUsageAll = ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGles2Texture2D sl@0: | ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGles2Surface; sl@0: const TInt KSgUsageAllSurfaceTypes = ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGles2Surface; sl@0: sl@0: enum TSgResourceImplPanicReason sl@0: { sl@0: ESgPanicResourceImplGeneral = 1, sl@0: ESgPanicBadRefCount = 2, sl@0: ESgPanicBadImagePointer = 3 sl@0: }; sl@0: sl@0: void Panic(TSgResourceImplPanicReason aReason); sl@0: sl@0: NONSHARABLE_CLASS(XSgImage) sl@0: : public MSgImage_Sw sl@0: { sl@0: public: sl@0: XSgImage(TSgDrawableId aId, TUint32 aAttribs, const TSgImageMetaData& aMetaData, TAny* aDataAddress, TInt aDataStride); sl@0: ~XSgImage(); sl@0: TInt Open(); sl@0: void Close(); sl@0: TInt RefCount() const; sl@0: TSgDrawableId Id() const; sl@0: TUid DrawableType() const; sl@0: TInt GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr); sl@0: void GetInfo(TSgImageInfo& aInfo) const; sl@0: TInt GetAttribute(TUid aUid, TInt& aValue) const; sl@0: static TInt Compare(const XSgImage& aImage1, const XSgImage& aImage2); sl@0: static TInt Compare(const TSgDrawableId* aId, const XSgImage& aImage); sl@0: // From MSgImage_Sw sl@0: TAny* DataAddress() const; sl@0: TInt DataStride() const; sl@0: private: sl@0: TInt iRefCount; sl@0: TSgDrawableId iId; sl@0: TSgImageInfo iInfo; sl@0: TAny* iDataAddress; sl@0: TInt iDataStride; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(XSgDriver) sl@0: : public MSgDriver_Profiling sl@0: #ifdef _DEBUG sl@0: , public MSgDriver_Test sl@0: #endif sl@0: { sl@0: public: sl@0: XSgDriver(RHeap* aHeap); sl@0: ~XSgDriver(); sl@0: TInt Construct(); sl@0: void Delete(); sl@0: TInt CreateImage(const TSgImageInfo& aInfo, const TAny* aDataAddress, TInt aDataStride, const TSgAttributeArrayBase* aAttributes, TAny*& aResult); sl@0: TInt CreateImage(const TSgImageInfo& aInfo, const XSgImage* aImageImpl, const TSgAttributeArrayBase* aAttributes, TAny*& aResult); sl@0: TInt FindAndOpenImage(TSgDrawableId aId, const TSgAttributeArrayBase* aAttributes, TAny*& aResult); sl@0: void DeleteImage(XSgImage* aImageImpl); sl@0: TUint32 MatchingEglConfigUsage(TUint32 aUsage) const; sl@0: TInt CheckImageInfo(const TSgImageInfo& aInfo) const; sl@0: TBool CheckImage(const TAny* aImageImpl) const; sl@0: TInt GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr); sl@0: // From MSgDriver_Profiling sl@0: TInt LocalResourceCount() const; sl@0: TInt GlobalResourceCount() const; sl@0: TInt LocalGraphicsMemoryUsed() const; sl@0: TInt GlobalGraphicsMemoryUsed() const; sl@0: #ifdef _DEBUG sl@0: // From MSgDriver_Test sl@0: void AllocMarkStart(); sl@0: void AllocMarkEnd(TInt aCount); sl@0: void SetAllocFail(RAllocator::TAllocFail aType, TInt aRate); sl@0: #endif sl@0: private: sl@0: RHeap* iHeap; sl@0: mutable RMutex iMutex; sl@0: mutable RSgDevice iDevice; sl@0: RPointerArray iImagesByAddress; sl@0: RPointerArray iImagesById; sl@0: TBool iHasOpenVg; sl@0: TBool iHasOpenGles; sl@0: TBool iHasOpenGles2; sl@0: }; sl@0: sl@0: NONSHARABLE_CLASS(XSgDriverPls) sl@0: { sl@0: public: sl@0: XSgDriverPls(); sl@0: public: sl@0: TInt iError; sl@0: RMutex iMutex; sl@0: TInt iOpenCount; sl@0: XSgDriver* iDriver; sl@0: }; sl@0: sl@0: #ifdef __WINS__ sl@0: #define gPls (*Pls(KSgResourceLibraryUid)) sl@0: #else sl@0: extern XSgDriverPls gPls; sl@0: #endif sl@0: sl@0: #endif // SGDRIVER_H