uiacceltk/hitchcock/coretoolkit/inc/huicanvaswspainter.h
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
child 13 8f67d927ea57
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Definition of CHuiCanvasWsPainter.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUICANVASWSPAINTER_H__
       
    21 #define __HUICANVASWSPAINTER_H__
       
    22 
       
    23 #include "huicanvaspainter.h"
       
    24 #include "uiacceltk/HuiCanvasCmdBufferReader.h"
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <uiacceltk/HuiOwnedPointer.h>
       
    28 #include <uiacceltk/HuiVisual.h>    
       
    29 #include <uiacceltk/HuiDisplay.h>    
       
    30 #include <uiacceltk/huilowmemoryobserver.h>
       
    31 #include "huicanvaswshwgc.h"
       
    32 
       
    33 const TInt KHuiCanvasWsPainterRegionGranularity = 10;
       
    34 
       
    35 class CHuiCanvasWsSwGc;
       
    36 class CHuiCanvasWsHwGc;
       
    37 class CAlfCommandDebug;
       
    38 class CHuiCanvasWsBitGc;
       
    39 
       
    40 /**
       
    41  * This class is used internally by the toolkit and thus should
       
    42  * not be used by the applications directly.
       
    43  */
       
    44 NONSHARABLE_CLASS(CHuiCanvasWsPainter) : public CHuiCanvasPainter, public MHuiMemoryLevelObserver
       
    45     {    
       
    46 public:
       
    47 
       
    48 	/**
       
    49      * Constructor.
       
    50      */
       
    51     static CHuiCanvasWsPainter* NewL();
       
    52     
       
    53     /**
       
    54      * Destructor.
       
    55      */
       
    56     ~CHuiCanvasWsPainter();
       
    57 
       
    58 public: // From CHuiCanvasPainter
       
    59 
       
    60     /**
       
    61      * Sets buffer that contains canvas drawing commands. This
       
    62      * method clears previous buffer(s), so this is eqvivalent
       
    63      * to calling both ClearCommandSet and AddCommandSetL.
       
    64      *
       
    65      * @param aCommands Commanbuffer
       
    66      */
       
    67     virtual void SetCommandSetL( const TDesC8& aCommands );
       
    68 
       
    69     /**
       
    70      * Clears buffer(s) that contains canvas drawing commands. 
       
    71      */
       
    72     virtual void ClearCommandSet();
       
    73 
       
    74     /**
       
    75      * Adds buffer that contains more canvas drawing commands,
       
    76      * those will be executed after the buffers that has been
       
    77      * added previously.
       
    78      * @param aMoreCommands Commanbuffer
       
    79      */
       
    80     virtual void AddCommandSetL( const TDesC8& aMoreCommands );
       
    81 
       
    82     /**
       
    83      * Adds partial buffer that contains more canvas drawing commands. These
       
    84      * commands are appended to the commands set previously with this method
       
    85      * until param aLastPart has value ETrue. After that whole command set
       
    86      * will be added among possibly already existing command sets and
       
    87      * it will be drawable.
       
    88      * 
       
    89      * @param aMoreCommands Commanbuffer
       
    90      * @param aLastPart EFalse if there are more commands to be added into this
       
    91      * command set before it is wanted to be available for drawing. ETrue if
       
    92      * command set is ready and no more parts are expected.
       
    93      */
       
    94     virtual void AddPartialCommandSetL( const TDesC8& aMoreCommands, TBool aLastPart );
       
    95 
       
    96 #ifdef HUI_DEBUG_TRACK_DRAWING
       
    97 	virtual void SetTrackCommandSet( TFileName& aFileName, TBool aTrack );
       
    98 #endif
       
    99 	
       
   100     /**
       
   101      * Clears internal cached texts and images.
       
   102      */
       
   103     virtual void ClearCache();
       
   104   
       
   105     /**
       
   106      * Handles the command buffer(s), either draws or performs a scan.
       
   107      *
       
   108      * @param aDisplayRect Area where painter is supposed to draw
       
   109      * @param aAction Action that painter is supposed to do with the buffer.
       
   110      * @param aUser Canvas visual using this painter
       
   111      * @param aGc Toolkit graphics context
       
   112      */
       
   113     virtual void HandleBufferL(TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint aPos ) ;
       
   114     virtual void HandleBufferL(TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint aPos, TPtrC8 aCommands, CHuiCanvasCommandBuffer *buf);
       
   115 
       
   116     /**
       
   117      * Returns the number of rectangular areas which contain something that is
       
   118      * drawn by the painter.
       
   119      *
       
   120      * @return number of painted areas.
       
   121      * @see PaintedArea()
       
   122      */
       
   123     virtual TInt PaintedAreaCount() const;
       
   124     
       
   125     /**
       
   126      * Returns information of the painted area at given index. 
       
   127      *
       
   128      * @aIndex Index of the painted area.
       
   129      * @return Painted area info.
       
   130      * @see PaintedAreaCount()
       
   131      */
       
   132     virtual THuiCanvasPaintedArea PaintedArea(TInt aIndex);
       
   133     
       
   134     /**
       
   135      * Draws content of the window in pixel format to the given bitmap. 
       
   136      * This method may not be supported in all commanbuffertype/renderer combinations.
       
   137      *
       
   138      * @param aTargetBuffer where content of the window is to be drawn. NULL if the drawing
       
   139      * is to be stopped.
       
   140      *
       
   141      * @return KErrNotSupported if the current renderer/painter does not support the
       
   142      * feature. Leave happens in other unexpected error situtations. 
       
   143      *         
       
   144      */
       
   145     virtual TInt SetCapturingBufferL(CFbsBitmap* aTarget);
       
   146     
       
   147     /**
       
   148      * Tells painter to enable/disable render buffer (if it is supported by the
       
   149      * painter implementation)
       
   150      *  
       
   151      * @return KErrNotSupported if the current renderer/painter does not support the
       
   152      * feature.     
       
   153      */
       
   154     virtual TInt EnableRenderBuffer(TBool aEnable = ETrue);
       
   155     
       
   156     /**
       
   157      * Returns reference to canvas gc which is used by this painter.
       
   158      */
       
   159     virtual CHuiCanvasGc& CanvasGc() const;
       
   160     CHuiCanvasWsGc *CanvasWsGc() const { return iCanvasWsGc; }
       
   161 private:
       
   162 
       
   163     /**
       
   164 	 * From MHuiMemoryLevelObserver
       
   165 	 */
       
   166     void SetMemoryLevel(THuiMemoryLevel aLevel);
       
   167 
       
   168     /**
       
   169      * Constructor.
       
   170      */
       
   171     CHuiCanvasWsPainter();
       
   172 
       
   173     /**
       
   174      * Second-phase constructor.
       
   175      */
       
   176     void ConstructL();
       
   177     
       
   178 private:
       
   179 
       
   180     void DoHandleAllBuffersL(TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint& aPos, 
       
   181             TBool aIgnoreUnChangedBuffers, 
       
   182             TBool aIgnoreClippedBuffers, 
       
   183             TBool aIgnoreHandledBuffers,
       
   184             TBool aClearBeforeHandlingBuffers);
       
   185     void DoHandleBufferL(TInt aIndex, TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint& aPos); 
       
   186     void DoHandleBufferStringL(TInt aIndex, TRect& aDisplayRect, TInt aAction, const CHuiCanvasVisual& aUser, CHuiGc* aGc, TPoint& aPos, TPtr8 aCommandBuffer, CHuiCanvasCommandBuffer *aBuffer);
       
   187 
       
   188     void DoPeekBufferL(TInt aIndex);     
       
   189     void DoDigestPaddingL();
       
   190 
       
   191     TBool RemoveRedundantBuffers();    
       
   192     void RemoveBuffersWithOldDisplayRect();
       
   193     void RemoveBuffersWithEmptyUpdateRegion();
       
   194     void RemoveBuffersWithOverlappingUpdateRegion();        
       
   195     void RemoveBuffersWithoutRealDrawing();
       
   196     void DestroyBuffer(TInt aIndex);
       
   197     void UpdateBufferUpdateRegions(TPoint aPos);
       
   198     
       
   199 public:    
       
   200     void EnableRenderBufferIfNeeded(TBool aEnable);
       
   201 private:
       
   202     
       
   203     void SelectGcL();
       
   204     CHuiGc::TOrientation CalculateRelativeOrientation();    
       
   205     TRect DirtyRect()const;
       
   206     TBool IsBufferCompletelyOutisideClippingRegion(const CHuiCanvasCommandBuffer& aCommandbuffer) const;
       
   207     void RenewAllBuffers();    
       
   208     
       
   209     void WsSetUpdateRegionL(TInt aIndex);
       
   210     void WsBitBltL() ;
       
   211     void WsBitBltRectL() ;
       
   212     void WsBitBltMaskedL() ;
       
   213     void WsCombinedBitBlitMaskedL();
       
   214     void WsBitBltMaskedPointL() ;
       
   215     void WsResetClippingRegionL() ;
       
   216     void WsClearL() ;
       
   217     void WsClearRectL() ;    
       
   218     void WsResetBrushPatternL() ;
       
   219     void WsResetFontL() ;
       
   220     void WsDrawArcL() ;
       
   221     void WsDrawPieL() ;
       
   222     void WsDrawBitmap1L() ;
       
   223     void WsDrawBitmap2L() ;
       
   224     void WsDrawBitmap3L() ;
       
   225     void WsDrawBitmapMaskedL() ;
       
   226     void WsDrawRoundRectL() ;
       
   227     void WsDrawPolyLineL();
       
   228     void WsDrawPolyLineNoEndPointL() ;
       
   229     void WsDrawPolygonL() ;
       
   230     void WsDrawEllipseL() ;
       
   231     void WsDrawLineL() ;
       
   232     void WsDrawLineToL() ;
       
   233     void WsDrawLineByL() ;
       
   234     void WsDrawRectL() ;
       
   235     void WsDrawText1L() ;
       
   236     void WsDrawText2L() ;
       
   237     void WsDrawText3L() ;
       
   238     void WsDrawText4L() ;
       
   239     void WsDrawText5L() ;
       
   240     void WsDrawTextVertical1L() ;
       
   241     void WsDrawTextVertical2L() ;
       
   242     void WsDrawTextVertical3L() ;
       
   243     void WsDrawTextVertical4L() ;
       
   244     void WsDrawTextVertical5L() ;
       
   245     void WsMoveToL() ;
       
   246     void WsMoveByL() ;
       
   247     void WsPlotL() ;
       
   248     void WsResetL() ;
       
   249     void WsSetBrushColorL() ;
       
   250     void WsSetBrushOriginL() ;
       
   251     void WsSetBrushStyleL() ;
       
   252     void WsSetClippingRegionL() ;
       
   253     void WsSetDrawModeL() ;
       
   254     void WsSetOriginL() ;
       
   255     void WsSetPenColorL() ;
       
   256     void WsSetPenStyleL() ;
       
   257     void WsSetPenSizeL() ;
       
   258     void WsSetTextShadowColorL() ;
       
   259     void WsSetCharJustificationL() ;
       
   260     void WsSetWordJustificationL() ;
       
   261     void WsSetUnderlineStyleL() ;
       
   262     void WsSetStrikethroughStyleL() ;
       
   263     void WsSetBrushPatternL() ;
       
   264     void WsSetFontL() ;
       
   265     void WsContentTagL();
       
   266     void WsCopyRectL() ;
       
   267     void WsUpdateJustificationL() ;
       
   268     void WsUpdateJustificationVerticalL() ;
       
   269     void WsSetFontNoDuplicateL() ;
       
   270     void WsCopySettingsL() ;
       
   271     void WsSetClippingRectL() ;
       
   272     void WsCancelClippingRectL() ;
       
   273     void WsSetFadedL() ;
       
   274     void WsSetFadingParametersL() ;
       
   275     void WsFadeAreaL() ;
       
   276     void WsMapColorsL() ;
       
   277     void WsSetUserDisplayModeL() ;
       
   278     void WsUseFontL() ;
       
   279 	void WsSetShapeRegionL( TInt aIndex );
       
   280     
       
   281 private:
       
   282     
       
   283     /** Region which this painter updates with current command buffers */
       
   284     RRegionBuf<KHuiCanvasWsPainterRegionGranularity> iFullUpdateRegion;
       
   285 	
       
   286     /** Window shape region */
       
   287     RRegionBuf<KHuiCanvasCommandBufferRegionGranularity> iShapeRegion;
       
   288     
       
   289     /** Command buffer reader instance */
       
   290     CHuiCanvasCmdBufferReader* iWsCommandBufferReader;    
       
   291  
       
   292     /** Pointer to active canvaswsgc instance */
       
   293     CHuiCanvasWsGc *iCanvasWsGc;
       
   294     
       
   295     /** Fully bitgdi based version of canvaswsgc */
       
   296     CHuiCanvasWsBitGc *iCanvasWsBitGc;
       
   297 
       
   298     /** Partially SW/HW based version of canvaswsgc */
       
   299     CHuiCanvasWsSwGc *iCanvasWsSwGc;
       
   300     
       
   301     /** Fully HW accelerated canvaswsgc */
       
   302     CHuiCanvasWsHwGc *iCanvasWsHwGc;
       
   303 
       
   304     /** Flag to tell whether cache has been cleared */
       
   305     TBool iCacheCleared;
       
   306     
       
   307     /** Use of render buffer has been disabled/enabled automatically */
       
   308     TBool iAutomaticRenderBufferUsage;
       
   309     
       
   310     /** Flags to tell whether the window shape region has been changed  */
       
   311     TBool iShapeRegionClearingPending;
       
   312     TBool iShapeRegionClippingPending;
       
   313     
       
   314 	#ifdef __ALF_SYMBIAN_RWINDOW_CLEARING_BUG_WORKAROUND__
       
   315     TRgb iTestBrushColor;
       
   316     TRect iTestFullDisplayRect;
       
   317     #endif
       
   318 	
       
   319 	// Stream read optimizations
       
   320     struct TStructBitBlitRect
       
   321         {
       
   322         TPoint iPoint;
       
   323         TInt iBitmapHandle;
       
   324         TRect iRect;
       
   325         };
       
   326 
       
   327     struct TStructBitBlitMasked
       
   328         {
       
   329         TPoint iPoint;
       
   330         TInt iBitmapHandle;
       
   331         TRect iRect;
       
   332         TInt iMaskHandle;
       
   333         TInt iInvertMask;
       
   334         };
       
   335 
       
   336     struct TStructDrawBitmapMasked
       
   337         {
       
   338         TRect iRect1;
       
   339         TInt iBitmapHandle;
       
   340         TRect iRect2;
       
   341         TInt iMaskHandle;
       
   342         TInt iInvertMask;
       
   343         };
       
   344     
       
   345     struct TStructDrawTextGeneral
       
   346         {
       
   347         TRect iRect;
       
   348         TInt iValue1;
       
   349         TInt iValue2;
       
   350         TInt iValue3;
       
   351         TInt iValue4;
       
   352         
       
   353         };
       
   354     
       
   355     class TBlitStruct
       
   356         {
       
   357     public:
       
   358         TBlitStruct( TInt aHandle, TInt aMaskHandle, TPoint aTl ) : iHandle( aHandle ), iMaskHandle( aMaskHandle ), iTl( aTl ){};
       
   359         TInt iHandle;
       
   360         TInt iMaskHandle;
       
   361         TPoint iTl;
       
   362         };
       
   363     
       
   364 	TStructBitBlitMasked    iStructBitBlitMasked;
       
   365     
       
   366 	TStructBitBlitRect      iStructBitBlitRect;
       
   367     
       
   368 	TStructDrawBitmapMasked iStructDrawBitmapMasked;
       
   369     
       
   370 	TStructDrawTextGeneral  iStructDrawTextGeneral;
       
   371 	
       
   372 	THuiCanvasTextParameters iTextParametersGeneral;
       
   373   
       
   374     /** Private temp region for general purpose, used to avoid excessive allocations of RRegion heap objects */
       
   375     mutable RRegionBuf<KHuiCanvasWsPainterRegionGranularity> iTempRegion;
       
   376     mutable RRegionBuf<KHuiCanvasWsPainterRegionGranularity> iTempCurrentSubRegion;
       
   377     mutable RRegionBuf<KHuiCanvasWsPainterRegionGranularity> iTempIntersectingRegion;
       
   378 
       
   379 #ifdef HUI_DEBUG_TRACK_DRAWING
       
   380     CAlfCommandDebug* iCommandDebugger;
       
   381 #endif
       
   382   };
       
   383     
       
   384 #endif  // __HUICANVASWSPAINTER_H__