56
|
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 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
|
|
20 |
#include "HgVgMediaWallRenderer.h"
|
|
21 |
#include "HgVgHelper.h"
|
|
22 |
#include "HgConstants.h"
|
|
23 |
#include "HgVgConstants.h"
|
|
24 |
|
|
25 |
#include <VG/vgu.h>
|
|
26 |
#include <ganes/HgVgItem.h>
|
|
27 |
#include <AknUtils.h>
|
|
28 |
#include <layoutmetadata.cdl.h>
|
|
29 |
#include <AknLayout2ScalableDef.h>
|
|
30 |
#include <AknsDrawUtils.h>
|
|
31 |
#include <e32math.h>
|
|
32 |
|
|
33 |
using namespace HgVgConstants;
|
|
34 |
|
|
35 |
const VGfloat KColorByteToFloat(255.0f);
|
|
36 |
// Ending position of the left album stack
|
|
37 |
const VGfloat KLeftStackEndX(-1.04);//-235.0f);
|
|
38 |
// Ending position of the right album stack
|
|
39 |
const VGfloat KRightStackStartX(1.04);//235.0f);
|
|
40 |
|
|
41 |
// Space between albums in stacks
|
|
42 |
const VGfloat KSpaceBetween(1.04);//235);
|
|
43 |
|
|
44 |
const TInt KGroundHeightFactor(2);
|
|
45 |
const TInt KNumGroundGradientValues(4);
|
|
46 |
const VGfloat KGroundGradient[] = {
|
|
47 |
0.0f, 0.0f, 0.0f, 1.0f
|
|
48 |
};
|
|
49 |
const TInt KGroundVerticesHint(4);
|
|
50 |
const TInt KGroundSegmentsHint(4);
|
|
51 |
const VGfloat KGroundScale(1.0f);
|
|
52 |
const VGfloat KGroundBias(0.0f);
|
|
53 |
|
|
54 |
const VGfloat KFov(PI/2);
|
|
55 |
|
|
56 |
const VGfloat KFlipAngle(PI);
|
|
57 |
|
|
58 |
const VGfloat KQuadVerts[] =
|
|
59 |
{
|
|
60 |
-1.0f, -1.0f, 0.0f,
|
|
61 |
1.0f, -1.0f, 0.0f,
|
|
62 |
1.0f, 1.0f, 0.0f,
|
|
63 |
-1.0f, 1.0f, 0.0f
|
|
64 |
};
|
|
65 |
|
|
66 |
|
|
67 |
VGfloat EaseOutQuad(VGfloat start, VGfloat end, VGfloat t)
|
|
68 |
{
|
|
69 |
VGfloat s = t - 1.0f;
|
|
70 |
VGfloat f = -(s*s*s*s) + 1.0f;
|
|
71 |
return start * (1.0f - f) + end * f;
|
|
72 |
}
|
|
73 |
|
|
74 |
VGfloat EaseInQuad(VGfloat start, VGfloat end, VGfloat t)
|
|
75 |
{
|
|
76 |
VGfloat s = t;
|
|
77 |
VGfloat f = (s*s*s*s);
|
|
78 |
return start * (1.0f - f) + end * f;
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
VGfloat BoundValue(VGfloat value, VGfloat min, VGfloat max)
|
|
83 |
{
|
|
84 |
if (value > max) return max;
|
|
85 |
if (value < min) return min;
|
|
86 |
|
|
87 |
return value;
|
|
88 |
}
|
|
89 |
|
|
90 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// CHgVgCoverflowRenderer::NewL()
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
CHgVgMediaWallRenderer* CHgVgMediaWallRenderer::NewL(TInt aMaxQuads, const TRect& aRect,
|
|
97 |
const TRect& aFrontRect, TReal aZOffset )
|
|
98 |
{
|
|
99 |
CHgVgMediaWallRenderer* self = new (ELeave) CHgVgMediaWallRenderer( aRect,
|
|
100 |
aFrontRect, aZOffset);
|
|
101 |
CleanupStack::PushL( self );
|
|
102 |
self->ConstructL(aMaxQuads);
|
|
103 |
CleanupStack::Pop( self );
|
|
104 |
return self;
|
|
105 |
}
|
|
106 |
|
|
107 |
// -----------------------------------------------------------------------------
|
|
108 |
// CHgVgMediaWallRenderer::ConstructL()
|
|
109 |
// Symbian 2nd phase constructor can leave.
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void CHgVgMediaWallRenderer::ConstructL (TInt aMaxQuads)
|
|
113 |
{
|
|
114 |
for (TInt i = 0; i < aMaxQuads; i++)
|
|
115 |
{
|
|
116 |
TQuad* q = new (ELeave)TQuad;
|
|
117 |
q->iItemIndex = -1;
|
|
118 |
CleanupStack::PushL(q);
|
|
119 |
iQuads.AppendL(q);
|
|
120 |
CleanupStack::Pop(q);
|
|
121 |
}
|
|
122 |
CreateGround();
|
|
123 |
}
|
|
124 |
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
// CHgVgMediaWallRenderer::CHgVgMediaWallRenderer()
|
|
127 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
CHgVgMediaWallRenderer::CHgVgMediaWallRenderer(
|
|
131 |
const TRect& aWindowRect,
|
|
132 |
const TRect& aFrontRect,
|
|
133 |
TReal aZOffset) :
|
|
134 |
iRect(aWindowRect),
|
|
135 |
iReflectionsEnabled(ETrue),
|
|
136 |
iSelectedItemIndex(KSelectedItemIndex),
|
|
137 |
iLeftStackEndX(KLeftStackEndX),
|
|
138 |
iRightStackStartX(KRightStackStartX),
|
|
139 |
iSpaceBetween(KSpaceBetween),
|
|
140 |
iFov(KFov),
|
|
141 |
iFlipAngle(KFlipAngle)
|
|
142 |
{
|
|
143 |
AdjustSettingsBasedOnRects(aFrontRect, aZOffset);
|
|
144 |
}
|
|
145 |
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
// CHgVgScrollBar::~CHgVgScrollBar()
|
|
148 |
// Destructor.
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
CHgVgMediaWallRenderer::~CHgVgMediaWallRenderer ( )
|
|
152 |
{
|
|
153 |
if (iDefaultImage != VG_INVALID_HANDLE)
|
|
154 |
vgDestroyImage(iDefaultImage);
|
|
155 |
|
|
156 |
if (iChildBlurImage != VG_INVALID_HANDLE)
|
|
157 |
vgDestroyImage(iChildBlurImage);
|
|
158 |
|
|
159 |
if (iBlurImage != VG_INVALID_HANDLE)
|
|
160 |
vgDestroyImage(iBlurImage);
|
|
161 |
|
|
162 |
vgDestroyPaint(iGroundPaint);
|
|
163 |
vgDestroyPath(iGroundPath);
|
|
164 |
|
|
165 |
iQuads.ResetAndDestroy();
|
|
166 |
iSortedQuads.Reset();
|
|
167 |
}
|
|
168 |
|
|
169 |
// -----------------------------------------------------------------------------
|
|
170 |
// CHgMediaWallRenderer::SetDefaultImage()
|
|
171 |
// Setter for default image used to draw quads.
|
|
172 |
// -----------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
void CHgVgMediaWallRenderer::SetDefaultIconL(const CGulIcon& aIcon)
|
|
175 |
{
|
|
176 |
iDefaultImage = HgVgHelper::CreateVgImageFromIconL(aIcon);
|
|
177 |
}
|
|
178 |
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
// CHgMediaWallRenderer::SetCameraPosition()
|
|
181 |
// Setter for camera position modifier.
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
void CHgVgMediaWallRenderer::SetCameraPosition(TReal aX, TReal aY, TReal aZ)
|
|
185 |
{
|
|
186 |
iCameraX = aX;
|
|
187 |
iCameraY = aY;
|
|
188 |
iCameraZ = aZ;
|
|
189 |
}
|
|
190 |
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
// CHgMediaWallRenderer::SetCameraRotation()
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
void CHgVgMediaWallRenderer::SetCameraRotation(TReal aAngle)
|
|
196 |
{
|
|
197 |
iCameraRotation = aAngle;
|
|
198 |
}
|
|
199 |
|
|
200 |
// -----------------------------------------------------------------------------
|
|
201 |
// CHgVgScrollBar::SortQuads
|
|
202 |
// Sorts quads from iQuads to iSortedQuads.
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
void CHgVgMediaWallRenderer::SortQuadsL(TInt aNumQuads)
|
|
206 |
{
|
|
207 |
|
|
208 |
iSortedQuads.Reset();
|
|
209 |
|
|
210 |
for(TInt i = 0; i < aNumQuads; ++i)
|
|
211 |
{
|
|
212 |
iSortedQuads.AppendL(iQuads[i]);
|
|
213 |
}
|
|
214 |
|
|
215 |
for (TInt i = 1; i < aNumQuads; i++)
|
|
216 |
{
|
|
217 |
for (int j = 0; j < aNumQuads; j++)
|
|
218 |
{
|
|
219 |
if( iSortedQuads[i]->iZ > iSortedQuads[j]->iZ )
|
|
220 |
{
|
|
221 |
TQuad* q1 = iSortedQuads[i];
|
|
222 |
TQuad* q2 = iSortedQuads[j];
|
|
223 |
iSortedQuads[i] = q2;
|
|
224 |
iSortedQuads[j] = q1;
|
|
225 |
}
|
|
226 |
}
|
|
227 |
}
|
|
228 |
}
|
|
229 |
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// CHgVgScrollBar::GetItemIndex
|
|
232 |
// gets index of the item under pointer position.
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
TInt CHgVgMediaWallRenderer::GetItemIndex(const TPoint& aPointerPosition) const
|
|
236 |
{
|
|
237 |
for (TInt i = 0; i < iSortedQuads.Count(); i++)
|
|
238 |
{
|
|
239 |
VGfloat* verts = iSortedQuads[iSortedQuads.Count()-i-1]->iPoints;
|
|
240 |
TRect rect;
|
|
241 |
HgVgHelper::CalculateBoundingRect(rect, verts, 4, iRect);
|
|
242 |
if (rect.Contains(aPointerPosition))
|
|
243 |
{
|
|
244 |
TInt index = iSortedQuads.Count()-i-1;
|
|
245 |
return iSortedQuads[index]->iItemIndex;
|
|
246 |
}
|
|
247 |
}
|
|
248 |
return KErrNotFound;
|
|
249 |
}
|
|
250 |
|
|
251 |
|
|
252 |
// -----------------------------------------------------------------------------
|
|
253 |
// CHgVgScrollBar::TransformQuads
|
|
254 |
// Draws quads using OpenVG.
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CHgVgMediaWallRenderer::TransformQuads(TInt aNumVisibleQuads,
|
|
258 |
TBool aMirrored, VGfloat aFov, CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType)
|
|
259 |
{
|
|
260 |
|
|
261 |
VGfloat scW = (VGfloat) iRect.Width();
|
|
262 |
VGfloat scH = (VGfloat) iRect.Height();
|
|
263 |
|
|
264 |
VGfloat imW = (VGfloat)iImageSize.iWidth;
|
|
265 |
VGfloat imH = (VGfloat)iImageSize.iHeight;
|
|
266 |
|
|
267 |
// construct mirror matrix
|
|
268 |
HgVgHelper::TMatrix mirrorMatrix;
|
|
269 |
mirrorMatrix.Scale(1, -1, 1);
|
|
270 |
|
|
271 |
// construct camera rotation matrix
|
|
272 |
HgVgHelper::TMatrix cameraRotMatrix;
|
|
273 |
if (iFlipXY)
|
|
274 |
{
|
|
275 |
cameraRotMatrix.RotationX(iCameraRotation);
|
|
276 |
}
|
|
277 |
else
|
|
278 |
{
|
|
279 |
cameraRotMatrix.RotationY(iCameraRotation);
|
|
280 |
}
|
|
281 |
|
|
282 |
// mat[0] = transform
|
|
283 |
// mat[1] = mirrored transform
|
|
284 |
HgVgHelper::TMatrix mat[2];
|
|
285 |
|
|
286 |
VGfloat cameraX = iCameraBaseX + iCameraX;
|
|
287 |
VGfloat cameraY = iCameraBaseY + iCameraY;
|
|
288 |
VGfloat cameraZ = iCameraBaseZ + iCameraZ;
|
|
289 |
|
|
290 |
if (iFlipXY)
|
|
291 |
{
|
|
292 |
VGfloat foobar = cameraX;
|
|
293 |
cameraX = cameraY;
|
|
294 |
cameraY = foobar;
|
|
295 |
}
|
|
296 |
|
|
297 |
// scaling matrix is used to set correct size for the
|
|
298 |
// quad by image size
|
|
299 |
VGfloat hImW = (VGfloat)KWorldQuadWidth * 0.5f;
|
|
300 |
VGfloat hImH = (VGfloat)imH * (KWorldQuadWidth / imW) * 0.5f;
|
|
301 |
VGfloat oldHImH = hImH;
|
|
302 |
|
|
303 |
// flips image upside down
|
|
304 |
HgVgHelper::TMatrix scaleMatrix;
|
|
305 |
scaleMatrix.Scale(hImW, -hImH, 1); // negative scale because our all images are updaside down.
|
|
306 |
|
|
307 |
TBool deform =
|
|
308 |
(aOpeningAnimationType == CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront) ||
|
|
309 |
(aOpeningAnimationType == CHgVgMediaWall::EHgVgOpeningAnimationZoomToFront);
|
|
310 |
|
|
311 |
for (TInt j = 0; j < aNumVisibleQuads; j++)
|
|
312 |
{
|
|
313 |
TQuad* q = iQuads[j];
|
|
314 |
|
|
315 |
if (q->iFlipped && deform)
|
|
316 |
{
|
|
317 |
// animate scaling to flipped rect size
|
|
318 |
VGfloat newH = (VGfloat)iFlippedHeight * (KWorldQuadWidth / iFlippedWidth) * 0.5f;
|
|
319 |
hImH = HgVgHelper::Lerp(hImH, newH, iBlurAlpha);
|
|
320 |
mat[0].Identity();
|
|
321 |
mat[0].Scale(hImW, -hImH, 1);
|
|
322 |
}
|
|
323 |
else
|
|
324 |
{
|
|
325 |
// restore old normal half image height
|
|
326 |
hImH = oldHImH;
|
|
327 |
mat[0] = scaleMatrix;
|
|
328 |
}
|
|
329 |
|
|
330 |
// rotMatrix rotates by quads angle
|
|
331 |
HgVgHelper::TMatrix rotMatrix;
|
|
332 |
rotMatrix.RotationY(-q->iAngle);
|
|
333 |
|
|
334 |
// trMatrix translates by quads position
|
|
335 |
HgVgHelper::TMatrix trMatrix;
|
|
336 |
trMatrix.Translation(q->iX, q->iY + hImH, q->iZ);
|
|
337 |
|
|
338 |
// then rotate
|
|
339 |
if (q->iAngle != 0)
|
|
340 |
{
|
|
341 |
mat[0].Multiply(rotMatrix);
|
|
342 |
}
|
|
343 |
|
|
344 |
// then translate to position
|
|
345 |
mat[0].Multiply(trMatrix);
|
|
346 |
|
|
347 |
// construct mirroring matrix
|
|
348 |
if (aMirrored)
|
|
349 |
{
|
|
350 |
mat[1] = mat[0];
|
|
351 |
mat[1].Multiply(mirrorMatrix);
|
|
352 |
}
|
|
353 |
|
|
354 |
// construct camera translation matrix
|
|
355 |
HgVgHelper::TMatrix cameraMatrix;
|
|
356 |
cameraMatrix.Translation(-cameraX, -cameraY - hImH, -cameraZ);
|
|
357 |
|
|
358 |
// apply camera movement
|
|
359 |
mat[0].Multiply(cameraMatrix);
|
|
360 |
|
|
361 |
// apply camera rotation hack
|
|
362 |
mat[0].Multiply(cameraRotMatrix);
|
|
363 |
|
|
364 |
// apply to mirror matrix also
|
|
365 |
if (aMirrored)
|
|
366 |
{
|
|
367 |
mat[1].Multiply(cameraMatrix);
|
|
368 |
mat[1].Multiply(cameraRotMatrix);
|
|
369 |
}
|
|
370 |
|
|
371 |
// transform all points by resulting transformation matrix
|
|
372 |
// and project to screen coordinates.
|
|
373 |
TInt count = aMirrored ? 2 : 1;
|
|
374 |
for (TInt k = 0; k < count; k++)
|
|
375 |
{
|
|
376 |
VGfloat* tverts = NULL;
|
|
377 |
VGfloat* tm = NULL;
|
|
378 |
|
|
379 |
if (k == 0)
|
|
380 |
{
|
|
381 |
tverts = q->iPoints;
|
|
382 |
tm = q->iTM;
|
|
383 |
}
|
|
384 |
else
|
|
385 |
{
|
|
386 |
tverts = q->iMirroredPoints;
|
|
387 |
tm = q->iMirroredTM;
|
|
388 |
}
|
|
389 |
|
|
390 |
for (TInt i = 0; i < 4; i++)
|
|
391 |
{
|
|
392 |
|
|
393 |
HgVgHelper::TVertex v;
|
|
394 |
|
|
395 |
v.iX = KQuadVerts[i*3+0];
|
|
396 |
v.iY = KQuadVerts[i*3+1];
|
|
397 |
v.iZ = KQuadVerts[i*3+2];
|
|
398 |
|
|
399 |
v.TransformPoint(mat[k]);
|
|
400 |
|
|
401 |
v.ProjectPoint(scW, scH, aFov);
|
|
402 |
|
|
403 |
tverts[i*2+0] = v.iScreenX;
|
|
404 |
tverts[i*2+1] = v.iScreenY;
|
|
405 |
|
|
406 |
}
|
|
407 |
|
|
408 |
VGImage image = q->iNoImage ? iDefaultImage : q->iImage;
|
|
409 |
VGfloat pxWidth = vgGetParameteri(image, VG_IMAGE_WIDTH);
|
|
410 |
VGfloat pxHeight = vgGetParameteri(image, VG_IMAGE_HEIGHT);
|
|
411 |
|
|
412 |
// use screen coordinates to build warp matrix
|
|
413 |
// for rendering the image
|
|
414 |
vguComputeWarpQuadToQuad(tverts[0], tverts[1], tverts[2], tverts[3],
|
|
415 |
tverts[4], tverts[5], tverts[6], tverts[7], 0, 0, pxWidth, 0,
|
|
416 |
pxWidth, pxHeight, 0, pxHeight, tm);
|
|
417 |
|
|
418 |
}
|
|
419 |
}
|
|
420 |
}
|
|
421 |
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
// CHgVgScrollBar::DrawQuads
|
|
424 |
// Draws quads using OpenVG.
|
|
425 |
// -----------------------------------------------------------------------------
|
|
426 |
//
|
|
427 |
void CHgVgMediaWallRenderer::DrawQuads(TBool aDrawMirrored)
|
|
428 |
{
|
|
429 |
|
|
430 |
VGfloat values[] = { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
|
|
431 |
|
|
432 |
vgSeti(VG_COLOR_TRANSFORM, VG_TRUE);
|
|
433 |
|
|
434 |
for (TInt j = 0; j < iSortedQuads.Count(); j++)
|
|
435 |
{
|
|
436 |
TQuad* q = iSortedQuads[j];
|
|
437 |
|
|
438 |
if (q->iAlpha < 0.01f)
|
|
439 |
continue;
|
|
440 |
|
|
441 |
values[3] = q->iAlpha;
|
|
442 |
|
|
443 |
vgSetfv(VG_COLOR_TRANSFORM_VALUES, 8, values);
|
|
444 |
|
|
445 |
if (q->iZ < 0)
|
|
446 |
continue;
|
|
447 |
|
|
448 |
DrawQuad(q, aDrawMirrored);
|
|
449 |
|
|
450 |
}
|
|
451 |
|
|
452 |
vgSeti(VG_COLOR_TRANSFORM, VG_FALSE);
|
|
453 |
|
|
454 |
}
|
|
455 |
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
// CHgVgMediaWallRenderer::DrawQuad
|
|
458 |
// -----------------------------------------------------------------------------
|
|
459 |
//
|
|
460 |
void CHgVgMediaWallRenderer::DrawQuad(CHgVgMediaWallRenderer::TQuad* q, TBool aDrawMirrored)
|
|
461 |
{
|
|
462 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
|
|
463 |
vgLoadIdentity();
|
|
464 |
|
|
465 |
if (iLandscape)
|
|
466 |
{
|
|
467 |
vgTranslate(0.0f, 640.0f);
|
|
468 |
vgRotate(-90.0f);
|
|
469 |
}
|
|
470 |
|
|
471 |
vgTranslate(iOffset.iX, iOffset.iY);
|
|
472 |
|
|
473 |
|
|
474 |
VGImage image = q->iImage;
|
|
475 |
if (q->iNoImage)
|
|
476 |
{
|
|
477 |
image = iDefaultImage;
|
|
478 |
}
|
|
479 |
|
|
480 |
if (aDrawMirrored)
|
|
481 |
{
|
|
482 |
vgMultMatrix(q->iMirroredTM);
|
|
483 |
}
|
|
484 |
else
|
|
485 |
{
|
|
486 |
vgMultMatrix(q->iTM);
|
|
487 |
if ((iBlurImage != VG_INVALID_HANDLE) && (iChildBlurImage != VG_INVALID_HANDLE) && q->iFlipped)
|
|
488 |
{
|
|
489 |
vgGaussianBlur(iChildBlurImage, image, iBlurDeviationX*iBlurAlpha,
|
|
490 |
iBlurDeviationY*iBlurAlpha, VG_TILE_PAD);
|
|
491 |
image = iChildBlurImage;
|
|
492 |
}
|
|
493 |
}
|
|
494 |
|
|
495 |
|
|
496 |
vgDrawImage(image);
|
|
497 |
}
|
|
498 |
|
|
499 |
|
|
500 |
// -----------------------------------------------------------------------------
|
|
501 |
// CHgVgScrollBar::Draw()
|
|
502 |
// -----------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
void CHgVgMediaWallRenderer::Draw(RPointerArray<CHgVgItem>& aItems,
|
|
505 |
TInt aSelectedIndex, TReal aNextIndex,
|
|
506 |
TReal aViewPosition,
|
|
507 |
TReal aAnimationAlpha,
|
|
508 |
CHgVgMediaWall::THgVgAnimationState aState,
|
|
509 |
CHgVgMediaWall::THgVgOpeningAnimationType aSelectionAnimationType,
|
|
510 |
CHgVgMediaWall::THgVgMediaWallStyle /*aStyle*/,
|
|
511 |
TReal aStartIndex,
|
|
512 |
TReal aSpringVelocity)
|
|
513 |
{
|
|
514 |
|
|
515 |
TInt itemsOnScreen = 0;
|
|
516 |
itemsOnScreen = SetupQuads(aItems,
|
|
517 |
aSelectedIndex, aNextIndex,
|
|
518 |
aViewPosition,
|
|
519 |
aAnimationAlpha,
|
|
520 |
aState, aSelectionAnimationType, aStartIndex, aSpringVelocity);
|
|
521 |
|
|
522 |
TransformAndDraw(itemsOnScreen, aSelectionAnimationType);
|
|
523 |
}
|
|
524 |
|
|
525 |
|
|
526 |
// ---------------------------------------------------------------------------
|
|
527 |
// CHgVgMediaWallRenderer::DrawGrid()
|
|
528 |
// ---------------------------------------------------------------------------
|
|
529 |
//
|
|
530 |
void CHgVgMediaWallRenderer::DrawGrid(
|
|
531 |
TInt aRowCount,
|
|
532 |
RPointerArray<CHgVgItem>& aItems,
|
|
533 |
TReal aViewX, TReal aViewY,
|
|
534 |
TInt aCurItem, TInt aPrevItem,
|
|
535 |
TReal aAnimationAlpha,
|
|
536 |
CHgVgMediaWall::THgVgAnimationState aAnimationState,
|
|
537 |
TInt aPickedItem,
|
|
538 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationType)
|
|
539 |
{
|
|
540 |
TInt itemsOnScreen = 0;
|
|
541 |
|
|
542 |
for (TInt i = 0; i < aRowCount; i++)
|
|
543 |
{
|
|
544 |
SetupQuadsToRow(i, aRowCount, itemsOnScreen,
|
|
545 |
aItems, aViewX, aViewY, aCurItem, aPrevItem,
|
|
546 |
aAnimationAlpha, aAnimationState, aPickedItem,
|
|
547 |
aAnimationType);
|
|
548 |
}
|
|
549 |
|
|
550 |
TransformAndDraw(itemsOnScreen, aAnimationType);
|
|
551 |
}
|
|
552 |
|
|
553 |
|
|
554 |
TReal CHgVgMediaWallRenderer::GetWorldSpaceRowHeight() const
|
|
555 |
{
|
|
556 |
// TODO: replace these macig numbers
|
|
557 |
return (120.0 / 90.0 * 0.25 + 0.02);
|
|
558 |
}
|
|
559 |
|
|
560 |
|
|
561 |
// ---------------------------------------------------------------------------
|
|
562 |
// CHgVgCoverflowRenderer::CreateGround()
|
|
563 |
// ---------------------------------------------------------------------------
|
|
564 |
//
|
|
565 |
void CHgVgMediaWallRenderer::CreateGround()
|
|
566 |
{
|
|
567 |
// Create path and paint for drawing ground plane
|
|
568 |
|
|
569 |
iGroundPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, KGroundScale, KGroundBias,
|
|
570 |
KGroundVerticesHint, KGroundSegmentsHint, (unsigned int)VG_PATH_CAPABILITY_ALL);
|
|
571 |
|
|
572 |
vguRect(iGroundPath, 0, 0, 1, 1);
|
|
573 |
|
|
574 |
VGfloat gradientStops[] = {
|
|
575 |
0, 0.0f, 0.0f, 0.0f, 1.0f,
|
|
576 |
0.01f, 0.0f, 0.0f, 0.0f, 0.95f,
|
|
577 |
1.0f, 0.0f, 0.0f, 0.0f, 0.0f
|
|
578 |
};
|
|
579 |
|
|
580 |
VGfloat groundColor[4];
|
|
581 |
GetGroundColorFromSkin(groundColor);
|
|
582 |
|
|
583 |
gradientStops[1] = groundColor[0];
|
|
584 |
gradientStops[2] = groundColor[1];
|
|
585 |
gradientStops[3] = groundColor[2];
|
|
586 |
|
|
587 |
gradientStops[6] = groundColor[0];
|
|
588 |
gradientStops[7] = groundColor[1];
|
|
589 |
gradientStops[8] = groundColor[2];
|
|
590 |
|
|
591 |
gradientStops[11] = groundColor[0];
|
|
592 |
gradientStops[12] = groundColor[1];
|
|
593 |
gradientStops[13] = groundColor[2];
|
|
594 |
|
|
595 |
iGroundPaint = vgCreatePaint();
|
|
596 |
|
|
597 |
vgSetParameteri(iGroundPaint, VG_PAINT_TYPE,
|
|
598 |
VG_PAINT_TYPE_LINEAR_GRADIENT);
|
|
599 |
|
|
600 |
vgSetParameterfv(iGroundPaint, VG_PAINT_LINEAR_GRADIENT,
|
|
601 |
KNumGroundGradientValues, KGroundGradient);
|
|
602 |
|
|
603 |
vgSetParameteri(iGroundPaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE,
|
|
604 |
VG_COLOR_RAMP_SPREAD_PAD);
|
|
605 |
|
|
606 |
vgSetParameterfv(iGroundPaint, VG_PAINT_COLOR_RAMP_STOPS,
|
|
607 |
5*3, gradientStops);
|
|
608 |
|
|
609 |
|
|
610 |
}
|
|
611 |
|
|
612 |
// ---------------------------------------------------------------------------
|
|
613 |
// CHgVgCoverflowRenderer::DrawGround()
|
|
614 |
// ---------------------------------------------------------------------------
|
|
615 |
//
|
|
616 |
void CHgVgMediaWallRenderer::DrawGround(TInt aWidth, TInt aHeight)
|
|
617 |
{
|
|
618 |
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
|
|
619 |
vgLoadIdentity();
|
|
620 |
if (iLandscape)
|
|
621 |
{
|
|
622 |
vgTranslate(0.0f, 640.0f);
|
|
623 |
vgRotate(-90.0f);
|
|
624 |
}
|
|
625 |
|
|
626 |
//vgTranslate(iOffset.iX, iOffset.iY);
|
|
627 |
vgScale(aWidth, aHeight);
|
|
628 |
vgSetPaint(iGroundPaint, VG_FILL_PATH);
|
|
629 |
vgDrawPath(iGroundPath, VG_FILL_PATH);
|
|
630 |
}
|
|
631 |
|
|
632 |
|
|
633 |
|
|
634 |
// ---------------------------------------------------------------------------
|
|
635 |
// CHgVgMediaWallRenderer::SetupQuadsToRow()
|
|
636 |
// ---------------------------------------------------------------------------
|
|
637 |
//
|
|
638 |
void CHgVgMediaWallRenderer::SetupQuadsToRow(
|
|
639 |
TInt aRow,
|
|
640 |
TInt aRowCount,
|
|
641 |
TInt &aItemsOnScreen,
|
|
642 |
RPointerArray<CHgVgItem>& aItems,
|
|
643 |
TReal aViewX, TReal aViewY,
|
|
644 |
TInt aCurItem, TInt aPrevItem,
|
|
645 |
TReal aAnimationAlpha,
|
|
646 |
CHgVgMediaWall::THgVgAnimationState aState,
|
|
647 |
TInt aPickedItem,
|
|
648 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationType)
|
|
649 |
{
|
|
650 |
|
|
651 |
if (aItems.Count() <= 0)
|
|
652 |
return;
|
|
653 |
|
|
654 |
TReal src = aViewX;
|
|
655 |
TReal frac;
|
|
656 |
Math::Frac(frac, src);
|
|
657 |
VGfloat fDiff = frac;
|
|
658 |
|
|
659 |
TBool isSelectionToFocusedItem =
|
|
660 |
(
|
|
661 |
(aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateOpening) ||
|
|
662 |
(aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateClosing) ||
|
|
663 |
(aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateItemOpened)
|
|
664 |
) &&
|
|
665 |
(aAnimationType != CHgVgMediaWall::EHgVgOpeningAnimationNone);
|
|
666 |
|
|
667 |
TReal selectionAnimationAlpha = aAnimationAlpha;
|
|
668 |
if (aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateItemOpened)
|
|
669 |
selectionAnimationAlpha = 1.0f;
|
|
670 |
|
|
671 |
VGfloat leftIndex = (VGfloat)(iSelectedItemIndex - 1);
|
|
672 |
VGfloat leftX = iLeftStackEndX;
|
|
673 |
VGfloat step = iSpaceBetween;
|
|
674 |
|
|
675 |
if (AknLayoutUtils::LayoutMirrored())
|
|
676 |
{
|
|
677 |
leftX = iRightStackStartX;
|
|
678 |
step = -step;
|
|
679 |
}
|
|
680 |
|
|
681 |
TInt i = 0;
|
|
682 |
|
|
683 |
TInt currentRow = ((TInt)aViewX - (iSelectedItemIndex)) * aRowCount;
|
|
684 |
|
|
685 |
VGfloat zFar = iZNear;
|
|
686 |
VGfloat zNear = zFar - 0.8;
|
|
687 |
|
|
688 |
TInt itemsOnRow = 0;
|
|
689 |
|
|
690 |
TInt selX = aCurItem / 3;
|
|
691 |
TInt selY = aCurItem % 3;
|
|
692 |
|
|
693 |
TReal div = (TReal)(iQuads.Count()/aRowCount/2-1);
|
|
694 |
|
|
695 |
while (itemsOnRow < (iQuads.Count()/aRowCount))
|
|
696 |
{
|
|
697 |
|
|
698 |
TInt itemIndex = currentRow + i * 3 + aRow;
|
|
699 |
|
|
700 |
if (itemIndex < 0)
|
|
701 |
{
|
|
702 |
i++;
|
|
703 |
continue;
|
|
704 |
}
|
|
705 |
|
|
706 |
// all items drawn and at the end of the list, lets bail out.
|
|
707 |
if (itemIndex >= aItems.Count())
|
|
708 |
{
|
|
709 |
break;
|
|
710 |
}
|
|
711 |
|
|
712 |
TQuad* q = iQuads[aItemsOnScreen + itemsOnRow];
|
|
713 |
|
|
714 |
q->iZ = zFar;
|
|
715 |
q->iAngle = 0;
|
|
716 |
q->iFlipped = EFalse;
|
|
717 |
|
|
718 |
VGfloat fi = (VGfloat)i - fDiff;
|
|
719 |
|
|
720 |
q->iX = leftX - step * (leftIndex - fi);
|
|
721 |
q->iAlpha = 1;
|
|
722 |
|
|
723 |
q->iItemIndex = itemIndex;
|
|
724 |
|
|
725 |
if (aItems[itemIndex]->VgImage() == VG_INVALID_HANDLE)
|
|
726 |
{
|
|
727 |
q->iNoImage = ETrue;
|
|
728 |
}
|
|
729 |
else
|
|
730 |
{
|
|
731 |
q->iNoImage = EFalse;
|
|
732 |
q->iImage = aItems[itemIndex]->VgImage();
|
|
733 |
}
|
|
734 |
|
|
735 |
|
|
736 |
VGfloat imW = (VGfloat) iImageSize.iWidth;
|
|
737 |
VGfloat imH = (VGfloat) iImageSize.iHeight;
|
|
738 |
|
|
739 |
// width is constant but same aspect ratio must be preserved
|
|
740 |
VGfloat worldImageHeight = imH * (KWorldQuadWidth / imW);
|
|
741 |
|
|
742 |
q->iY = (2 - aRow) * (worldImageHeight + KSpaceBetweenGridItems);
|
|
743 |
|
|
744 |
if (aCurItem != KErrNotFound && itemIndex == aCurItem)
|
|
745 |
{
|
|
746 |
TReal alphaX = 1.0 - Min(Abs(aViewX - (TReal)selX), 1);
|
|
747 |
TReal alphaY = 1.0 - Min(Abs(aViewY - (TReal)selY), 1);
|
|
748 |
|
|
749 |
q->iZ = HgVgHelper::Lerp(zFar, zNear, Min(alphaX, alphaY));
|
|
750 |
}
|
|
751 |
else if (aPrevItem != KErrNotFound && itemIndex == aPrevItem)
|
|
752 |
{
|
|
753 |
TReal alphaX = 1.0 - Min(Abs(aViewX - (TReal)selX), 1);
|
|
754 |
TReal alphaY = 1.0 - Min(Abs(aViewY - (TReal)selY), 1);
|
|
755 |
|
|
756 |
q->iZ = HgVgHelper::Lerp(zFar, zNear, 1.0f - Min(alphaX, alphaY));
|
|
757 |
}
|
|
758 |
|
|
759 |
q->iAlpha = HgVgHelper::Lerp(1, 0, Max(0.0, (Abs(q->iX)-1.0) / div));
|
|
760 |
|
|
761 |
if (isSelectionToFocusedItem && (itemIndex == aPickedItem))
|
|
762 |
{
|
|
763 |
q->iAlpha = 1;
|
|
764 |
q->iFlipped = ETrue;
|
|
765 |
iBlurAlpha = selectionAnimationAlpha;
|
|
766 |
ApplyOpeningAnimation(q, selectionAnimationAlpha, zFar,
|
|
767 |
CHgVgMediaWall::EHgVgMediaWallStyleGrid,
|
|
768 |
aAnimationType);
|
|
769 |
}
|
|
770 |
|
|
771 |
if (iFlipXY)
|
|
772 |
{
|
|
773 |
VGfloat temp = q->iX;
|
|
774 |
q->iX = q->iY;
|
|
775 |
q->iY = -temp;
|
|
776 |
}
|
|
777 |
|
|
778 |
i++;
|
|
779 |
itemsOnRow++;
|
|
780 |
}
|
|
781 |
|
|
782 |
aItemsOnScreen += itemsOnRow;
|
|
783 |
|
|
784 |
}
|
|
785 |
|
|
786 |
|
|
787 |
|
|
788 |
// ---------------------------------------------------------------------------
|
|
789 |
// CHgVgMediaWallRenderer::SetupQuads()
|
|
790 |
// ---------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
TInt CHgVgMediaWallRenderer::SetupQuads(RPointerArray<CHgVgItem>& aItems,
|
|
793 |
TInt aSelectedIndex, TReal /*aNextIndex*/,
|
|
794 |
VGfloat aViewPosition,
|
|
795 |
VGfloat aAnimationAlpha,
|
|
796 |
CHgVgMediaWall::THgVgAnimationState aState,
|
|
797 |
CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType,
|
|
798 |
TReal /*aStartIndex*/,
|
|
799 |
TReal aSpringVelocity)
|
|
800 |
{
|
|
801 |
|
|
802 |
|
|
803 |
if (aItems.Count() <= 0)
|
|
804 |
return 0;
|
|
805 |
|
|
806 |
VGfloat selectionAnimationAlpha = aAnimationAlpha;
|
|
807 |
|
|
808 |
TBool isSelectionToFocusedItem =
|
|
809 |
((aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateOpening) ||
|
|
810 |
(aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateClosing) ||
|
|
811 |
(aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateItemOpened)) &&
|
|
812 |
(aOpeningAnimationType != CHgVgMediaWall::EHgVgOpeningAnimationNone);
|
|
813 |
|
|
814 |
if (aState == CHgVgMediaWall::EHgVgMediaWallAnimationStateItemOpened)
|
|
815 |
selectionAnimationAlpha = 1.0f;
|
|
816 |
|
|
817 |
TReal src = aViewPosition;
|
|
818 |
TReal frac;
|
|
819 |
Math::Frac(frac, src);
|
|
820 |
VGfloat fDiff = frac;
|
|
821 |
|
|
822 |
VGfloat leftIndex = (VGfloat)(iSelectedItemIndex - 1);
|
|
823 |
VGfloat leftX = iLeftStackEndX;
|
|
824 |
VGfloat step = iSpaceBetween;
|
|
825 |
|
|
826 |
// support mirrored layouts (right-to-left reading)
|
|
827 |
if (AknLayoutUtils::LayoutMirrored())
|
|
828 |
{
|
|
829 |
leftX = -iLeftStackEndX;
|
|
830 |
step = -step;
|
|
831 |
}
|
|
832 |
|
|
833 |
TInt i = 0;
|
|
834 |
TInt itemsOnScreen = 0;
|
|
835 |
TInt currentRow = (TInt)aViewPosition - KSelectedItemIndex;
|
|
836 |
|
|
837 |
TReal zAlpha = Abs(aSpringVelocity / KSpringVelocityToZAlpha);
|
|
838 |
VGfloat zNear = HgVgHelper::Lerp(iZFar, iZNear, 1.0f - BoundValue(zAlpha, 0, 1));
|
|
839 |
|
|
840 |
while (itemsOnScreen < iQuads.Count())
|
|
841 |
{
|
|
842 |
TInt itemIndex = currentRow + i;
|
|
843 |
|
|
844 |
// not really an item
|
|
845 |
if (itemIndex < 0)
|
|
846 |
{
|
|
847 |
i++;
|
|
848 |
continue;
|
|
849 |
}
|
|
850 |
|
|
851 |
// got past all items
|
|
852 |
if (itemIndex >= aItems.Count())
|
|
853 |
{
|
|
854 |
break;
|
|
855 |
}
|
|
856 |
|
|
857 |
// setup quads to represent coverflow
|
|
858 |
TQuad* q = iQuads[itemsOnScreen];
|
|
859 |
|
|
860 |
q->iY = 0;
|
|
861 |
q->iZ = iZFar;
|
|
862 |
q->iAngle = 0;
|
|
863 |
|
|
864 |
q->iFlipped = EFalse;
|
|
865 |
|
|
866 |
VGfloat fi = (VGfloat)i - fDiff;
|
|
867 |
|
|
868 |
q->iX = leftX - step * (leftIndex - fi);
|
|
869 |
|
|
870 |
|
|
871 |
/*if (aStartIndex != aNextIndex)
|
|
872 |
{
|
|
873 |
// if start and next index are not same, we can just interpolate
|
|
874 |
// items at these indices.
|
|
875 |
if (itemIndex == (TInt)aStartIndex ||
|
|
876 |
itemIndex == (TInt)aNextIndex)
|
|
877 |
{
|
|
878 |
q->iZ = EaseInQuad((VGfloat)zNear, (VGfloat)iZFar, BoundValue(Abs(q->iX / leftX), 0, 1));
|
|
879 |
q->iZ = Min(q->iZ, (VGfloat)iZFar);
|
|
880 |
}
|
|
881 |
}
|
|
882 |
else*/
|
|
883 |
{
|
|
884 |
// in this case we are just dragging and startindex and left index are
|
|
885 |
// same so we need to interpolate z for all items coming/leaving center
|
|
886 |
// of the screen.
|
|
887 |
|
|
888 |
q->iZ = EaseInQuad((VGfloat)zNear, (VGfloat)iZFar, BoundValue(Abs(q->iX / leftX), 0, 1));
|
|
889 |
q->iZ = Min(q->iZ, (VGfloat)iZFar);
|
|
890 |
}
|
|
891 |
|
|
892 |
// calculate alpha so that items further are more transparent.
|
|
893 |
q->iAlpha = HgVgHelper::Lerp(1, 0, Max(0.0, (Abs(q->iX)-2.0) / (TReal)(iQuads.Count()/2-2)));
|
|
894 |
|
|
895 |
q->iItemIndex = itemIndex;
|
|
896 |
|
|
897 |
// setup image to quad from item
|
|
898 |
if (aItems[itemIndex]->VgImage() == VG_INVALID_HANDLE)
|
|
899 |
{
|
|
900 |
q->iNoImage = ETrue;
|
|
901 |
}
|
|
902 |
else
|
|
903 |
{
|
|
904 |
q->iNoImage = EFalse;
|
|
905 |
q->iImage = aItems[itemIndex]->VgImage();
|
|
906 |
}
|
|
907 |
|
|
908 |
// apply opening animation to item if needed
|
|
909 |
if (isSelectionToFocusedItem && (itemIndex == aSelectedIndex))
|
|
910 |
{
|
|
911 |
q->iAlpha = 1;
|
|
912 |
q->iFlipped = ETrue;
|
|
913 |
iBlurAlpha = selectionAnimationAlpha;
|
|
914 |
ApplyOpeningAnimation(q, selectionAnimationAlpha, q->iZ,
|
|
915 |
CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen,
|
|
916 |
aOpeningAnimationType);
|
|
917 |
}
|
|
918 |
|
|
919 |
i++;
|
|
920 |
itemsOnScreen++;
|
|
921 |
}
|
|
922 |
|
|
923 |
return itemsOnScreen;
|
|
924 |
}
|
|
925 |
|
|
926 |
|
|
927 |
// ---------------------------------------------------------------------------
|
|
928 |
// CHgVgMediaWallRenderer::ApplyFlipAnimation()
|
|
929 |
// ---------------------------------------------------------------------------
|
|
930 |
//
|
|
931 |
void CHgVgMediaWallRenderer::ApplyOpeningAnimation(CHgVgMediaWallRenderer::TQuad* aQuad,
|
|
932 |
TReal aAnimationAlpha, TReal aZNear, CHgVgMediaWall::THgVgMediaWallStyle /*aMediaWallStyle*/,
|
|
933 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationStyle)
|
|
934 |
{
|
|
935 |
VGfloat wz = 0.0f;
|
|
936 |
VGfloat wy = (iCameraBaseY + iCameraY);
|
|
937 |
VGfloat wx = (iCameraBaseX + iCameraX);
|
|
938 |
VGfloat angle = 0;
|
|
939 |
|
|
940 |
if (aAnimationStyle == CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront)
|
|
941 |
{
|
|
942 |
wz = iFlippedZ;
|
|
943 |
angle = iFlipAngle;
|
|
944 |
wx += iFlippedX;
|
|
945 |
wy += iFlippedY;
|
|
946 |
}
|
|
947 |
else if (aAnimationStyle == CHgVgMediaWall::EHgVgOpeningAnimationZoomToFront)
|
|
948 |
{
|
|
949 |
wz = iFlippedZ;
|
|
950 |
wx += iFlippedX;
|
|
951 |
wy += iFlippedY;
|
|
952 |
}
|
|
953 |
|
|
954 |
if (iBlurImage != VG_INVALID_HANDLE)
|
|
955 |
{
|
|
956 |
VGImage image = aQuad->iNoImage ? iDefaultImage : aQuad->iImage;
|
|
957 |
UpdateBlurChildImage(image);
|
|
958 |
}
|
|
959 |
|
|
960 |
aQuad->iZ = HgVgHelper::Lerp(aZNear, wz, aAnimationAlpha);
|
|
961 |
aQuad->iX = HgVgHelper::Lerp(aQuad->iX, wx, aAnimationAlpha);
|
|
962 |
aQuad->iY = HgVgHelper::Lerp(aQuad->iY, wy, aAnimationAlpha);
|
|
963 |
aQuad->iAngle = -aAnimationAlpha * angle;
|
|
964 |
}
|
|
965 |
|
|
966 |
// ---------------------------------------------------------------------------
|
|
967 |
// CHgVgMediaWallRenderer::GetGroundColorFromSkin()
|
|
968 |
// ---------------------------------------------------------------------------
|
|
969 |
//
|
|
970 |
void CHgVgMediaWallRenderer::GetGroundColorFromSkin(VGfloat* aColor)
|
|
971 |
{
|
|
972 |
TRgb color(KRgbBlack);
|
|
973 |
// get text color from skin
|
|
974 |
if ( AknsUtils::AvkonSkinEnabled() )
|
|
975 |
{
|
|
976 |
// this does not modify color unless it gets a correct one
|
|
977 |
// no real need to check errors
|
|
978 |
AknsUtils::GetCachedColor(
|
|
979 |
AknsUtils::SkinInstance(),
|
|
980 |
color,
|
|
981 |
KAknsIIDQsnTextColors,
|
|
982 |
EAknsCIQsnTextColorsCG6 );
|
|
983 |
}
|
|
984 |
|
|
985 |
if (color.Blue() < 128)
|
|
986 |
color = KRgbWhite;
|
|
987 |
else
|
|
988 |
color = KRgbBlack;
|
|
989 |
|
|
990 |
aColor[0] = (VGfloat)color.Red() / KColorByteToFloat;
|
|
991 |
aColor[1] = (VGfloat)color.Green() / KColorByteToFloat;
|
|
992 |
aColor[2] = (VGfloat)color.Blue() / KColorByteToFloat;
|
|
993 |
aColor[3] = 1.0f;
|
|
994 |
}
|
|
995 |
|
|
996 |
// ---------------------------------------------------------------------------
|
|
997 |
// CHgVgMediaWallRenderer::HandleSkinChange()
|
|
998 |
// ---------------------------------------------------------------------------
|
|
999 |
//
|
|
1000 |
void CHgVgMediaWallRenderer::HandleSkinChange()
|
|
1001 |
{
|
|
1002 |
vgDestroyPaint(iGroundPaint);
|
|
1003 |
vgDestroyPath(iGroundPath);
|
|
1004 |
CreateGround();
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
// ---------------------------------------------------------------------------
|
|
1008 |
// CHgVgMediaWallRenderer::AdjustSettingsBaseOnFrontRect()
|
|
1009 |
// ---------------------------------------------------------------------------
|
|
1010 |
//
|
|
1011 |
void CHgVgMediaWallRenderer::AdjustSettingsBasedOnRects(const TRect& aFrontRect,
|
|
1012 |
TReal aZOffset)
|
|
1013 |
{
|
|
1014 |
|
|
1015 |
// size of the images should be the same as given for aFrontRect
|
|
1016 |
iImageSize = aFrontRect.Size();
|
|
1017 |
|
|
1018 |
// calculate screen center point
|
|
1019 |
TPoint center(iRect.Width()/2, iRect.Height()/2);
|
|
1020 |
|
|
1021 |
// near z coordinate is calculated so that the size of the quad at front matches
|
|
1022 |
// aFrontRect
|
|
1023 |
iZNear = GetZInWorldSpaceBasedOnWidth(aFrontRect.Width());
|
|
1024 |
iZFar = iZNear + aZOffset;
|
|
1025 |
|
|
1026 |
// width is always constant
|
|
1027 |
VGfloat ImW = KWorldQuadWidth;
|
|
1028 |
// height is altered by image aspect ratio
|
|
1029 |
VGfloat ImH = (VGfloat)(iImageSize.iHeight) * (KWorldQuadWidth / (VGfloat)iImageSize.iWidth);
|
|
1030 |
|
|
1031 |
// camera coordinates are altered so that the front quad
|
|
1032 |
// is at correct place
|
|
1033 |
VGfloat deltaX = aFrontRect.Center().iX - center.iX;
|
|
1034 |
VGfloat deltaY = aFrontRect.Center().iY - center.iY;
|
|
1035 |
|
|
1036 |
iCameraBaseX = ImW * (deltaX / (VGfloat)iImageSize.iWidth);
|
|
1037 |
iCameraBaseY = ImH * (deltaY / (VGfloat)iImageSize.iHeight);
|
|
1038 |
iCameraBaseZ = 0;
|
|
1039 |
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
|
|
1043 |
void CHgVgMediaWallRenderer::TransformAndDraw(TInt itemsOnScreen,
|
|
1044 |
CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType)
|
|
1045 |
{
|
|
1046 |
/*
|
|
1047 |
vgSeti( VG_SCISSORING, VG_TRUE );
|
|
1048 |
VGfloat rects[4];
|
|
1049 |
rects[0]= 0;
|
|
1050 |
rects[1]= 0;
|
|
1051 |
rects[2]= iRect.Width();
|
|
1052 |
rects[3]= iRect.Height();
|
|
1053 |
vgSetfv( VG_SCISSOR_RECTS, 4, rects );
|
|
1054 |
*/
|
|
1055 |
vgSeti( VG_SCISSORING, VG_FALSE );
|
|
1056 |
|
|
1057 |
if (itemsOnScreen > 0)
|
|
1058 |
{
|
|
1059 |
|
|
1060 |
// draw reflections
|
|
1061 |
|
|
1062 |
TransformQuads(itemsOnScreen,
|
|
1063 |
iReflectionsEnabled, iFov, aOpeningAnimationType);
|
|
1064 |
|
|
1065 |
TRAP_IGNORE( SortQuadsL(itemsOnScreen); )
|
|
1066 |
|
|
1067 |
if (iReflectionsEnabled)
|
|
1068 |
DrawQuads(ETrue);
|
|
1069 |
|
|
1070 |
DrawGround(iRect.Width(), iRect.Height() / KGroundHeightFactor);
|
|
1071 |
|
|
1072 |
DrawQuads(EFalse);
|
|
1073 |
|
|
1074 |
}
|
|
1075 |
else
|
|
1076 |
{
|
|
1077 |
|
|
1078 |
// if no items exists, just draw ground plane.
|
|
1079 |
DrawGround(iRect.Width(), iRect.Height() / KGroundHeightFactor);
|
|
1080 |
|
|
1081 |
}
|
|
1082 |
|
|
1083 |
//vgSeti( VG_SCISSORING, VG_FALSE );
|
|
1084 |
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
void CHgVgMediaWallRenderer::SetReflections(TBool aEnabled)
|
|
1088 |
{
|
|
1089 |
iReflectionsEnabled = aEnabled;
|
|
1090 |
}
|
|
1091 |
|
|
1092 |
TBool CHgVgMediaWallRenderer::ReflectionsEnabled() const
|
|
1093 |
{
|
|
1094 |
return iReflectionsEnabled;
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
TSize CHgVgMediaWallRenderer::ImageSize() const
|
|
1098 |
{
|
|
1099 |
return iImageSize;
|
|
1100 |
}
|
|
1101 |
|
|
1102 |
|
|
1103 |
void CHgVgMediaWallRenderer::SetFlippedRect(const TRect& aFlippedRect)
|
|
1104 |
{
|
|
1105 |
iFlippedWidth = aFlippedRect.Width();
|
|
1106 |
iFlippedHeight = aFlippedRect.Height();
|
|
1107 |
iFlippedZ = GetZInWorldSpaceBasedOnWidth(aFlippedRect.Width());
|
|
1108 |
TPoint center = iRect.Center();
|
|
1109 |
|
|
1110 |
VGfloat ImW = KWorldQuadWidth;
|
|
1111 |
VGfloat ImH = (VGfloat)(iImageSize.iHeight) * (KWorldQuadWidth / (VGfloat)iImageSize.iWidth);
|
|
1112 |
VGfloat deltaX = aFlippedRect.Center().iX - center.iX;
|
|
1113 |
VGfloat deltaY = aFlippedRect.Center().iY - center.iY;
|
|
1114 |
|
|
1115 |
iFlippedY = -ImH * (deltaY / (VGfloat)aFlippedRect.Height());
|
|
1116 |
iFlippedX = ImW * (deltaX / (VGfloat)aFlippedRect.Width());
|
|
1117 |
}
|
|
1118 |
|
|
1119 |
VGfloat CHgVgMediaWallRenderer::GetZInWorldSpaceBasedOnWidth(VGfloat aWidth)
|
|
1120 |
{
|
|
1121 |
|
|
1122 |
// calculate screen center point
|
|
1123 |
TPoint center(iRect.Width()/2, iRect.Height()/2);
|
|
1124 |
|
|
1125 |
// Z-coordinate is set so that the front quad has
|
|
1126 |
// the correct size
|
|
1127 |
TReal hw = iRect.Width() * 0.5f;
|
|
1128 |
TReal alpha = iFov / 2.0f;
|
|
1129 |
TReal tanAlpha;
|
|
1130 |
Math::Tan(tanAlpha, alpha);
|
|
1131 |
TReal d = hw / tanAlpha;
|
|
1132 |
|
|
1133 |
return (d * (-KWorldQuadWidth/2)) / ((TReal)(center.iX - aWidth/2) - hw);
|
|
1134 |
|
|
1135 |
}
|
|
1136 |
|
|
1137 |
void CHgVgMediaWallRenderer::SetFlipAngle(TReal aAngle)
|
|
1138 |
{
|
|
1139 |
iFlipAngle = aAngle;
|
|
1140 |
}
|
|
1141 |
|
|
1142 |
|
|
1143 |
void CHgVgMediaWallRenderer::EnableBlurOnFlip(TBool aEnabled, TReal aBlurX, TReal aBlurY)
|
|
1144 |
{
|
|
1145 |
if (iBlurImage != VG_INVALID_HANDLE)
|
|
1146 |
{
|
|
1147 |
vgDestroyImage(iBlurImage);
|
|
1148 |
iBlurImage = VG_INVALID_HANDLE;
|
|
1149 |
}
|
|
1150 |
if (aEnabled)
|
|
1151 |
{
|
|
1152 |
iBlurDeviationX = aBlurX;
|
|
1153 |
iBlurDeviationY = aBlurY;
|
|
1154 |
iBlurImage = vgCreateImage(VG_sRGBA_8888_PRE, iImageSize.iWidth, iImageSize.iHeight,
|
|
1155 |
VG_IMAGE_QUALITY_NONANTIALIASED);
|
|
1156 |
}
|
|
1157 |
}
|
|
1158 |
|
|
1159 |
void CHgVgMediaWallRenderer::UpdateBlurChildImage(VGImage aImage)
|
|
1160 |
{
|
|
1161 |
VGint width = vgGetParameteri(aImage, VG_IMAGE_WIDTH);
|
|
1162 |
VGint height = vgGetParameteri(aImage, VG_IMAGE_HEIGHT);
|
|
1163 |
|
|
1164 |
if (iBlurImageWidth != width || iBlurImageHeight != height)
|
|
1165 |
{
|
|
1166 |
vgDestroyImage(iChildBlurImage);
|
|
1167 |
iChildBlurImage = vgChildImage(iBlurImage, 0, 0, width, height);
|
|
1168 |
iBlurImageWidth = width;
|
|
1169 |
iBlurImageHeight = height;
|
|
1170 |
}
|
|
1171 |
}
|
|
1172 |
|
|
1173 |
|
|
1174 |
void CHgVgMediaWallRenderer::SetOffset(const TPoint& aOffset)
|
|
1175 |
{
|
|
1176 |
iOffset = aOffset;
|
|
1177 |
}
|
|
1178 |
|
|
1179 |
void CHgVgMediaWallRenderer::EnableFlipXY(TBool aEnabled)
|
|
1180 |
{
|
|
1181 |
iFlipXY = aEnabled;
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
void CHgVgMediaWallRenderer::EnableLandscapeMode(TBool enabled)
|
|
1185 |
{
|
|
1186 |
iLandscape = enabled;
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
|
|
1190 |
// End of File
|