os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanualsecondprocess.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32msgqueue.h>
sl@0
    17
#include <sgresource/sgimage.h>
sl@0
    18
#include "tgraphicsresourcemultiprocessthread.h"
sl@0
    19
sl@0
    20
// The second process waits for image IDs sent by the main test process
sl@0
    21
// and opens and closes RSgImage handles to the corresponding images.
sl@0
    22
// Image IDs are received through a message queue and synchronisation
sl@0
    23
// with the main process is achieved by means of rendezvous objects.
sl@0
    24
// A null ID indicates the end of the test.
sl@0
    25
void MainL()
sl@0
    26
	{
sl@0
    27
	RSgDriver driver;
sl@0
    28
	User::LeaveIfError(driver.Open());
sl@0
    29
	CleanupClosePushL(driver);
sl@0
    30
	RMsgQueue<TSgDrawableId> msgQ;
sl@0
    31
	User::LeaveIfError(msgQ.OpenGlobal(KSgTestMultiprocessMsgQ));
sl@0
    32
	CleanupClosePushL(msgQ);
sl@0
    33
	for (;;)
sl@0
    34
		{
sl@0
    35
		TSgDrawableId id;
sl@0
    36
		msgQ.ReceiveBlocking(id);
sl@0
    37
		if (id == KSgNullDrawableId)
sl@0
    38
			{
sl@0
    39
			break;
sl@0
    40
			}
sl@0
    41
		RSgImage image;
sl@0
    42
		TInt err = image.Open(id);
sl@0
    43
		image.Close();
sl@0
    44
		RProcess::Rendezvous(err);
sl@0
    45
		}
sl@0
    46
	CleanupStack::PopAndDestroy(2);
sl@0
    47
	}
sl@0
    48
sl@0
    49
GLDEF_C TInt E32Main()
sl@0
    50
	{
sl@0
    51
	__UHEAP_MARK;
sl@0
    52
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
    53
	if (!cleanup)
sl@0
    54
		{
sl@0
    55
		return KErrNoMemory;
sl@0
    56
		}
sl@0
    57
	TRAPD(ret, MainL());
sl@0
    58
	delete cleanup;
sl@0
    59
	__UHEAP_MARKEND;
sl@0
    60
	return ret;
sl@0
    61
	}