sl@0
|
1 |
/**
|
sl@0
|
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
* @file
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#ifndef __SURFACE_UTILITY__
|
sl@0
|
23 |
#define __SURFACE_UTILITY__
|
sl@0
|
24 |
|
sl@0
|
25 |
#include <e32base.h>
|
sl@0
|
26 |
#include <graphics/surface.h>
|
sl@0
|
27 |
#include <graphics/surfacemanager.h>
|
sl@0
|
28 |
#include <graphics/surfaceupdateclient.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
#define ENABLE_TEST_LOGGING
|
sl@0
|
31 |
#define ALPHA_FIX_24BIT 0x7f //This forces a non-zero value into the X byte of 16MU color values
|
sl@0
|
32 |
|
sl@0
|
33 |
#if defined(ENABLE_TEST_LOGGING)
|
sl@0
|
34 |
#define LOG(X) RDebug::Printf X
|
sl@0
|
35 |
#else
|
sl@0
|
36 |
#define LOG(X)
|
sl@0
|
37 |
#endif
|
sl@0
|
38 |
|
sl@0
|
39 |
class TRgb;
|
sl@0
|
40 |
class CFbsBitmap;
|
sl@0
|
41 |
|
sl@0
|
42 |
class CSurfaceUtility : public CBase
|
sl@0
|
43 |
{
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
static CSurfaceUtility* NewL(CSurfaceUtility* aClone=NULL);
|
sl@0
|
46 |
virtual ~CSurfaceUtility();
|
sl@0
|
47 |
TSize SurfaceSize(const TSurfaceId& aSurface);
|
sl@0
|
48 |
void CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface);
|
sl@0
|
49 |
TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers = 1);
|
sl@0
|
50 |
void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor);
|
sl@0
|
51 |
void FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber);
|
sl@0
|
52 |
void FillRectangleL(TSurfaceId& aSurface, TPoint& aStartPos, TSize& aSize, const TRgb& aColor);
|
sl@0
|
53 |
void FillRectangleNoUpdateL(TSurfaceId& aSurface, TPoint& aStartPos, TSize& aSize, const TRgb& aColor);
|
sl@0
|
54 |
void GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines);
|
sl@0
|
55 |
void PatternFillSurfaceL(TSurfaceId& aSurface);
|
sl@0
|
56 |
void FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL,const TRgb& aLinesBR);
|
sl@0
|
57 |
void LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition);
|
sl@0
|
58 |
CFbsBitmap* EquivalentBitmapL(TSurfaceId& aSurface, CFbsBitmap* aCopyTo=NULL);
|
sl@0
|
59 |
void DestroySurface(TSurfaceId& aSurface);
|
sl@0
|
60 |
TBool DestroyAll();
|
sl@0
|
61 |
void SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion, TInt aBufferNumber = 0);
|
sl@0
|
62 |
void MapAndSubmitUpdateL(RChunk& aChunk, TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion);
|
sl@0
|
63 |
void MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk);
|
sl@0
|
64 |
void CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, const TSurfaceId& aSurface);
|
sl@0
|
65 |
void ScaleBitmapFromFileToSurfaceL(const TDesC& aFileName, const TSurfaceId& aSurface);
|
sl@0
|
66 |
void CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface);
|
sl@0
|
67 |
void CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap);
|
sl@0
|
68 |
TInt PixelDataOffet(const TSurfaceId& aSurface);
|
sl@0
|
69 |
TInt BytesPerPixelL(TUidPixelFormat aPixelFormat);
|
sl@0
|
70 |
private:
|
sl@0
|
71 |
CSurfaceUtility(CSurfaceUtility* aClone);
|
sl@0
|
72 |
void ConstructL();
|
sl@0
|
73 |
|
sl@0
|
74 |
private:
|
sl@0
|
75 |
RSurfaceManager iManager;
|
sl@0
|
76 |
RSurfaceUpdateSession iSurfaceUpdateSession;
|
sl@0
|
77 |
//This local object wraps the array operations in a heap switch
|
sl@0
|
78 |
//The reason for providing this wrapper is to allow threads to share the surface manager surface ID list.
|
sl@0
|
79 |
//In particular, the next test can attempt to release the previous test's surfaces if it paniced.
|
sl@0
|
80 |
//Note that the presumption is that the owning thread will be paused,
|
sl@0
|
81 |
//so there will be no thread interlock issues with it's heap manager.
|
sl@0
|
82 |
class RHeapSurfaceArray
|
sl@0
|
83 |
{
|
sl@0
|
84 |
public:
|
sl@0
|
85 |
typedef RArray<TSurfaceId> Array;
|
sl@0
|
86 |
RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray=NULL);
|
sl@0
|
87 |
|
sl@0
|
88 |
//Emulation of RArray entrypoints. Add more stub methods if required...
|
sl@0
|
89 |
TSurfaceId& operator[](TUint aIndex);
|
sl@0
|
90 |
void Close();
|
sl@0
|
91 |
TInt Count() const;
|
sl@0
|
92 |
inline void Reset();
|
sl@0
|
93 |
void AppendL(const TSurfaceId &anEntry);
|
sl@0
|
94 |
TInt Find(const TSurfaceId &anEntry) const;
|
sl@0
|
95 |
void Remove(TInt anIndex);
|
sl@0
|
96 |
|
sl@0
|
97 |
private:
|
sl@0
|
98 |
static void PopHeap(void* mainheap);
|
sl@0
|
99 |
static void SwitchHeapLC(RHeap* aNewHeap);
|
sl@0
|
100 |
|
sl@0
|
101 |
Array iLocalArray;
|
sl@0
|
102 |
Array* iUseArray;
|
sl@0
|
103 |
RHeap &iExternalHeapRef;
|
sl@0
|
104 |
} iSurfaces;
|
sl@0
|
105 |
};
|
sl@0
|
106 |
|
sl@0
|
107 |
/**
|
sl@0
|
108 |
CActiveListener provides the asynchronous operation
|
sl@0
|
109 |
of an active object
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
class CActiveListener : public CActive
|
sl@0
|
112 |
{
|
sl@0
|
113 |
public:
|
sl@0
|
114 |
static CActiveListener* NewLC();
|
sl@0
|
115 |
~CActiveListener();
|
sl@0
|
116 |
|
sl@0
|
117 |
void Initialize();
|
sl@0
|
118 |
TBool IsRequestCancelled();
|
sl@0
|
119 |
|
sl@0
|
120 |
private:
|
sl@0
|
121 |
CActiveListener();
|
sl@0
|
122 |
|
sl@0
|
123 |
virtual void RunL();
|
sl@0
|
124 |
virtual void DoCancel();
|
sl@0
|
125 |
};
|
sl@0
|
126 |
|
sl@0
|
127 |
#endif // __SURFACE_UTILITY__
|
sl@0
|
128 |
|