|
1 /* |
|
2 * Copyright (c) 2004-2008 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: ChannelBlend provides functionality to combine bitmaps arithmetically. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef AKNSRLEFFECTPLUGINCHANNELBLEND_H |
|
20 #define AKNSRLEFFECTPLUGINCHANNELBLEND_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "AknsRlEffectPlugin.h" |
|
24 #include <AknsRlEffect.h> |
|
25 |
|
26 // CONSTANTS |
|
27 |
|
28 // Effect plugin UID |
|
29 const TInt KAknsRlEffectPluginChannelBlendUID = 0x10204AE0; |
|
30 |
|
31 // Constants for parameter names |
|
32 _LIT( KAknsRlEffectChannelBlendARed, "ar" ); |
|
33 _LIT( KAknsRlEffectChannelBlendAGreen, "ag" ); |
|
34 _LIT( KAknsRlEffectChannelBlendABlue, "ab" ); |
|
35 |
|
36 _LIT( KAknsRlEffectChannelBlendBRed, "br" ); |
|
37 _LIT( KAknsRlEffectChannelBlendBGreen, "bg" ); |
|
38 _LIT( KAknsRlEffectChannelBlendBBlue, "bb" ); |
|
39 |
|
40 _LIT( KAknsRlEffectChannelBlendAMask, "am" ); |
|
41 _LIT( KAknsRlEffectChannelBlendBMask, "bm" ); |
|
42 |
|
43 _LIT( KAknsRlEffectChannelBlendMode, "m" ); |
|
44 |
|
45 _LIT( KAknsRlEffectChannelBlendBlendFactor, "f" ); |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 class CAknsRlScanlines; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 /** |
|
53 * ChannelBlend provides functionality to combine bitmaps arithmetically. |
|
54 * Most image manipulation tools support operations similar to channel |
|
55 * blending between different layers in images or as brush drawing modes. |
|
56 * |
|
57 * @since 2.8 |
|
58 */ |
|
59 NONSHARABLE_CLASS(CAknsRlEffectPluginChannelBlend): |
|
60 public CAknsRlEffectPlugin, |
|
61 public MAknsRlEffect |
|
62 { |
|
63 public: |
|
64 /** |
|
65 * Flags for marking set parameters, internally used. |
|
66 */ |
|
67 enum TConstantFlag |
|
68 { |
|
69 EConstantAColor = 0x01, |
|
70 EConstantBColor = 0x02, |
|
71 EConstantAMask = 0x04, |
|
72 EConstantBMask = 0x08 |
|
73 }; |
|
74 |
|
75 public: // Constructors and destructor |
|
76 |
|
77 /** |
|
78 * Default constructor. |
|
79 * |
|
80 * @since 2.8 |
|
81 */ |
|
82 CAknsRlEffectPluginChannelBlend(); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 * |
|
87 * @since 2.8 |
|
88 */ |
|
89 virtual ~CAknsRlEffectPluginChannelBlend(); |
|
90 |
|
91 public: // Implementation of CAknsEffectPlugin |
|
92 |
|
93 TUid EffectUid() const; |
|
94 MAknsRlEffect* Effect( const TInt aInterface ); |
|
95 |
|
96 public: // Implementation of MAknsRlEffect |
|
97 |
|
98 void InitializeL(); |
|
99 void Release(); |
|
100 |
|
101 void ActivateL( MAknsRlEffectContext* aContext ); |
|
102 void Deactivate(); |
|
103 |
|
104 /** |
|
105 * Accepted named parameters: |
|
106 * |
|
107 * Constant color A: |
|
108 * - "ar", integer, channel value for red, truncated to range [0, 255] |
|
109 * - "ag", integer, channel value for green, truncated to range [0, 255] |
|
110 * - "ab", integer, channel value for blue, truncated to range [0, 255] |
|
111 * Constant color B: |
|
112 * - "br", integer, channel value for red, truncated to range [0, 255] |
|
113 * - "bg", integer, channel value for green, truncated to range [0, 255] |
|
114 * - "bb", integer, channel value for blue, truncated to range [0, 255] |
|
115 * Constant mask A: |
|
116 * - "am", integer, 8-bit shade, truncated to range [0, 255] |
|
117 * Constant mask B: |
|
118 * - "bm", integer, 8-bit shade, truncated to range [0, 255] |
|
119 * Blend mode: |
|
120 * - "m", integer (enumeration), one of the ChannelBlend modes |
|
121 * Blend factor: |
|
122 * - "f", integer, normal range [0, 255], blend factor. |
|
123 * |
|
124 * Constant color A and B: |
|
125 * If any of the A color channel values is set the processing will use a |
|
126 * constant color for A. The same goes with B. If the processed bitmaps |
|
127 * are grayscale the constant colors are converted to grayscale shade. |
|
128 * |
|
129 * The next input/output combinations are supported: |
|
130 * |
|
131 * A | B | T A | B | T A | B | T |
|
132 * --------- ---------- ---------- |
|
133 * 8 | 8 | 8 16| 16| 16 32| 32| 32 |
|
134 * 8 | C | 8 16| C | 16 32| C | 32 |
|
135 * C | 8 | 8 C | 16| 16 C | 32| 32 |
|
136 * C | C | 8 C | C | 16 C | C | 32 |
|
137 * |
|
138 * A = input layer A, B = input layer B, T = target layer |
|
139 * 8 = 8-bit grayscale bitmap (EGray256) |
|
140 * 16 = 16-bit RGB bitmap (EColor64K) |
|
141 * 32 = 24-bit unpacked RGB bitmap (EColor16MU) |
|
142 * C = 24-bit constant color (converted to 8-bit gray if needed) |
|
143 * |
|
144 * Constant mask A and B: |
|
145 * If constant mask A is set the processing will use constant mask for |
|
146 * A. The same goes for mask B. The next mask combinations are |
|
147 * supported: |
|
148 * |
|
149 * MA|MB |
|
150 * ----- |
|
151 * 8 | 8 MA = input mask A, MB = input mask B |
|
152 * 8 | C 8 = 8-bit grayscale bitmap |
|
153 * C | 8 C = 8-bit constant shade |
|
154 * C | C |
|
155 * |
|
156 * Blend mode: |
|
157 * Defines the used channel blend operation. Possible values are defined |
|
158 * in enumeration TAknsRlChannelBlendMode. Using any other value will |
|
159 * cause leave. |
|
160 * |
|
161 * Blend factor: |
|
162 * Blend factor controls the resulting opacity of the applied effect. |
|
163 * Normal value range is [0, 255] but values outside will also work. |
|
164 * - Value 0 will result in the original image. |
|
165 * - Value 255 will result in the filtered image. |
|
166 * - Values outside range [0, 255] will result in underexposure or |
|
167 * overexposure. |
|
168 * |
|
169 * Default values: |
|
170 * - "ar" = 255 |
|
171 * - "ag" = 255 |
|
172 * - "ab" = 255 |
|
173 * - "br" = 255 |
|
174 * - "bg" = 255 |
|
175 * - "bb" = 255 |
|
176 * - "am" = 255 |
|
177 * - "bm" = 255 |
|
178 * - "m" = EAknsRlChannelBlendNormal |
|
179 * - "f" = 255, full filter opacity |
|
180 * |
|
181 * Note that constant color and mask values are not used by default. You |
|
182 * must pass at least one value per constant (yes, a default value for |
|
183 * constant mask is actually quite pointless). |
|
184 */ |
|
185 void SetParametersL( MAknsRlParameterIterator& aParameters ); |
|
186 |
|
187 /** |
|
188 * Supported modes: |
|
189 * - EColor64K -> EColor64K |
|
190 * - EColor16MU -> EColor16MU |
|
191 * - EGray256 -> EGray256 |
|
192 */ |
|
193 void GetCapabilities( TAknsRlEffectCaps& aCaps ); |
|
194 |
|
195 /** |
|
196 * Using a mask is optional. Masked rendering is done if any mask |
|
197 * constant is set or if both input layers have the KAknsRlLayerRGBA bit |
|
198 * set. |
|
199 * |
|
200 * Defining constants allows dropping layers. If color constant and mask |
|
201 * constant are both defined the corresponding layer is never queried. |
|
202 * |
|
203 * If non-masked rendering is used and color constant is defined the |
|
204 * corresponding layer is not queried. |
|
205 * |
|
206 * The target layer may or may not have mask bitmap. If target mask |
|
207 * bitmap exists it is filled with white. |
|
208 */ |
|
209 TInt Render( const TAknsRlRenderOpParam& aParam ); |
|
210 |
|
211 void DoRenderL( const TAknsRlRenderOpParam& aParam ); |
|
212 |
|
213 private: |
|
214 |
|
215 MAknsRlEffectContext* iContext; |
|
216 |
|
217 TInt iBlendMode; |
|
218 TInt iBlendFactor; |
|
219 |
|
220 /** |
|
221 * Any constants set during the parameter iteration are flagged here |
|
222 * using TConstantFlags. |
|
223 */ |
|
224 TUint8 iFlags; |
|
225 |
|
226 TUint8 iARed; |
|
227 TUint8 iAGreen; |
|
228 TUint8 iABlue; |
|
229 |
|
230 TUint8 iBRed; |
|
231 TUint8 iBGreen; |
|
232 TUint8 iBBlue; |
|
233 |
|
234 TUint8 iAMask; |
|
235 TUint8 iBMask; |
|
236 |
|
237 // Cache for constant scanlines, reduces memory allocations for |
|
238 // constant scanlines during animations. |
|
239 CAknsRlScanlines* iScans; |
|
240 }; |
|
241 |
|
242 #endif // AKNSRLEFFECTPLUGINCHANNELBLEND_H |
|
243 |
|
244 // End of File |