os/graphics/graphicsresourceservices/graphicsresourceimplementation/inc/sgdriver.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresourceimplementation/inc/sgdriver.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,127 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Graphics Resource - internal functionality
1.18 +//
1.19 +
1.20 +#ifndef SGDRIVER_H
1.21 +#define SGDRIVER_H
1.22 +
1.23 +#include <sgresource/sgimage.h>
1.24 +#include <sgresource/sgimage_sw.h>
1.25 +#include <sgresource/sgdriver_test.h>
1.26 +#include <sgresource/sgdriver_profiling.h>
1.27 +#include <pls.h>
1.28 +#include "sgdevice.h"
1.29 +
1.30 +const TUid KSgResourceLibraryUid = {0x102872C5};
1.31 +
1.32 +const TInt KSgUsageAll = ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGles2Texture2D
1.33 + | ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGles2Surface;
1.34 +const TInt KSgUsageAllSurfaceTypes = ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGles2Surface;
1.35 +
1.36 +enum TSgResourceImplPanicReason
1.37 + {
1.38 + ESgPanicResourceImplGeneral = 1,
1.39 + ESgPanicBadRefCount = 2,
1.40 + ESgPanicBadImagePointer = 3
1.41 + };
1.42 +
1.43 +void Panic(TSgResourceImplPanicReason aReason);
1.44 +
1.45 +NONSHARABLE_CLASS(XSgImage)
1.46 + : public MSgImage_Sw
1.47 + {
1.48 +public:
1.49 + XSgImage(TSgDrawableId aId, TUint32 aAttribs, const TSgImageMetaData& aMetaData, TAny* aDataAddress, TInt aDataStride);
1.50 + ~XSgImage();
1.51 + TInt Open();
1.52 + void Close();
1.53 + TInt RefCount() const;
1.54 + TSgDrawableId Id() const;
1.55 + TUid DrawableType() const;
1.56 + TInt GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr);
1.57 + void GetInfo(TSgImageInfo& aInfo) const;
1.58 + TInt GetAttribute(TUid aUid, TInt& aValue) const;
1.59 + static TInt Compare(const XSgImage& aImage1, const XSgImage& aImage2);
1.60 + static TInt Compare(const TSgDrawableId* aId, const XSgImage& aImage);
1.61 + // From MSgImage_Sw
1.62 + TAny* DataAddress() const;
1.63 + TInt DataStride() const;
1.64 +private:
1.65 + TInt iRefCount;
1.66 + TSgDrawableId iId;
1.67 + TSgImageInfo iInfo;
1.68 + TAny* iDataAddress;
1.69 + TInt iDataStride;
1.70 + };
1.71 +
1.72 +NONSHARABLE_CLASS(XSgDriver)
1.73 + : public MSgDriver_Profiling
1.74 +#ifdef _DEBUG
1.75 + , public MSgDriver_Test
1.76 +#endif
1.77 + {
1.78 +public:
1.79 + XSgDriver(RHeap* aHeap);
1.80 + ~XSgDriver();
1.81 + TInt Construct();
1.82 + void Delete();
1.83 + TInt CreateImage(const TSgImageInfo& aInfo, const TAny* aDataAddress, TInt aDataStride, const TSgAttributeArrayBase* aAttributes, TAny*& aResult);
1.84 + TInt CreateImage(const TSgImageInfo& aInfo, const XSgImage* aImageImpl, const TSgAttributeArrayBase* aAttributes, TAny*& aResult);
1.85 + TInt FindAndOpenImage(TSgDrawableId aId, const TSgAttributeArrayBase* aAttributes, TAny*& aResult);
1.86 + void DeleteImage(XSgImage* aImageImpl);
1.87 + TUint32 MatchingEglConfigUsage(TUint32 aUsage) const;
1.88 + TInt CheckImageInfo(const TSgImageInfo& aInfo) const;
1.89 + TBool CheckImage(const TAny* aImageImpl) const;
1.90 + TInt GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr);
1.91 + // From MSgDriver_Profiling
1.92 + TInt LocalResourceCount() const;
1.93 + TInt GlobalResourceCount() const;
1.94 + TInt LocalGraphicsMemoryUsed() const;
1.95 + TInt GlobalGraphicsMemoryUsed() const;
1.96 +#ifdef _DEBUG
1.97 + // From MSgDriver_Test
1.98 + void AllocMarkStart();
1.99 + void AllocMarkEnd(TInt aCount);
1.100 + void SetAllocFail(RAllocator::TAllocFail aType, TInt aRate);
1.101 +#endif
1.102 +private:
1.103 + RHeap* iHeap;
1.104 + mutable RMutex iMutex;
1.105 + mutable RSgDevice iDevice;
1.106 + RPointerArray<XSgImage> iImagesByAddress;
1.107 + RPointerArray<XSgImage> iImagesById;
1.108 + TBool iHasOpenVg;
1.109 + TBool iHasOpenGles;
1.110 + TBool iHasOpenGles2;
1.111 + };
1.112 +
1.113 +NONSHARABLE_CLASS(XSgDriverPls)
1.114 + {
1.115 +public:
1.116 + XSgDriverPls();
1.117 +public:
1.118 + TInt iError;
1.119 + RMutex iMutex;
1.120 + TInt iOpenCount;
1.121 + XSgDriver* iDriver;
1.122 + };
1.123 +
1.124 +#ifdef __WINS__
1.125 +#define gPls (*Pls<XSgDriverPls>(KSgResourceLibraryUid))
1.126 +#else
1.127 +extern XSgDriverPls gPls;
1.128 +#endif
1.129 +
1.130 +#endif // SGDRIVER_H