windowing/windowserver/nga/SERVER/openwfc/wnredraw.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2006-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 // CWsWindowRedraw and associated classes definitions
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __WNREDRAW_H__
       
    19 #define __WNREDRAW_H__
       
    20 
       
    21 #include "server.h"
       
    22 #include "panics.h"
       
    23 
       
    24 class TSurfaceId;
       
    25 
       
    26 class CPlaybackGc;
       
    27 class MWsGraphicsContext;
       
    28 class TBackgroundAttributes;
       
    29 
       
    30 //
       
    31 // Base class defining how a window is redrawn, i.e. Backed up, redraw from client, blanked...
       
    32 //
       
    33 class CWsWindowRedraw : public CBase
       
    34 	{
       
    35 private:
       
    36 	enum TStateFlags
       
    37 		{
       
    38 		EHasElement=0x01,
       
    39 		EMayContainElement=0x10,
       
    40 		};
       
    41 public:
       
    42 	~CWsWindowRedraw();
       
    43 	virtual void ConstructL();
       
    44 	virtual TBool CommandL(TInt aOpcode, TWsWinCmdUnion &aCmd)=0;
       
    45 	virtual TRgb BackColor() const=0;
       
    46 	virtual TBool NeedsRedraw() const=0;
       
    47 	virtual TBool GetRedrawRect(TRect &aRect) const=0;
       
    48 	virtual const TRegion &BaseDrawRegion() const;
       
    49 	virtual void ClipInvalidRegion(const TRect &aRect);
       
    50 	virtual const TRegion& InvalidArea() const;
       
    51 	virtual void Resize(const TSize &aSize, const TSize &aOldSize);
       
    52 	virtual CWsBackedUpWindow *Backup() const;
       
    53 	virtual void Scroll(const TRect &aClipRect, const TPoint &aOffset,const TRect &aRect);
       
    54 	virtual void UpdateAnimArea();
       
    55 	virtual void PrepareForResizeL(const TSize &aSize, TSize &aOldSize);
       
    56 	virtual void Moved() {}
       
    57 	virtual void ClearRedrawStore(TBool aClearPendingRedraw=EFalse);
       
    58 	virtual TBool DrawCommand(CWsGc* aGc,const TAny *aCmdData);
       
    59 	virtual void GcAttributeChange(CWsGc* aGc,const TAny *aCmdData);
       
    60 	virtual void GcDeactivate(CWsGc* aGc);
       
    61 	inline CWsWindow *WsWin();	// Link back to main window class
       
    62 	virtual void ClientExposing();
       
    63 	virtual void DrawWindow()=0;
       
    64 	TInt DrawBackgroundColor(const TRegion& aRegion, TBool aDoFillColor);
       
    65 	virtual TBool Contains(const TArray<TGraphicDrawerId>& aDrawers,const TRegion& aRegion) const;
       
    66 	const TRegion * RedrawRegion();
       
    67 	virtual TBool ReleaseMemory(MWsMemoryRelease::TMemoryReleaseLevel aLevel);
       
    68 	virtual CFbsDevice* OutputDevice() const;
       
    69 	virtual void VisibleRegionChange();
       
    70 	virtual TBool ReadyToDraw() const;
       
    71 	void PreDrawWindow(MWsGraphicsContext * aGc, const TRegion &aWindowRegion);
       
    72 	void PostDrawWindow(MWsGraphicsContext* aGc, const TRegion& aWindowChildNodeRegion);
       
    73 	virtual void Invalidate(const TRect *) {}	
       
    74 	virtual TInt SizeInBytes() const { return 0; }
       
    75 	inline TBool HasElement() const;
       
    76 	inline TBool MayContainElement() const;
       
    77 	inline void SetHasElement(TBool);
       
    78 	inline TBool HasElementExtentDefined() const;
       
    79 	inline void  ClearMayContainElement();
       
    80 	virtual TBool RedrawingInProgress() const; 
       
    81 	virtual void WindowClosing();
       
    82 	virtual TBool IsRedrawStoreEmpty() const { return EFalse; }
       
    83 	virtual TBool IsBackgroundClearEnabled() const { return ETrue; }
       
    84 	virtual CFbsBitmap* BitmapFromHandle(TInt /*aHandle*/) const { return NULL; }
       
    85 
       
    86 	void SetDsaElementL();
       
    87 	inline void QueueRedraw();
       
    88 	void Fade(MWsGraphicsContext * aGc, const TRegion& aRegion);
       
    89 protected:
       
    90 	CWsWindowRedraw(CWsWindow *aWin);
       
    91 	void SetReply(TInt aReply);
       
    92 	void OwnerPanic(TClientPanic aPanic);
       
    93 	inline CScreen* Screen() const;
       
    94 	inline CWsClientWindow *CliWin() const;
       
    95 	void DrawWindowAnimsL(MWsGraphicsContext * aGc, const TRegion& aRegion);
       
    96 	TBackgroundAttributes& AcquireBackgroundElementL();
       
    97 	void SetBackgroundSurfaceL(const TSurfaceId& aSurface);
       
    98 	void SetBackgroundSurfaceL(const TSurfaceConfiguration& aConfiguration, TBool aTriggerRedraw, TBool aAllowScreenSurface);
       
    99 	void SetElementExtentL(TRect& aNewExtent, TBackgroundAttributes& aAttributes);
       
   100 	void ElementRedraw(const TRect& aOldExtent, const TRect& aNewExtent, TBool aAlwaysScheduleUpdate);
       
   101 	void RemoveBackgroundSurface(TBool aTriggerRedraw);
       
   102 	void RemoveBackgroundElement(TBool aTriggerRedraw);
       
   103 	void GetBackgroundSurfaceL(TSurfaceConfiguration& aConfiguration);
       
   104 	void ReleaseBackgroundElement();
       
   105 	void SetMayContainElementFlags();
       
   106 private:
       
   107 	void DoFade(const TRegion& aRegion);
       
   108 	void DrawWindowAnims(MWsGraphicsContext * aGc, const TRegion& aRegion);
       
   109 	void DrawCursorAndSprites(MWsGraphicsContext * aGc, const TRegion& aRegion);
       
   110 	TBool HasDsaElement() const;
       
   111 
       
   112 protected:
       
   113 	CWsWindow *iWsWin;	// Link back to main window class
       
   114 	TUint iStateFlags; 	// Flags affecting how drawing is done
       
   115 	const TRegion * iRedrawRegion; // During a scheduled draw, this is the window area scheduled to be drawn.
       
   116 	};							   // In ChangeTracking mode, iRedrawRegion doesn't include the area to be drawn by window-sprites, cursors or window-anims.
       
   117 								   // All of them use the sprite region, declared in CWsWindow::iDirtySpriteRegion.
       
   118 
       
   119 class CWsBlankWindow : public CWsWindowRedraw
       
   120 	{
       
   121 public:
       
   122 	CWsBlankWindow(CWsWindow *aWin);
       
   123 	~CWsBlankWindow();
       
   124 	void ConstructL();
       
   125 	
       
   126 	//from CWsWindowRedraw
       
   127 	TBool CommandL(TInt aOpcode, TWsWinCmdUnion &aCmd);
       
   128 	TBool NeedsRedraw() const;
       
   129 	TBool GetRedrawRect(TRect &aRect) const;
       
   130 	void DrawWindow();
       
   131 	
       
   132 	void SetColor(TRgb aColor);
       
   133 	inline void SetBackgroundClear();
       
   134 	inline TBool IsBackgroundColor();
       
   135 private:
       
   136 	TRgb BackColor() const;
       
   137 private:
       
   138 	TRgb iColor;
       
   139 	TBool iNoColor;
       
   140 	};
       
   141 	
       
   142 #include "window.h"
       
   143 
       
   144 inline CWsWindow *CWsWindowRedraw::WsWin()
       
   145 	{
       
   146 	return iWsWin;
       
   147 	}
       
   148 
       
   149 inline CScreen* CWsWindowRedraw::Screen() const
       
   150 	{
       
   151 	return iWsWin->Screen();
       
   152 	}
       
   153 
       
   154 inline CWsClientWindow *CWsWindowRedraw::CliWin() const
       
   155 	{
       
   156 	return (CWsClientWindow *)iWsWin;
       
   157 	}
       
   158 
       
   159 inline TBool CWsWindowRedraw::HasElement() const
       
   160 	{
       
   161 	return (iStateFlags&EHasElement)>0;
       
   162 	}
       
   163 inline void CWsWindowRedraw::SetHasElement(TBool aSet)
       
   164 	{
       
   165 	TInt oldStateFlags = iStateFlags; 
       
   166 	if (aSet)
       
   167 		{
       
   168 		iStateFlags|=EHasElement;
       
   169 		}
       
   170 	else
       
   171 		{
       
   172 		iStateFlags&=~EHasElement;
       
   173 		}
       
   174 	if (oldStateFlags!=iStateFlags)
       
   175 		{
       
   176 		iWsWin->SetupVisibleRegionTracking(aSet);
       
   177 		}
       
   178 	}
       
   179 
       
   180 inline TBool CWsWindowRedraw::MayContainElement() const
       
   181 	{
       
   182 	return (iStateFlags&EMayContainElement)>0;
       
   183 	}
       
   184 
       
   185 inline void CWsWindowRedraw::ClearMayContainElement()
       
   186 	{
       
   187 	iStateFlags&=~EMayContainElement;
       
   188 	}
       
   189 
       
   190 
       
   191 inline void CWsBlankWindow::SetBackgroundClear()
       
   192 	{
       
   193 	iNoColor=ETrue;
       
   194 	}
       
   195 
       
   196 inline TBool CWsBlankWindow::IsBackgroundColor()
       
   197 	{
       
   198 	return !iNoColor;
       
   199 	}
       
   200 
       
   201 inline void CWsWindowRedraw::QueueRedraw()
       
   202 	{
       
   203 	if (iWsWin->IsActive())
       
   204 		{
       
   205 		iWsWin->WsOwner()->RedrawQueue()->AddInvalid(this);
       
   206 		}
       
   207 	}
       
   208 
       
   209 inline const TRegion * CWsWindowRedraw::RedrawRegion()
       
   210 	{
       
   211 	return iRedrawRegion;
       
   212 	}
       
   213 
       
   214 #endif