|
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // |
|
3 // Permission is hereby granted, free of charge, to any person obtaining a |
|
4 // copy of this software and/or associated documentation files (the |
|
5 // "Materials"), to deal in the Materials without restriction, including |
|
6 // without limitation the rights to use, copy, modify, merge, publish, |
|
7 // distribute, sublicense, and/or sell copies of the Materials, and to |
|
8 // permit persons to whom the Materials are furnished to do so, subject to |
|
9 // the following conditions: |
|
10 // |
|
11 // The above copyright notice and this permission notice shall be included |
|
12 // in all copies or substantial portions of the Materials. |
|
13 // |
|
14 // THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
18 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
19 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
20 // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 // |
|
22 // Description: |
|
23 // |
|
24 |
|
25 /** |
|
26 @file |
|
27 */ |
|
28 |
|
29 #ifndef __STREAM_UTILITY__ |
|
30 #define __STREAM_UTILITY__ |
|
31 |
|
32 #include <e32base.h> |
|
33 #include <graphics/surface.h> |
|
34 #include <graphics/surfacemanager.h> |
|
35 #include <graphics/surfaceupdateclient.h> |
|
36 #define ENABLE_TEST_LOGGING |
|
37 |
|
38 #if defined(ENABLE_TEST_LOGGING) |
|
39 #define LOG(X) RDebug::Printf X |
|
40 #else |
|
41 #define LOG(X) |
|
42 #endif |
|
43 |
|
44 class TRgb; |
|
45 class CFbsBitmap; |
|
46 |
|
47 class CStreamUtility : public CBase |
|
48 { |
|
49 public: |
|
50 CStreamUtility(); |
|
51 static CStreamUtility* NewL(); |
|
52 virtual ~CStreamUtility(); |
|
53 TSize StreamSize(const SymbianStreamType aStream); |
|
54 SymbianStreamType CreateStreamL(const TSize& aSize, TUidPixelFormat aPixelFormat, |
|
55 TInt aStride, TSurfaceId& aReturnSurface, TBool aContiguous, TInt aBuffers = 1); |
|
56 TInt BytesPerPixelL(const SymbianStreamType aStream); |
|
57 TInt BytesPerPixelL(TUidPixelFormat aPixelFormat); |
|
58 void FillStreamL(SymbianStreamType aStream, const TRgb& aColor); |
|
59 void DestroyStream(SymbianStreamType aStream); |
|
60 TBool DestroyAll(); |
|
61 RSurfaceManager& Manager() {return iManager;} |
|
62 private: |
|
63 CStreamUtility(CStreamUtility* aClone); |
|
64 void ConstructL(); |
|
65 |
|
66 private: |
|
67 RSurfaceManager iManager; |
|
68 TInt iScreenNum; |
|
69 |
|
70 //This local object wraps the array operations in a heap switch |
|
71 //The reason for providing this wrapper is to allow threads to share the surface manager stream ID list. |
|
72 //In particular, the next test can attempt to release the previous test's stream if it paniced. |
|
73 //Note that the presumption is that the owning thread will be paused, |
|
74 //so there will be no thread interlock issues with it's heap manager. |
|
75 class RHeapStreamArray |
|
76 { |
|
77 public: |
|
78 typedef RArray<SymbianStreamType> Array; |
|
79 RHeapStreamArray(RHeapStreamArray* aUseExternalArray=NULL); |
|
80 |
|
81 //Emulation of RArray entrypoints. Add more stub methods if required... |
|
82 SymbianStreamType& operator[](TUint aIndex); |
|
83 void Close(); |
|
84 TInt Count() const; |
|
85 inline void Reset(); |
|
86 void AppendL(const SymbianStreamType &anEntry); |
|
87 TInt Find(const SymbianStreamType &anEntry) const; |
|
88 void Remove(TInt anIndex); |
|
89 |
|
90 private: |
|
91 static void PopHeap(void* mainheap); |
|
92 |
|
93 Array iLocalArray; |
|
94 Array* iUseArray; |
|
95 RHeap &iExternalHeapRef; |
|
96 } iStreams; |
|
97 }; |
|
98 |
|
99 #endif // __STREAM_UTILITY__ |