|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbCore module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 #include <hbglobal.h> |
|
26 #ifdef HB_FILTER_EFFECTS |
|
27 |
|
28 #include "hbeffectbc_p.h" |
|
29 #include "hbeffectgroup_p.h" |
|
30 #include "hbeffectdef_p.h" |
|
31 #include "hbvgchainedeffect_p.h" |
|
32 #include "hbvgbceffect_p.h" |
|
33 #include "hbeffectfilter_p.h" |
|
34 #include <QGraphicsItem> |
|
35 #include <QtDebug> |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 |
|
39 // HbEffectBc |
|
40 |
|
41 HbEffectBc::HbEffectBc( |
|
42 const HbEffectFxmlFilterData &data, |
|
43 QGraphicsItem *item, |
|
44 HbEffectGroup *group) : |
|
45 HbEffectFilter(0, item, group), |
|
46 mAnimationO(0), |
|
47 mAnimationB(0), |
|
48 mAnimationC(0), |
|
49 mVgBc(0) |
|
50 { |
|
51 // Default values of if something is not passed in FXML |
|
52 qreal opacity_start = 1; |
|
53 qreal opacity_end = 1; |
|
54 qreal brightness_start = 0; |
|
55 qreal brightness_end = 0; |
|
56 qreal contrast_start = 1; |
|
57 qreal contrast_end = 1; |
|
58 |
|
59 QList<HbEffectFxmlParamData> params = data.paramData(); |
|
60 |
|
61 // Handle FXML parameters |
|
62 Q_FOREACH(const HbEffectFxmlParamData ¶m, params) { |
|
63 if (param.name() == FXML_KEYWORD_BRIGHTNESS_CONTRAST_OPACITY) { |
|
64 mAnimationO = createAnimation(param, opacity_start, opacity_end, group); |
|
65 } |
|
66 else if (param.name() == FXML_KEYWORD_BRIGHTNESS_CONTRAST_BRIGHTNESS) { |
|
67 mAnimationB = createAnimation(param, brightness_start, brightness_end, group); |
|
68 } |
|
69 else if (param.name() == FXML_KEYWORD_BRIGHTNESS_CONTRAST_CONTRAST) { |
|
70 mAnimationC = createAnimation(param, contrast_start, contrast_end, group); |
|
71 } |
|
72 } |
|
73 |
|
74 // Create VG effect if there were effect parameters defined |
|
75 if (mEffectDefined) { |
|
76 // Add effect to the filter effect chain in the effect group |
|
77 HbVgChainedEffect *chain = HbEffectAbstract::group()->vgEffect(); |
|
78 |
|
79 mVgBc = new HbVgBcEffect(); |
|
80 mVgBc->setCaching(true); |
|
81 |
|
82 chain->add(mVgBc); |
|
83 |
|
84 // Set initial values for the effect |
|
85 mVgBc->setOpacity(opacity_start); |
|
86 mVgBc->setBrightness(brightness_start); |
|
87 mVgBc->setContrast(contrast_start); |
|
88 } |
|
89 } |
|
90 |
|
91 HbEffectBc::~HbEffectBc() |
|
92 { |
|
93 } |
|
94 |
|
95 QString HbEffectBc::name() const |
|
96 { |
|
97 return HB_EFFECT_NAME_BRIGHTNESS_CONTRAST; |
|
98 } |
|
99 |
|
100 void HbEffectBc::updateFilterEffect() |
|
101 { |
|
102 // Only update the graphics effect if the effect is running |
|
103 if (group()->isRunning()) { |
|
104 if (mAnimationO) { |
|
105 mVgBc->setOpacity(qVariantValue<qreal>(mAnimationO->currentValue())); |
|
106 } |
|
107 if (mAnimationB) { |
|
108 mVgBc->setBrightness(qVariantValue<qreal>(mAnimationB->currentValue())); |
|
109 } |
|
110 if (mAnimationC) { |
|
111 mVgBc->setContrast(qVariantValue<qreal>(mAnimationC->currentValue())); |
|
112 } |
|
113 } |
|
114 } |
|
115 |
|
116 #endif |