graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanualsecondprocess.cpp
changeset 111 29ddb8a72f0e
equal deleted inserted replaced
110:7f25ef56562d 111:29ddb8a72f0e
       
     1 // Copyright (c) 2010 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 #include <e32msgqueue.h>
       
    17 #include <sgresource/sgimage.h>
       
    18 #include "tgraphicsresourcemultiprocessthread.h"
       
    19 
       
    20 // The second process waits for image IDs sent by the main test process
       
    21 // and opens and closes RSgImage handles to the corresponding images.
       
    22 // Image IDs are received through a message queue and synchronisation
       
    23 // with the main process is achieved by means of rendezvous objects.
       
    24 // A null ID indicates the end of the test.
       
    25 void MainL()
       
    26 	{
       
    27 	RSgDriver driver;
       
    28 	User::LeaveIfError(driver.Open());
       
    29 	CleanupClosePushL(driver);
       
    30 	RMsgQueue<TSgDrawableId> msgQ;
       
    31 	User::LeaveIfError(msgQ.OpenGlobal(KSgTestMultiprocessMsgQ));
       
    32 	CleanupClosePushL(msgQ);
       
    33 	for (;;)
       
    34 		{
       
    35 		TSgDrawableId id;
       
    36 		msgQ.ReceiveBlocking(id);
       
    37 		if (id == KSgNullDrawableId)
       
    38 			{
       
    39 			break;
       
    40 			}
       
    41 		RSgImage image;
       
    42 		TInt err = image.Open(id);
       
    43 		image.Close();
       
    44 		RProcess::Rendezvous(err);
       
    45 		}
       
    46 	CleanupStack::PopAndDestroy(2);
       
    47 	}
       
    48 
       
    49 GLDEF_C TInt E32Main()
       
    50 	{
       
    51 	__UHEAP_MARK;
       
    52 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    53 	if (!cleanup)
       
    54 		{
       
    55 		return KErrNoMemory;
       
    56 		}
       
    57 	TRAPD(ret, MainL());
       
    58 	delete cleanup;
       
    59 	__UHEAP_MARKEND;
       
    60 	return ret;
       
    61 	}