os/graphics/graphicsdeviceinterface/screendriver/sgeneric/scdraw.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     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(TRequestStatus& aStatus);
    65 
    66 	void UpdateRegion(const TRect& aRect);
    67 	void ResetUpdateRegion();
    68 	void NotifyWhenAvailable(TRequestStatus& aStatus);
    69 	void CancelUpdateNotification();
    70 
    71 	void GetSurface(TSurfaceId& aSid) const ;
    72 	TUint DeviceOrientationsAvailable(const TSize& aScreenSize) const ;
    73 	TUint BytesPerScanline() const;
    74 	void* AddressFirstPixel() const;
    75 
    76 	TBool SetDeviceOrientation(TDeviceOrientation aOrientation, TSize& aNewSize);
    77 	
    78 	TDeviceOrientation DeviceOrientation() const ;
    79 	TBool	DeviceFlipped() const;
    80 
    81 	TInt	HorzTwipsPerThousandPixels(const TSize& aPixels)const; 
    82 	TInt	VertTwipsPerThousandPixels(const TSize& aPixels)const; 
    83 	
    84 protected:
    85 	template <class Type> Type SecondIfFlipped(Type aValueUnFlipped,Type aValueFlipped)const
    86 		{
    87 		if (DeviceFlipped())
    88 			{
    89 			return aValueFlipped;
    90 			}
    91 		else
    92 			{
    93 			return aValueUnFlipped;
    94 			}
    95 		}
    96 	TBool SetDeviceFlipMode(TBool aFlip, TSize& aNewSize);
    97 	inline static TBool ConvertFlip(TDeviceOrientation aOrientation)
    98 		{
    99 		return (aOrientation&(EDeviceOrientation90CW|EDeviceOrientation270CW))!=0;
   100 		}
   101 		
   102 private:
   103     TSurfaceId iSurface;
   104     TDeviceOrientation iAssignedOrientation;
   105 	RSurfaceUpdateSession iSurfaceUpdateSession;
   106 	TRegionFix<KMaxUpdateRegionRectangles> iUpdateRegion;
   107 	RChunk iChunk;
   108 	TBool  iHasChunk;
   109 	};
   110 
   111 /**
   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.
   114 **/
   115 template <class TCDrawXxxBppBitmap> 
   116 class CGenericScreenDevice : public TCDrawXxxBppBitmap , public MSurfaceId
   117 	{
   118 public:
   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;
   125 
   126 	virtual void Update();
   127 	virtual void Update(const TRegion& aRegion);
   128 	virtual void UpdateRegion(const TRect& aRect);
   129 
   130 	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
   131 
   132 	// From MSurfaceId
   133 	virtual void GetSurface(TSurfaceId& aSid) const ;
   134 	virtual TUint DeviceOrientationsAvailable() const ;
   135 	virtual TDeviceOrientation DeviceOrientation() const ;
   136 protected:
   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;
   140 
   141 	};
   142 
   143 /**
   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.
   147 params:	
   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
   151 **/
   152 template <class TCDrawXxxBppBitmap,TDisplayMode displayMode,TInt pixelsPerWord>
   153 class CPalettizedScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
   154 	{
   155 public:
   156 	typedef  CGenericScreenDevice<TCDrawXxxBppBitmap>	CGenericScreenDevice;
   157 	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
   158 	virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
   159 protected:
   160 	virtual void SetSize(const TSize& aSize);
   161 	};
   162 
   163 /**
   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.
   166 params:	
   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
   170 **/
   171 template <class TCDrawXxxBppBitmap,TUidPixelFormat guidMode,TInt pixelsPerWord> 
   172 class CGuidScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
   173 	{
   174 public:
   175 	typedef  ::CGenericScreenDevice<TCDrawXxxBppBitmap>	CGenericScreenDevice;
   176 	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
   177 	virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
   178 protected:
   179 	virtual void SetSize(const TSize& aSize);
   180 	};
   181 
   182 /**
   183 @internalComponent
   184 */
   185 class CDrawOneBppScreenBitmap : public CPalettizedScreenDevice<CDrawOneBppBitmap,EGray2,32>
   186 	{};
   187 
   188 /**
   189 @internalComponent
   190 */
   191 class CDrawTwoBppScreenBitmap : public CPalettizedScreenDevice<CDrawTwoBppBitmap,EGray4,16>
   192 	{};
   193 
   194 /**
   195 @internalComponent
   196 */
   197 class CDrawFourBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawFourBppBitmapGray,EGray16,8>
   198 	{};
   199 
   200 /**
   201 @internalComponent
   202 */
   203 class CDrawFourBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawFourBppBitmapColor,EColor16,8>
   204 	{};
   205 
   206 /**
   207 @internalComponent
   208 */
   209 class CDrawEightBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawEightBppBitmapGray,EGray256,4>
   210 	{};
   211 
   212 /**
   213 @internalComponent
   214 */
   215 class CDrawEightBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawEightBppBitmapColor,EColor256,4>
   216 	{};
   217 
   218 /**
   219 @internalComponent
   220 */
   221 class CDrawTwelveBppScreenBitmapColor : public CGuidScreenDevice<CDrawTwelveBppBitmap,EUidPixelFormatXRGB_4444,2>
   222 	{};
   223 
   224 /**
   225 @internalComponent
   226 */
   227 class CDrawSixteenBppScreenBitmap : public CGuidScreenDevice<CDrawSixteenBppBitmap,EUidPixelFormatRGB_565,2>
   228 	{};
   229 
   230 /**
   231 @internalComponent
   232 */
   233 class CDrawUTwentyFourBppScreenBitmap : public CGuidScreenDevice<CDrawUTwentyFourBppBitmap,EUidPixelFormatXRGB_8888,1>
   234 	{};
   235 
   236 /**
   237 @internalComponent
   238 */
   239 class CDrawThirtyTwoBppScreenBitmapAlpha : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlpha,EUidPixelFormatARGB_8888,1>
   240 	{};
   241 
   242 
   243 /**
   244 @internalComponent
   245 */
   246 class CDrawThirtyTwoBppScreenBitmapAlphaPM : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlphaPM,EUidPixelFormatARGB_8888_PRE,1>
   247 	{};
   248 
   249 
   250 #endif /* __SCDRAW_H__ */
   251