graphicsdeviceinterface/screendriver/sgeneric/scdraw.h
changeset 0 5d03bc08d59c
child 26 15986eb6c500
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2006-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 // This module define the class and constants used for the different display
       
    15 // mode supported.
       
    16 // Include files                                                   
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @prototype
       
    24 */
       
    25 /********************************************************************/
       
    26 #ifndef __SCDRAW_H__
       
    27 #define __SCDRAW_H__
       
    28 
       
    29 #if !defined(__E32SVR_H__)
       
    30     #include <e32svr.h>
       
    31 #endif /* __E32SVR_H__ */
       
    32 
       
    33 #include <graphics/surfaceupdateclient.h>
       
    34 #include "BMDRAW.H"
       
    35 #include "BitDrawInterfaceId.h"
       
    36 #include "bitdrawsurface.h"
       
    37 #include <graphics/surface.h>
       
    38 #include <pixelformats.h>
       
    39 
       
    40 
       
    41 class TSurfaceId;
       
    42 
       
    43 /**
       
    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
       
    46 disjoint rectangles.
       
    47 */
       
    48 const TInt		KMaxUpdateRegionRectangles	= 10;
       
    49 
       
    50 /**
       
    51  * Provide common features shared between screen devices. Included by composition
       
    52  * rather than inheritance, to avoid multiple inheritance of implementation.
       
    53  */
       
    54 NONSHARABLE_CLASS(CScreenDeviceHelper) : public CBase
       
    55 	{
       
    56 public:
       
    57 	// Default constructor.
       
    58 	TInt Construct(TInt aScreenNo, TUidPixelFormat aPixelFormat, TUint aHalMode);
       
    59 	~CScreenDeviceHelper();
       
    60 
       
    61 	inline TInt ScreenNumber() const { return iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField]; }
       
    62 
       
    63 	void Update();
       
    64 	void Update(const TRegion& aRegion);
       
    65 	void UpdateRegion(const TRect& aRect);
       
    66 	void ResetUpdateRegion();
       
    67 	void NotifyWhenAvailable(TRequestStatus& aStatus);
       
    68 
       
    69 	void GetSurface(TSurfaceId& aSid) const ;
       
    70 	TUint DeviceOrientationsAvailable(const TSize& aScreenSize) const ;
       
    71 	TUint BytesPerScanline() const;
       
    72 	void* AddressFirstPixel() const;
       
    73 
       
    74 	TBool SetDeviceOrientation(TDeviceOrientation aOrientation, TSize& aNewSize);
       
    75 	
       
    76 	TDeviceOrientation DeviceOrientation() const ;
       
    77 	TBool	DeviceFlipped() const;
       
    78 
       
    79 	TInt	HorzTwipsPerThousandPixels(const TSize& aPixels)const; 
       
    80 	TInt	VertTwipsPerThousandPixels(const TSize& aPixels)const; 
       
    81 	
       
    82 protected:
       
    83 	template <class Type> Type SecondIfFlipped(Type aValueUnFlipped,Type aValueFlipped)const
       
    84 		{
       
    85 		if (DeviceFlipped())
       
    86 			{
       
    87 			return aValueFlipped;
       
    88 			}
       
    89 		else
       
    90 			{
       
    91 			return aValueUnFlipped;
       
    92 			}
       
    93 		}
       
    94 	TBool SetDeviceFlipMode(TBool aFlip, TSize& aNewSize);
       
    95 	inline static TBool ConvertFlip(TDeviceOrientation aOrientation)
       
    96 		{
       
    97 		return (aOrientation&(EDeviceOrientation90CW|EDeviceOrientation270CW))!=0;
       
    98 		}
       
    99 		
       
   100 private:
       
   101     TSurfaceId iSurface;
       
   102     TDeviceOrientation iAssignedOrientation;
       
   103 	RSurfaceUpdateSession iSurfaceUpdateSession;
       
   104 	TRegionFix<KMaxUpdateRegionRectangles> iUpdateRegion;
       
   105 	RChunk iChunk;
       
   106 	TBool  iHasChunk;
       
   107 	};
       
   108 
       
   109 /**
       
   110 This template class is a helper to genericise the common implementation of the screen device.
       
   111 This class implements all the non-specific implementation.
       
   112 **/
       
   113 template <class TCDrawXxxBppBitmap> 
       
   114 class CGenericScreenDevice : public TCDrawXxxBppBitmap , public MSurfaceId
       
   115 	{
       
   116 public:
       
   117 	typedef TCDrawXxxBppBitmap		CDrawXxxBppBitmap;
       
   118 	virtual TInt  InitScreen() ;
       
   119 	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
       
   120     virtual void SetDisplayMode(CFbsDrawDevice*);
       
   121    	virtual TInt HorzTwipsPerThousandPixels() const;
       
   122 	virtual TInt VertTwipsPerThousandPixels() const;
       
   123 
       
   124 	virtual void Update();
       
   125 	virtual void Update(const TRegion& aRegion);
       
   126 	virtual void UpdateRegion(const TRect& aRect);
       
   127 
       
   128 	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
       
   129 
       
   130 	// From MSurfaceId
       
   131 	virtual void GetSurface(TSurfaceId& aSid) const ;
       
   132 	virtual TUint DeviceOrientationsAvailable() const ;
       
   133 	virtual TDeviceOrientation DeviceOrientation() const ;
       
   134 protected:
       
   135 	//derived classes must implement virtual void SetSize(const TSize& aSize);
       
   136 	//derived classes must implement virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation)=0;
       
   137 	CScreenDeviceHelper iHelper;
       
   138 
       
   139 	};
       
   140 
       
   141 /**
       
   142 This template class is a helper to genericise the common implementation of the screen device.
       
   143 This class implements the "bits per pixel" specific implementation for modes that do not have GUIDs,
       
   144 but probably have palettes instead.
       
   145 params:	
       
   146 	-	CDrawXxxBppBitmap	The base pixel class that provides most of the drawing functionality.
       
   147 	-	displayMode			The symbian enumeraion for the mode - used when no GUID is defined.
       
   148 	-	pixelsPerWord		Number of pixels packed in a 32-bit word
       
   149 **/
       
   150 template <class TCDrawXxxBppBitmap,TDisplayMode displayMode,TInt pixelsPerWord>
       
   151 class CPalettizedScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
       
   152 	{
       
   153 public:
       
   154 	typedef  CGenericScreenDevice<TCDrawXxxBppBitmap>	CGenericScreenDevice;
       
   155 	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
       
   156 	virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
       
   157 protected:
       
   158 	virtual void SetSize(const TSize& aSize);
       
   159 	};
       
   160 
       
   161 /**
       
   162 This template class is a helper to genericise the common implementation of the screen device.
       
   163 This class implements the "bits per pixel" specific implementation for modes that do have GUIDs.
       
   164 params:	
       
   165 	-	CDrawXxxBppBitmap	The base pixel class that provides most of the drawing functionality.
       
   166 	-	guidMode			The GUID for the mode - used by GCE
       
   167 	-	pixelsPerWord		Number of pixels packed in a 32-bit word
       
   168 **/
       
   169 template <class TCDrawXxxBppBitmap,TUidPixelFormat guidMode,TInt pixelsPerWord> 
       
   170 class CGuidScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
       
   171 	{
       
   172 public:
       
   173 	typedef  ::CGenericScreenDevice<TCDrawXxxBppBitmap>	CGenericScreenDevice;
       
   174 	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
       
   175 	virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
       
   176 protected:
       
   177 	virtual void SetSize(const TSize& aSize);
       
   178 	};
       
   179 
       
   180 /**
       
   181 @internalComponent
       
   182 */
       
   183 class CDrawOneBppScreenBitmap : public CPalettizedScreenDevice<CDrawOneBppBitmap,EGray2,32>
       
   184 	{};
       
   185 
       
   186 /**
       
   187 @internalComponent
       
   188 */
       
   189 class CDrawTwoBppScreenBitmap : public CPalettizedScreenDevice<CDrawTwoBppBitmap,EGray4,16>
       
   190 	{};
       
   191 
       
   192 /**
       
   193 @internalComponent
       
   194 */
       
   195 class CDrawFourBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawFourBppBitmapGray,EGray16,8>
       
   196 	{};
       
   197 
       
   198 /**
       
   199 @internalComponent
       
   200 */
       
   201 class CDrawFourBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawFourBppBitmapColor,EColor16,8>
       
   202 	{};
       
   203 
       
   204 /**
       
   205 @internalComponent
       
   206 */
       
   207 class CDrawEightBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawEightBppBitmapGray,EGray256,4>
       
   208 	{};
       
   209 
       
   210 /**
       
   211 @internalComponent
       
   212 */
       
   213 class CDrawEightBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawEightBppBitmapColor,EColor256,4>
       
   214 	{};
       
   215 
       
   216 /**
       
   217 @internalComponent
       
   218 */
       
   219 class CDrawTwelveBppScreenBitmapColor : public CGuidScreenDevice<CDrawTwelveBppBitmap,EUidPixelFormatXRGB_4444,2>
       
   220 	{};
       
   221 
       
   222 /**
       
   223 @internalComponent
       
   224 */
       
   225 class CDrawSixteenBppScreenBitmap : public CGuidScreenDevice<CDrawSixteenBppBitmap,EUidPixelFormatRGB_565,2>
       
   226 	{};
       
   227 
       
   228 /**
       
   229 @internalComponent
       
   230 */
       
   231 class CDrawUTwentyFourBppScreenBitmap : public CGuidScreenDevice<CDrawUTwentyFourBppBitmap,EUidPixelFormatXRGB_8888,1>
       
   232 	{};
       
   233 
       
   234 /**
       
   235 @internalComponent
       
   236 */
       
   237 class CDrawThirtyTwoBppScreenBitmapAlpha : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlpha,EUidPixelFormatARGB_8888,1>
       
   238 	{};
       
   239 
       
   240 
       
   241 /**
       
   242 @internalComponent
       
   243 */
       
   244 class CDrawThirtyTwoBppScreenBitmapAlphaPM : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlphaPM,EUidPixelFormatARGB_8888_PRE,1>
       
   245 	{};
       
   246 
       
   247 
       
   248 #endif /* __SCDRAW_H__ */
       
   249