os/graphics/graphicscomposition/openwftest/inc/surfaceutility.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
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
*/
sl@0
    19
sl@0
    20
#ifndef __SURFACE_UTILITY__
sl@0
    21
#define __SURFACE_UTILITY__
sl@0
    22
sl@0
    23
#include <e32base.h>
sl@0
    24
#include <graphics/surface.h>
sl@0
    25
#include <graphics/surfacemanager.h>
sl@0
    26
#include <graphics/surfaceupdateclient.h>
sl@0
    27
#include <graphics/symbianstream.h>
sl@0
    28
#include <WF/wfc.h>
sl@0
    29
sl@0
    30
//#define ENABLE_TEST_LOGGING
sl@0
    31
#if defined(ENABLE_TEST_LOGGING)
sl@0
    32
#define LOG(X)	RDebug::Printf X
sl@0
    33
#define LOGL(X)	RDebug::Print X
sl@0
    34
#else
sl@0
    35
#define LOG(X)
sl@0
    36
#define LOGL(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
    CSurfaceUtility();
sl@0
    46
	static CSurfaceUtility* NewL();
sl@0
    47
	virtual ~CSurfaceUtility();
sl@0
    48
	TSize SurfaceSize(const TSurfaceId& aSurface);
sl@0
    49
	TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TBool aContiguous, TInt aBuffers);
sl@0
    50
	TInt BytesPerPixelL(TUidPixelFormat aPixelFormat);
sl@0
    51
	void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor);
sl@0
    52
	void FillSurfaceL(TSurfaceId& aSurface, TInt aBuffer, const TRgb& aColor);
sl@0
    53
	void DestroySurface(TSurfaceId& aSurface);
sl@0
    54
	TBool DestroyAll();
sl@0
    55
    TBool CheckRectColor(const TSurfaceId& aSurface, TRect& aRect, TInt aNumOfBuffer, const TRgb& aExpectedColor, TInt aTolerance);
sl@0
    56
    TBool SaveResultImageTGAL(const TSurfaceId& aOnscreenSurface, TInt aBufferNumber, TDesC& aDestination);
sl@0
    57
    TInt SubmitUpdate(const TSurfaceId& aSurface, TInt aBufferNumber, const TRegion* aRegion = NULL);
sl@0
    58
    void NotifyWhenDisplayed(TRequestStatus& aStatusDisplayed, TTimeStamp& aTimeStamp);
sl@0
    59
    void NotifyWhenDisplayedXTimes(TInt aCount, TRequestStatus& aStatusDisplayedX);
sl@0
    60
    void NotifyWhenAvailable(TRequestStatus& aStatusAvailable);	
sl@0
    61
	RSurfaceManager& Manager()	{return iManager;}
sl@0
    62
	RSurfaceUpdateSession& Session()	{return iSurfaceUpdateSession;}
sl@0
    63
	SymbianStreamType GetOnScreenStream(WFCDevice aDev, WFCContext aContext);
sl@0
    64
	TBool CreateImagePath(TDesC& aDir);
sl@0
    65
sl@0
    66
private:
sl@0
    67
	void ConstructL();
sl@0
    68
    TInt GetHeader(const TSurfaceId& aSurface, RSurfaceManager::TInfoBuf& aInfo);
sl@0
    69
    TUint8* GetBufferPointerL(const TSurfaceId& aSurface, TInt aNumOfBuffer, RChunk& aChunk);
sl@0
    70
    TRgb GetPixelL(RSurfaceManager::TInfoBuf& aInfo, TAny* aPixelData, TPoint aPosition);
sl@0
    71
sl@0
    72
private:
sl@0
    73
	RSurfaceManager iManager;
sl@0
    74
	RSurfaceUpdateSession iSurfaceUpdateSession;
sl@0
    75
sl@0
    76
	//This local object wraps the array operations in a heap switch
sl@0
    77
	//The reason for providing this wrapper is to allow threads to share the surface manager surface ID list.
sl@0
    78
	//In particular, the next test can attempt to release the previous test's surfaces if it paniced. 
sl@0
    79
	//Note that the presumption is that the owning thread will be paused, 
sl@0
    80
	//so there will be no thread interlock issues with it's heap manager.
sl@0
    81
	class RHeapSurfaceArray
sl@0
    82
		{
sl@0
    83
		public:
sl@0
    84
		typedef RArray<TSurfaceId>	Array;
sl@0
    85
		RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray=NULL);
sl@0
    86
sl@0
    87
		//Emulation of RArray entrypoints. Add more stub methods if required...
sl@0
    88
		TSurfaceId& operator[](TUint aIndex);
sl@0
    89
		void Close();
sl@0
    90
		TInt Count() const;
sl@0
    91
		inline void Reset();
sl@0
    92
		void AppendL(const TSurfaceId &anEntry);
sl@0
    93
		TInt Find(const TSurfaceId &anEntry) const;
sl@0
    94
		void Remove(TInt anIndex);
sl@0
    95
		
sl@0
    96
		private:
sl@0
    97
		static void PopHeap(void* mainheap);
sl@0
    98
		
sl@0
    99
		Array iLocalArray;
sl@0
   100
		Array* iUseArray;
sl@0
   101
		RHeap &iExternalHeapRef;
sl@0
   102
		}	iSurfaces;
sl@0
   103
	};
sl@0
   104
sl@0
   105
#endif // __SURFACE_UTILITY__
sl@0
   106