|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "HuiFxScalarParameter.h" |
|
21 |
|
22 template<> |
|
23 TInt32 RHuiFxScalarTimeLine::ToFixedPoint(const TReal32& aValue) |
|
24 { |
|
25 return (TInt32)(aValue * 0x10000); |
|
26 } |
|
27 |
|
28 template<> |
|
29 TReal32 RHuiFxScalarTimeLine::FromFixedPoint(const TInt32& aValue) |
|
30 { |
|
31 return aValue / (TReal32)(0x10000); |
|
32 } |
|
33 |
|
34 template<> |
|
35 TInt32 RHuiFxScalarTimeLine::Blend(const TInt32& aValue1, const TInt32& aValue2, TInt32 aAlpha) |
|
36 { |
|
37 TInt64 diff = aValue2 - aValue1; |
|
38 return (TInt32)((TInt64)aValue1 + ((diff * (aAlpha >> 8)) >> 8)); |
|
39 } |
|
40 |
|
41 template<> |
|
42 TInt32 RHuiFxScalarTimeLine::WeightedSum4(const TInt32& aValue1, const TInt32& aValue2, const TInt32& aValue3, const TInt32& aValue4, |
|
43 TInt32 aWeight1, TInt32 aWeight2, TInt32 aWeight3, TInt32 aWeight4) |
|
44 { |
|
45 TInt64 f1 = (TInt64)aValue1 * (TInt64)aWeight1; |
|
46 TInt64 f2 = (TInt64)aValue2 * (TInt64)aWeight2; |
|
47 TInt64 f3 = (TInt64)aValue3 * (TInt64)aWeight3; |
|
48 TInt64 f4 = (TInt64)aValue4 * (TInt64)aWeight4; |
|
49 return (TInt32)((f1 + f2 + f3 + f4) >> 16); |
|
50 } |