sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Graphics Resource - internal functionality
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef SGDRIVER_H
|
sl@0
|
18 |
#define SGDRIVER_H
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <sgresource/sgimage.h>
|
sl@0
|
21 |
#include <sgresource/sgimage_sw.h>
|
sl@0
|
22 |
#include <sgresource/sgdriver_test.h>
|
sl@0
|
23 |
#include <sgresource/sgdriver_profiling.h>
|
sl@0
|
24 |
#include <pls.h>
|
sl@0
|
25 |
#include "sgdevice.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
const TUid KSgResourceLibraryUid = {0x102872C5};
|
sl@0
|
28 |
|
sl@0
|
29 |
const TInt KSgUsageAll = ESgUsageBitOpenVgImage | ESgUsageBitOpenGlesTexture2D | ESgUsageBitOpenGles2Texture2D
|
sl@0
|
30 |
| ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGles2Surface;
|
sl@0
|
31 |
const TInt KSgUsageAllSurfaceTypes = ESgUsageBitOpenVgSurface | ESgUsageBitOpenGlesSurface | ESgUsageBitOpenGles2Surface;
|
sl@0
|
32 |
|
sl@0
|
33 |
enum TSgResourceImplPanicReason
|
sl@0
|
34 |
{
|
sl@0
|
35 |
ESgPanicResourceImplGeneral = 1,
|
sl@0
|
36 |
ESgPanicBadRefCount = 2,
|
sl@0
|
37 |
ESgPanicBadImagePointer = 3
|
sl@0
|
38 |
};
|
sl@0
|
39 |
|
sl@0
|
40 |
void Panic(TSgResourceImplPanicReason aReason);
|
sl@0
|
41 |
|
sl@0
|
42 |
NONSHARABLE_CLASS(XSgImage)
|
sl@0
|
43 |
: public MSgImage_Sw
|
sl@0
|
44 |
{
|
sl@0
|
45 |
public:
|
sl@0
|
46 |
XSgImage(TSgDrawableId aId, TUint32 aAttribs, const TSgImageMetaData& aMetaData, TAny* aDataAddress, TInt aDataStride);
|
sl@0
|
47 |
~XSgImage();
|
sl@0
|
48 |
TInt Open();
|
sl@0
|
49 |
void Close();
|
sl@0
|
50 |
TInt RefCount() const;
|
sl@0
|
51 |
TSgDrawableId Id() const;
|
sl@0
|
52 |
TUid DrawableType() const;
|
sl@0
|
53 |
TInt GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr);
|
sl@0
|
54 |
void GetInfo(TSgImageInfo& aInfo) const;
|
sl@0
|
55 |
TInt GetAttribute(TUid aUid, TInt& aValue) const;
|
sl@0
|
56 |
static TInt Compare(const XSgImage& aImage1, const XSgImage& aImage2);
|
sl@0
|
57 |
static TInt Compare(const TSgDrawableId* aId, const XSgImage& aImage);
|
sl@0
|
58 |
// From MSgImage_Sw
|
sl@0
|
59 |
TAny* DataAddress() const;
|
sl@0
|
60 |
TInt DataStride() const;
|
sl@0
|
61 |
private:
|
sl@0
|
62 |
TInt iRefCount;
|
sl@0
|
63 |
TSgDrawableId iId;
|
sl@0
|
64 |
TSgImageInfo iInfo;
|
sl@0
|
65 |
TAny* iDataAddress;
|
sl@0
|
66 |
TInt iDataStride;
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
NONSHARABLE_CLASS(XSgDriver)
|
sl@0
|
70 |
: public MSgDriver_Profiling
|
sl@0
|
71 |
#ifdef _DEBUG
|
sl@0
|
72 |
, public MSgDriver_Test
|
sl@0
|
73 |
#endif
|
sl@0
|
74 |
{
|
sl@0
|
75 |
public:
|
sl@0
|
76 |
XSgDriver(RHeap* aHeap);
|
sl@0
|
77 |
~XSgDriver();
|
sl@0
|
78 |
TInt Construct();
|
sl@0
|
79 |
void Delete();
|
sl@0
|
80 |
TInt CreateImage(const TSgImageInfo& aInfo, const TAny* aDataAddress, TInt aDataStride, const TSgAttributeArrayBase* aAttributes, TAny*& aResult);
|
sl@0
|
81 |
TInt CreateImage(const TSgImageInfo& aInfo, const XSgImage* aImageImpl, const TSgAttributeArrayBase* aAttributes, TAny*& aResult);
|
sl@0
|
82 |
TInt FindAndOpenImage(TSgDrawableId aId, const TSgAttributeArrayBase* aAttributes, TAny*& aResult);
|
sl@0
|
83 |
void DeleteImage(XSgImage* aImageImpl);
|
sl@0
|
84 |
TUint32 MatchingEglConfigUsage(TUint32 aUsage) const;
|
sl@0
|
85 |
TInt CheckImageInfo(const TSgImageInfo& aInfo) const;
|
sl@0
|
86 |
TBool CheckImage(const TAny* aImageImpl) const;
|
sl@0
|
87 |
TInt GetInterface(TUid aInterfaceUid, TAny*& aInterfacePtr);
|
sl@0
|
88 |
// From MSgDriver_Profiling
|
sl@0
|
89 |
TInt LocalResourceCount() const;
|
sl@0
|
90 |
TInt GlobalResourceCount() const;
|
sl@0
|
91 |
TInt LocalGraphicsMemoryUsed() const;
|
sl@0
|
92 |
TInt GlobalGraphicsMemoryUsed() const;
|
sl@0
|
93 |
#ifdef _DEBUG
|
sl@0
|
94 |
// From MSgDriver_Test
|
sl@0
|
95 |
void AllocMarkStart();
|
sl@0
|
96 |
void AllocMarkEnd(TInt aCount);
|
sl@0
|
97 |
void SetAllocFail(RAllocator::TAllocFail aType, TInt aRate);
|
sl@0
|
98 |
#endif
|
sl@0
|
99 |
private:
|
sl@0
|
100 |
RHeap* iHeap;
|
sl@0
|
101 |
mutable RMutex iMutex;
|
sl@0
|
102 |
mutable RSgDevice iDevice;
|
sl@0
|
103 |
RPointerArray<XSgImage> iImagesByAddress;
|
sl@0
|
104 |
RPointerArray<XSgImage> iImagesById;
|
sl@0
|
105 |
TBool iHasOpenVg;
|
sl@0
|
106 |
TBool iHasOpenGles;
|
sl@0
|
107 |
TBool iHasOpenGles2;
|
sl@0
|
108 |
};
|
sl@0
|
109 |
|
sl@0
|
110 |
NONSHARABLE_CLASS(XSgDriverPls)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
public:
|
sl@0
|
113 |
XSgDriverPls();
|
sl@0
|
114 |
public:
|
sl@0
|
115 |
TInt iError;
|
sl@0
|
116 |
RMutex iMutex;
|
sl@0
|
117 |
TInt iOpenCount;
|
sl@0
|
118 |
XSgDriver* iDriver;
|
sl@0
|
119 |
};
|
sl@0
|
120 |
|
sl@0
|
121 |
#ifdef __WINS__
|
sl@0
|
122 |
#define gPls (*Pls<XSgDriverPls>(KSgResourceLibraryUid))
|
sl@0
|
123 |
#else
|
sl@0
|
124 |
extern XSgDriverPls gPls;
|
sl@0
|
125 |
#endif
|
sl@0
|
126 |
|
sl@0
|
127 |
#endif // SGDRIVER_H
|