os/graphics/egl/egltest/endpointtestsuite/automated/src/renderstage.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 
    14 /**
    15  @file
    16  @test
    17  @internalComponent - Internal Symbian test code
    18 */
    19 
    20 
    21 //This render stage sets up a test thread within window server that waits on
    22 //an asynchonous message queue for test commands that are sent from the TEF driver app.
    23 //All render stage calls are simply forwarded to the next stage in the chain. The
    24 //renderstage is a NULL renderstage.
    25 
    26 
    27 #include "renderstage.h"
    28 #include "remotetestbase.h"
    29 #include <e32math.h>
    30 
    31 
    32 CRenderStage* CRenderStage::NewL(MWsGraphicDrawerEnvironment* /*aEnv*/, MWsScreen* /*aScreen*/, MWsScreenRedraw* /*aScreenRedraw*/, CWsRenderStage* aNextStage)
    33     {
    34     CRenderStage* stage = new(ELeave) CRenderStage();
    35     CleanupStack::PushL(stage);
    36     stage->ConstructL(aNextStage);
    37     CleanupStack::Pop(stage);
    38     return stage;
    39     }
    40 
    41 
    42 CRenderStage::CRenderStage()
    43     {
    44     }
    45 
    46 
    47 void CRenderStage::ConstructL(CWsRenderStage* aNextStage)
    48     {
    49     ENDPOINT_ASSERT_DEBUG(aNextStage, User::Invariant());
    50     BaseConstructL();
    51     SetNext(aNextStage);
    52 
    53     //Stack and heap sizes.
    54     static const TInt KStackSize =   0x2000;      //  8KB
    55     static const TInt KHeapMinSize = 0x1000;      //  4KB
    56     static const TInt KHeapMaxSize = 0x1000000;   // 16MB
    57 
    58     //Create test environment thread.
    59     TUint32 random = Math::Random();
    60     TName threadName;
    61     _LIT(KThreadNameFormat, "%S-%u");
    62     _LIT(KEnvName, "EpTestRemoteEnv");
    63     threadName.Format(KThreadNameFormat, &KEnvName, random);
    64     User::LeaveIfError(iTestEnvThread.Create(threadName, TestEnvThreadEntryPoint, KStackSize, KHeapMinSize, KHeapMaxSize, this));
    65     iTestEnvThread.Resume();
    66     }
    67 
    68 
    69 CRenderStage::~CRenderStage()
    70     {
    71     iTestEnvThread.Kill(KErrNone);
    72     }
    73 
    74 
    75 TAny* CRenderStage::ResolveObjectInterface(TUint aTypeId)
    76     {
    77     return Next()->ResolveObjectInterface(aTypeId);
    78     }
    79 
    80 
    81 void CRenderStage::Begin(const TRegion* aRegion)
    82     {
    83     Next()->Begin(aRegion);
    84     }
    85 
    86 
    87 void CRenderStage::End(TRequestStatus* aCompositorReady)
    88     {
    89     Next()->End(aCompositorReady);
    90     }
    91 
    92 
    93 TInt CRenderStage::TestEnvThreadEntryPoint(TAny* /*aSelf*/)
    94     {
    95     RDebug::Printf("CRenderStage: Entering Test Environment Thread...");
    96     
    97     //Create cleanup stack.
    98     CTrapCleanup* cleanup = CTrapCleanup::New();
    99     ASSERT(cleanup);
   100     
   101     //Create active scheduler.
   102     CActiveScheduler* scheduler = new CActiveScheduler();
   103     ASSERT(scheduler);
   104     CActiveScheduler::Install(scheduler);
   105     
   106     //Create a CRemoteTestEnv.
   107     CRemoteTestEnv* testEnv = NULL;
   108     TRAPD(err, testEnv = CRemoteTestEnv::NewL());
   109     __ASSERT_ALWAYS(err == KErrNone, User::Invariant());
   110     testEnv->StartReceivingCmds();
   111 
   112     //Clean up.
   113     delete scheduler;
   114     delete cleanup;
   115     RDebug::Printf("CRenderStage: Leaving Test Environment Thread...");
   116     return KErrNone;
   117     }
   118