windowing/windowserver/test/t_gdcoverage/gdcoverage.cpp
author Faisal Memon <faisal.memon@nokia.com>
Fri, 14 May 2010 15:41:33 +0100
branchNewGraphicsArchitecture
changeset 64 5c983aa672ea
parent 0 5d03bc08d59c
permissions -rw-r--r--
Merge 1. Pull in cpp files in the performance enhanced Khronos RI OVG files which are newly added. I've ignored platform-specific cpp files for linux, macosx, and null operating systems because this local solution has its own platform glue (i.e. facility to target Bitmaps but no full windowing support). I've ignored sfEGLInterface.cpp because this is used as a bridge to go from EGL to Nokia's Platsim which offers an EGL service. That's not relevant to this implementation because this is ARM side code, not Intel side. I just left a comment to sfEGLInterface.cpp in case we need to pick up this later on. The current code compiles on winscw. Prior to this fix, the code works on winscw, and can launch the SVG tiger (tiger.exe). That takes about 20 seconds to render. I hope to always be able to show this icon on each commit, and the plan is for the render time to reduce with this series of submissions. On this commit, the tiger renders ok in 20 seconds.

// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

/**
 @file
 @test
 @internalComponent - Internal Symbian test coverage code for GraphicDrawer related code
*/

#include "gdcoverage.h"
#include <fbs.h>
#include <bitdev.h>
#include <bitstd.h>
#include <gdi.h>
#include <graphics/wsscreendevice.h>

const TInt KDefaultScreen = 0;

//
CWsGraphicDrawerCoverage* CWsGraphicDrawerCoverage::NewL()
	{
	return new(ELeave) CWsGraphicDrawerCoverage;
	}
	
CWsGraphicDrawerCoverage::~CWsGraphicDrawerCoverage()
	{
	}
	
void CWsGraphicDrawerCoverage::ConstructL(
	MWsGraphicDrawerEnvironment& aEnv,
	const TGraphicDrawerId& aId,
	MWsClient& aOwner,
	const TDesC8& aData)
	{
	BaseConstructL(aEnv, aId, aOwner);

	iScreenId = KDefaultScreen;
	if (aData.Length()>0)
		iScreenId = aData[0];
	MWsScreen* scr = aEnv.Screen(iScreenId);
	User::LeaveIfNull(scr);

	//NGA supports MWsScreenDevice and non-NGA supports MWsScreenConfig, MWsFrontBuffer, MWsBackBuffer
	MWsScreenDevice* screenDevice = scr->ObjectInterface<MWsScreenDevice>();
	if(screenDevice)
		{
		//empty for now
		}
	else
		{
		MWsScreenConfig* cfg = scr->ObjectInterface<MWsScreenConfig>();
		User::LeaveIfNull(cfg);
		TSize sizeInPixels = cfg->ScreenModeSizeInPixels();
		__ASSERT_ALWAYS(sizeInPixels.iWidth>0 && sizeInPixels.iHeight>0, User::Invariant());
		__ASSERT_ALWAYS(cfg->Stride()>0, User::Invariant());
		__ASSERT_ALWAYS(cfg->ScalingFactor()==TSize(1,1), User::Invariant());
		__ASSERT_ALWAYS(cfg->Origin()==TPoint(0,0), User::Invariant());
		
		MWsFrontBuffer* fBuffer = scr->ObjectInterface<MWsFrontBuffer>();
		User::LeaveIfNull(fBuffer);
		__ASSERT_ALWAYS(fBuffer->GetBits()!=NULL, User::Invariant());
		__ASSERT_ALWAYS(fBuffer->GetBitGc()!=NULL, User::Invariant());
		}

	MWsScreenRedraw* redraw = scr->ObjectInterface<MWsScreenRedraw>();
	User::LeaveIfNull(redraw);
	}

void CWsGraphicDrawerCoverage::HandleMessage(const TDesC8& aData)
	{
	// wserv already check data size, and won't invoke this handler if it's empty
	TBuf8<1> ack;
	ack.Append(KGdCoverageInfoSig);

	MWsGraphicDrawerEnvironment& env = Env();
	MWsScreen* scr = env.Screen(iScreenId);
	MWsScreenRedraw* redraw = scr->ObjectInterface<MWsScreenRedraw>();
	
	switch (aData[0])
		{
		case KGdCoverageCmdQuery:
			SendInfo();
			break;

		case KGdCoverageCmdCoverRedraw:
			{
			//Hint: for extra coverage in ScheduleRender find a way to call
			//CWsTop::WindowServer()->AnimationScheduler()->Animate(*scr);
		
			//cannot create a real observer, for coverage null is sufficient
			redraw->SetObserver(NULL);
			redraw->IsUpdatePending();
			TTimeIntervalMicroSeconds interval(1);
			redraw->ScheduleRender(interval);
			const TRegion *r = redraw->AnimationRegion();
			redraw->UpdateDevice();
			//although redraw is actually a CScreenRedraw, we cannot include
			//the ScreenRedraw.h here so the following methods are not available:
			//redraw->AddRedrawRegion(*r, ETrue, ERedrawTopOnly);
			//redraw->OnAnimation();
			break;
			}
			
		default:
			SendMessage(ack);
			break;
		}
	}
	
void CWsGraphicDrawerCoverage::DoDraw(MWsGc& /*aGc*/, const TRect& /*aRect*/, const TDesC8& /*aData*/) const
	{
	}

void CWsGraphicDrawerCoverage::SendInfo()
	{
	TPckgBuf<TGdCoverageInfo> buf;
	MWsScreen* scr = Env().Screen(iScreenId);
	if (scr)
		{
		buf().iSignature = KGdCoverageInfoSig;
		buf().iNumTests = 1;
		}
	TInt err = SendMessage(buf);
	__ASSERT_ALWAYS(err>=KErrNone, User::Invariant());
	}