26 #include <graphics/wsgraphicdrawer.h> |
26 #include <graphics/wsgraphicdrawer.h> |
27 #include <graphics/wsgraphicscontext.h> |
27 #include <graphics/wsgraphicscontext.h> |
28 #include <nvg.h> |
28 #include <nvg.h> |
29 #include "vgigraphicsinterface.h" |
29 #include "vgigraphicsinterface.h" |
30 |
30 |
|
31 /** Struct to form a simple LRU cache of conversion results |
|
32 */ |
|
33 class TCachedConversion |
|
34 { |
|
35 public: |
|
36 TCachedConversion(); |
|
37 ~TCachedConversion(); |
|
38 inline void Deque(); |
|
39 |
|
40 public: |
|
41 TDblQueLink iLink; |
|
42 TUint32 iBitmapID; |
|
43 TUint32 iDiscriminator; |
|
44 CFbsBitmap* iCachedResult; |
|
45 }; |
31 |
46 |
32 /** This is a test render stage used for integration testing extended bitmaps of |
47 void TCachedConversion::Deque() {iLink.Deque();} |
33 type 0x10285A78. This particular type of extended bitmap was created to test the |
48 |
34 extended bitmap APIs added to CFbsBitGc (CreateExtendedBitmap(), ExtendedBitmapType() |
49 /** This is a render stage used for processing NVG Icon bitmaps in the absence of |
35 and DataSize()) and also to test the extended bitmap rasterizer interface, CFbsRasterizer. |
50 graphics acceleration hardware. The software implementation of OpenVG is used to |
36 The proprietary data contained in an extended bitmap of type 0x10285A78 defines |
51 render the NVG drawing commands onto a normal CFbsBitmap, and a simple LRU cache |
37 the colours and stripe direction of a tricolour flag. |
52 is used to keep the results for faster redrawing. |
38 |
53 |
39 This render stage implements the MWsGraphicsContext interface so that it can intercept |
54 This render stage implements the MWsGraphicsContext interface so that it can intercept |
40 any drawing commands that draw an extended bitmap, any commands that draw a normal |
55 any drawing commands that draw an extended bitmap, any commands that draw a normal |
41 bitmap are just passed through to the next renderstage (along with any commands that |
56 bitmap are just passed through to the next renderstage (along with any commands that |
42 do not involve bitmaps at all). |
57 do not involve bitmaps at all). |
129 CNvgRenderStage(); |
144 CNvgRenderStage(); |
130 void ConstructL(CWsRenderStage* aNextStage); |
145 void ConstructL(CWsRenderStage* aNextStage); |
131 |
146 |
132 private: |
147 private: |
133 // Helper methods that support the implementation of MWsGraphicsContext |
148 // Helper methods that support the implementation of MWsGraphicsContext |
134 void DrawExtendedBitmap(MWsGraphicsContext& aGc, const TRect& aDestRect, const CFbsBitmap& aSourceBitmap); |
149 CFbsBitmap* GetConvertedBitmap(const CFbsBitmap& aSourceBitmap); |
135 void DrawExtendedBitmap(CFbsBitGc& aGc, const TRect& aDestRect, const CFbsBitmap& aSourceBitmap); |
|
136 void CopyExtendedBitmapToNormalBitmap(const CFbsBitmap& aExtendedBitmapSrc, CFbsBitmap& aBitmapDst); |
150 void CopyExtendedBitmapToNormalBitmap(const CFbsBitmap& aExtendedBitmapSrc, CFbsBitmap& aBitmapDst); |
137 |
151 |
138 private: |
152 private: |
139 MWsGraphicsContext* iGc; |
153 MWsGraphicsContext* iGc; |
140 TInt iExtendedBitmapError; |
154 TInt iExtendedBitmapError; |
141 TPoint iOrigin; |
155 TPoint iOrigin; |
142 RRegion iEmptyRegion; |
156 RRegion iEmptyRegion; |
143 CFbsBitmap* iBmp; |
|
144 CFbsBitmap* iMaskBmp; |
|
145 CFbsBitmap* iBrushPattern; |
157 CFbsBitmap* iBrushPattern; |
146 CFbsBitmap* iInternalBrushPattern; |
158 CFbsBitmap* iInternalBrushPattern; |
147 MWsGraphicsContext::TBrushStyle iBrushStyle; |
159 MWsGraphicsContext::TBrushStyle iBrushStyle; |
148 CVGIGraphicsInterface* iGraphicsInterface; |
160 CVGIGraphicsInterface* iGraphicsInterface; |
149 CNvgEngine* iNvgEngine; |
161 CNvgEngine* iNvgEngine; |
|
162 |
|
163 // LRU Cache of rendered bitmaps |
|
164 #define MAX_NVG_CACHE_SIZE 128 |
|
165 |
|
166 TDblQue<TCachedConversion> iCache; |
|
167 TDblQueIter<TCachedConversion> iCacheIterator; |
|
168 TUint iCacheFree; |
150 }; |
169 }; |
151 |
170 |
|
171 // #define DEBUG_NVG_RENDERSTAGE |
|
172 |
152 #endif // NVGRENDERSTAGE_H |
173 #endif // NVGRENDERSTAGE_H |