os/mm/mmplugins/mmfwplugins/src/Plugin/subtitle/subtitlegraphicdrawer/mmfsubtitlegraphicdrawer.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-2009 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 //
    15 
    16 /**
    17  @file
    18  @internalComponent
    19 */
    20 
    21 #ifndef MMFSUBTITLEGRAPHICDRAWER_H
    22 #define MMFSUBTITLEGRAPHICDRAWER_H
    23   
    24 #include <bitstd.h>
    25 #include <graphics/wsgraphicdrawer.h>
    26 #include <graphics/wsgraphicdrawerinterface.h>
    27 
    28 #include "mmfsubtitlegraphicmessage.h"
    29 
    30 /**
    31  * Forward declarations
    32  */
    33 class TSubtitleGraphicState;
    34 
    35 /** 
    36 Defines the MMF subtitle graphic drawer CRP component.  Used to display subtitles 
    37 over video content.  
    38 */
    39 NONSHARABLE_CLASS(CMMFSubtitleGraphicDrawer): public CWsGraphicDrawer
    40     {  
    41 public:
    42     enum {EImplUid = 0x10285C9C};
    43                 
    44 public:
    45 	virtual ~CMMFSubtitleGraphicDrawer();
    46     static CMMFSubtitleGraphicDrawer* NewL();
    47    
    48 	// From CwsGraphicDrawer
    49     void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId, MWsClient& aOwner, const TDesC8& aData);
    50     virtual void HandleMessage(const TDesC8& aData);
    51     virtual void DoDraw(MWsGc& aGc, const TRect& aRect, const TDesC8& aData) const;
    52 
    53 private:
    54 	// Message handling..
    55 	void ProcessMessageInit(TSubtitleCrpMsgInit& aMessage);
    56 	void ProcessMessageDrawFrame(TSubtitleCrpMsgDrawFrame& aMessage);
    57 	void ProcessMessageSwapFrame(TSubtitleCrpMsgRenderSwapFrame& aMessage);
    58 	void DoBitBlt(MWsGc& aGc, const TRect& aRect) const;
    59 	
    60 private:
    61     enum TSubtitleGraphicState
    62 		{
    63 		ESubtitleGraphicStateWaiting    			= 0,
    64 		ESubtitleGraphicStateInit 					= 10,
    65 		ESubtitleGraphicStateInitSimple 			= 20,
    66 		ESubtitleGraphicStateDrawFrame 				= 30,
    67 		ESubtitleGraphicStateRefreshContent			= 40,
    68 		ESubtitleGraphicStateSwapFrame 				= 50,
    69 		ESubtitleGraphicStateClear					= 60
    70 		};
    71 		
    72 	enum TSubtitleGraphicFrame
    73 		{
    74 		ESubtitleGraphicFrame1 = 1,
    75 		ESubtitleGraphicFrame2 = 2,
    76 		ESubtitleGraphicFrame3 = 3
    77 		};
    78       
    79 private:
    80 	/**
    81 	Handles to subtitle frames.
    82 	Used for double-buffered rendering approach 
    83 	@see CWsInterleaveGraphicDrawer::ProcessMessageInit()
    84 	*/
    85     CFbsBitmap* iBitmap1;
    86     CFbsBitmap* iBitmap2; 
    87     
    88     /**
    89     Used to store one-off subtitle rendering requests
    90     @see CWsInterleaveGraphicDrawer::ProcessMessageDrawFrame()
    91     */
    92     CFbsBitmap* iTempBitmap;
    93     
    94     /**
    95     Status of current bitmap handles.  Stored here for effeciency as they are 
    96     checked every DoDraw() call.
    97     */
    98     TBool iBitmap1Valid;
    99     TBool iBitmap2Valid;
   100     TBool iTempBitmapValid;
   101     
   102    
   103     /**
   104     Indicates the current frame.  This is the buffer that will be drawn
   105     on the next call to @see SwapFrame() or when WServ invalidates a sub-portion
   106     of the screen
   107     ESubtitleGraphicFrame1: @see iBitmapHandle1
   108     ESubtitleGraphicFrame2: @see iBitmapHandle2
   109     ESubtitleGraphicFrame3: @see iTempBitmapHandle
   110     */
   111     TSubtitleGraphicFrame iCurrentFrame;
   112     	
   113 	/**
   114 	Indicates the region of the current bitmap that contains new image data
   115 	*/
   116 	TRect iDirtyRegion;
   117 	
   118 	/**
   119 	Stores the previous frames dirty region. 
   120 	*/
   121 	TRect iOldDirtyRegion;
   122 	
   123 	/**
   124 	The current CRP region stored on the first call to DoDraw()
   125 	*/
   126 	mutable TRect iSubtitleRegion;
   127 	
   128 	/**
   129 	Indicates how long the current frame should be displayed for
   130 	*/
   131 	TTimeIntervalMicroSeconds iDisplayDuration;
   132 	
   133 	/**
   134 	Indicates the system time that the current frame expires.   Calculated
   135 	from the current system time and the display duration given on a 
   136 	ESubtitleGraphicStateDrawFrame/ESubtitleGraphicStateSwapFrame frame message.
   137 	*/
   138 	mutable TTime iDisplayClearDue;
   139 	
   140 	/**
   141 	The current CRP state
   142 	*/
   143 	mutable TSubtitleGraphicState iState;
   144 	
   145 	mutable TBool iCaptureRegion;
   146 };
   147 
   148 #endif