os/graphics/graphicscomposition/surfaceupdate/tsrc/trequestorder.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19  @internalComponent - Internal Symbian test code 
    20 */
    21 
    22 #include "trequestorder.h"
    23 
    24 CRequestOrder::CRequestOrder(TInt aNumberAsynchronousRequests) :
    25     iNumberAsynchronousRequests(aNumberAsynchronousRequests)
    26     {
    27     }
    28 
    29 CRequestOrder::~CRequestOrder()
    30     {
    31     delete iOrderArray;
    32     iLock.Close();
    33     }
    34     
    35 void CRequestOrder::ConstructL()
    36     {
    37     User::LeaveIfError(iLock.CreateLocal());
    38     
    39     iOrderArray = new (ELeave) TOrderArray[iNumberAsynchronousRequests];
    40     User::LeaveIfNull(iOrderArray);
    41     
    42     ResetAll();
    43     }
    44 
    45 CRequestOrder* CRequestOrder::NewL(const TInt aNumberAsynchronousRequests)
    46     {
    47     CRequestOrder* requestOrder = new (ELeave) CRequestOrder(aNumberAsynchronousRequests);
    48     CleanupStack::PushL(requestOrder);
    49     requestOrder->ConstructL();
    50     CleanupStack::Pop();
    51     return requestOrder;
    52     }
    53 
    54 
    55 void CRequestOrder::ResetAll() 
    56     {
    57     iIndex=0;
    58     iOrderIndexBefore=0;
    59     iOrderIndexComposition=0;
    60     iOrderIndexAfter=0;
    61     
    62     for(TInt i=0; i<iNumberAsynchronousRequests;i++)
    63             {
    64             iOrderArray[i].iType = EOrderErr;
    65             iOrderArray[i].iNumber = 0;
    66             }
    67     }
    68 
    69 TInt CRequestOrder::GetIndex() 
    70     {
    71     return iIndex;
    72     }
    73 
    74 void CRequestOrder::SetOrder(TOrderType aOrderType) 
    75     {
    76     iLock.Wait();
    77     iOrderArray[iIndex].iType = aOrderType;
    78     switch (aOrderType)
    79         {
    80         case EOrderBefore:
    81             {
    82             iOrderArray[iIndex].iNumber = iOrderIndexBefore++;
    83             break;
    84             }
    85         case EOrderComposition:
    86             {
    87             iOrderArray[iIndex].iNumber = iOrderIndexComposition++;
    88             break;
    89             }
    90         case EOrderAfter:
    91             {
    92             iOrderArray[iIndex].iNumber = iOrderIndexAfter++;
    93             break;
    94             }
    95         default:
    96             {
    97             _LIT(KMsg, "GRAPHICS-SURFACEUPDATE-0003");
    98             User::Panic(KMsg, 1);
    99             break;
   100             }
   101         }
   102     iIndex++;
   103     iLock.Signal();
   104     }
   105 
   106 TOrderType CRequestOrder::GetOrderType(TInt aIndex) 
   107     { 
   108     return iOrderArray[aIndex].iType;
   109     }
   110 
   111 TInt CRequestOrder::GetOrderNumber(TInt aIndex)
   112     {
   113     return iOrderArray[aIndex].iNumber;
   114     }