|
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 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 inline |
|
22 CPixelConsumerBase::CPixelConsumerBase(TInt aPixelSize) |
|
23 :iPixelSize(aPixelSize) |
|
24 { |
|
25 } |
|
26 |
|
27 inline |
|
28 void CPixelConsumerBase::GetBuffer() |
|
29 { |
|
30 iNeedBufferFlush = ETrue; |
|
31 ASSERT(iFrameBuffer); |
|
32 } |
|
33 |
|
34 inline |
|
35 TBool CPixelConsumerBase::Enabled() const |
|
36 { |
|
37 return iEnabled; |
|
38 } |
|
39 |
|
40 inline |
|
41 void CPixelConsumerBase::SetEnabled(TBool aEnabled) |
|
42 { |
|
43 iEnabled = aEnabled; |
|
44 } |
|
45 |
|
46 inline |
|
47 const TRect& CPixelConsumerBase::ClippingRect() const |
|
48 { |
|
49 return iClippingRect; |
|
50 } |
|
51 |
|
52 |
|
53 inline |
|
54 void CPixelConsumerBase::SetPos(const TPoint& aPosition) |
|
55 { |
|
56 iCurrentPos = aPosition; |
|
57 } |
|
58 |
|
59 inline |
|
60 void CPixelConsumerBase::SetOrigin(const TPoint& aOrigin) |
|
61 { |
|
62 iOrigin = aOrigin; |
|
63 } |
|
64 |
|
65 inline |
|
66 void CPixelConsumerBase::SetAlphaEnabledBitmap(TBool aEnabled) |
|
67 { |
|
68 ASSERT(iPixelSize == KRgbaPixelSize); |
|
69 iAlphaEnabled = aEnabled; |
|
70 } |
|
71 |
|
72 inline |
|
73 TInt CPixelConsumerBase::PixelSize() const |
|
74 { |
|
75 return iPixelSize; |
|
76 } |
|
77 |
|
78 inline |
|
79 CRgbPixelConsumer::CRgbPixelConsumer(TInt aPixelSize) |
|
80 :CPixelConsumerBase(aPixelSize) |
|
81 { |
|
82 ASSERT(KRedShift==16 && KGreenShift==8 && KBlueShift==0 && KAlphaShift==24); |
|
83 } |
|
84 |
|
85 inline |
|
86 TUint CRgbPixelConsumer::GetPixel(const TUint8* aPtr) const |
|
87 { |
|
88 return TUint(*aPtr) | TUint(aPtr[1]<<8) | TUint(aPtr[2]<<16); |
|
89 } |
|
90 |
|
91 inline |
|
92 void CRgbPixelConsumer::SetAlphaConsumer(CAlphaPixelConsumer* aAlphaConsumer) |
|
93 { |
|
94 iAlphaConsumer = aAlphaConsumer; |
|
95 } |
|
96 |
|
97 inline |
|
98 TUint CRgbPixelConsumer::GetPixel(const TPoint& aPosition) const |
|
99 { |
|
100 const TPoint RealPos = iOrigin + aPosition; |
|
101 if (Contains(iRealOutputRect, RealPos)) |
|
102 { |
|
103 const TUint8* ptr=iFrameBuffer+KRgbPixelSize*(RealPos.iY*iFrameSize.iWidth+RealPos.iX); |
|
104 return GetPixel(ptr); |
|
105 } |
|
106 return 0; |
|
107 } |
|
108 |
|
109 inline |
|
110 void CAlphaPixelConsumer::FillBy(TUint aAlpha) |
|
111 { |
|
112 GetBuffer(); |
|
113 Mem::Fill(iFrameBuffer, iFrameBufferSize, aAlpha); |
|
114 } |
|
115 |
|
116 inline |
|
117 CAlphaPixelConsumer::CAlphaPixelConsumer() |
|
118 :CPixelConsumerBase(KAlphaPixelSize) |
|
119 { |
|
120 } |
|
121 |
|
122 inline |
|
123 TUint CAlphaPixelConsumer::GetPixel(const TPoint& aPosition) const |
|
124 { |
|
125 const TPoint RealPos = iOrigin + aPosition; |
|
126 if (Contains(iRealOutputRect, RealPos)) |
|
127 { |
|
128 return *(iFrameBuffer + RealPos.iY*iFrameSize.iWidth + RealPos.iX ); |
|
129 } |
|
130 return 0; |
|
131 } |
|
132 |
|
133 inline |
|
134 TUint CAlphaPixelConsumer::GetPixel(TInt aBufferOffset) const |
|
135 { |
|
136 ASSERT(aBufferOffset < iFrameBufferSize); |
|
137 return TUint( iFrameBuffer[aBufferOffset] ); |
|
138 } |
|
139 |
|
140 inline |
|
141 void CAlphaPixelConsumer::SetPixel(TRgbaColour aPixelAlpha) |
|
142 { |
|
143 const TPoint RealPos = iOrigin + iCurrentPos; |
|
144 |
|
145 TUint8* ptr=iFrameBuffer + RealPos.iY*iFrameSize.iWidth + RealPos.iX ; |
|
146 *ptr=TUint8(aPixelAlpha & 0xff); |
|
147 } |
|
148 |
|
149 inline |
|
150 void CAlphaPixelConsumer::SetPixelByBufferOffset(TInt aPixelOffset, TRgbaColour aPixelAlpha) |
|
151 { |
|
152 ASSERT(aPixelOffset < iFrameBufferSize); |
|
153 iFrameBuffer[aPixelOffset] = TUint8(aPixelAlpha & 0xff); |
|
154 } |
|
155 |
|
156 |