sl@0: // Copyright (c) 2008-2009 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: //
sl@0: 
sl@0: /**
sl@0:  @file
sl@0:  @internalComponent
sl@0: */
sl@0: 
sl@0: #ifndef MMFSUBTITLEGRAPHICDRAWER_H
sl@0: #define MMFSUBTITLEGRAPHICDRAWER_H
sl@0:   
sl@0: #include <bitstd.h>
sl@0: #include <graphics/wsgraphicdrawer.h>
sl@0: #include <graphics/wsgraphicdrawerinterface.h>
sl@0: 
sl@0: #include "mmfsubtitlegraphicmessage.h"
sl@0: 
sl@0: /**
sl@0:  * Forward declarations
sl@0:  */
sl@0: class TSubtitleGraphicState;
sl@0: 
sl@0: /** 
sl@0: Defines the MMF subtitle graphic drawer CRP component.  Used to display subtitles 
sl@0: over video content.  
sl@0: */
sl@0: NONSHARABLE_CLASS(CMMFSubtitleGraphicDrawer): public CWsGraphicDrawer
sl@0:     {  
sl@0: public:
sl@0:     enum {EImplUid = 0x10285C9C};
sl@0:                 
sl@0: public:
sl@0: 	virtual ~CMMFSubtitleGraphicDrawer();
sl@0:     static CMMFSubtitleGraphicDrawer* NewL();
sl@0:    
sl@0: 	// From CwsGraphicDrawer
sl@0:     void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData);
sl@0:     virtual void HandleMessage(const TDesC8& aData);
sl@0:     virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const;
sl@0: 
sl@0: private:
sl@0: 	// Message handling..
sl@0: 	void ProcessMessageInit(TSubtitleCrpMsgInit& aMessage);
sl@0: 	void ProcessMessageDrawFrame(TSubtitleCrpMsgDrawFrame& aMessage);
sl@0: 	void ProcessMessageSwapFrame(TSubtitleCrpMsgRenderSwapFrame& aMessage);
sl@0: 	void DoBitBlt(MWsGc& aGc, const TRect& aRect) const;
sl@0: 	
sl@0: private:
sl@0:     enum TSubtitleGraphicState
sl@0: 		{
sl@0: 		ESubtitleGraphicStateWaiting    			= 0,
sl@0: 		ESubtitleGraphicStateInit 					= 10,
sl@0: 		ESubtitleGraphicStateInitSimple 			= 20,
sl@0: 		ESubtitleGraphicStateDrawFrame 				= 30,
sl@0: 		ESubtitleGraphicStateRefreshContent			= 40,
sl@0: 		ESubtitleGraphicStateSwapFrame 				= 50,
sl@0: 		ESubtitleGraphicStateClear					= 60
sl@0: 		};
sl@0: 		
sl@0: 	enum TSubtitleGraphicFrame
sl@0: 		{
sl@0: 		ESubtitleGraphicFrame1 = 1,
sl@0: 		ESubtitleGraphicFrame2 = 2,
sl@0: 		ESubtitleGraphicFrame3 = 3
sl@0: 		};
sl@0:       
sl@0: private:
sl@0: 	/**
sl@0: 	Handles to subtitle frames.
sl@0: 	Used for double-buffered rendering approach 
sl@0: 	@see CWsInterleaveGraphicDrawer::ProcessMessageInit()
sl@0: 	*/
sl@0:     CFbsBitmap* iBitmap1;
sl@0:     CFbsBitmap* iBitmap2; 
sl@0:     
sl@0:     /**
sl@0:     Used to store one-off subtitle rendering requests
sl@0:     @see CWsInterleaveGraphicDrawer::ProcessMessageDrawFrame()
sl@0:     */
sl@0:     CFbsBitmap* iTempBitmap;
sl@0:     
sl@0:     /**
sl@0:     Status of current bitmap handles.  Stored here for effeciency as they are 
sl@0:     checked every DoDraw() call.
sl@0:     */
sl@0:     TBool iBitmap1Valid;
sl@0:     TBool iBitmap2Valid;
sl@0:     TBool iTempBitmapValid;
sl@0:     
sl@0:    
sl@0:     /**
sl@0:     Indicates the current frame.  This is the buffer that will be drawn
sl@0:     on the next call to @see SwapFrame() or when WServ invalidates a sub-portion
sl@0:     of the screen
sl@0:     ESubtitleGraphicFrame1: @see iBitmapHandle1
sl@0:     ESubtitleGraphicFrame2: @see iBitmapHandle2
sl@0:     ESubtitleGraphicFrame3: @see iTempBitmapHandle
sl@0:     */
sl@0:     TSubtitleGraphicFrame iCurrentFrame;
sl@0:     	
sl@0: 	/**
sl@0: 	Indicates the region of the current bitmap that contains new image data
sl@0: 	*/
sl@0: 	TRect iDirtyRegion;
sl@0: 	
sl@0: 	/**
sl@0: 	Stores the previous frames dirty region. 
sl@0: 	*/
sl@0: 	TRect iOldDirtyRegion;
sl@0: 	
sl@0: 	/**
sl@0: 	The current CRP region stored on the first call to DoDraw()
sl@0: 	*/
sl@0: 	mutable TRect iSubtitleRegion;
sl@0: 	
sl@0: 	/**
sl@0: 	Indicates how long the current frame should be displayed for
sl@0: 	*/
sl@0: 	TTimeIntervalMicroSeconds iDisplayDuration;
sl@0: 	
sl@0: 	/**
sl@0: 	Indicates the system time that the current frame expires.   Calculated
sl@0: 	from the current system time and the display duration given on a 
sl@0: 	ESubtitleGraphicStateDrawFrame/ESubtitleGraphicStateSwapFrame frame message.
sl@0: 	*/
sl@0: 	mutable TTime iDisplayClearDue;
sl@0: 	
sl@0: 	/**
sl@0: 	The current CRP state
sl@0: 	*/
sl@0: 	mutable TSubtitleGraphicState iState;
sl@0: 	
sl@0: 	mutable TBool iCaptureRegion;
sl@0: };
sl@0: 
sl@0: #endif