os/graphics/graphicscomposition/openwfcompositionengine/test/tscreeninterface/streamutility.h
First public contribution.
1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
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:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Materials.
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.
29 #ifndef __STREAM_UTILITY__
30 #define __STREAM_UTILITY__
33 #include <graphics/surface.h>
34 #include <graphics/surfacemanager.h>
35 #include <graphics/surfaceupdateclient.h>
36 #define ENABLE_TEST_LOGGING
38 #if defined(ENABLE_TEST_LOGGING)
39 #define LOG(X) RDebug::Printf X
47 class CStreamUtility : public CBase
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);
61 RSurfaceManager& Manager() {return iManager;}
63 CStreamUtility(CStreamUtility* aClone);
67 RSurfaceManager iManager;
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
78 typedef RArray<SymbianStreamType> Array;
79 RHeapStreamArray(RHeapStreamArray* aUseExternalArray=NULL);
81 //Emulation of RArray entrypoints. Add more stub methods if required...
82 SymbianStreamType& operator[](TUint aIndex);
86 void AppendL(const SymbianStreamType &anEntry);
87 TInt Find(const SymbianStreamType &anEntry) const;
88 void Remove(TInt anIndex);
91 static void PopHeap(void* mainheap);
95 RHeap &iExternalHeapRef;
99 #endif // __STREAM_UTILITY__