sl@0
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#include "openvgengine.h"
|
sl@0
|
18 |
#include "eglrendering.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <eikenv.h>
|
sl@0
|
21 |
#include <e32math.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
_LIT(KCoverBitmaps, "z:\\resource\\apps\\covers.mbm");
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
GLDEF_D VGUErrorCode vguComputeWarpQuadToQuadProxy(VGfloat dx0, VGfloat dy0,
|
sl@0
|
28 |
VGfloat dx1, VGfloat dy1,
|
sl@0
|
29 |
VGfloat dx2, VGfloat dy2,
|
sl@0
|
30 |
VGfloat dx3, VGfloat dy3,
|
sl@0
|
31 |
VGfloat sx0, VGfloat sy0,
|
sl@0
|
32 |
VGfloat sx1, VGfloat sy1,
|
sl@0
|
33 |
VGfloat sx2, VGfloat sy2,
|
sl@0
|
34 |
VGfloat sx3, VGfloat sy3,
|
sl@0
|
35 |
VGfloat * matrix)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
vguComputeWarpQuadToQuad(
|
sl@0
|
38 |
sx0, sy0,
|
sl@0
|
39 |
sx1, sy1,
|
sl@0
|
40 |
sx2, sy2,
|
sl@0
|
41 |
sx3, sy3,
|
sl@0
|
42 |
dx0, dy0,
|
sl@0
|
43 |
dx1, dy1,
|
sl@0
|
44 |
dx2, dy2,
|
sl@0
|
45 |
dx3, dy3,
|
sl@0
|
46 |
matrix);
|
sl@0
|
47 |
return VGU_NO_ERROR;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
COpenVGEngine* COpenVGEngine::NewL(RWindow& aWindow,EGLDisplay& aDisplay, EGLSurface& aSurface, EGLContext& aContext)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
COpenVGEngine* self = new(ELeave) COpenVGEngine(aWindow, aDisplay, aSurface, aContext);
|
sl@0
|
53 |
return self;
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
COpenVGEngine::COpenVGEngine(RWindow& aWindow,EGLDisplay& aDisplay, EGLSurface& aSurface, EGLContext& aContext) :
|
sl@0
|
57 |
iWindow(aWindow), iDisplay(aDisplay), iSurface(aSurface), iContext(aContext), iWantedCover(20),
|
sl@0
|
58 |
iHasPendingDraw(EFalse), iShowCoverImage(EFalse), iSpeedOffset(0), iShowMirror(ETrue), iSpeed(0),
|
sl@0
|
59 |
iCurrentImageIndex(0)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
#ifdef PORTRAIT_MODE
|
sl@0
|
62 |
iSurfaceSize.iWidth = iWindow.Size().iHeight;
|
sl@0
|
63 |
iSurfaceSize.iHeight = iWindow.Size().iWidth;
|
sl@0
|
64 |
#else
|
sl@0
|
65 |
iSurfaceSize = iWindow.Size();
|
sl@0
|
66 |
#endif
|
sl@0
|
67 |
// initiate the location of each cover & make the wanted one the cover at the opposite end
|
sl@0
|
68 |
for(TInt i = 0; i < KMaxCoversExample3; ++i)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
iCoverLocation[i] = i;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
COpenVGEngine::~COpenVGEngine()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
Deactivate();
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
TInt COpenVGEngine::GetSpeed()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
return static_cast<TInt>(iSpeed * 100000);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
TBool COpenVGEngine::IsPending()
|
sl@0
|
85 |
{
|
sl@0
|
86 |
return iHasPendingDraw;
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
void COpenVGEngine::ActivateL()
|
sl@0
|
90 |
{
|
sl@0
|
91 |
CEGLRendering::EGLCheckReturnError(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
|
sl@0
|
92 |
|
sl@0
|
93 |
// Setup initial OpenVG context state
|
sl@0
|
94 |
VGfloat clearColour[] = { 0.1f, 0.1f, 0.2f, 1.0f };
|
sl@0
|
95 |
vgSetfv(VG_CLEAR_COLOR, 4, clearColour);
|
sl@0
|
96 |
vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED);
|
sl@0
|
97 |
vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_NONANTIALIASED);
|
sl@0
|
98 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
sl@0
|
99 |
|
sl@0
|
100 |
CFbsBitmap* bitmap = new(ELeave) CFbsBitmap();
|
sl@0
|
101 |
CleanupStack::PushL(bitmap);
|
sl@0
|
102 |
TInt idx = 0;
|
sl@0
|
103 |
while(bitmap->Load(KCoverBitmaps, idx++) == KErrNone)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
VGint width = bitmap->SizeInPixels().iWidth;
|
sl@0
|
106 |
VGint height = bitmap->SizeInPixels().iHeight;
|
sl@0
|
107 |
// Crate VGImage
|
sl@0
|
108 |
VGImage image = vgCreateImage(VG_sRGB_565, width, height, VG_IMAGE_QUALITY_NONANTIALIASED);
|
sl@0
|
109 |
CEGLRendering::VGCheckError();
|
sl@0
|
110 |
//Load Symbian bitmap into VGImage
|
sl@0
|
111 |
vgImageSubData(image, bitmap->DataAddress(), bitmap->DataStride(), VG_sRGB_565, 0, 0, width, height);
|
sl@0
|
112 |
CEGLRendering::VGCheckError();
|
sl@0
|
113 |
iImages.AppendL(image);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
CleanupStack::PopAndDestroy(bitmap);
|
sl@0
|
116 |
iHasPendingDraw = ETrue;
|
sl@0
|
117 |
|
sl@0
|
118 |
//Checks if any images were loaded
|
sl@0
|
119 |
if(iImages.Count() == 0)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
User::Leave(KErrNotFound);
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
iShadowPaint = vgCreatePaint();
|
sl@0
|
125 |
CEGLRendering::VGCheckError();
|
sl@0
|
126 |
if (iShadowPaint != VG_INVALID_HANDLE)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
VGfloat paintColour[4] = { 0.4f, 0.4f, 0.6f, 1.0f };
|
sl@0
|
129 |
vgSetParameterfv(iShadowPaint, VG_PAINT_COLOR, 4, paintColour);
|
sl@0
|
130 |
CEGLRendering::VGCheckError();
|
sl@0
|
131 |
}
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
void COpenVGEngine::Deactivate()
|
sl@0
|
135 |
{
|
sl@0
|
136 |
CEGLRendering::EGLCheckReturnError(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
|
sl@0
|
137 |
for (TInt i = iImages.Count() - 1; i >= 0; --i)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
vgDestroyImage(iImages[i]);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
vgDestroyPaint(iShadowPaint);
|
sl@0
|
142 |
eglWaitClient();
|
sl@0
|
143 |
iImages.Reset();
|
sl@0
|
144 |
iHasPendingDraw = EFalse;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
void COpenVGEngine::Step()
|
sl@0
|
148 |
{
|
sl@0
|
149 |
CEGLRendering::EGLCheckReturnError(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
|
sl@0
|
150 |
|
sl@0
|
151 |
#ifdef PORTRAIT_MODE
|
sl@0
|
152 |
vgClear(0, 0, iSurfaceSize.iHeight, iSurfaceSize.iWidth);
|
sl@0
|
153 |
#else
|
sl@0
|
154 |
vgClear(0, 0, iSurfaceSize.iWidth, iSurfaceSize.iHeight);
|
sl@0
|
155 |
#endif
|
sl@0
|
156 |
|
sl@0
|
157 |
if (Abs(iCoverLocation[iWantedCover]) < 0.03)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
iSpeed = 0.0f;
|
sl@0
|
160 |
iHasPendingDraw = EFalse;
|
sl@0
|
161 |
}
|
sl@0
|
162 |
else if (Abs(iCoverLocation[iWantedCover]) < 0.5)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
iSpeed *= 0.7;
|
sl@0
|
165 |
}
|
sl@0
|
166 |
else
|
sl@0
|
167 |
{
|
sl@0
|
168 |
iSpeed = 0.05 * (2 + Abs(iCoverLocation[iWantedCover]) + (Abs(iCoverLocation[iWantedCover]) + 1)
|
sl@0
|
169 |
* (Abs(iCoverLocation[iWantedCover]) + 1) / 2);
|
sl@0
|
170 |
}
|
sl@0
|
171 |
// For each Cover, update its location in the correct direction
|
sl@0
|
172 |
// Check if the wanted cover is already at the CenterStage point
|
sl@0
|
173 |
|
sl@0
|
174 |
VGfloat moveEachCover = iSpeed;
|
sl@0
|
175 |
if (iCoverLocation[iWantedCover] > 0.0)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
moveEachCover *= -1;
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
for (TInt i = 0; i < KMaxCoversExample3; ++i)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
iCoverLocation[i] += moveEachCover;
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
TInt coverClippingCount = 10;
|
sl@0
|
186 |
TInt middleCoverPos = 0;
|
sl@0
|
187 |
VGfloat threshold = 0.50f;
|
sl@0
|
188 |
|
sl@0
|
189 |
while(Abs(iCoverLocation[middleCoverPos]) > threshold)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
++middleCoverPos;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
|
sl@0
|
195 |
//left
|
sl@0
|
196 |
TInt cutOff = middleCoverPos - coverClippingCount;
|
sl@0
|
197 |
if (cutOff <0 )
|
sl@0
|
198 |
{
|
sl@0
|
199 |
cutOff = 0;
|
sl@0
|
200 |
}
|
sl@0
|
201 |
for (TInt i = cutOff; i < middleCoverPos; ++i)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
DrawCover(i);
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
//right
|
sl@0
|
207 |
cutOff = coverClippingCount + middleCoverPos;
|
sl@0
|
208 |
if (cutOff >= KMaxCoversExample3)
|
sl@0
|
209 |
{
|
sl@0
|
210 |
cutOff = KMaxCoversExample3-1;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
for (TInt j = cutOff; j >= middleCoverPos; --j)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
DrawCover(j);
|
sl@0
|
216 |
}
|
sl@0
|
217 |
|
sl@0
|
218 |
static TInt dir = 1;
|
sl@0
|
219 |
if (iWantedCover == (KMaxCoversExample3 - 1))
|
sl@0
|
220 |
{
|
sl@0
|
221 |
dir = -1;
|
sl@0
|
222 |
}
|
sl@0
|
223 |
else if (iWantedCover == 0)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
dir = 1;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
iWantedCover += dir;
|
sl@0
|
229 |
iHasPendingDraw = ETrue;
|
sl@0
|
230 |
}
|
sl@0
|
231 |
|
sl@0
|
232 |
void COpenVGEngine::DrawCover(TInt coverIndex)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
VGImage image = iImages[coverIndex % iImages.Count()];
|
sl@0
|
235 |
// Starting at the outside, render each visible (+/- KMaxDisplayCoversExample3/2) Cover
|
sl@0
|
236 |
// Calculate its path
|
sl@0
|
237 |
vgLoadIdentity();
|
sl@0
|
238 |
#ifdef PORTRAIT_MODE
|
sl@0
|
239 |
vgTranslate(iSurfaceSize.iHeight, 0);
|
sl@0
|
240 |
vgRotate(90);
|
sl@0
|
241 |
#endif
|
sl@0
|
242 |
VGfloat coverPosition = iCoverLocation[coverIndex];
|
sl@0
|
243 |
VGfloat tempMatrix[3][3];
|
sl@0
|
244 |
|
sl@0
|
245 |
//flip coords
|
sl@0
|
246 |
VGfloat flipmatrix[] =
|
sl@0
|
247 |
{
|
sl@0
|
248 |
1.0f, 0.0f, 0.0f,
|
sl@0
|
249 |
0.0f, -1.0f, 0.0f,
|
sl@0
|
250 |
0.0f, 0.0f, 1.0f
|
sl@0
|
251 |
};
|
sl@0
|
252 |
vgMultMatrix(flipmatrix);
|
sl@0
|
253 |
VGint imageWidth = vgGetParameteri(image, VG_IMAGE_WIDTH);
|
sl@0
|
254 |
VGint imageHeight = vgGetParameteri(image, VG_IMAGE_HEIGHT);
|
sl@0
|
255 |
|
sl@0
|
256 |
//VGint yTrans = -200;
|
sl@0
|
257 |
|
sl@0
|
258 |
//factors which must be multiplied with side of image which will be projected towards back
|
sl@0
|
259 |
//valid if projecting right image side to back
|
sl@0
|
260 |
//opposite is (1 - factor) for projecting left image side.
|
sl@0
|
261 |
|
sl@0
|
262 |
VGfloat bottomProjectXFactor= (0.75f);
|
sl@0
|
263 |
VGfloat bottomProjectYFactor = (0.20f);
|
sl@0
|
264 |
|
sl@0
|
265 |
VGfloat topProjectXFactor = (0.75f);
|
sl@0
|
266 |
VGfloat topProjectYFactor = (0.90f);
|
sl@0
|
267 |
|
sl@0
|
268 |
VGfloat imageSpacingFactor = 0.16;
|
sl@0
|
269 |
|
sl@0
|
270 |
VGfloat translationOffset = 0.0;
|
sl@0
|
271 |
|
sl@0
|
272 |
|
sl@0
|
273 |
//float yscale = 1.7;
|
sl@0
|
274 |
//float xscale = 4.4;
|
sl@0
|
275 |
//imageHeight = Min(iSurfaceSize.iWidth/xscale, iSurfaceSize.iHeight/yscale);
|
sl@0
|
276 |
//imageWidth = imageHeight;
|
sl@0
|
277 |
//TInt KImageSize = imageHeight/1.125;
|
sl@0
|
278 |
//VGint yTrans = iSurfaceSize.iHeight/-1.2;
|
sl@0
|
279 |
|
sl@0
|
280 |
TInt KImageSize = (imageHeight * 8) / 9; //KImageSize - secondary covers should be 8/9 of the size of the middle cover
|
sl@0
|
281 |
//VGint yTrans = -200;
|
sl@0
|
282 |
VGint yTrans = - (iWindow.Size().iHeight * 5) / 6;
|
sl@0
|
283 |
|
sl@0
|
284 |
|
sl@0
|
285 |
VGfloat middleTranslationOffset = KImageSize / 2;
|
sl@0
|
286 |
VGfloat coverProjectionLimit = 10;
|
sl@0
|
287 |
|
sl@0
|
288 |
if (coverPosition >= 1)
|
sl@0
|
289 |
{
|
sl@0
|
290 |
//if considering an image on the right side, this is offset from middle to place image on screen
|
sl@0
|
291 |
translationOffset = middleTranslationOffset- KImageSize/2 + KImageSize*imageSpacingFactor * (coverPosition -1);
|
sl@0
|
292 |
|
sl@0
|
293 |
//left side of image goes back.
|
sl@0
|
294 |
vguComputeWarpQuadToQuadProxy(0.0f, 0.0f,
|
sl@0
|
295 |
imageWidth, 0.0f,
|
sl@0
|
296 |
0.0f, imageHeight,
|
sl@0
|
297 |
imageWidth, imageHeight,
|
sl@0
|
298 |
KImageSize * (1 - bottomProjectXFactor*(1-Abs(coverPosition)/coverProjectionLimit)),KImageSize * bottomProjectYFactor,//left vertex
|
sl@0
|
299 |
KImageSize, 0.0f,
|
sl@0
|
300 |
KImageSize * (1 - topProjectXFactor*(1-Abs(coverPosition)/coverProjectionLimit)), KImageSize * topProjectYFactor,//left vertex
|
sl@0
|
301 |
KImageSize, KImageSize,
|
sl@0
|
302 |
&tempMatrix[0][0]);
|
sl@0
|
303 |
}
|
sl@0
|
304 |
else if (coverPosition < -1)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
//must move an extra image width from center , as coordinates from bottom left corner of image.
|
sl@0
|
307 |
translationOffset = - (middleTranslationOffset + (KImageSize * imageSpacingFactor) * ( -coverPosition - 1) + KImageSize/2) ;
|
sl@0
|
308 |
|
sl@0
|
309 |
vguComputeWarpQuadToQuadProxy( 0.0f, 0.0f,
|
sl@0
|
310 |
imageWidth, 0.0f,
|
sl@0
|
311 |
0.0f, imageHeight,
|
sl@0
|
312 |
imageWidth, imageHeight,
|
sl@0
|
313 |
|
sl@0
|
314 |
0.0f, 0.0f,
|
sl@0
|
315 |
(bottomProjectXFactor*(1-Abs(coverPosition)/coverProjectionLimit))* KImageSize, bottomProjectYFactor * KImageSize, //Right Vertex
|
sl@0
|
316 |
0.0f, (KImageSize),
|
sl@0
|
317 |
(topProjectXFactor*(1-Abs(coverPosition)/coverProjectionLimit)) * KImageSize, topProjectYFactor * KImageSize, //Right Vertex
|
sl@0
|
318 |
|
sl@0
|
319 |
&tempMatrix[0][0]);
|
sl@0
|
320 |
}
|
sl@0
|
321 |
else if((coverPosition > -1) && (coverPosition <= 0))// -0.07))
|
sl@0
|
322 |
{
|
sl@0
|
323 |
translationOffset = -middleTranslationOffset * Abs(coverPosition) - KImageSize/2 ;
|
sl@0
|
324 |
|
sl@0
|
325 |
vguComputeWarpQuadToQuadProxy( 0.0f, 0.0f,
|
sl@0
|
326 |
imageWidth, 0.0f,
|
sl@0
|
327 |
0.0f, imageHeight,
|
sl@0
|
328 |
imageWidth, imageHeight,
|
sl@0
|
329 |
0.0f, 0.0f,
|
sl@0
|
330 |
KImageSize * (1 - (1-bottomProjectXFactor) * Abs(coverPosition)), KImageSize * bottomProjectYFactor * Abs(coverPosition),
|
sl@0
|
331 |
0.0f, KImageSize,
|
sl@0
|
332 |
(KImageSize * (1 - ( 1 - topProjectXFactor) * Abs(coverPosition))) , KImageSize * (1 - (1 - topProjectYFactor) * Abs(coverPosition)),
|
sl@0
|
333 |
&tempMatrix[0][0]);
|
sl@0
|
334 |
}
|
sl@0
|
335 |
else if ((coverPosition >=0) && (coverPosition <= 1))
|
sl@0
|
336 |
{
|
sl@0
|
337 |
translationOffset = middleTranslationOffset * Abs(coverPosition) - KImageSize / 2;
|
sl@0
|
338 |
vguComputeWarpQuadToQuadProxy( 0.0f, 0.0f,
|
sl@0
|
339 |
imageWidth, 0.0f,
|
sl@0
|
340 |
0.0f, imageHeight,
|
sl@0
|
341 |
imageWidth, imageHeight,
|
sl@0
|
342 |
KImageSize * (1-bottomProjectXFactor)* (coverPosition), KImageSize * (bottomProjectYFactor) * (coverPosition),
|
sl@0
|
343 |
KImageSize, 0,
|
sl@0
|
344 |
KImageSize * ( 1 - topProjectXFactor) * (coverPosition) , KImageSize * (1 - (1 - topProjectYFactor) * Abs(coverPosition)),
|
sl@0
|
345 |
KImageSize, KImageSize,
|
sl@0
|
346 |
&tempMatrix[0][0]);
|
sl@0
|
347 |
}
|
sl@0
|
348 |
iSpeedOffset = 140*(iSpeed)*(iSpeed);
|
sl@0
|
349 |
if (iCoverLocation[iWantedCover] < 0)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
iSpeedOffset *= -1;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
vgTranslate(iWindow.Size().iWidth/2 + translationOffset + iSpeedOffset, yTrans);
|
sl@0
|
354 |
|
sl@0
|
355 |
vgMultMatrix(&tempMatrix[0][0]);
|
sl@0
|
356 |
if (Abs(coverPosition) <= 1)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
VGfloat scale = GetMiddleCoverScalingFactor(coverPosition);
|
sl@0
|
359 |
vgScale(scale,scale);
|
sl@0
|
360 |
vgTranslate(-(scale-1)/2 * KImageSize,-(scale-1)/2 * KImageSize);
|
sl@0
|
361 |
}
|
sl@0
|
362 |
vgDrawImage(image);
|
sl@0
|
363 |
CEGLRendering::VGCheckError();
|
sl@0
|
364 |
if (iShowMirror)
|
sl@0
|
365 |
{
|
sl@0
|
366 |
vgScale(1,-1);
|
sl@0
|
367 |
vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
|
sl@0
|
368 |
vgTranslate(0,-4*KImageSize+226);
|
sl@0
|
369 |
//vgTranslate(0,iSurfaceSize.iHeight/-.839);
|
sl@0
|
370 |
|
sl@0
|
371 |
vgSetPaint(iShadowPaint, VG_FILL_PATH);
|
sl@0
|
372 |
vgDrawImage(image);
|
sl@0
|
373 |
CEGLRendering::VGCheckError();
|
sl@0
|
374 |
|
sl@0
|
375 |
vgSeti(VG_IMAGE_MODE,VG_DRAW_IMAGE_NORMAL);
|
sl@0
|
376 |
}
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
TKeyResponse COpenVGEngine::HandleKeyEventL(const TKeyEvent& aKeyEvent)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
TKeyResponse response = EKeyWasConsumed;
|
sl@0
|
382 |
switch (aKeyEvent.iCode)
|
sl@0
|
383 |
{
|
sl@0
|
384 |
case EKeyRightArrow:
|
sl@0
|
385 |
NextCover();
|
sl@0
|
386 |
break;
|
sl@0
|
387 |
case EKeyLeftArrow:
|
sl@0
|
388 |
PreviousCover();
|
sl@0
|
389 |
break;
|
sl@0
|
390 |
case EKeyBackspace:
|
sl@0
|
391 |
ToggleCoverReflection();
|
sl@0
|
392 |
break;
|
sl@0
|
393 |
default:
|
sl@0
|
394 |
response = EKeyWasNotConsumed;
|
sl@0
|
395 |
break;
|
sl@0
|
396 |
};
|
sl@0
|
397 |
return response;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
void COpenVGEngine::NextCover()
|
sl@0
|
401 |
{
|
sl@0
|
402 |
if (iWantedCover < (KMaxCoversExample3 - 1))
|
sl@0
|
403 |
{
|
sl@0
|
404 |
++iWantedCover;
|
sl@0
|
405 |
iHasPendingDraw = ETrue;
|
sl@0
|
406 |
}
|
sl@0
|
407 |
}
|
sl@0
|
408 |
|
sl@0
|
409 |
void COpenVGEngine::PreviousCover()
|
sl@0
|
410 |
{
|
sl@0
|
411 |
if (iWantedCover > 0)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
--iWantedCover;
|
sl@0
|
414 |
iHasPendingDraw = ETrue;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
}
|
sl@0
|
417 |
|
sl@0
|
418 |
void COpenVGEngine::ToggleCoverReflection()
|
sl@0
|
419 |
{
|
sl@0
|
420 |
iShowMirror = !iShowMirror;
|
sl@0
|
421 |
}
|
sl@0
|
422 |
|
sl@0
|
423 |
VGfloat COpenVGEngine::GetMiddleCoverScalingFactor(VGfloat aCoverPosition)
|
sl@0
|
424 |
{
|
sl@0
|
425 |
if(Abs(aCoverPosition) > 1)
|
sl@0
|
426 |
{
|
sl@0
|
427 |
return 0.0f;
|
sl@0
|
428 |
}
|
sl@0
|
429 |
return (-0.125 * Abs(aCoverPosition) + 1.125);
|
sl@0
|
430 |
}
|
sl@0
|
431 |
|
sl@0
|
432 |
void COpenVGEngine::Refresh()
|
sl@0
|
433 |
{
|
sl@0
|
434 |
iHasPendingDraw = ETrue;
|
sl@0
|
435 |
}
|