|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 #include <e32base.h> |
|
18 #include "AknExtendedFaderGfx.h" |
|
19 |
|
20 |
|
21 void TAknExtendedFaderGfx::FadeRect_GrayColorize_16MX(TUint32* aPixels, TUint32 aStrideInPixels, TInt x1, TInt y1, TInt x2, TInt y2, const TInt aFadeMapFactor, const TInt aFadeMapOffset, const TUint32 aROverlay, const TUint32 aGOverlay, const TUint32 aBOverlay) |
|
22 { |
|
23 // Width and height of the rectangle |
|
24 TUint32 width = x2-x1; |
|
25 TUint32 height = y2-y1; |
|
26 |
|
27 // Get pointer to first pixel |
|
28 register TUint32* data = aPixels + x1 + aStrideInPixels*y1; |
|
29 |
|
30 // Padding is the amount of bytes we need to skip after single scanline to reach the beginning of the next one |
|
31 TUint32 padding = (aStrideInPixels - width)<<2; |
|
32 |
|
33 // Align address to 32-byte boundary |
|
34 TUint32 leftwidth, middlewidth, rightwidth; |
|
35 AlignTo32Bytes(data, width, leftwidth, middlewidth, rightwidth); |
|
36 |
|
37 // 8 pixels at a time in the midsection |
|
38 middlewidth>>=3; |
|
39 |
|
40 // Shift offset so we can remove one shift operation for each pixel |
|
41 const TUint32 shiftedFadeMapOffset = aFadeMapOffset << 18; |
|
42 |
|
43 // Constants for greyscale conversion |
|
44 const TUint32 KRBCoef(0x0144007C); // Coefficients for R & B: 324, 124 (/ 1024) |
|
45 const TUint32 KGCoef(0x00000240); // Coefficient for G: 576 |
|
46 TUint32 rbOverlay = (aROverlay << 16) | aBOverlay; // Combine R & B overlays to do two calculations at once |
|
47 |
|
48 FadeAlignedRect_GrayColorize_16MX(data, height, KRBCoef, KGCoef, aFadeMapFactor, shiftedFadeMapOffset, rbOverlay, aGOverlay, leftwidth, middlewidth, rightwidth, padding); |
|
49 } |
|
50 |
|
51 |
|
52 void TAknExtendedFaderGfx::FadeRect_GrayColorize_64K(TUint16* aPixels, TUint32 aStrideInPixels, TInt x1, TInt y1, TInt x2, TInt y2, const TInt aFadeMapFactor, const TInt aFadeMapOffset, const TUint32 aROverlay, const TUint32 aGOverlay, const TUint32 aBOverlay) |
|
53 { |
|
54 // Width and height of the rectangle |
|
55 TUint32 width = x2-x1; |
|
56 TUint32 height = y2-y1; |
|
57 |
|
58 // Get pointer to first pixel |
|
59 register TUint16* data = aPixels + x1 + aStrideInPixels*y1; |
|
60 |
|
61 // Padding is the amount of pixels we need to skip after single scanline to reach the beginning of the next one |
|
62 TUint32 padding = aStrideInPixels - width; |
|
63 |
|
64 // Helper variables |
|
65 register TInt x; |
|
66 |
|
67 while(height--) |
|
68 { |
|
69 x = width; |
|
70 |
|
71 while(x--) |
|
72 { |
|
73 // Process pixels |
|
74 *data++ = PixelToGrayscaleWithFade_64K((TUint32)*data, aFadeMapFactor, aFadeMapOffset, aROverlay, aGOverlay, aBOverlay); |
|
75 } |
|
76 |
|
77 data+=padding; |
|
78 } |
|
79 } |
|
80 |