|
1 /* |
|
2 * Copyright (c) 2010 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: Ctelbubbleimagescaler implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "telbubbleimagescaler.h" |
|
19 #include "BMBubbleDebug.h" |
|
20 #include <bitmaptransforms.h> |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // Constructor |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CTelBubbleImageScaler::CTelBubbleImageScaler( |
|
27 MTelBubbleImageScalerObserver& aObserver) : |
|
28 CActive(CActive::EPriorityStandard), iObserver(aObserver), iState(EScalingIdle), |
|
29 iScaler( NULL ) |
|
30 { |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // NewLC |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CTelBubbleImageScaler* CTelBubbleImageScaler::NewLC( |
|
38 MTelBubbleImageScalerObserver& aObserver) |
|
39 { |
|
40 CTelBubbleImageScaler* self = new (ELeave) CTelBubbleImageScaler( |
|
41 aObserver); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // NewL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CTelBubbleImageScaler* CTelBubbleImageScaler::NewL( |
|
52 MTelBubbleImageScalerObserver& aObserver) |
|
53 { |
|
54 CTelBubbleImageScaler* self = CTelBubbleImageScaler::NewLC(aObserver); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CTelBubbleImageScaler::ConstructL |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CTelBubbleImageScaler::ConstructL() |
|
64 { |
|
65 CActiveScheduler::Add( this ); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Destructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CTelBubbleImageScaler::~CTelBubbleImageScaler() |
|
73 { |
|
74 if ( iScaler ) |
|
75 { |
|
76 iScaler->Cancel(); // Cancel any request, if outstanding |
|
77 } |
|
78 |
|
79 delete iScaler; |
|
80 iState = EScalingIdle; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CTelBubbleImageScaler::StartScaleL |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CTelBubbleImageScaler::StartScaleL(CFbsBitmap* aSrc, CFbsBitmap* aTarget) |
|
88 { |
|
89 BM_TRACE_( "CTelBubbleImageScaler::StartScaleL()" ); |
|
90 if ( !iScaler ) |
|
91 { |
|
92 iScaler = CBitmapScaler::NewL(); |
|
93 } |
|
94 |
|
95 iScaledBitmap = aTarget; |
|
96 |
|
97 iScaler->SetQualityAlgorithm( CBitmapScaler::EMaximumQuality ); |
|
98 iScaler->Scale( &iStatus, *aSrc, *aTarget, EFalse ); |
|
99 iState = EScalingStarted; |
|
100 SetActive(); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CTelBubbleImageScaler::DoCancel |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CTelBubbleImageScaler::DoCancel() |
|
108 { |
|
109 BM_TRACE_( "CTelBubbleImageScaler::DoCancel()" ); |
|
110 if ( iScaler ) |
|
111 { |
|
112 iScaler->Cancel(); |
|
113 } |
|
114 |
|
115 iObserver.ImageScalingComplete( KErrCancel, iScaledBitmap ); |
|
116 iState = EScalingDone; |
|
117 iScaledBitmap = NULL; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CTelBubbleImageScaler::RunL |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CTelBubbleImageScaler::RunL() |
|
125 { |
|
126 BM_TRACE_( "CTelBubbleImageScaler::RunL()" ); |
|
127 iState = EScalingDone; |
|
128 TInt status = iStatus.Int(); |
|
129 iObserver.ImageScalingComplete( status, iScaledBitmap ); |
|
130 iScaledBitmap = NULL; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CTelBubbleImageScaler::RunError |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CTelBubbleImageScaler::RunError( TInt aError ) |
|
138 { |
|
139 BM_TRACE_( "CTelBubbleImageScaler::RunError()" ); |
|
140 iState = EScalingDone; |
|
141 iObserver.ImageScalingComplete( aError, iScaledBitmap ); |
|
142 iScaledBitmap = NULL; |
|
143 return KErrNone; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CTelBubbleImageScaler::SetState |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CTelBubbleImageScaler::SetState(TState aState) |
|
151 { |
|
152 BM_TRACE_1( "CTelBubbleImageScaler::SetState(): %d", aState ); |
|
153 iState = aState; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CTelBubbleImageScaler::GetState |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 TInt CTelBubbleImageScaler::GetState() |
|
161 { |
|
162 BM_TRACE_1( "CTelBubbleImageScaler::GetState(): %d", iState ); |
|
163 return iState; |
|
164 } |