Update contrib.
1 // Copyright (c) 2006-2010 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.
14 // This module define the class and constants used for the different display
25 /********************************************************************/
29 #if !defined(__E32SVR_H__)
31 #endif /* __E32SVR_H__ */
33 #include <graphics/surfaceupdateclient.h>
35 #include "BitDrawInterfaceId.h"
36 #include "bitdrawsurface.h"
37 #include <graphics/surface.h>
38 #include <pixelformats.h>
44 The maximum number of rectangles to be held in the update region. This must be
45 at least 3, since it has to be able to hold the union of two rectangles using
48 const TInt KMaxUpdateRegionRectangles = 10;
51 * Provide common features shared between screen devices. Included by composition
52 * rather than inheritance, to avoid multiple inheritance of implementation.
54 NONSHARABLE_CLASS(CScreenDeviceHelper) : public CBase
57 // Default constructor.
58 TInt Construct(TInt aScreenNo, TUidPixelFormat aPixelFormat, TUint aHalMode);
59 ~CScreenDeviceHelper();
61 inline TInt ScreenNumber() const { return iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField]; }
64 void Update(TRequestStatus& aStatus);
66 void UpdateRegion(const TRect& aRect);
67 void ResetUpdateRegion();
68 void NotifyWhenAvailable(TRequestStatus& aStatus);
69 void CancelUpdateNotification();
71 void GetSurface(TSurfaceId& aSid) const ;
72 TUint DeviceOrientationsAvailable(const TSize& aScreenSize) const ;
73 TUint BytesPerScanline() const;
74 void* AddressFirstPixel() const;
76 TBool SetDeviceOrientation(TDeviceOrientation aOrientation, TSize& aNewSize);
78 TDeviceOrientation DeviceOrientation() const ;
79 TBool DeviceFlipped() const;
81 TInt HorzTwipsPerThousandPixels(const TSize& aPixels)const;
82 TInt VertTwipsPerThousandPixels(const TSize& aPixels)const;
85 template <class Type> Type SecondIfFlipped(Type aValueUnFlipped,Type aValueFlipped)const
93 return aValueUnFlipped;
96 TBool SetDeviceFlipMode(TBool aFlip, TSize& aNewSize);
97 inline static TBool ConvertFlip(TDeviceOrientation aOrientation)
99 return (aOrientation&(EDeviceOrientation90CW|EDeviceOrientation270CW))!=0;
104 TDeviceOrientation iAssignedOrientation;
105 RSurfaceUpdateSession iSurfaceUpdateSession;
106 TRegionFix<KMaxUpdateRegionRectangles> iUpdateRegion;
112 This template class is a helper to genericise the common implementation of the screen device.
113 This class implements all the non-specific implementation.
115 template <class TCDrawXxxBppBitmap>
116 class CGenericScreenDevice : public TCDrawXxxBppBitmap , public MSurfaceId
119 typedef TCDrawXxxBppBitmap CDrawXxxBppBitmap;
120 virtual TInt InitScreen() ;
121 virtual TInt ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
122 virtual void SetDisplayMode(CFbsDrawDevice*);
123 virtual TInt HorzTwipsPerThousandPixels() const;
124 virtual TInt VertTwipsPerThousandPixels() const;
126 virtual void Update();
127 virtual void Update(const TRegion& aRegion);
128 virtual void UpdateRegion(const TRect& aRect);
130 virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
133 virtual void GetSurface(TSurfaceId& aSid) const ;
134 virtual TUint DeviceOrientationsAvailable() const ;
135 virtual TDeviceOrientation DeviceOrientation() const ;
137 //derived classes must implement virtual void SetSize(const TSize& aSize);
138 //derived classes must implement virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation)=0;
139 CScreenDeviceHelper iHelper;
144 This template class is a helper to genericise the common implementation of the screen device.
145 This class implements the "bits per pixel" specific implementation for modes that do not have GUIDs,
146 but probably have palettes instead.
148 - CDrawXxxBppBitmap The base pixel class that provides most of the drawing functionality.
149 - displayMode The symbian enumeraion for the mode - used when no GUID is defined.
150 - pixelsPerWord Number of pixels packed in a 32-bit word
152 template <class TCDrawXxxBppBitmap,TDisplayMode displayMode,TInt pixelsPerWord>
153 class CPalettizedScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
156 typedef CGenericScreenDevice<TCDrawXxxBppBitmap> CGenericScreenDevice;
157 virtual TInt ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
158 virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
160 virtual void SetSize(const TSize& aSize);
164 This template class is a helper to genericise the common implementation of the screen device.
165 This class implements the "bits per pixel" specific implementation for modes that do have GUIDs.
167 - CDrawXxxBppBitmap The base pixel class that provides most of the drawing functionality.
168 - guidMode The GUID for the mode - used by GCE
169 - pixelsPerWord Number of pixels packed in a 32-bit word
171 template <class TCDrawXxxBppBitmap,TUidPixelFormat guidMode,TInt pixelsPerWord>
172 class CGuidScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
175 typedef ::CGenericScreenDevice<TCDrawXxxBppBitmap> CGenericScreenDevice;
176 virtual TInt ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
177 virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
179 virtual void SetSize(const TSize& aSize);
185 class CDrawOneBppScreenBitmap : public CPalettizedScreenDevice<CDrawOneBppBitmap,EGray2,32>
191 class CDrawTwoBppScreenBitmap : public CPalettizedScreenDevice<CDrawTwoBppBitmap,EGray4,16>
197 class CDrawFourBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawFourBppBitmapGray,EGray16,8>
203 class CDrawFourBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawFourBppBitmapColor,EColor16,8>
209 class CDrawEightBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawEightBppBitmapGray,EGray256,4>
215 class CDrawEightBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawEightBppBitmapColor,EColor256,4>
221 class CDrawTwelveBppScreenBitmapColor : public CGuidScreenDevice<CDrawTwelveBppBitmap,EUidPixelFormatXRGB_4444,2>
227 class CDrawSixteenBppScreenBitmap : public CGuidScreenDevice<CDrawSixteenBppBitmap,EUidPixelFormatRGB_565,2>
233 class CDrawUTwentyFourBppScreenBitmap : public CGuidScreenDevice<CDrawUTwentyFourBppBitmap,EUidPixelFormatXRGB_8888,1>
239 class CDrawThirtyTwoBppScreenBitmapAlpha : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlpha,EUidPixelFormatARGB_8888,1>
246 class CDrawThirtyTwoBppScreenBitmapAlphaPM : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlphaPM,EUidPixelFormatARGB_8888_PRE,1>
250 #endif /* __SCDRAW_H__ */