os/graphics/windowing/windowserverplugins/openwfc/inc/rendertarget.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-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 #ifndef __RENDERTARGET_H__
    17 #define __RENDERTARGET_H__
    18 
    19 #include <graphics/sgimagecollection.h>
    20 #include <graphics/wsuibuffer.h>
    21 #include "directgdigcwrapper.h"
    22 
    23 #if defined(__WINS__) && defined(_DEBUG)
    24 class CDebugOsbWin;
    25 #endif
    26 
    27 class RWsOffScreenImageTarget
    28 	{
    29 public:
    30 	RWsOffScreenImageTarget();
    31 	void OpenL(TUint32 aUsage,TSgCpuAccess aCpuAccess,TUidPixelFormat aPixelFormat,const TSize& aSize, TInt aScreenNumber);
    32 	void Close();
    33 public:
    34 	static const TInt KAspectRatioCount = 2;
    35 	TSgImageInfo iImageInfos[KAspectRatioCount];
    36 	RDirectGdiImageTarget iImageTargets[KAspectRatioCount];
    37 	RSgImageCollection iImageCollections[KAspectRatioCount];
    38 	RSgImage iImages[KAspectRatioCount];
    39 	};
    40 
    41 class CRenderTarget : public CBase, public MWsUiBuffer
    42 	{
    43 public:
    44 	enum TAspectRatio
    45 		{
    46 		ENormalAspectRatio = 0,
    47 		EInvertedAspectRatio = 1,
    48 		EAspectRatioCount = RWsOffScreenImageTarget::KAspectRatioCount
    49 		};
    50 public:
    51 	static CRenderTarget* NewL(MWsIniFile* aIniFile, TUint32 aUsage, TSgCpuAccess aCpuAccess, TDisplayMode aDisplayMode, 
    52 			const TSize& aSize, TInt aScreenNumber);
    53 	~CRenderTarget();
    54 
    55 	TAny* ResolveObjectInterface(TUint aTypeId);
    56 
    57 	TDisplayMode DisplayMode() const;
    58 	const TSurfaceId& SurfaceId() const;
    59 
    60 	inline TAspectRatio AspectRatio() const;
    61 	void SetAspectRatio(TAspectRatio aAspectRatio);
    62 	const TSgDrawableId& ImageId(TAspectRatio aAspectRatio) const;
    63 
    64 	inline CDirectGdiGcWrapper* DirectGdiGc() const;
    65 	TInt SetDrawDeviceOffset(TPoint& aOrigin);
    66 	
    67 	TInt AllocNewTarget(RWsOffScreenImageTarget& aNewTarget, const TSize& aNewSize);
    68 	void SwitchTarget(RWsOffScreenImageTarget& aNewTarget);	//takes ownership of aNewTarget
    69 
    70 	void GetPixel(TRgb& aColor, const TPoint& aPixel) const;
    71 	void GetScanLine(TDes8& aScanLine, const TPoint& aStartPixel, TInt aPixelLength, TDisplayMode aDispMode) const;
    72 	TBool RectCompare(const TRect& aRect1, const TRect& aRect2) const;
    73 	void CopyToBitmapL(CFbsBitmap* aBitmap, const TRect& aRect) const;
    74 
    75 #if defined(__WINS__) && defined(_DEBUG)
    76 	void UpdateDebugWin();
    77 #endif	
    78 
    79 public: //from MWsUiBuffer
    80 	TInt MapReadWrite(TAny*& aDataAddress, TInt& aDataStride);
    81 	TInt MapWriteOnly(TAny*& aDataAddress, TInt& aDataStride);
    82 	TInt Unmap();
    83 	TUidPixelFormat PixelFormat() const;
    84 	TSize SizeInPixels() const;
    85 	
    86 public:
    87 	TPoint iOffset;
    88 
    89 private:
    90 	CRenderTarget();
    91 	void ConstructL(MWsIniFile* aIniFile, TUint32 aUsage, TSgCpuAccess aCpuAccess, TDisplayMode aDisplayMode, const TSize& aSize, TInt aScreenNumber);
    92 	inline RSgImage& Image();
    93 	inline const RSgImage& Image() const;
    94 	inline const RSgImageCollection& ImageCollection() const;
    95 	inline const TSgImageInfo& ImageInfo() const;
    96 	const TUint8* DataAddress(const TAny* aStartDataAddress, const TPoint& aStartPoint, TInt aDataStride, TInt aBpp) const;
    97 	TInt MapReadOnly(const TAny*& aDataAddress, TInt& aDataStride) const;
    98 	TInt Unmap() const;
    99 
   100 private:
   101 	RWsOffScreenImageTarget iTarget;
   102 	TAspectRatio iCurrentAspectRatio;
   103 	CDirectGdiGcWrapper* iDirectGdiGcWrapper;
   104 #if defined(__WINS__) && defined(_DEBUG)
   105 	CDebugOsbWin* iOsbWin;
   106 #endif
   107 	};
   108 
   109 inline CRenderTarget::TAspectRatio CRenderTarget::AspectRatio() const
   110 	{ return iCurrentAspectRatio; }
   111 
   112 inline CDirectGdiGcWrapper* CRenderTarget::DirectGdiGc() const
   113 	{ return iDirectGdiGcWrapper; }
   114 
   115 inline RSgImage& CRenderTarget::Image()
   116 	{ return iTarget.iImages[iCurrentAspectRatio]; }
   117 
   118 inline const RSgImage& CRenderTarget::Image() const
   119 	{ return iTarget.iImages[iCurrentAspectRatio]; }
   120 
   121 inline const RSgImageCollection& CRenderTarget::ImageCollection() const
   122 	{ return iTarget.iImageCollections[iCurrentAspectRatio]; }
   123 
   124 inline const TSgImageInfo& CRenderTarget::ImageInfo() const
   125 	{ return iTarget.iImageInfos[iCurrentAspectRatio]; }
   126 
   127 #endif // __RENDERTARGET_H__