|
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @publishedPartner |
|
19 @prototype |
|
20 */ |
|
21 |
|
22 #ifndef __SURFACEMANAGER_DEV_H__ |
|
23 #define __SURFACEMANAGER_DEV_H__ |
|
24 |
|
25 #include <graphics/surface.h> |
|
26 #include "surfacemanagerdriver.h" |
|
27 |
|
28 #ifdef GRAPHICS_SURFACEMANAGER_SYBORG |
|
29 #include "syborgvirtualhwmemory.h" |
|
30 #endif |
|
31 |
|
32 #if 0 |
|
33 #define TRACE(x) x |
|
34 #else |
|
35 #define TRACE(x) |
|
36 #endif |
|
37 |
|
38 /** Maximum number of HintPairs per surface */ |
|
39 const TInt KMaxHintsPerSurface = 16; |
|
40 |
|
41 /** Maximum number of elements in the table. This value must be a power of 2 */ |
|
42 #define KMaxLists 16 |
|
43 |
|
44 /** |
|
45 Logical Device (factory class) for Surface manager |
|
46 */ |
|
47 class DSurfaceManagerFactory : public DLogicalDevice |
|
48 { |
|
49 public: |
|
50 DSurfaceManagerFactory(); |
|
51 TInt Install(); |
|
52 void GetCaps(TDes8& aDes) const; |
|
53 TInt Create(DLogicalChannelBase*& aChannel); |
|
54 }; |
|
55 |
|
56 |
|
57 /** |
|
58 Logical Channel class for SurfaceManager |
|
59 */ |
|
60 class DSurfaceManagerChannel : public DLogicalChannelBase |
|
61 { |
|
62 public: |
|
63 DSurfaceManagerChannel(); |
|
64 ~DSurfaceManagerChannel(); |
|
65 |
|
66 // Inherited from DLogicalChannelBase |
|
67 TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer); |
|
68 TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
69 private: |
|
70 // Implementation for the different kinds of messages sent through RBusLogicalChannel |
|
71 TInt DoControl(TInt aFunction, TAny* a1, TAny* a2); |
|
72 |
|
73 private: |
|
74 DProcess* iOwner; |
|
75 }; |
|
76 |
|
77 |
|
78 /** |
|
79 Class to hold a reference count and process pointer. |
|
80 Each surface has a linked list of these owning processes. |
|
81 The surface manager has a linked list of these to track connections. |
|
82 @internalTechnology |
|
83 */ |
|
84 class TProcessListItem |
|
85 { |
|
86 public: |
|
87 TProcessListItem* iNext; //pointer to next one in list |
|
88 DProcess* iOwningProcess; //pointer to the process object which is being reference counted |
|
89 TInt iCount; //reference count |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 Class to hold the information about a surface. |
|
95 Each surface has a linked list of owners. The surfaces are arranged in a linked list, |
|
96 with these objects being elements in the list. |
|
97 @internalTechnology |
|
98 */ |
|
99 class TSurface //one of these per surface |
|
100 { |
|
101 public: |
|
102 TSurface* iNext; //singly linked list, points to next surface |
|
103 TSurfaceId iId; //the surface id |
|
104 TSize iSize; //pixel width/height |
|
105 TInt iBuffers; //number of buffers |
|
106 TUidPixelFormat iPixelFormat; //pixel format |
|
107 TInt iStride; //offset from start of one line to the next, in bytes |
|
108 TInt iOffsetToFirstBuffer; //offset between the start of the surface memory and the start of the first pixel buffer |
|
109 TInt iOffsetBetweenBuffers; //offset between pixel buffers |
|
110 TInt iAlignment; //byte alignment of the pixel buffers |
|
111 TBool iContiguous; //if it is in contiguous physical memory |
|
112 DChunk* iChunk; //ptr to the shared chunk |
|
113 RSurfaceManager::TCacheAttribute iCacheAttrib; //Caching attribute to create chunks memory |
|
114 RSurfaceManager::THintPair iSurfaceHints[KMaxHintsPerSurface]; //Arbitrary key-value pairs associated with a surface |
|
115 TBool iMappable; //Is the Surface Mappable |
|
116 TProcessListItem* iOwners; //owner list. Singly linked list, points to next surface owner |
|
117 |
|
118 public: |
|
119 TProcessListItem* ProcessOwnerInfo(const DProcess* aProcess); |
|
120 }; |
|
121 |
|
122 /** |
|
123 Surface manager extension object. |
|
124 There is one static instance of this in the kernel extension. |
|
125 @internalTechnology |
|
126 */ |
|
127 class DSurfaceManager : public DBase |
|
128 { |
|
129 public: |
|
130 TInt CreateSurface(const TDesC8* aConfig, TSurfaceId* aId); |
|
131 TInt SurfaceInfo(const TSurfaceId* aId, TDes8* aInfo); |
|
132 TInt OpenSurface(const TSurfaceId* aId); |
|
133 TInt CloseSurface(const TSurfaceId* aId); |
|
134 TInt MapSurface(const TSurfaceId* aId); |
|
135 TInt AddConnection(const DProcess* iProcess); |
|
136 void RemoveConnection(const DProcess* iProcess); |
|
137 TInt CreateSurface(RSurfaceManagerDriver::TDeviceParam* aParam, TInt aChunkHandle); |
|
138 TInt SynchronizeCache(RSurfaceManagerDriver::TDeviceParam* aId, RSurfaceManager::TSyncOperation aOperation); |
|
139 TInt GetSurfaceHint(const TSurfaceId* aSurfaceId, RSurfaceManager::THintPair* aHintPair); |
|
140 TInt SetSurfaceHint(const TSurfaceId* aSurfaceId, const RSurfaceManager::THintPair* aHintPair); |
|
141 TInt AddSurfaceHint(const TSurfaceId* aSurfaceId, const RSurfaceManager::THintPair* aHintPair); |
|
142 TInt GetBufferOffset(RSurfaceManagerDriver::TDeviceParam* aParam,TUint* aOffset); |
|
143 TInt GetSurfaceManagerAttrib(RSurfaceManager::TSurfaceManagerAttrib* aAttrib,TInt* aValue); |
|
144 private: |
|
145 void GenerateSurfaceId(TSurfaceId& aId); |
|
146 TInt CreateSurfaceChunk(const RSurfaceManager::TSurfaceCreationAttributes& attribs); |
|
147 TInt ValidateAndCalculateChunkSize(RSurfaceManager::TSurfaceCreationAttributes& aAttribs, TInt& aOffset, |
|
148 TUint& aActualBufferSize, const TBool aNewChunk = EFalse); |
|
149 TInt ValidatePhysicalMemory(DChunk* aChunk, const RSurfaceManager::TSurfaceCreationAttributes& aAttribs, |
|
150 TUint aBuffersize, TUint32& aMapAttr, TBool &aIsContiguous); |
|
151 TSurface* FindSurfaceById(const TSurfaceId& aId); |
|
152 void CloseSurfaceHandlesForProcess(const DProcess* iProcess); |
|
153 TProcessListItem* FindConnectedProcess(const DProcess* aProcess); |
|
154 TInt FindHintKey(const RSurfaceManager::THintPair* aHints, TUint32 aKey) const; |
|
155 TBool SortHints(RSurfaceManager::THintPair* aHints, TInt aNumberOfHints) const; |
|
156 TInt InsertHintKey(RSurfaceManager::THintPair* aHints, const RSurfaceManager::THintPair& aHintPair) const; |
|
157 |
|
158 #ifdef GRAPHICS_SURFACEMANAGER_SYBORG |
|
159 TInt CreateMemory(); |
|
160 #endif |
|
161 |
|
162 private: |
|
163 TSurface* iSurfacesIndex[KMaxLists]; // A table with elements pointing to the head of each singly linked list |
|
164 NFastMutex iMutex; // Mutex to protect access to surface lists |
|
165 TProcessListItem* iConnectedProcesses; //reference counted list of processes connected to the driver |
|
166 |
|
167 #ifdef GRAPHICS_SURFACEMANAGER_SYBORG |
|
168 DVirtualHWMemoryManager* iVHWMemoryManager; |
|
169 #endif |
|
170 }; |
|
171 |
|
172 |
|
173 #endif |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |