sl@0: /** sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: /** sl@0: * @file sl@0: */ sl@0: sl@0: #ifndef __SURFACE_UTILITY__ sl@0: #define __SURFACE_UTILITY__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #define ENABLE_TEST_LOGGING sl@0: #define ALPHA_FIX_24BIT 0x7f //This forces a non-zero value into the X byte of 16MU color values sl@0: sl@0: #if defined(ENABLE_TEST_LOGGING) sl@0: #define LOG(X) RDebug::Printf X sl@0: #else sl@0: #define LOG(X) sl@0: #endif sl@0: sl@0: class TRgb; sl@0: class CFbsBitmap; sl@0: sl@0: class CSurfaceUtility : public CBase sl@0: { sl@0: public: sl@0: static CSurfaceUtility* NewL(CSurfaceUtility* aClone=NULL); sl@0: virtual ~CSurfaceUtility(); sl@0: TSize SurfaceSize(const TSurfaceId& aSurface); sl@0: void CreateSurfaceFromFileL(const TDesC& aFileName, TSurfaceId& aSurface); sl@0: TSurfaceId CreateSurfaceL(const TSize& aSize, TUidPixelFormat aPixelFormat, TInt aStride, TInt aBuffers = 1); sl@0: void FillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor); sl@0: void FillChunkL(TSurfaceId& aSurface, RChunk& aChunk, const TRgb& aColor, TInt aBufferNumber); sl@0: void FillRectangleL(TSurfaceId& aSurface, TPoint& aStartPos, TSize& aSize, const TRgb& aColor); sl@0: void FillRectangleNoUpdateL(TSurfaceId& aSurface, TPoint& aStartPos, TSize& aSize, const TRgb& aColor); sl@0: void GridFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLines); sl@0: void PatternFillSurfaceL(TSurfaceId& aSurface); sl@0: void FanFillSurfaceL(TSurfaceId& aSurface, const TRgb& aColor, const TRgb& aLinesTL,const TRgb& aLinesBR); sl@0: void LineFillSurfaceL(TSurfaceId& aSurface, const TRgb& aBackColor, const TRgb& aLineColor, TInt aPosition); sl@0: CFbsBitmap* EquivalentBitmapL(TSurfaceId& aSurface, CFbsBitmap* aCopyTo=NULL); sl@0: void DestroySurface(TSurfaceId& aSurface); sl@0: TBool DestroyAll(); sl@0: void SubmitUpdate(TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion, TInt aBufferNumber = 0); sl@0: void MapAndSubmitUpdateL(RChunk& aChunk, TInt aScreenNumber, const TSurfaceId& aSurface, const TRegion* aRegion); sl@0: void MapSurfaceL(const TSurfaceId& aSurface, RChunk& aChunk); sl@0: void CopyBitmapFromFileToSurfaceL(const TDesC& aFileName, const TSurfaceId& aSurface); sl@0: void ScaleBitmapFromFileToSurfaceL(const TDesC& aFileName, const TSurfaceId& aSurface); sl@0: void CopyBitmapSurfaceL(const CFbsBitmap* aBitmap, TSurfaceId& aSurface); sl@0: void CopyBitmapToSurfaceL(TSurfaceId& aSurface, const CFbsBitmap& aBitmap); sl@0: TInt PixelDataOffet(const TSurfaceId& aSurface); sl@0: TInt BytesPerPixelL(TUidPixelFormat aPixelFormat); sl@0: private: sl@0: CSurfaceUtility(CSurfaceUtility* aClone); sl@0: void ConstructL(); sl@0: sl@0: private: sl@0: RSurfaceManager iManager; sl@0: RSurfaceUpdateSession iSurfaceUpdateSession; sl@0: //This local object wraps the array operations in a heap switch sl@0: //The reason for providing this wrapper is to allow threads to share the surface manager surface ID list. sl@0: //In particular, the next test can attempt to release the previous test's surfaces if it paniced. sl@0: //Note that the presumption is that the owning thread will be paused, sl@0: //so there will be no thread interlock issues with it's heap manager. sl@0: class RHeapSurfaceArray sl@0: { sl@0: public: sl@0: typedef RArray Array; sl@0: RHeapSurfaceArray(RHeapSurfaceArray* aUseExternalArray=NULL); sl@0: sl@0: //Emulation of RArray entrypoints. Add more stub methods if required... sl@0: TSurfaceId& operator[](TUint aIndex); sl@0: void Close(); sl@0: TInt Count() const; sl@0: inline void Reset(); sl@0: void AppendL(const TSurfaceId &anEntry); sl@0: TInt Find(const TSurfaceId &anEntry) const; sl@0: void Remove(TInt anIndex); sl@0: sl@0: private: sl@0: static void PopHeap(void* mainheap); sl@0: static void SwitchHeapLC(RHeap* aNewHeap); sl@0: sl@0: Array iLocalArray; sl@0: Array* iUseArray; sl@0: RHeap &iExternalHeapRef; sl@0: } iSurfaces; sl@0: }; sl@0: sl@0: /** sl@0: CActiveListener provides the asynchronous operation sl@0: of an active object sl@0: */ sl@0: class CActiveListener : public CActive sl@0: { sl@0: public: sl@0: static CActiveListener* NewLC(); sl@0: ~CActiveListener(); sl@0: sl@0: void Initialize(); sl@0: TBool IsRequestCancelled(); sl@0: sl@0: private: sl@0: CActiveListener(); sl@0: sl@0: virtual void RunL(); sl@0: virtual void DoCancel(); sl@0: }; sl@0: sl@0: #endif // __SURFACE_UTILITY__ sl@0: