memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperFbServ.h
changeset 0 a03f92240627
child 20 ca8a1b6995f6
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MEMSPYENGINEHELPERFBSERV_H
       
    19 #define MEMSPYENGINEHELPERFBSERV_H
       
    20 
       
    21 // System includes
       
    22 #include <e32base.h>
       
    23 #include <badesca.h>
       
    24 #include <fbs.h>
       
    25 #include <bitmap.h>
       
    26 
       
    27 // Classes referenced
       
    28 class CMemSpyEngine;
       
    29 class CMemSpyThread;
       
    30 class TMemSpyDriverChunkInfo;
       
    31 class TMemSpyEngineFBServBitmapInfo;
       
    32 
       
    33 // Constants
       
    34 const TInt KMemSpyEngineDefaultBitmapCreationBatchSize = 4; // Create 4 bitmaps (asynchronously) at a time
       
    35 
       
    36 
       
    37 
       
    38 
       
    39 NONSHARABLE_CLASS( CMemSpyEngineHelperFbServ ) : public CBase
       
    40     {
       
    41 public: // Construct/destruct
       
    42     static CMemSpyEngineHelperFbServ* NewL( CMemSpyEngine& aEngine );
       
    43     ~CMemSpyEngineHelperFbServ();
       
    44 
       
    45 private: // Internal construction
       
    46     CMemSpyEngineHelperFbServ( CMemSpyEngine& aEngine );
       
    47     void ConstructL();
       
    48 
       
    49 public: // API
       
    50     IMPORT_C void GetArrayOfBitmapHandlesL( RArray<TInt>& aHandles );
       
    51 
       
    52 public: // API - but not exported
       
    53     void GetArrayOfBitmapHandlesL( RArray<TInt>& aHandles, TInt& aBitmapConCount, TInt& aFontConCount );
       
    54     static TBool IsLargeBitmapChunk( const TMemSpyDriverChunkInfo& aChunkInfo );
       
    55     static TBool IsSharedBitmapChunk( const TMemSpyDriverChunkInfo& aChunkInfo );
       
    56     static void GetBitmapInfoL( TInt aHandle, TMemSpyEngineFBServBitmapInfo& aInfo );
       
    57     static CFbsBitmap* GetBitmapInfoLC( TInt aHandle, TMemSpyEngineFBServBitmapInfo& aInfo );
       
    58 
       
    59 private: // Internal structures
       
    60     class CBitmapObject : public CObject
       
    61         {
       
    62     public:
       
    63         CBitmapObject* iThisPointer;
       
    64     public:
       
    65         CBase* iTop; // actually CFbTop*
       
    66         CBitwiseBitmap* iAddressPointer;
       
    67         TInt iHandle;
       
    68         CBitmapObject* iCleanBitmap;
       
    69         };
       
    70 
       
    71 private: // Internal methods
       
    72     CMemSpyThread& IdentifyFbServThreadL();
       
    73     HBufC8* LocateCFbTopHeapCellDataLC( CMemSpyThread& aFbServThread, TAny*& aCellAddress );
       
    74     HBufC8* LocateBitmapArrayHeapCellDataLC( TAny*& aArrayCellAddress, TInt aArrayAllocCount );
       
    75     void ReadCObjectConInfoL( TAny* aCellAddress, RArray<TAny*>& aContainerObjects, TInt& aCount, TInt& aAllocated );
       
    76     static void ParseCellDataAndExtractHandlesL( const TDesC8& aData, RArray<TInt>& aHandles, TInt aArrayEntryCount );
       
    77     static TBool VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapSize );
       
    78     static TUint OffsetToCObjectConBitmapCon();
       
    79     static TUint OffsetToCObjectConFontCon();
       
    80     static TUint OffsetToBitmapHandleArray();
       
    81     CBitmapObject* GetBitmapObjectLC( TAny* aAddress );
       
    82 
       
    83 private: // Data members
       
    84     CMemSpyEngine& iEngine;
       
    85     };
       
    86 
       
    87 
       
    88 
       
    89 
       
    90 
       
    91 
       
    92 
       
    93 
       
    94 NONSHARABLE_CLASS( CMemSpyEngineFbServBitmap ) : public CDesCArrayFlat
       
    95     {
       
    96 public: // Construct/destruct
       
    97     IMPORT_C static CMemSpyEngineFbServBitmap* NewLC( TInt aHandle );
       
    98     IMPORT_C ~CMemSpyEngineFbServBitmap();
       
    99 
       
   100 private: // Internal construction
       
   101     CMemSpyEngineFbServBitmap();
       
   102     void ConstructL( TInt aHandle );
       
   103 
       
   104 public: // API
       
   105     TInt BitmapSizeInBytes() const;
       
   106     IMPORT_C const TDesC& Caption() const;
       
   107     IMPORT_C CFbsBitmap& Bitmap();
       
   108     IMPORT_C const CFbsBitmap& Bitmap() const;
       
   109     IMPORT_C TInt Handle() const;
       
   110     IMPORT_C void OutputDataL( CMemSpyEngine& aEngine ) const;
       
   111     IMPORT_C static void OutputDataColumnsL( CMemSpyEngine& aEngine );
       
   112     IMPORT_C void GetExportableFileNameL( TDes& aAppendName ) const;
       
   113 
       
   114 public: // But not exported
       
   115     static void GetExportableFileNameL( const TMemSpyEngineFBServBitmapInfo& aInfo, TDes& aAppendName );
       
   116 
       
   117 private: // Internal
       
   118     void PrepareItemsL();
       
   119 
       
   120 private: 
       
   121     static void GetFileCompressionTypeAsString( TBitmapfileCompression aType, TDes& aString );
       
   122 
       
   123 private: // Data members
       
   124     CFbsBitmap* iBitmap;
       
   125     HBufC* iCaption;
       
   126     };
       
   127 
       
   128 
       
   129 
       
   130 
       
   131 
       
   132 
       
   133 
       
   134 
       
   135 
       
   136 
       
   137 class MMemSpyEngineFbSerbBitmapArrayObserver
       
   138     {
       
   139 public:
       
   140     enum TEvent
       
   141         {
       
   142         EBitmapItemsCreated = 0,
       
   143         EBitmapArrayConstructionComplete
       
   144         };
       
   145 
       
   146 public: // From MMemSpyEngineFbSerbBitmapArrayObserver
       
   147     virtual void HandleFbServBitmapArrayEventL( TEvent aEvent ) = 0;
       
   148     };
       
   149 
       
   150 
       
   151 
       
   152 
       
   153 
       
   154 
       
   155 
       
   156 
       
   157 
       
   158 
       
   159 
       
   160 
       
   161 NONSHARABLE_CLASS( CMemSpyEngineFbServBitmapArray ) : public CActive, public MDesCArray
       
   162     {
       
   163 public: // Construct/destruct
       
   164     IMPORT_C static CMemSpyEngineFbServBitmapArray* NewL( const RArray<TInt>& aBitmapHandles );
       
   165     IMPORT_C static CMemSpyEngineFbServBitmapArray* NewL( TInt aPriority, const RArray<TInt>& aBitmapHandles, MMemSpyEngineFbSerbBitmapArrayObserver& aObserver, TInt aGranularity = KMemSpyEngineDefaultBitmapCreationBatchSize );
       
   166     IMPORT_C ~CMemSpyEngineFbServBitmapArray();
       
   167 
       
   168 private: // Internal construction
       
   169     CMemSpyEngineFbServBitmapArray( const RArray<TInt>& aBitmapHandles );
       
   170     CMemSpyEngineFbServBitmapArray( TInt aPriority, const RArray<TInt>& aBitmapHandles, MMemSpyEngineFbSerbBitmapArrayObserver& aObserver, TInt aGranularity );
       
   171     void ConstructL();
       
   172 
       
   173 public: // API
       
   174     IMPORT_C TInt Count() const;
       
   175     IMPORT_C CMemSpyEngineFbServBitmap& At( TInt aIndex );
       
   176     IMPORT_C const CMemSpyEngineFbServBitmap& At( TInt aIndex ) const;
       
   177     IMPORT_C CMemSpyEngineFbServBitmap& BitmapByHandleL( TInt aHandle );
       
   178     IMPORT_C TInt BitmapIndexByHandle( TInt aHandle ) const;
       
   179 
       
   180 public: // From MDesCArray
       
   181     IMPORT_C TInt MdcaCount() const;
       
   182     IMPORT_C TPtrC MdcaPoint( TInt aIndex ) const;
       
   183 
       
   184 private: // From CActive
       
   185     void RunL();
       
   186     void DoCancel();
       
   187     TInt RunError( TInt aError );
       
   188 
       
   189 private: // Internal
       
   190     void CompleteSelf();
       
   191     void CreateBitmapL( TInt aHandle );
       
   192     void SortBySizeL();
       
   193     static TInt CompareBySize( const CMemSpyEngineFbServBitmap& aLeft, const CMemSpyEngineFbServBitmap& aRight );
       
   194 
       
   195 private: // Data members
       
   196     const RArray<TInt>& iBitmapHandles;
       
   197     MMemSpyEngineFbSerbBitmapArrayObserver* iObserver;
       
   198     const TInt iGranularity;
       
   199 
       
   200     // Transient
       
   201     TInt iIndex;
       
   202 
       
   203     // Owned
       
   204     RPointerArray< CMemSpyEngineFbServBitmap > iBitmaps;
       
   205     };
       
   206 
       
   207 
       
   208 
       
   209 
       
   210 
       
   211 
       
   212 
       
   213 class TMemSpyEngineFBServBitmapInfo
       
   214     {
       
   215 public:
       
   216     inline TMemSpyEngineFBServBitmapInfo()
       
   217         : iHandle( 0 ), iSizeInPixels( 0, 0 ), iCompressionType( ENoBitmapCompression ),
       
   218         iSizeInBytes( 0 ), iDisplayMode( 0 ), iBitsPerPixel( 0 ), iFlags( TMemSpyEngineFBServBitmapInfo::EFlagsNone )
       
   219         {}
       
   220 
       
   221 public: // Enumerations
       
   222     enum TFlags
       
   223         {
       
   224         EFlagsNone = 0,
       
   225         EFlagsIsRomBitmap = 1,
       
   226         EFlagsIsMonochrome = 2,
       
   227         EFlagsIsLarge = 4,
       
   228         EFlagsIsCompressedInRam = 8,
       
   229         };
       
   230 
       
   231 public: // Data members
       
   232     TInt iHandle;
       
   233     TSize iSizeInPixels;
       
   234     TBitmapfileCompression iCompressionType;
       
   235     TInt iSizeInBytes;
       
   236     TInt8 iDisplayMode;
       
   237     TInt8 iBitsPerPixel;
       
   238     TUint16 iFlags;
       
   239     TInt iColor;
       
   240     };
       
   241 
       
   242 
       
   243 #endif