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