os/graphics/windowing/windowserverplugins/openwfc/inc/rendertarget.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserverplugins/openwfc/inc/rendertarget.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,127 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __RENDERTARGET_H__
    1.20 +#define __RENDERTARGET_H__
    1.21 +
    1.22 +#include <graphics/sgimagecollection.h>
    1.23 +#include <graphics/wsuibuffer.h>
    1.24 +#include "directgdigcwrapper.h"
    1.25 +
    1.26 +#if defined(__WINS__) && defined(_DEBUG)
    1.27 +class CDebugOsbWin;
    1.28 +#endif
    1.29 +
    1.30 +class RWsOffScreenImageTarget
    1.31 +	{
    1.32 +public:
    1.33 +	RWsOffScreenImageTarget();
    1.34 +	void OpenL(TUint32 aUsage,TSgCpuAccess aCpuAccess,TUidPixelFormat aPixelFormat,const TSize& aSize, TInt aScreenNumber);
    1.35 +	void Close();
    1.36 +public:
    1.37 +	static const TInt KAspectRatioCount = 2;
    1.38 +	TSgImageInfo iImageInfos[KAspectRatioCount];
    1.39 +	RDirectGdiImageTarget iImageTargets[KAspectRatioCount];
    1.40 +	RSgImageCollection iImageCollections[KAspectRatioCount];
    1.41 +	RSgImage iImages[KAspectRatioCount];
    1.42 +	};
    1.43 +
    1.44 +class CRenderTarget : public CBase, public MWsUiBuffer
    1.45 +	{
    1.46 +public:
    1.47 +	enum TAspectRatio
    1.48 +		{
    1.49 +		ENormalAspectRatio = 0,
    1.50 +		EInvertedAspectRatio = 1,
    1.51 +		EAspectRatioCount = RWsOffScreenImageTarget::KAspectRatioCount
    1.52 +		};
    1.53 +public:
    1.54 +	static CRenderTarget* NewL(MWsIniFile* aIniFile, TUint32 aUsage, TSgCpuAccess aCpuAccess, TDisplayMode aDisplayMode, 
    1.55 +			const TSize& aSize, TInt aScreenNumber);
    1.56 +	~CRenderTarget();
    1.57 +
    1.58 +	TAny* ResolveObjectInterface(TUint aTypeId);
    1.59 +
    1.60 +	TDisplayMode DisplayMode() const;
    1.61 +	const TSurfaceId& SurfaceId() const;
    1.62 +
    1.63 +	inline TAspectRatio AspectRatio() const;
    1.64 +	void SetAspectRatio(TAspectRatio aAspectRatio);
    1.65 +	const TSgDrawableId& ImageId(TAspectRatio aAspectRatio) const;
    1.66 +
    1.67 +	inline CDirectGdiGcWrapper* DirectGdiGc() const;
    1.68 +	TInt SetDrawDeviceOffset(TPoint& aOrigin);
    1.69 +	
    1.70 +	TInt AllocNewTarget(RWsOffScreenImageTarget& aNewTarget, const TSize& aNewSize);
    1.71 +	void SwitchTarget(RWsOffScreenImageTarget& aNewTarget);	//takes ownership of aNewTarget
    1.72 +
    1.73 +	void GetPixel(TRgb& aColor, const TPoint& aPixel) const;
    1.74 +	void GetScanLine(TDes8& aScanLine, const TPoint& aStartPixel, TInt aPixelLength, TDisplayMode aDispMode) const;
    1.75 +	TBool RectCompare(const TRect& aRect1, const TRect& aRect2) const;
    1.76 +	void CopyToBitmapL(CFbsBitmap* aBitmap, const TRect& aRect) const;
    1.77 +
    1.78 +#if defined(__WINS__) && defined(_DEBUG)
    1.79 +	void UpdateDebugWin();
    1.80 +#endif	
    1.81 +
    1.82 +public: //from MWsUiBuffer
    1.83 +	TInt MapReadWrite(TAny*& aDataAddress, TInt& aDataStride);
    1.84 +	TInt MapWriteOnly(TAny*& aDataAddress, TInt& aDataStride);
    1.85 +	TInt Unmap();
    1.86 +	TUidPixelFormat PixelFormat() const;
    1.87 +	TSize SizeInPixels() const;
    1.88 +	
    1.89 +public:
    1.90 +	TPoint iOffset;
    1.91 +
    1.92 +private:
    1.93 +	CRenderTarget();
    1.94 +	void ConstructL(MWsIniFile* aIniFile, TUint32 aUsage, TSgCpuAccess aCpuAccess, TDisplayMode aDisplayMode, const TSize& aSize, TInt aScreenNumber);
    1.95 +	inline RSgImage& Image();
    1.96 +	inline const RSgImage& Image() const;
    1.97 +	inline const RSgImageCollection& ImageCollection() const;
    1.98 +	inline const TSgImageInfo& ImageInfo() const;
    1.99 +	const TUint8* DataAddress(const TAny* aStartDataAddress, const TPoint& aStartPoint, TInt aDataStride, TInt aBpp) const;
   1.100 +	TInt MapReadOnly(const TAny*& aDataAddress, TInt& aDataStride) const;
   1.101 +	TInt Unmap() const;
   1.102 +
   1.103 +private:
   1.104 +	RWsOffScreenImageTarget iTarget;
   1.105 +	TAspectRatio iCurrentAspectRatio;
   1.106 +	CDirectGdiGcWrapper* iDirectGdiGcWrapper;
   1.107 +#if defined(__WINS__) && defined(_DEBUG)
   1.108 +	CDebugOsbWin* iOsbWin;
   1.109 +#endif
   1.110 +	};
   1.111 +
   1.112 +inline CRenderTarget::TAspectRatio CRenderTarget::AspectRatio() const
   1.113 +	{ return iCurrentAspectRatio; }
   1.114 +
   1.115 +inline CDirectGdiGcWrapper* CRenderTarget::DirectGdiGc() const
   1.116 +	{ return iDirectGdiGcWrapper; }
   1.117 +
   1.118 +inline RSgImage& CRenderTarget::Image()
   1.119 +	{ return iTarget.iImages[iCurrentAspectRatio]; }
   1.120 +
   1.121 +inline const RSgImage& CRenderTarget::Image() const
   1.122 +	{ return iTarget.iImages[iCurrentAspectRatio]; }
   1.123 +
   1.124 +inline const RSgImageCollection& CRenderTarget::ImageCollection() const
   1.125 +	{ return iTarget.iImageCollections[iCurrentAspectRatio]; }
   1.126 +
   1.127 +inline const TSgImageInfo& CRenderTarget::ImageInfo() const
   1.128 +	{ return iTarget.iImageInfos[iCurrentAspectRatio]; }
   1.129 +
   1.130 +#endif // __RENDERTARGET_H__