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