sl@0: // Copyright (c) 2006-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: // CWsWindowRedraw and associated classes definitions sl@0: // sl@0: // sl@0: sl@0: #ifndef __WNREDRAW_H__ sl@0: #define __WNREDRAW_H__ sl@0: sl@0: #include "server.h" sl@0: #include "panics.h" sl@0: sl@0: class TSurfaceId; sl@0: sl@0: class CPlaybackGc; sl@0: class MWsGraphicsContext; sl@0: class TBackgroundAttributes; sl@0: sl@0: // sl@0: // Base class defining how a window is redrawn, i.e. Backed up, redraw from client, blanked... sl@0: // sl@0: class CWsWindowRedraw : public CBase sl@0: { sl@0: private: sl@0: enum TStateFlags sl@0: { sl@0: EHasElement=0x01, sl@0: EMayContainElement=0x10, sl@0: }; sl@0: public: sl@0: ~CWsWindowRedraw(); sl@0: virtual void ConstructL(); sl@0: virtual TBool CommandL(TInt aOpcode, TWsWinCmdUnion &aCmd)=0; sl@0: virtual TRgb BackColor() const=0; sl@0: virtual TBool NeedsRedraw() const=0; sl@0: virtual TBool GetRedrawRect(TRect &aRect) const=0; sl@0: virtual const TRegion &BaseDrawRegion() const; sl@0: virtual void ClipInvalidRegion(const TRect &aRect); sl@0: virtual const TRegion& InvalidArea() const; sl@0: virtual void Resize(const TSize &aSize, const TSize &aOldSize); sl@0: virtual CWsBackedUpWindow *Backup() const; sl@0: virtual void Scroll(const TRect &aClipRect, const TPoint &aOffset,const TRect &aRect); sl@0: virtual void UpdateAnimArea(); sl@0: virtual void PrepareForResizeL(const TSize &aSize, TSize &aOldSize); sl@0: virtual void Moved() {} sl@0: virtual void ClearRedrawStore(TBool aClearPendingRedraw=EFalse); sl@0: virtual TBool DrawCommand(CWsGc* aGc,const TAny *aCmdData); sl@0: virtual void GcAttributeChange(CWsGc* aGc,const TAny *aCmdData); sl@0: virtual void GcDeactivate(CWsGc* aGc); sl@0: inline CWsWindow *WsWin(); // Link back to main window class sl@0: virtual void ClientExposing(); sl@0: virtual void DrawWindow()=0; sl@0: TInt DrawBackgroundColor(const TRegion& aRegion, TBool aDoFillColor); sl@0: virtual TBool Contains(const TArray& aDrawers,const TRegion& aRegion) const; sl@0: const TRegion * RedrawRegion(); sl@0: virtual TBool ReleaseMemory(MWsMemoryRelease::TMemoryReleaseLevel aLevel); sl@0: virtual CFbsDevice* OutputDevice() const; sl@0: virtual void VisibleRegionChange(); sl@0: virtual TBool ReadyToDraw() const; sl@0: void PreDrawWindow(MWsGraphicsContext * aGc, const TRegion &aWindowRegion); sl@0: void PostDrawWindow(MWsGraphicsContext* aGc, const TRegion& aWindowChildNodeRegion); sl@0: virtual void Invalidate(const TRect *) {} sl@0: virtual TInt SizeInBytes() const { return 0; } sl@0: inline TBool HasElement() const; sl@0: inline TBool MayContainElement() const; sl@0: inline void SetHasElement(TBool); sl@0: inline TBool HasElementExtentDefined() const; sl@0: inline void ClearMayContainElement(); sl@0: virtual TBool RedrawingInProgress() const; sl@0: virtual void WindowClosing(); sl@0: virtual TBool IsRedrawStoreEmpty() const { return EFalse; } sl@0: virtual TBool IsBackgroundClearEnabled() const { return ETrue; } sl@0: virtual CFbsBitmap* BitmapFromHandle(TInt /*aHandle*/) const { return NULL; } sl@0: sl@0: void SetDsaElementL(); sl@0: inline void QueueRedraw(); sl@0: void Fade(MWsGraphicsContext * aGc, const TRegion& aRegion); sl@0: protected: sl@0: CWsWindowRedraw(CWsWindow *aWin); sl@0: void SetReply(TInt aReply); sl@0: void OwnerPanic(TClientPanic aPanic); sl@0: inline CScreen* Screen() const; sl@0: inline CWsClientWindow *CliWin() const; sl@0: void DrawWindowAnimsL(MWsGraphicsContext * aGc, const TRegion& aRegion); sl@0: TBackgroundAttributes& AcquireBackgroundElementL(); sl@0: void SetBackgroundSurfaceL(const TSurfaceId& aSurface); sl@0: void SetBackgroundSurfaceL(const TSurfaceConfiguration& aConfiguration, TBool aTriggerRedraw, TBool aAllowScreenSurface); sl@0: void SetElementExtentL(TRect& aNewExtent, TBackgroundAttributes& aAttributes); sl@0: void ElementRedraw(const TRect& aOldExtent, const TRect& aNewExtent, TBool aAlwaysScheduleUpdate); sl@0: void RemoveBackgroundSurface(TBool aTriggerRedraw); sl@0: void RemoveBackgroundElement(TBool aTriggerRedraw); sl@0: void GetBackgroundSurfaceL(TSurfaceConfiguration& aConfiguration); sl@0: void ReleaseBackgroundElement(); sl@0: void SetMayContainElementFlags(); sl@0: private: sl@0: void DoFade(const TRegion& aRegion); sl@0: void DrawWindowAnims(MWsGraphicsContext * aGc, const TRegion& aRegion); sl@0: void DrawCursorAndSprites(MWsGraphicsContext * aGc, const TRegion& aRegion); sl@0: TBool HasDsaElement() const; sl@0: sl@0: protected: sl@0: CWsWindow *iWsWin; // Link back to main window class sl@0: TUint iStateFlags; // Flags affecting how drawing is done sl@0: const TRegion * iRedrawRegion; // During a scheduled draw, this is the window area scheduled to be drawn. sl@0: }; // In ChangeTracking mode, iRedrawRegion doesn't include the area to be drawn by window-sprites, cursors or window-anims. sl@0: // All of them use the sprite region, declared in CWsWindow::iDirtySpriteRegion. sl@0: sl@0: class CWsBlankWindow : public CWsWindowRedraw sl@0: { sl@0: public: sl@0: CWsBlankWindow(CWsWindow *aWin); sl@0: ~CWsBlankWindow(); sl@0: void ConstructL(); sl@0: sl@0: //from CWsWindowRedraw sl@0: TBool CommandL(TInt aOpcode, TWsWinCmdUnion &aCmd); sl@0: TBool NeedsRedraw() const; sl@0: TBool GetRedrawRect(TRect &aRect) const; sl@0: void DrawWindow(); sl@0: sl@0: void SetColor(TRgb aColor); sl@0: inline void SetBackgroundClear(); sl@0: inline TBool IsBackgroundColor(); sl@0: private: sl@0: TRgb BackColor() const; sl@0: private: sl@0: TRgb iColor; sl@0: TBool iNoColor; sl@0: }; sl@0: sl@0: #include "window.h" sl@0: sl@0: inline CWsWindow *CWsWindowRedraw::WsWin() sl@0: { sl@0: return iWsWin; sl@0: } sl@0: sl@0: inline CScreen* CWsWindowRedraw::Screen() const sl@0: { sl@0: return iWsWin->Screen(); sl@0: } sl@0: sl@0: inline CWsClientWindow *CWsWindowRedraw::CliWin() const sl@0: { sl@0: return (CWsClientWindow *)iWsWin; sl@0: } sl@0: sl@0: inline TBool CWsWindowRedraw::HasElement() const sl@0: { sl@0: return (iStateFlags&EHasElement)>0; sl@0: } sl@0: inline void CWsWindowRedraw::SetHasElement(TBool aSet) sl@0: { sl@0: TInt oldStateFlags = iStateFlags; sl@0: if (aSet) sl@0: { sl@0: iStateFlags|=EHasElement; sl@0: } sl@0: else sl@0: { sl@0: iStateFlags&=~EHasElement; sl@0: } sl@0: if (oldStateFlags!=iStateFlags) sl@0: { sl@0: iWsWin->SetupVisibleRegionTracking(aSet); sl@0: } sl@0: } sl@0: sl@0: inline TBool CWsWindowRedraw::MayContainElement() const sl@0: { sl@0: return (iStateFlags&EMayContainElement)>0; sl@0: } sl@0: sl@0: inline void CWsWindowRedraw::ClearMayContainElement() sl@0: { sl@0: iStateFlags&=~EMayContainElement; sl@0: } sl@0: sl@0: sl@0: inline void CWsBlankWindow::SetBackgroundClear() sl@0: { sl@0: iNoColor=ETrue; sl@0: } sl@0: sl@0: inline TBool CWsBlankWindow::IsBackgroundColor() sl@0: { sl@0: return !iNoColor; sl@0: } sl@0: sl@0: inline void CWsWindowRedraw::QueueRedraw() sl@0: { sl@0: if (iWsWin->IsActive()) sl@0: { sl@0: iWsWin->WsOwner()->RedrawQueue()->AddInvalid(this); sl@0: } sl@0: } sl@0: sl@0: inline const TRegion * CWsWindowRedraw::RedrawRegion() sl@0: { sl@0: return iRedrawRegion; sl@0: } sl@0: sl@0: #endif