windowing/windowserver/nonnga/CLIENT/scrdevextension.cpp
author William Roberts <williamr@symbian.org>
Thu, 03 Jun 2010 17:39:46 +0100
branchNewGraphicsArchitecture
changeset 87 0709f76d91e5
parent 0 5d03bc08d59c
permissions -rw-r--r--
Add MMP files to build libOpenVG_sw.lib which uses LINKAS to redirect to libOpenVG.dll (and the same for libEGL_sw.lib and libOpenVGU_sw.lib). Only the libEGL_sw.lib redirection isn't activated - this can't happen until there is a merged libEGL.dll which supports the OpenWF synchronisation and also implements the graphical support functions. The overall aim is to eliminate the *_sw.dll implementations, at least as a compile-time way of choosing a software-only implementation.The correct way to choose is to put the right set of libraries into a ROM with suitable renaming, and in the emulator to use the "switching DLL" technique to pick the right set. As the Symbian Foundation doesn't have any alternative implementations, we don't need the switching DLLs and we can build directly to the correct name.

// Copyright (c) 2000-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:
//

#include "scrdevextension.h"
#include "../SERVER/w32cmd.h"
#include <graphics/displaycontrolbase.h>
#include "CLIENT.H"
#include "w32comm.h"

CWsScreenDevice::CScrDevExtension::CScrDevExtension(RWsBuffer *aBuffer,TInt32 aWsHandle):	MWsClientClass(aBuffer)
	{
	iWsHandle=aWsHandle;
	__ASSERT_DEBUG(aBuffer,Panic(EW32PanicBadClientInterface));
	__ASSERT_DEBUG(aWsHandle,Panic(EW32PanicBadClientInterface));
	}

CWsScreenDevice::CScrDevExtension::~CScrDevExtension()
	{
	//typeface store is not owned by this class, and is created/destroyed in CWsScreenDevice
	}
/** Interface Extension capability
 * 	Use of this interface going forward will allow the published client interface to be dynamically extended.
 * 	Note that the pointer returned is only good for the lifetime of the called CBase derived object.
 * 	@pre	caller has already checked that the implementation is initialised using RepeatableConstruct
 *	@param  aInterfaceId	uniqueid or well known id of interface
 * 	@return	pointer to interface object matching this ID or NULL if no match.
 **/
void* CWsScreenDevice::CScrDevExtension::GetInterface(TUint aInterfaceId)
	{
	__ASSERT_DEBUG(this!=NULL,Panic(EW32PanicBadClientInterface));
	__ASSERT_DEBUG(iBuffer,Panic(EW32PanicBadClientInterface));
	__ASSERT_DEBUG(iWsHandle!=NULL,Panic(EW32PanicBadClientInterface));
	
	switch (aInterfaceId)
		{
		case MTestScreenCapture::ETypeId:
			{
				return static_cast<MTestScreenCapture*>(this);
			}
		default:
			break;
		}
	return NULL;
}
//Accessor to typeface store instance
CFbsTypefaceStore* CWsScreenDevice::CScrDevExtension::TypefaceStore()
	{
	return iTypefaceStore;
	}
//Accessor to typeface store instance
void  CWsScreenDevice::CScrDevExtension::SetTypefaceStore(CFbsTypefaceStore* aTypeFaceStore)
	{
	iTypefaceStore=aTypeFaceStore;
	}


TInt CWsScreenDevice::CScrDevExtension::TranslateExtent(const TRect& aInitial, TRect& aTarget) const
	{
  	// Current screen mode scale
	TPckgBuf<TSize> pntPkg;
	TInt err = WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeScale);
	TSize scale = pntPkg();	
	
	// Current screen mode offset
	TPckgBuf<TPoint> soPkg;
	err = WriteReplyP(&soPkg,EWsSdOpGetCurrentScreenModeScaledOrigin);
	TPoint offset = soPkg();
	
	// Calculate the top left point taking into account scale and offset
	TInt startingPointWidth = (scale.iWidth * aInitial.iTl.iX) + offset.iX;
	TInt startingPointHeight = (scale.iHeight * aInitial.iTl.iY) + offset.iY;	
	TPoint targetXY(startingPointWidth,startingPointHeight);
	
	// Calculate the extent size taking into account scale
	TInt targetWidth = (scale.iWidth * aInitial.Width());
	TInt targetHeight = (scale.iHeight * aInitial.Height());
	TSize targetSize(targetWidth,targetHeight);
	
	aTarget.SetRect(targetXY,targetSize);
	return err;
	}


/** Gets the size of the screen device area in pixels.

This function always causes a flush of the window server buffer.

@return The x and y dimensions of the screen device area, in pixels. 
@see CGraphicsDevice::SizeInPixels() */
TInt CWsScreenDevice::CScrDevExtension::GetCompositedSize(TSize& aSize) const
	{
	TPckgBuf<TSize> sizePkg;
  	TInt err = WriteReplyP(&sizePkg,EWsSdOpPixelSize);
  	aSize = sizePkg();
	return err;
	}



/** Saves the entire screen to a bitmap.

This function always causes a flush of the window server buffer.

@param aBitmap Bitmap to be filled with the screen image. 
@return KErrNone if successful, otherwise one of the system-wide error codes. */
TInt CWsScreenDevice::CScrDevExtension::ComposeScreen(const CFbsBitmap& aBitmap) const
	{
	TInt bitmapHandle = aBitmap.Handle();
	AddToBitmapArray(bitmapHandle);
	TWsSdCmdCopyScreenToBitmap rectCompare(bitmapHandle);
	return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpCopyScreenToBitmap));
	}