|
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 0xffU //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 void CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface); |
|
51 TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers = 1); |
|
52 TInt BytesPerPixelL(TUidPixelFormat aPixelFormat); |
|
53 void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor); |
|
54 void FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber); |
|
55 void FillRectangleL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor); |
|
56 void FillRectangleNoUpdateL(TSurfaceId& aSurface, const TPoint& aStartPos, const TSize& aSize, const TRgb& aColor); |
|
57 void GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines); |
|
58 void PatternFillSurfaceL(TSurfaceId& aSurface); |
|
59 void FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL,const TRgb& aLinesBR); |
|
60 void LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition); |
|
61 CFbsBitmap* EquivalentBitmapL(TSurfaceId& aSurface, CFbsBitmap* aCopyTo=NULL); |
|
62 void DestroySurface(TSurfaceId& aSurface); |
|
63 TBool DestroyAll(); |
|
64 void SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion, TInt aBufferNumber = 0); |
|
65 void MapAndSubmitUpdateL(RChunk& aChunk, TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion); |
|
66 void MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk); |
|
67 void CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, TSurfaceId& aSurface); |
|
68 void CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface); |
|
69 void CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap); |
|
70 private: |
|
71 CSurfaceUtility(CSurfaceUtility* aClone); |
|
72 void ConstructL(); |
|
73 |
|
74 private: |
|
75 RSurfaceManager iManager; |
|
76 RSurfaceUpdateSession iSurfaceUpdateSession; |
|
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 |