sl@0: // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // This module define the class and constants used for the different display sl@0: // mode supported. sl@0: // Include files sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @prototype sl@0: */ sl@0: /********************************************************************/ sl@0: #ifndef __SCDRAW_H__ sl@0: #define __SCDRAW_H__ sl@0: sl@0: #if !defined(__E32SVR_H__) sl@0: #include sl@0: #endif /* __E32SVR_H__ */ sl@0: sl@0: #include sl@0: #include "BMDRAW.H" sl@0: #include "BitDrawInterfaceId.h" sl@0: #include "bitdrawsurface.h" sl@0: #include sl@0: #include sl@0: sl@0: sl@0: class TSurfaceId; sl@0: sl@0: /** sl@0: The maximum number of rectangles to be held in the update region. This must be sl@0: at least 3, since it has to be able to hold the union of two rectangles using sl@0: disjoint rectangles. sl@0: */ sl@0: const TInt KMaxUpdateRegionRectangles = 10; sl@0: sl@0: /** sl@0: * Provide common features shared between screen devices. Included by composition sl@0: * rather than inheritance, to avoid multiple inheritance of implementation. sl@0: */ sl@0: NONSHARABLE_CLASS(CScreenDeviceHelper) : public CBase sl@0: { sl@0: public: sl@0: // Default constructor. sl@0: TInt Construct(TInt aScreenNo, TUidPixelFormat aPixelFormat, TUint aHalMode); sl@0: ~CScreenDeviceHelper(); sl@0: sl@0: inline TInt ScreenNumber() const { return iSurface.iInternal[TSurfaceId::TScreenSurfaceUsage::EScreenField]; } sl@0: sl@0: void Update(); sl@0: void Update(TRequestStatus& aStatus); sl@0: sl@0: void UpdateRegion(const TRect& aRect); sl@0: void ResetUpdateRegion(); sl@0: void NotifyWhenAvailable(TRequestStatus& aStatus); sl@0: void CancelUpdateNotification(); sl@0: sl@0: void GetSurface(TSurfaceId& aSid) const ; sl@0: TUint DeviceOrientationsAvailable(const TSize& aScreenSize) const ; sl@0: TUint BytesPerScanline() const; sl@0: void* AddressFirstPixel() const; sl@0: sl@0: TBool SetDeviceOrientation(TDeviceOrientation aOrientation, TSize& aNewSize); sl@0: sl@0: TDeviceOrientation DeviceOrientation() const ; sl@0: TBool DeviceFlipped() const; sl@0: sl@0: TInt HorzTwipsPerThousandPixels(const TSize& aPixels)const; sl@0: TInt VertTwipsPerThousandPixels(const TSize& aPixels)const; sl@0: sl@0: protected: sl@0: template Type SecondIfFlipped(Type aValueUnFlipped,Type aValueFlipped)const sl@0: { sl@0: if (DeviceFlipped()) sl@0: { sl@0: return aValueFlipped; sl@0: } sl@0: else sl@0: { sl@0: return aValueUnFlipped; sl@0: } sl@0: } sl@0: TBool SetDeviceFlipMode(TBool aFlip, TSize& aNewSize); sl@0: inline static TBool ConvertFlip(TDeviceOrientation aOrientation) sl@0: { sl@0: return (aOrientation&(EDeviceOrientation90CW|EDeviceOrientation270CW))!=0; sl@0: } sl@0: sl@0: private: sl@0: TSurfaceId iSurface; sl@0: TDeviceOrientation iAssignedOrientation; sl@0: RSurfaceUpdateSession iSurfaceUpdateSession; sl@0: TRegionFix iUpdateRegion; sl@0: RChunk iChunk; sl@0: TBool iHasChunk; sl@0: }; sl@0: sl@0: /** sl@0: This template class is a helper to genericise the common implementation of the screen device. sl@0: This class implements all the non-specific implementation. sl@0: **/ sl@0: template sl@0: class CGenericScreenDevice : public TCDrawXxxBppBitmap , public MSurfaceId sl@0: { sl@0: public: sl@0: typedef TCDrawXxxBppBitmap CDrawXxxBppBitmap; sl@0: virtual TInt InitScreen() ; sl@0: virtual TInt ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ; sl@0: virtual void SetDisplayMode(CFbsDrawDevice*); sl@0: virtual TInt HorzTwipsPerThousandPixels() const; sl@0: virtual TInt VertTwipsPerThousandPixels() const; sl@0: sl@0: virtual void Update(); sl@0: virtual void Update(const TRegion& aRegion); sl@0: virtual void UpdateRegion(const TRect& aRect); sl@0: sl@0: virtual TInt GetInterface(TInt aInterfaceId, TAny*& aInterface); sl@0: sl@0: // From MSurfaceId sl@0: virtual void GetSurface(TSurfaceId& aSid) const ; sl@0: virtual TUint DeviceOrientationsAvailable() const ; sl@0: virtual TDeviceOrientation DeviceOrientation() const ; sl@0: protected: sl@0: //derived classes must implement virtual void SetSize(const TSize& aSize); sl@0: //derived classes must implement virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation)=0; sl@0: CScreenDeviceHelper iHelper; sl@0: sl@0: }; sl@0: sl@0: /** sl@0: This template class is a helper to genericise the common implementation of the screen device. sl@0: This class implements the "bits per pixel" specific implementation for modes that do not have GUIDs, sl@0: but probably have palettes instead. sl@0: params: sl@0: - CDrawXxxBppBitmap The base pixel class that provides most of the drawing functionality. sl@0: - displayMode The symbian enumeraion for the mode - used when no GUID is defined. sl@0: - pixelsPerWord Number of pixels packed in a 32-bit word sl@0: **/ sl@0: template sl@0: class CPalettizedScreenDevice : public CGenericScreenDevice sl@0: { sl@0: public: sl@0: typedef CGenericScreenDevice CGenericScreenDevice; sl@0: virtual TInt ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ; sl@0: virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: }; sl@0: sl@0: /** sl@0: This template class is a helper to genericise the common implementation of the screen device. sl@0: This class implements the "bits per pixel" specific implementation for modes that do have GUIDs. sl@0: params: sl@0: - CDrawXxxBppBitmap The base pixel class that provides most of the drawing functionality. sl@0: - guidMode The GUID for the mode - used by GCE sl@0: - pixelsPerWord Number of pixels packed in a 32-bit word sl@0: **/ sl@0: template sl@0: class CGuidScreenDevice : public CGenericScreenDevice sl@0: { sl@0: public: sl@0: typedef ::CGenericScreenDevice CGenericScreenDevice; sl@0: virtual TInt ConstructScreen(TInt aScreenNo, TAny *aBitmapAddress, TSize aSize, TInt aHalMode) ; sl@0: virtual TBool SetDeviceOrientation(TDeviceOrientation aOrientation); sl@0: protected: sl@0: virtual void SetSize(const TSize& aSize); sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawOneBppScreenBitmap : public CPalettizedScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawTwoBppScreenBitmap : public CPalettizedScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawFourBppScreenBitmapGray : public CPalettizedScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawFourBppScreenBitmapColor : public CPalettizedScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawEightBppScreenBitmapGray : public CPalettizedScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawEightBppScreenBitmapColor : public CPalettizedScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawTwelveBppScreenBitmapColor : public CGuidScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawSixteenBppScreenBitmap : public CGuidScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawUTwentyFourBppScreenBitmap : public CGuidScreenDevice sl@0: {}; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawThirtyTwoBppScreenBitmapAlpha : public CGuidScreenDevice sl@0: {}; sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class CDrawThirtyTwoBppScreenBitmapAlphaPM : public CGuidScreenDevice sl@0: {}; sl@0: sl@0: sl@0: #endif /* __SCDRAW_H__ */ sl@0: