sl@0
|
1 |
// Copyright (c) 2008-2009 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 |
@publishedPartner
|
sl@0
|
19 |
@prototype
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#ifndef EXAMPLERASTERIZER_H
|
sl@0
|
23 |
#define EXAMPLERASTERIZER_H
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
#include <graphics/fbsrasterizer.h>
|
sl@0
|
27 |
#include <graphics/fbsrasterizerclearcache.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
|
sl@0
|
30 |
class RMemReadStream;
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
const TUid KUidExampleExtendedBitmap = {0x10285A78};
|
sl@0
|
34 |
const TInt KMaxRecentBmpCacheSize = 0x40000; // 256 KB
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
/** Example implementation of a rasterizer that is used to generate pixel
|
sl@0
|
38 |
data for extended bitmaps of type KUidExampleExtendedBitmap.
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
class CExampleRasterizer : public CFbsRasterizer, public MFbsRasterizerClearCache
|
sl@0
|
41 |
{
|
sl@0
|
42 |
public:
|
sl@0
|
43 |
CExampleRasterizer();
|
sl@0
|
44 |
~CExampleRasterizer();
|
sl@0
|
45 |
|
sl@0
|
46 |
// From CFbsRasterizer
|
sl@0
|
47 |
void BeginBitmap(TInt64 aBitmapId, const TBitmapDesc& aBitmapDesc, const TRegion* aRegionOfInterest);
|
sl@0
|
48 |
void EndBitmap(TInt64 aBitmapId);
|
sl@0
|
49 |
const TUint32* ScanLine(TInt64 aBitmapId, const TPoint& aPixel, TInt aLength);
|
sl@0
|
50 |
TInt GetInterface(TUid aInterfaceId, TAny*& aInterface);
|
sl@0
|
51 |
|
sl@0
|
52 |
// From MFbsRasterizerClearCache
|
sl@0
|
53 |
void ClearCache();
|
sl@0
|
54 |
|
sl@0
|
55 |
private:
|
sl@0
|
56 |
/** Class for holding information about an extended bitmap registered with this rasterizer.
|
sl@0
|
57 |
The buffer to store the pre-rendered pixels is allocated in the same heap cell, after the
|
sl@0
|
58 |
instance variables, by using the overload of operator new with an extra size parameter.
|
sl@0
|
59 |
*/
|
sl@0
|
60 |
class CRegisteredBitmap : public CBase
|
sl@0
|
61 |
{
|
sl@0
|
62 |
public:
|
sl@0
|
63 |
CRegisteredBitmap(TInt64 aBitmapId, const TBitmapDesc& aBitmapDesc, TInt aBufLength);
|
sl@0
|
64 |
~CRegisteredBitmap();
|
sl@0
|
65 |
TInt Draw(RMemReadStream& aReadStream, const TRegion* aRegionOfInterest);
|
sl@0
|
66 |
TUint8* Buffer();
|
sl@0
|
67 |
|
sl@0
|
68 |
public:
|
sl@0
|
69 |
const TInt64 iBitmapId;
|
sl@0
|
70 |
const TSize iSizeInPixels;
|
sl@0
|
71 |
const TDisplayMode iDispMode;
|
sl@0
|
72 |
const TUid iDataType;
|
sl@0
|
73 |
const TInt iBufLength;
|
sl@0
|
74 |
TDblQueLink iLink;
|
sl@0
|
75 |
/** The number of times the bitmap with the ID aBitmapId is currently registered with this
|
sl@0
|
76 |
rasterizer or zero for recently used bitmaps.
|
sl@0
|
77 |
*/
|
sl@0
|
78 |
TInt iRefCount;
|
sl@0
|
79 |
/** Whether the whole bitmap has been rasterized into the buffer.
|
sl@0
|
80 |
*/
|
sl@0
|
81 |
TBool iWhole;
|
sl@0
|
82 |
};
|
sl@0
|
83 |
|
sl@0
|
84 |
private:
|
sl@0
|
85 |
CRegisteredBitmap* RegisteredBitmap(TInt64 aBitmapId);
|
sl@0
|
86 |
CRegisteredBitmap* RecentBitmap(TInt64 aBitmapId);
|
sl@0
|
87 |
static TInt IdleFunction(TAny* aPtr);
|
sl@0
|
88 |
|
sl@0
|
89 |
private:
|
sl@0
|
90 |
/** List of currently registered extended bitmaps, the key is the bitmap id.
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
TDblQue<CRegisteredBitmap> iRegisteredBmps;
|
sl@0
|
93 |
/** List of recently used extended bitmaps, the key is the bitmap id.
|
sl@0
|
94 |
*/
|
sl@0
|
95 |
TDblQue<CRegisteredBitmap> iRecentBmps;
|
sl@0
|
96 |
/** Total size in bytes of the pre-rendered buffers for all the recently used extended bitmaps.
|
sl@0
|
97 |
*/
|
sl@0
|
98 |
TInt iTotalRecentBmpSize;
|
sl@0
|
99 |
/** An idle-time active object to clean up the recently used extended bitmaps.
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
CIdle* iIdle;
|
sl@0
|
102 |
};
|
sl@0
|
103 |
|
sl@0
|
104 |
#endif // EXAMPLERASTERIZER_H
|