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