windowing/windowserver/nga/SERVER/openwfc/ScreenRedraw.h
changeset 0 5d03bc08d59c
child 4 15986eb6c500
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2007-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 // SCREEN_REDRAW.H
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __SCREEN_REDRAW_H__
       
    19 #define __SCREEN_REDRAW_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <e32std.h>
       
    23 #include <gdi.h>
       
    24 #include "wstypes.h"
       
    25 #include "tcursor.h"
       
    26 #include <Graphics/WSGRAPHICDRAWERINTERFACE.H>
       
    27 
       
    28 class CScreen;
       
    29 class CWsRenderStage;
       
    30 class TWalkWindowTreeSchedule;
       
    31 
       
    32 //#define USE_DEBUG_REGIONS
       
    33 
       
    34 /**
       
    35 The CScreenRedraw maintains the areas of the screen which need to be updated, and handles some of the
       
    36 scheduling of draw code to do so.  It has a close relationship with the animation scheduler, which 
       
    37 by default will be the CDefaultAnimationScheduler in server.cpp
       
    38 */
       
    39 class CScreenRedraw : public CBase, public MWsScreenRedraw, public MWsWindowVisibilityObserver
       
    40 	{
       
    41 public:
       
    42 	static CScreenRedraw * NewL(CScreen& aScreen);
       
    43 	virtual ~CScreenRedraw();
       
    44 	const TTime& Now() const;
       
    45 	void ScheduleRegionUpdate(const TRegion* aDefinitelyDirty);
       
    46 	void RegionUpdate();
       
    47 	void ScheduleRedraw();
       
    48 	void ScheduleAnimation(TAnimType aType, const TRect& aRect,const TTimeIntervalMicroSeconds& aFromNow,const TTimeIntervalMicroSeconds& aFreq,const TTimeIntervalMicroSeconds& aStop, CWsWindow* aWindow);
       
    49 	TBool IsScheduled(TAnimType aType, const TRect& aRect, CWsWindow* aWindow) const;
       
    50 	void OnAnimation(TRequestStatus* aFinished);
       
    51 	void AddRedrawRegion(const TRegion& aRegion, TBool aSchedule = ETrue, TRedrawDepth aDepth = ERedrawAll);
       
    52 	void DoRedrawNow();
       
    53 	void DiscardAllSchedules();
       
    54 	void ScheduleRender(const TTimeIntervalMicroSeconds& aFromNow);
       
    55 	void ScheduleWindow(CWsWindow* aWindow);
       
    56 	void RemoveFromScheduledList(CWsWindow* aWindow);
       
    57 	void RemoveFromTimedDrawList(CWsWindow* aWindow);
       
    58 	void ScheduleQuickFade( CWsWindow* aWin );	
       
    59 	void RemoveFromQuickFadeList( CWsWindow* aWin );
       
    60 	TBool IsQuickFadeScheduled( CWsWindow* aWin ) const;
       
    61 	void AcceptFadeRequest( CWsWindow* aWin, TBool	aFadeOn);
       
    62 	inline TBool IsAnimating() const { return iAnimating; }
       
    63 public: // Implementing MWsScreenRedraw
       
    64 	void SetObserver(MWsScreenRedrawObserver* aObserver);	
       
    65 	TBool IsUpdatePending();
       
    66 	const TRegion * AnimationRegion() const;
       
    67 	void UpdateDevice();
       
    68 	
       
    69 public: // Implementing MWsObjectProvider
       
    70 	TAny * ResolveObjectInterface(TUint aTypeId);
       
    71 
       
    72 public:	// Implementing MWsWindowVisibilityObserver
       
    73 	void VisibilityChanged();
       
    74 	void SetWindowVisibility(const MWsWindow& aWindow, const TRegion& aVisibleRegion);
       
    75 	
       
    76 public:
       
    77 	MWsTextCursor* RenderStageTextCursor() const;
       
    78 
       
    79 private:
       
    80 	CScreenRedraw(CScreen& aScreen);
       
    81 	void ConstructL();
       
    82 	void AddQuickFadeableRegions(TRegion& aRegion);
       
    83 	void DoQuickFade(MWsGraphicsContext* aGc, TRegion& aAccumulatedDrawing);
       
    84 	TBool ScheduleTimedRects(TRegion& aScheduledFloatingSpriteRegion);
       
    85 	void Render(CWsWindow& aWin, MWsGraphicsContext& aGc, const TWalkWindowTreeSchedule& aScheduler);
       
    86 	void OomRender(CWsWindow& aWin, MWsGraphicsContext& aGc, const TWalkWindowTreeSchedule& aScheduler);
       
    87 #ifdef USE_DEBUG_REGIONS
       
    88 	void DebugRect(TRgb aColor, TRgb aFill, const TRect * aRect);
       
    89 	void DebugRegion(TRgb aColor, TRgb aFill, const TRegion * aRegion);
       
    90 #endif
       
    91 #ifdef USE_DEBUG_FRAME_CAPTURE
       
    92 	void CaptureFrame(const TRegion* aRegion);
       
    93 	void SetupFrameCaptureResourcesL(const TSize& aScreenSize, TDisplayMode aScreenDisplayMode);
       
    94 	void LogRegion(const TDesC& aPrefix, const TDesC& aFunctionName, const TRegion* aRegion);
       
    95 #endif
       
    96 
       
    97 private:
       
    98 	struct TTimedRect
       
    99 		{
       
   100 		TTimedRect(TAnimType aType, const TRect& aRect, const TTime& aTime, CWsWindow* aWindow);
       
   101 		TAnimType iType;
       
   102 		TRect iRect;
       
   103 		TTime iTime;
       
   104 		CWsWindow* iWindow;
       
   105 		static TInt Compare(const TTimedRect& aOne,const TTimedRect& aOther);
       
   106 		};
       
   107 
       
   108 private:
       
   109 	CScreen& iScreen;
       
   110 	mutable TTime iNow;
       
   111 	mutable TTime iNext;
       
   112 	TBool iScheduled;
       
   113 	TBool iAnimating;
       
   114 	TBool iRegionUpdateScheduled;
       
   115 	TBool iRenderScheduled;
       
   116 	RArray<TTimedRect> iTimedDrawRect;
       
   117 	RWsRegionBuf<20> iInvalid;  // Region that needs to be redrawn (eg window contents changed).
       
   118 	RWsRegionBuf<20> iTopElement; // Region that we need to draw, but don't need to redraw (eg new window)
       
   119 	const TRegion * iAnimationRegion; // Region being redrawn during animation
       
   120 	MWsScreenRedrawObserver* iObserver;
       
   121 	CWsRenderStage * iRenderStages;
       
   122 	MWsTextCursor* iRenderStageTextCursor;
       
   123 	CWsWindow* iScheduledWindowList; // Linked list of scheduled windows (only used in DirtyWindowTracking mode)
       
   124 	TBool iVisibilityUpdateScheduled;
       
   125 	RPointerArray<CWsWindow> iQuickFadeList;
       
   126 #ifdef USE_DEBUG_FRAME_CAPTURE
       
   127 	TBool iFrameCapture;
       
   128 	TPtrC iFrameCaptureLocation;
       
   129 	CFbsBitmap* iDebugBitmap;
       
   130 	CFbsBitmapDevice* iDebugBitmapDevice;
       
   131 	CFbsBitGc* iDebugBitmapGc;
       
   132 #endif //USE_DEBUG_FRAME_CAPTURE
       
   133 	};
       
   134 
       
   135 #endif //__SCREEN_REDRAW_H__