os/graphics/graphicsdeviceinterface/screendriver/sgeneric/scdraw.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/screendriver/sgeneric/scdraw.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,251 @@
     1.4 +// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This module define the class and constants used for the different display
    1.18 +// mode supported.
    1.19 +// Include files                                                   
    1.20 +// 
    1.21 +//
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalComponent
    1.26 + @prototype
    1.27 +*/
    1.28 +/********************************************************************/
    1.29 +#ifndef __SCDRAW_H__
    1.30 +#define __SCDRAW_H__
    1.31 +
    1.32 +#if !defined(__E32SVR_H__)
    1.33 +    #include <e32svr.h>
    1.34 +#endif /* __E32SVR_H__ */
    1.35 +
    1.36 +#include <graphics/surfaceupdateclient.h>
    1.37 +#include "BMDRAW.H"
    1.38 +#include "BitDrawInterfaceId.h"
    1.39 +#include "bitdrawsurface.h"
    1.40 +#include <graphics/surface.h>
    1.41 +#include <pixelformats.h>
    1.42 +
    1.43 +
    1.44 +class TSurfaceId;
    1.45 +
    1.46 +/**
    1.47 +The maximum number of rectangles to be held in the update region. This must be
    1.48 +at least 3, since it has to be able to hold the union of two rectangles using
    1.49 +disjoint rectangles.
    1.50 +*/
    1.51 +const TInt		KMaxUpdateRegionRectangles	= 10;
    1.52 +
    1.53 +/**
    1.54 + * Provide common features shared between screen devices. Included by composition
    1.55 + * rather than inheritance, to avoid multiple inheritance of implementation.
    1.56 + */
    1.57 +NONSHARABLE_CLASS(CScreenDeviceHelper) : public CBase
    1.58 +	{
    1.59 +public:
    1.60 +	// Default constructor.
    1.61 +	TInt Construct(TInt aScreenNo, TUidPixelFormat aPixelFormat, TUint aHalMode);
    1.62 +	~CScreenDeviceHelper();
    1.63 +
    1.64 +	inline TInt ScreenNumber() const { return iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField]; }
    1.65 +
    1.66 +	void Update();
    1.67 +	void Update(TRequestStatus& aStatus);
    1.68 +
    1.69 +	void UpdateRegion(const TRect& aRect);
    1.70 +	void ResetUpdateRegion();
    1.71 +	void NotifyWhenAvailable(TRequestStatus& aStatus);
    1.72 +	void CancelUpdateNotification();
    1.73 +
    1.74 +	void GetSurface(TSurfaceId& aSid) const ;
    1.75 +	TUint DeviceOrientationsAvailable(const TSize& aScreenSize) const ;
    1.76 +	TUint BytesPerScanline() const;
    1.77 +	void* AddressFirstPixel() const;
    1.78 +
    1.79 +	TBool SetDeviceOrientation(TDeviceOrientation aOrientation, TSize& aNewSize);
    1.80 +	
    1.81 +	TDeviceOrientation DeviceOrientation() const ;
    1.82 +	TBool	DeviceFlipped() const;
    1.83 +
    1.84 +	TInt	HorzTwipsPerThousandPixels(const TSize& aPixels)const; 
    1.85 +	TInt	VertTwipsPerThousandPixels(const TSize& aPixels)const; 
    1.86 +	
    1.87 +protected:
    1.88 +	template <class Type> Type SecondIfFlipped(Type aValueUnFlipped,Type aValueFlipped)const
    1.89 +		{
    1.90 +		if (DeviceFlipped())
    1.91 +			{
    1.92 +			return aValueFlipped;
    1.93 +			}
    1.94 +		else
    1.95 +			{
    1.96 +			return aValueUnFlipped;
    1.97 +			}
    1.98 +		}
    1.99 +	TBool SetDeviceFlipMode(TBool aFlip, TSize& aNewSize);
   1.100 +	inline static TBool ConvertFlip(TDeviceOrientation aOrientation)
   1.101 +		{
   1.102 +		return (aOrientation&(EDeviceOrientation90CW|EDeviceOrientation270CW))!=0;
   1.103 +		}
   1.104 +		
   1.105 +private:
   1.106 +    TSurfaceId iSurface;
   1.107 +    TDeviceOrientation iAssignedOrientation;
   1.108 +	RSurfaceUpdateSession iSurfaceUpdateSession;
   1.109 +	TRegionFix<KMaxUpdateRegionRectangles> iUpdateRegion;
   1.110 +	RChunk iChunk;
   1.111 +	TBool  iHasChunk;
   1.112 +	};
   1.113 +
   1.114 +/**
   1.115 +This template class is a helper to genericise the common implementation of the screen device.
   1.116 +This class implements all the non-specific implementation.
   1.117 +**/
   1.118 +template <class TCDrawXxxBppBitmap> 
   1.119 +class CGenericScreenDevice : public TCDrawXxxBppBitmap , public MSurfaceId
   1.120 +	{
   1.121 +public:
   1.122 +	typedef TCDrawXxxBppBitmap		CDrawXxxBppBitmap;
   1.123 +	virtual TInt  InitScreen() ;
   1.124 +	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
   1.125 +    virtual void SetDisplayMode(CFbsDrawDevice*);
   1.126 +   	virtual TInt HorzTwipsPerThousandPixels() const;
   1.127 +	virtual TInt VertTwipsPerThousandPixels() const;
   1.128 +
   1.129 +	virtual void Update();
   1.130 +	virtual void Update(const TRegion& aRegion);
   1.131 +	virtual void UpdateRegion(const TRect& aRect);
   1.132 +
   1.133 +	virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface);
   1.134 +
   1.135 +	// From MSurfaceId
   1.136 +	virtual void GetSurface(TSurfaceId& aSid) const ;
   1.137 +	virtual TUint DeviceOrientationsAvailable() const ;
   1.138 +	virtual TDeviceOrientation DeviceOrientation() const ;
   1.139 +protected:
   1.140 +	//derived classes must implement virtual void SetSize(const TSize& aSize);
   1.141 +	//derived classes must implement virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation)=0;
   1.142 +	CScreenDeviceHelper iHelper;
   1.143 +
   1.144 +	};
   1.145 +
   1.146 +/**
   1.147 +This template class is a helper to genericise the common implementation of the screen device.
   1.148 +This class implements the "bits per pixel" specific implementation for modes that do not have GUIDs,
   1.149 +but probably have palettes instead.
   1.150 +params:	
   1.151 +	-	CDrawXxxBppBitmap	The base pixel class that provides most of the drawing functionality.
   1.152 +	-	displayMode			The symbian enumeraion for the mode - used when no GUID is defined.
   1.153 +	-	pixelsPerWord		Number of pixels packed in a 32-bit word
   1.154 +**/
   1.155 +template <class TCDrawXxxBppBitmap,TDisplayMode displayMode,TInt pixelsPerWord>
   1.156 +class CPalettizedScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
   1.157 +	{
   1.158 +public:
   1.159 +	typedef  CGenericScreenDevice<TCDrawXxxBppBitmap>	CGenericScreenDevice;
   1.160 +	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
   1.161 +	virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
   1.162 +protected:
   1.163 +	virtual void SetSize(const TSize& aSize);
   1.164 +	};
   1.165 +
   1.166 +/**
   1.167 +This template class is a helper to genericise the common implementation of the screen device.
   1.168 +This class implements the "bits per pixel" specific implementation for modes that do have GUIDs.
   1.169 +params:	
   1.170 +	-	CDrawXxxBppBitmap	The base pixel class that provides most of the drawing functionality.
   1.171 +	-	guidMode			The GUID for the mode - used by GCE
   1.172 +	-	pixelsPerWord		Number of pixels packed in a 32-bit word
   1.173 +**/
   1.174 +template <class TCDrawXxxBppBitmap,TUidPixelFormat guidMode,TInt pixelsPerWord> 
   1.175 +class CGuidScreenDevice : public CGenericScreenDevice<TCDrawXxxBppBitmap>
   1.176 +	{
   1.177 +public:
   1.178 +	typedef  ::CGenericScreenDevice<TCDrawXxxBppBitmap>	CGenericScreenDevice;
   1.179 +	virtual TInt  ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ;
   1.180 +	virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation);
   1.181 +protected:
   1.182 +	virtual void SetSize(const TSize& aSize);
   1.183 +	};
   1.184 +
   1.185 +/**
   1.186 +@internalComponent
   1.187 +*/
   1.188 +class CDrawOneBppScreenBitmap : public CPalettizedScreenDevice<CDrawOneBppBitmap,EGray2,32>
   1.189 +	{};
   1.190 +
   1.191 +/**
   1.192 +@internalComponent
   1.193 +*/
   1.194 +class CDrawTwoBppScreenBitmap : public CPalettizedScreenDevice<CDrawTwoBppBitmap,EGray4,16>
   1.195 +	{};
   1.196 +
   1.197 +/**
   1.198 +@internalComponent
   1.199 +*/
   1.200 +class CDrawFourBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawFourBppBitmapGray,EGray16,8>
   1.201 +	{};
   1.202 +
   1.203 +/**
   1.204 +@internalComponent
   1.205 +*/
   1.206 +class CDrawFourBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawFourBppBitmapColor,EColor16,8>
   1.207 +	{};
   1.208 +
   1.209 +/**
   1.210 +@internalComponent
   1.211 +*/
   1.212 +class CDrawEightBppScreenBitmapGray : public CPalettizedScreenDevice<CDrawEightBppBitmapGray,EGray256,4>
   1.213 +	{};
   1.214 +
   1.215 +/**
   1.216 +@internalComponent
   1.217 +*/
   1.218 +class CDrawEightBppScreenBitmapColor : public CPalettizedScreenDevice<CDrawEightBppBitmapColor,EColor256,4>
   1.219 +	{};
   1.220 +
   1.221 +/**
   1.222 +@internalComponent
   1.223 +*/
   1.224 +class CDrawTwelveBppScreenBitmapColor : public CGuidScreenDevice<CDrawTwelveBppBitmap,EUidPixelFormatXRGB_4444,2>
   1.225 +	{};
   1.226 +
   1.227 +/**
   1.228 +@internalComponent
   1.229 +*/
   1.230 +class CDrawSixteenBppScreenBitmap : public CGuidScreenDevice<CDrawSixteenBppBitmap,EUidPixelFormatRGB_565,2>
   1.231 +	{};
   1.232 +
   1.233 +/**
   1.234 +@internalComponent
   1.235 +*/
   1.236 +class CDrawUTwentyFourBppScreenBitmap : public CGuidScreenDevice<CDrawUTwentyFourBppBitmap,EUidPixelFormatXRGB_8888,1>
   1.237 +	{};
   1.238 +
   1.239 +/**
   1.240 +@internalComponent
   1.241 +*/
   1.242 +class CDrawThirtyTwoBppScreenBitmapAlpha : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlpha,EUidPixelFormatARGB_8888,1>
   1.243 +	{};
   1.244 +
   1.245 +
   1.246 +/**
   1.247 +@internalComponent
   1.248 +*/
   1.249 +class CDrawThirtyTwoBppScreenBitmapAlphaPM : public CGuidScreenDevice<CDrawThirtyTwoBppBitmapAlphaPM,EUidPixelFormatARGB_8888_PRE,1>
   1.250 +	{};
   1.251 +
   1.252 +
   1.253 +#endif /* __SCDRAW_H__ */
   1.254 +