uiacceltk/hitchcock/coretoolkit/src/HuiStatic_stubs.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     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 "uiacceltk/huiStatic.h"  // Class definition
       
    19 #include "uiacceltk/huiUtil.h"
       
    20 #include "uiacceltk/huiEnv.h"
       
    21 #include "huirenderplugin.h"
       
    22 #include "huistatictlsdata.h"
       
    23 #include "uiacceltk/huiProbe.h"
       
    24 #include <e32math.h>
       
    25 #include <eikenv.h>
       
    26 #include <flogger.h>
       
    27 
       
    28 
       
    29 
       
    30 void CHuiStatic::UpdateTime(TTlsData* aData)
       
    31     {
       
    32     ASSERT( aData );
       
    33     // Updates the toolkit's time counters. This includes the toolkit's
       
    34     // realtime clock, the internal absolute clock (which is affected by the
       
    35     // time factor), the amount of elapsed time since last UpdateTime()
       
    36     // invocation, and the amount of elapsed time since the first UpdateTime()
       
    37     // invocation (which was done in the beginning of the first refresh).
       
    38 
       
    39     if(aData->iIsFirstUpdateTime)
       
    40         {
       
    41         aData->iIsFirstUpdateTime = EFalse;
       
    42         aData->iFirstUpdateTime.UniversalTime();
       
    43         aData->iUniversalTime = aData->iFirstUpdateTime;
       
    44         aData->iRealUniversalTime = aData->iUniversalTime;
       
    45         return;
       
    46         }
       
    47 
       
    48     TTime now;
       
    49     now.UniversalTime();
       
    50 
       
    51     // Advance the toolkit's internal clock, applying the time factor.
       
    52     if(!aData->iTimePaused)
       
    53         {
       
    54         aData->iInternalElapsed = now.MicroSecondsFrom(aData->iRealUniversalTime).Int64();
       
    55         aData->iInternalElapsed = (TInt64)((TReal32)aData->iInternalElapsed * aData->iTimeFactor);
       
    56         aData->iUniversalTime += TTimeIntervalMicroSeconds(aData->iInternalElapsed);
       
    57         }
       
    58     else
       
    59         {
       
    60         aData->iInternalElapsed = aData->iInternalElapsedBeforePausing;
       
    61         aData->iInternalElapsedBeforePausing = 0;        
       
    62         }
       
    63 
       
    64     aData->iRealUniversalTime = now;      
       
    65     }
       
    66 
       
    67 
       
    68 TUint32 CHuiStatic::MilliSecondsSinceUpdateTime()
       
    69     {
       
    70     TTlsData* data = Data();
       
    71     
       
    72     TTime now;
       
    73     now.UniversalTime();
       
    74     
       
    75     return now.MicroSecondsFrom(data->iRealUniversalTime).Int64() / 1000;
       
    76     }
       
    77 
       
    78 
       
    79 
       
    80 void CHuiStatic::SetRenderer(CHuiRenderPlugin& aRenderer)
       
    81     {
       
    82     if(!Data())
       
    83         {
       
    84         THuiPanic::Panic(THuiPanic::EStaticDataNotCreated);
       
    85         }
       
    86     Data()->iRenderer = &aRenderer;
       
    87     }
       
    88 
       
    89 
       
    90 void CHuiStatic::UpdateTime()
       
    91     {
       
    92     // Updates the toolkit's time counters. This includes the toolkit's
       
    93     // realtime clock, the internal absolute clock (which is affected by the
       
    94     // time factor), the amount of elapsed time since last UpdateTime()
       
    95     // invocation, and the amount of elapsed time since the first UpdateTime()
       
    96     // invocation (which was done in the beginning of the first refresh).
       
    97 
       
    98     TTlsData* data = Data();
       
    99     
       
   100     UpdateTime(data);
       
   101     }
       
   102 
       
   103 
       
   104 
       
   105 TInt CHuiStatic::GenerateId()
       
   106     {
       
   107     TTlsData* data = Data();
       
   108 
       
   109     // The ID counter counts backwards.
       
   110     TInt id = data->iIdCounter;
       
   111 
       
   112     if(data->iIdCounter == KMinTInt)
       
   113         {
       
   114         // Wrap around to stay negative.
       
   115         data->iIdCounter = -1;
       
   116         }
       
   117     else
       
   118         {
       
   119         --data->iIdCounter;
       
   120         }
       
   121 
       
   122     return id;
       
   123     }
       
   124 
       
   125 
       
   126 void CHuiStatic::ReportNewFrame()
       
   127     {
       
   128     TTlsData* data = Data();
       
   129     data->iFrameCounter++;
       
   130     data->iCurrentFrameCounter++;
       
   131     }
       
   132