|
1 // Copyright (c) 1999-2009 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 // Window server client side local header file |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __CLIENT_H__ |
|
19 #define __CLIENT_H__ |
|
20 |
|
21 #include <e32hashtab.h> |
|
22 |
|
23 #if defined(_DEBUG) && defined(__WINS__) |
|
24 //#define __AUTO_FLUSH //Define this for test purposes only, it hard codes auto flushing |
|
25 #endif |
|
26 |
|
27 /** Panics the client. This will result in the client thread being destroyed. */ |
|
28 GLREF_C void Panic(TW32Panic aPanic); |
|
29 GLREF_C void Assert(TW32Assert aPanic); |
|
30 |
|
31 class TReadDescriptorType; |
|
32 class TWriteDescriptorType; |
|
33 |
|
34 class RWsBuffer |
|
35 { |
|
36 friend class RWsSession; |
|
37 public: |
|
38 enum bufferSizes |
|
39 { |
|
40 EDefBufferSize=EClientBufferSize, |
|
41 EMinBufferSize=EClientBufferSize, |
|
42 EMaxBufferSize=EClientBufferMaxSize |
|
43 }; |
|
44 public: |
|
45 RWsBuffer(RWsSession *aSession); |
|
46 void Close(); |
|
47 void Destroy(); |
|
48 TInt Open(); |
|
49 TInt Connect(TUint32 handle); |
|
50 TInt WriteReplyWs(TUint opcode); |
|
51 TInt WriteReplyWs(const TAny *pData, TInt length,TUint opcode); |
|
52 TInt WriteReplyWs(const TAny *pData, TInt length, const TAny *pData2, TInt length2, TUint opcode); |
|
53 void SetBufferSizeL(TInt aBufSize); |
|
54 void SetMaxBufferSizeL(TInt aMaxBufSize); |
|
55 TInt Flush(const TIpcArgs* aIpcArgs=NULL,TBool aRequestFinish=EFalse); |
|
56 TBool SetAutoFlush(TBool aState); |
|
57 void Write(TInt handle,TUint opcode,const TAny *pData, TInt length,const TAny *pData2, TInt length2); |
|
58 void Write(TInt handle,TUint opcode,const TAny *buf, TInt bufLen); |
|
59 void Write(TInt handle,TUint opcode); |
|
60 TInt WriteReply(TInt handle,TUint opcode, const TIpcArgs* aIpcArgs=NULL); |
|
61 TInt WriteReply(TInt handle,TUint opcode,const TAny *buf, TInt bufLen, const TIpcArgs* aIpcArgs=NULL); |
|
62 TInt WriteReply(TInt handle,TUint opcode,const TAny *buf, TInt bufLen,const TAny *buf2, TInt buflen2, const TIpcArgs* aIpcArgs=NULL); |
|
63 TInt WriteReplyP(TInt aHandle,TUint aOpcode,const TWriteDescriptorType& aReplyBuffer); |
|
64 TInt WriteReplyP(TInt aHandle,TUint aOpcode,const TAny *aData,TInt aLength,const TWriteDescriptorType& aReplyBuffer); |
|
65 TInt WriteReplyP(TInt aHandle,TUint aOpcode,const TAny *aData1,TInt aLengthData1,const TAny *aData2,TInt aLengthData2,const TWriteDescriptorType& aReplyBuffer); |
|
66 TInt WriteReplyByProvidingRemoteReadAccess(TInt aHandle,TUint aOpcode,const TAny *aData, TInt aLength,const TReadDescriptorType& aRemoteReadBuffer); |
|
67 |
|
68 inline TInt BufferSize() const; |
|
69 inline TBool IsEmpty() const; |
|
70 inline RWsSession* Session() {return iSession;} |
|
71 static void FlushAllBuffers(TInt aBitmapHandle); |
|
72 void SetCallBack(); |
|
73 void CancelCallBack(); |
|
74 void AddToBitmapArray(TInt aBitmapHandle); |
|
75 |
|
76 void SetWsGraphicManager(CWsGraphic::CManager* aManager); |
|
77 static CWsGraphic::CManager* WsGraphicManager(); |
|
78 |
|
79 void AsyncRequest(TInt aHandle, TUint aOpcode, TRequestStatus& aStatus); |
|
80 |
|
81 void EnableWindowSizeCacheL(); |
|
82 inline TBool WindowSizeCacheEnabled() const; |
|
83 inline void MarkWindowSizeCacheDirty(TInt aHandle); |
|
84 inline void RefreshWindowSizeCache(TInt aHandle, const TSize& aNewSize); |
|
85 inline TInt CachedWindowSize(TInt aHandle, TSize& aSize); |
|
86 inline void DestroyWindowSizeCacheEntry(TInt aHandle); |
|
87 |
|
88 private: |
|
89 TInt DoWrite(TInt aHandle, TUint aOpcode, TBool aFlush, const TIpcArgs* aIpcArgs, const TAny* aData1=NULL, TInt aLength1=0, const TAny* aData2=NULL, TInt aLength2=0); |
|
90 inline void SetAndLimitMaxBufSize(TInt aMaxBufSize); |
|
91 void ReAllocBufferL(TInt aNewSize); |
|
92 TBool ReAllocBuffer(TInt aNewSize); |
|
93 void GrowBuffer(TInt aRequiredSpace, TInt aMsgSize); |
|
94 |
|
95 private: |
|
96 RWsSession *iSession; |
|
97 CWsGraphic::CManager* iManager; |
|
98 TBool iAutoFlush; |
|
99 TPtr8 iBuf; |
|
100 RWsBuffer *iNext; |
|
101 TInt iPreviousHandle; |
|
102 TInt iBufSize; // current buffer size, DoWrite can expand this up to iMaxBufize |
|
103 TInt iMaxBufSize; // maximum buffer size, set by SetBufferSizeL or SetMaxBufferSizeL |
|
104 private: //Added here as adding it to RWsSession breaks BC. |
|
105 TInt iDirectAcessCount; |
|
106 RArray<TInt> iBitmapArray; |
|
107 TBool iInvalidBitmapArray; |
|
108 |
|
109 class TWindowSizeCacheEntry |
|
110 { |
|
111 public: |
|
112 inline TWindowSizeCacheEntry(const TSize& aSize); |
|
113 public: |
|
114 TSize iSize; |
|
115 TBool iDirty; |
|
116 }; |
|
117 |
|
118 RHashMap<TInt, TWindowSizeCacheEntry>* iWindowSizeCache; |
|
119 }; |
|
120 |
|
121 |
|
122 inline TInt RWsBuffer::BufferSize() const |
|
123 {return(iBuf.MaxLength());} |
|
124 |
|
125 inline TBool RWsBuffer::IsEmpty() const |
|
126 {return iBuf.Length()==0;} |
|
127 |
|
128 inline RWsBuffer::TWindowSizeCacheEntry::TWindowSizeCacheEntry(const TSize& aSize) |
|
129 : iSize(aSize), iDirty(EFalse) |
|
130 { |
|
131 } |
|
132 |
|
133 inline TBool RWsBuffer::WindowSizeCacheEnabled() const |
|
134 { |
|
135 return iWindowSizeCache ? ETrue : EFalse; |
|
136 } |
|
137 |
|
138 inline void RWsBuffer::MarkWindowSizeCacheDirty(TInt aHandle) |
|
139 { |
|
140 __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure)); |
|
141 RWsBuffer::TWindowSizeCacheEntry* entry = iWindowSizeCache->Find(aHandle); |
|
142 if (entry != NULL) |
|
143 { |
|
144 entry->iDirty = ETrue; |
|
145 } |
|
146 } |
|
147 |
|
148 inline void RWsBuffer::RefreshWindowSizeCache(TInt aHandle, const TSize& aNewSize) |
|
149 { |
|
150 __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure)); |
|
151 RWsBuffer::TWindowSizeCacheEntry* entry = iWindowSizeCache->Find(aHandle); |
|
152 if (entry == NULL) |
|
153 { |
|
154 iWindowSizeCache->Insert(aHandle, RWsBuffer::TWindowSizeCacheEntry(aNewSize)); |
|
155 } |
|
156 else |
|
157 { |
|
158 entry->iSize = aNewSize; |
|
159 entry->iDirty = EFalse; |
|
160 } |
|
161 } |
|
162 |
|
163 inline TInt RWsBuffer::CachedWindowSize(TInt aHandle, TSize& aSize) |
|
164 { |
|
165 __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure)); |
|
166 RWsBuffer::TWindowSizeCacheEntry* entry = iWindowSizeCache->Find(aHandle); |
|
167 if ( entry && !(entry->iDirty) ) |
|
168 { |
|
169 aSize = entry->iSize; |
|
170 return KErrNone; |
|
171 } |
|
172 else |
|
173 { |
|
174 // return KErrNotFound when either entry not found for aHandle, or entry is dirty |
|
175 return KErrNotFound; |
|
176 } |
|
177 } |
|
178 |
|
179 inline void RWsBuffer::DestroyWindowSizeCacheEntry(TInt aHandle) |
|
180 { |
|
181 __ASSERT_ALWAYS(iWindowSizeCache != NULL, Assert(EW32AssertWindowSizeCacheFailure)); |
|
182 TInt err = iWindowSizeCache->Remove(aHandle); |
|
183 // If there is a window size cache entry, then err == KErrNone. |
|
184 // Otherwise, there isn't a size cache entry, and err == KErrNotFound. |
|
185 __ASSERT_DEBUG(err == KErrNone || err == KErrNotFound, Assert(EW32AssertWindowSizeCacheFailure)); |
|
186 } |
|
187 |
|
188 |
|
189 #endif |