|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __PIXELCONSUMER_H__ |
|
17 |
|
18 #define __PIXELCONSUMER_H__ |
|
19 /** @file |
|
20 @internalTechnology */ |
|
21 |
|
22 #include "ColourDefs.h" |
|
23 |
|
24 class CFbsBitmap; |
|
25 |
|
26 inline |
|
27 TBool Contains(const TRect& aR, const TPoint &aPoint) |
|
28 { |
|
29 return !(aPoint.iX<aR.iTl.iX || aPoint.iX>=aR.iBr.iX || aPoint.iY<aR.iTl.iY || aPoint.iY>=aR.iBr.iY); |
|
30 } |
|
31 |
|
32 /* |
|
33 #define used to improve readability of the code where it is used. |
|
34 |
|
35 @see CRgbPixelConsumer::SetRGBPixel |
|
36 @see CRgbPixelConsumer::SetRGBAPixel |
|
37 */ |
|
38 #define CALL_SETPIXEL_FUNCTION(pixelConsumer, ptrToSetPixelFn) ((pixelConsumer).*(ptrToSetPixelFn)) |
|
39 |
|
40 class CPixelConsumerBase: public CBase |
|
41 { |
|
42 public: |
|
43 |
|
44 ~CPixelConsumerBase(); |
|
45 void InitL(const TSize& aFrameSize); |
|
46 inline void SetPos(const TPoint& aPosition); |
|
47 void Prepare(); |
|
48 void GetBitmap(CFbsBitmap& aBitmap, const TRect& aSourceRect); |
|
49 inline const TRect& ClippingRect() const; |
|
50 void SetClippingRect(const TRect& aRect); |
|
51 inline void SetOrigin(const TPoint& aOrigin); |
|
52 inline TBool Enabled() const; |
|
53 inline void SetEnabled(TBool aEnabled); |
|
54 void Clear(TUint aColour, const TRect& aRect); |
|
55 inline void SetAlphaEnabledBitmap(TBool aEnabled); |
|
56 void ClearAlpha(TUint aColour, const TRect& aRect); |
|
57 inline TInt PixelSize() const; |
|
58 |
|
59 protected: |
|
60 inline CPixelConsumerBase(TInt aPixelSize); |
|
61 inline void GetBuffer(); |
|
62 |
|
63 protected: |
|
64 TInt iPixelSize; |
|
65 TUint8* iFrameBuffer; |
|
66 TInt iFrameBufferSize; |
|
67 TSize iFrameSize; |
|
68 TRect iClippingRect; |
|
69 TRect iRealOutputRect; |
|
70 TRect iImageRect; |
|
71 TPoint iCurrentPos; |
|
72 TPoint iOrigin; |
|
73 TBool iAlphaEnabled; |
|
74 private: |
|
75 TBool iNeedBufferFlush; |
|
76 TBool iEnabled; |
|
77 }; |
|
78 |
|
79 class CAlphaPixelConsumer; |
|
80 class CRgbPixelConsumer:public CPixelConsumerBase |
|
81 { |
|
82 public: |
|
83 typedef void (CRgbPixelConsumer::*SetPixelFunc)(TRgbaColour aPixelColour); |
|
84 inline CRgbPixelConsumer(TInt aPixelSize); |
|
85 void SetRGBPixel(TRgbaColour aPixelColour); |
|
86 void SetRGBAPixel(TRgbaColour aPixelColour); |
|
87 TUint GetPixel(const TPoint& aPosition) const; |
|
88 inline void SetAlphaConsumer(CAlphaPixelConsumer* aAlphaConsumer); |
|
89 protected: |
|
90 inline TUint GetPixel(const TUint8* aPtr) const; |
|
91 |
|
92 protected: |
|
93 CAlphaPixelConsumer* iAlphaConsumer; |
|
94 }; |
|
95 |
|
96 class CAlphaPixelConsumer:public CPixelConsumerBase |
|
97 { |
|
98 public: |
|
99 inline CAlphaPixelConsumer(); |
|
100 void SetPixel(TRgbaColour aPixelAlpha); |
|
101 inline void SetPixelByBufferOffset(TInt aOffset, TRgbaColour aPixelAlpha); |
|
102 inline void FillBy(TUint aAlpha); |
|
103 inline TUint GetPixel(const TPoint& aPosition) const; |
|
104 inline TUint GetPixel(TInt aBufferOffset) const; |
|
105 }; |
|
106 |
|
107 #include "PixelConsumer.inl" |
|
108 |
|
109 #endif // __PIXELCONSUMER_H__ |