|
1 /** |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #ifndef __SURFACE_UTILITY__ |
|
25 #define __SURFACE_UTILITY__ |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <graphics/surface.h> |
|
29 #include <graphics/surfacemanager.h> |
|
30 #include <graphics/surfaceupdateclient.h> |
|
31 |
|
32 #define ENABLE_TEST_LOGGING |
|
33 #define ALPHA_FIX_24BIT 0x7f //This forces a non-zero value into the X byte of 16MU color values |
|
34 |
|
35 #if defined(ENABLE_TEST_LOGGING) |
|
36 #define LOG(X) RDebug::Printf X |
|
37 #else |
|
38 #define LOG(X) |
|
39 #endif |
|
40 |
|
41 class TRgb; |
|
42 class CFbsBitmap; |
|
43 |
|
44 class CSurfaceUtility : public CBase |
|
45 { |
|
46 public: |
|
47 static CSurfaceUtility* NewL(CSurfaceUtility* aClone=NULL); |
|
48 virtual ~CSurfaceUtility(); |
|
49 TSize SurfaceSize(const TSurfaceId& aSurface); |
|
50 TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers = 1); |
|
51 TInt BytesPerPixelL(TUidPixelFormat aPixelFormat); |
|
52 void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor); |
|
53 void FillSurfaceL(TSurfaceId& aSurface, TInt aBuffer, const TRgb& aColor); |
|
54 void DestroySurface(TSurfaceId& aSurface); |
|
55 TBool DestroyAll(); |
|
56 TInt SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, TInt aBufferNumber,TInt aNullRegion); |
|
57 TInt SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, TInt aBufferNumber,const TRegion* aRegion = NULL); |
|
58 TInt SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion, TInt aBufferNumber = 0); |
|
59 void NotifyWhenDisplayed(TRequestStatus& aStatusDisplayed, TTimeStamp& aTimeStamp); |
|
60 void NotifyWhenDisplayedXTimes(TInt aCount, TRequestStatus& aStatusDisplayedX); |
|
61 void NotifyWhenAvailable(TRequestStatus& aStatusAvailable); |
|
62 //Native Stream |
|
63 void FillNativeStreamSurfaceL(TSurfaceId& aSurface, TUint8* aBufferPtr, const TRgb& aColor); |
|
64 TBool CompareSurfacesL(TSurfaceId& aSurface, TInt aBuffer, TSurfaceId& aStreamSurface, TUint8* aBufferPtr); |
|
65 |
|
66 void SetAutoUpdateScreenNum(TInt aScreenNum); |
|
67 RSurfaceManager& Manager() {return iManager;} |
|
68 RSurfaceUpdateSession& Session() {return iSurfaceUpdateSession;} |
|
69 private: |
|
70 CSurfaceUtility(CSurfaceUtility* aClone); |
|
71 void ConstructL(); |
|
72 |
|
73 private: |
|
74 RSurfaceManager iManager; |
|
75 RSurfaceUpdateSession iSurfaceUpdateSession; |
|
76 TInt iScreenNum; |
|
77 //This local object wraps the array operations in a heap switch |
|
78 //The reason for providing this wrapper is to allow threads to share the surface manager surface ID list. |
|
79 //In particular, the next test can attempt to release the previous test's surfaces if it paniced. |
|
80 //Note that the presumption is that the owning thread will be paused, |
|
81 //so there will be no thread interlock issues with it's heap manager. |
|
82 class RHeapSurfaceArray |
|
83 { |
|
84 public: |
|
85 typedef RArray<TSurfaceId> Array; |
|
86 RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray=NULL); |
|
87 |
|
88 //Emulation of RArray entrypoints. Add more stub methods if required... |
|
89 TSurfaceId& operator[](TUint aIndex); |
|
90 void Close(); |
|
91 TInt Count() const; |
|
92 inline void Reset(); |
|
93 void AppendL(const TSurfaceId &anEntry); |
|
94 TInt Find(const TSurfaceId &anEntry) const; |
|
95 void Remove(TInt anIndex); |
|
96 |
|
97 private: |
|
98 static void PopHeap(void* mainheap); |
|
99 static void SwitchHeapLC(RHeap* aNewHeap); |
|
100 |
|
101 Array iLocalArray; |
|
102 Array* iUseArray; |
|
103 RHeap &iExternalHeapRef; |
|
104 } iSurfaces; |
|
105 }; |
|
106 |
|
107 #endif // __SURFACE_UTILITY__ |
|
108 |