windowing/windowserver/nonnga/CLIENT/scrdevextension.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2000-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 // Description:
       
    14 //
       
    15 
       
    16 #include "scrdevextension.h"
       
    17 #include "../SERVER/w32cmd.h"
       
    18 #include <graphics/displaycontrolbase.h>
       
    19 #include "CLIENT.H"
       
    20 #include "w32comm.h"
       
    21 
       
    22 CWsScreenDevice::CScrDevExtension::CScrDevExtension(RWsBuffer *aBuffer,TInt32 aWsHandle):	MWsClientClass(aBuffer)
       
    23 	{
       
    24 	iWsHandle=aWsHandle;
       
    25 	__ASSERT_DEBUG(aBuffer,Panic(EW32PanicBadClientInterface));
       
    26 	__ASSERT_DEBUG(aWsHandle,Panic(EW32PanicBadClientInterface));
       
    27 	}
       
    28 
       
    29 CWsScreenDevice::CScrDevExtension::~CScrDevExtension()
       
    30 	{
       
    31 	//typeface store is not owned by this class, and is created/destroyed in CWsScreenDevice
       
    32 	}
       
    33 /** Interface Extension capability
       
    34  * 	Use of this interface going forward will allow the published client interface to be dynamically extended.
       
    35  * 	Note that the pointer returned is only good for the lifetime of the called CBase derived object.
       
    36  * 	@pre	caller has already checked that the implementation is initialised using RepeatableConstruct
       
    37  *	@param  aInterfaceId	uniqueid or well known id of interface
       
    38  * 	@return	pointer to interface object matching this ID or NULL if no match.
       
    39  **/
       
    40 void* CWsScreenDevice::CScrDevExtension::GetInterface(TUint aInterfaceId)
       
    41 	{
       
    42 	__ASSERT_DEBUG(this!=NULL,Panic(EW32PanicBadClientInterface));
       
    43 	__ASSERT_DEBUG(iBuffer,Panic(EW32PanicBadClientInterface));
       
    44 	__ASSERT_DEBUG(iWsHandle!=NULL,Panic(EW32PanicBadClientInterface));
       
    45 	
       
    46 	switch (aInterfaceId)
       
    47 		{
       
    48 		case MTestScreenCapture::ETypeId:
       
    49 			{
       
    50 				return static_cast<MTestScreenCapture*>(this);
       
    51 			}
       
    52 		default:
       
    53 			break;
       
    54 		}
       
    55 	return NULL;
       
    56 }
       
    57 //Accessor to typeface store instance
       
    58 CFbsTypefaceStore* CWsScreenDevice::CScrDevExtension::TypefaceStore()
       
    59 	{
       
    60 	return iTypefaceStore;
       
    61 	}
       
    62 //Accessor to typeface store instance
       
    63 void  CWsScreenDevice::CScrDevExtension::SetTypefaceStore(CFbsTypefaceStore* aTypeFaceStore)
       
    64 	{
       
    65 	iTypefaceStore=aTypeFaceStore;
       
    66 	}
       
    67 
       
    68 
       
    69 TInt CWsScreenDevice::CScrDevExtension::TranslateExtent(const TRect& aInitial, TRect& aTarget) const
       
    70 	{
       
    71   	// Current screen mode scale
       
    72 	TPckgBuf<TSize> pntPkg;
       
    73 	TInt err = WriteReplyP(&pntPkg,EWsSdOpGetCurrentScreenModeScale);
       
    74 	TSize scale = pntPkg();	
       
    75 	
       
    76 	// Current screen mode offset
       
    77 	TPckgBuf<TPoint> soPkg;
       
    78 	err = WriteReplyP(&soPkg,EWsSdOpGetCurrentScreenModeScaledOrigin);
       
    79 	TPoint offset = soPkg();
       
    80 	
       
    81 	// Calculate the top left point taking into account scale and offset
       
    82 	TInt startingPointWidth = (scale.iWidth * aInitial.iTl.iX) + offset.iX;
       
    83 	TInt startingPointHeight = (scale.iHeight * aInitial.iTl.iY) + offset.iY;	
       
    84 	TPoint targetXY(startingPointWidth,startingPointHeight);
       
    85 	
       
    86 	// Calculate the extent size taking into account scale
       
    87 	TInt targetWidth = (scale.iWidth * aInitial.Width());
       
    88 	TInt targetHeight = (scale.iHeight * aInitial.Height());
       
    89 	TSize targetSize(targetWidth,targetHeight);
       
    90 	
       
    91 	aTarget.SetRect(targetXY,targetSize);
       
    92 	return err;
       
    93 	}
       
    94 
       
    95 
       
    96 /** Gets the size of the screen device area in pixels.
       
    97 
       
    98 This function always causes a flush of the window server buffer.
       
    99 
       
   100 @return The x and y dimensions of the screen device area, in pixels. 
       
   101 @see CGraphicsDevice::SizeInPixels() */
       
   102 TInt CWsScreenDevice::CScrDevExtension::GetCompositedSize(TSize& aSize) const
       
   103 	{
       
   104 	TPckgBuf<TSize> sizePkg;
       
   105   	TInt err = WriteReplyP(&sizePkg,EWsSdOpPixelSize);
       
   106   	aSize = sizePkg();
       
   107 	return err;
       
   108 	}
       
   109 
       
   110 
       
   111 
       
   112 /** Saves the entire screen to a bitmap.
       
   113 
       
   114 This function always causes a flush of the window server buffer.
       
   115 
       
   116 @param aBitmap Bitmap to be filled with the screen image. 
       
   117 @return KErrNone if successful, otherwise one of the system-wide error codes. */
       
   118 TInt CWsScreenDevice::CScrDevExtension::ComposeScreen(const CFbsBitmap& aBitmap) const
       
   119 	{
       
   120 	TInt bitmapHandle = aBitmap.Handle();
       
   121 	AddToBitmapArray(bitmapHandle);
       
   122 	TWsSdCmdCopyScreenToBitmap rectCompare(bitmapHandle);
       
   123 	return(WriteReply(&rectCompare,sizeof(rectCompare),EWsSdOpCopyScreenToBitmap));
       
   124 	}