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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __RENDERTARGET_H__
17 #define __RENDERTARGET_H__
19 #include <graphics/sgimagecollection.h>
20 #include <graphics/wsuibuffer.h>
21 #include "directgdigcwrapper.h"
23 #if defined(__WINS__) && defined(_DEBUG)
27 class RWsOffScreenImageTarget
30 RWsOffScreenImageTarget();
31 void OpenL(TUint32 aUsage,TSgCpuAccess aCpuAccess,TUidPixelFormat aPixelFormat,const TSize& aSize, TInt aScreenNumber);
34 static const TInt KAspectRatioCount = 2;
35 TSgImageInfo iImageInfos[KAspectRatioCount];
36 RDirectGdiImageTarget iImageTargets[KAspectRatioCount];
37 RSgImageCollection iImageCollections[KAspectRatioCount];
38 RSgImage iImages[KAspectRatioCount];
41 class CRenderTarget : public CBase, public MWsUiBuffer
46 ENormalAspectRatio = 0,
47 EInvertedAspectRatio = 1,
48 EAspectRatioCount = RWsOffScreenImageTarget::KAspectRatioCount
51 static CRenderTarget* NewL(MWsIniFile* aIniFile, TUint32 aUsage, TSgCpuAccess aCpuAccess, TDisplayMode aDisplayMode,
52 const TSize& aSize, TInt aScreenNumber);
55 TAny* ResolveObjectInterface(TUint aTypeId);
57 TDisplayMode DisplayMode() const;
58 const TSurfaceId& SurfaceId() const;
60 inline TAspectRatio AspectRatio() const;
61 void SetAspectRatio(TAspectRatio aAspectRatio);
62 const TSgDrawableId& ImageId(TAspectRatio aAspectRatio) const;
64 inline CDirectGdiGcWrapper* DirectGdiGc() const;
65 TInt SetDrawDeviceOffset(TPoint& aOrigin);
67 TInt AllocNewTarget(RWsOffScreenImageTarget& aNewTarget, const TSize& aNewSize);
68 void SwitchTarget(RWsOffScreenImageTarget& aNewTarget); //takes ownership of aNewTarget
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;
75 #if defined(__WINS__) && defined(_DEBUG)
76 void UpdateDebugWin();
79 public: //from MWsUiBuffer
80 TInt MapReadWrite(TAny*& aDataAddress, TInt& aDataStride);
81 TInt MapWriteOnly(TAny*& aDataAddress, TInt& aDataStride);
83 TUidPixelFormat PixelFormat() const;
84 TSize SizeInPixels() const;
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;
101 RWsOffScreenImageTarget iTarget;
102 TAspectRatio iCurrentAspectRatio;
103 CDirectGdiGcWrapper* iDirectGdiGcWrapper;
104 #if defined(__WINS__) && defined(_DEBUG)
105 CDebugOsbWin* iOsbWin;
109 inline CRenderTarget::TAspectRatio CRenderTarget::AspectRatio() const
110 { return iCurrentAspectRatio; }
112 inline CDirectGdiGcWrapper* CRenderTarget::DirectGdiGc() const
113 { return iDirectGdiGcWrapper; }
115 inline RSgImage& CRenderTarget::Image()
116 { return iTarget.iImages[iCurrentAspectRatio]; }
118 inline const RSgImage& CRenderTarget::Image() const
119 { return iTarget.iImages[iCurrentAspectRatio]; }
121 inline const RSgImageCollection& CRenderTarget::ImageCollection() const
122 { return iTarget.iImageCollections[iCurrentAspectRatio]; }
124 inline const TSgImageInfo& CRenderTarget::ImageInfo() const
125 { return iTarget.iImageInfos[iCurrentAspectRatio]; }
127 #endif // __RENDERTARGET_H__