uiacceltk/hitchcock/coretoolkit/src/huicanvaswspainter.cpp
branchRCL_3
changeset 7 433cbbb6a04b
parent 3 d8a3531bc6b8
child 8 10534483575f
equal deleted inserted replaced
3:d8a3531bc6b8 7:433cbbb6a04b
    60  */
    60  */
    61 const TBool KHuiCanvasAutomaticRenderBufferUsage = EFalse; // Disbaled until all UI isses has been solved  
    61 const TBool KHuiCanvasAutomaticRenderBufferUsage = EFalse; // Disbaled until all UI isses has been solved  
    62 const TInt KHuiCanvasDisableRenderBufferHandleInterval = 100; // Milliseconds 
    62 const TInt KHuiCanvasDisableRenderBufferHandleInterval = 100; // Milliseconds 
    63 const TInt KHuiCanvasEnableRenderBufferHandleInterval = 500;  // Milliseconds
    63 const TInt KHuiCanvasEnableRenderBufferHandleInterval = 500;  // Milliseconds
    64 
    64 
    65 /** Internal constant to identify complex command buffers */
       
    66 const TInt KPossiblePerformanceProblemInWindow = 64;
       
    67 
       
    68 
       
    69 /** ETrue - use SelectGcL to select gc implementation, 
    65 /** ETrue - use SelectGcL to select gc implementation, 
    70     EFalse - use KHuiDefaultCanvasWsGc. */
    66     EFalse - use KHuiDefaultCanvasWsGc. */
    71 const TBool KHuiUseSelectGc = ETrue;
    67 const TBool KHuiUseSelectGc = ETrue;
    72 
    68 
    73 /** Change this to select default rendering ws gc implementation.
    69 /** Change this to select default rendering ws gc implementation.
   300             RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL - relativeOrientation = %i "), relativeOrientation);    
   296             RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL - relativeOrientation = %i "), relativeOrientation);    
   301             #endif
   297             #endif
   302             
   298             
   303             /* If window shape region has been changed, we should clear the window to get rid of old content. 
   299             /* If window shape region has been changed, we should clear the window to get rid of old content. 
   304              * We also set all command buffers to "not drawn" state so that everything will be redrawn.
   300              * We also set all command buffers to "not drawn" state so that everything will be redrawn.
       
   301              * Actual clearing is done after BeginActionL, because drawing phase will start only after calling it.
   305              */
   302              */
       
   303             if(iShapeRegionClearingPending)
       
   304                 {
       
   305                 // Cause a full redraw for the canvas visual
       
   306                 SetAllBuffersChanged(ETrue);    
       
   307                 ClearAllBufferStatusFlags(EHuiCanvasBufferStatusDrawn);
       
   308                 }
       
   309             
       
   310             
       
   311             /* Check if we have buffers that are not yet been drawn (or we render buffer is disabled) */
       
   312             TBool cachePrepared = !HasCommandBuffersWithoutFlags(EHuiCanvasBufferStatusDrawn) || !iCanvasWsGc->IsRenderBufferEnabled();
       
   313 
       
   314             /* Begin draw. If render buffer is used this sets up the render buffer if needed */
       
   315             iCanvasWsGc->BeginActionL(aAction,aDisplayRect,aUser,cachePrepared,iFullUpdateRegion);                   
       
   316 
   306             TBool isFullUpdateRegionCleared = EFalse;
   317             TBool isFullUpdateRegionCleared = EFalse;
   307             if(iShapeRegionClearingPending)
   318             if(iShapeRegionClearingPending)
   308                 {
   319                 {
   309                 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
   320                 #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
   310                 RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL - Clearing fullupdateregion"));    
   321                     RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL - Clearing fullupdateregion"));    
   311                 #endif
   322                 #endif
   312                 // Clear the window update region area
   323                 // Clear the window update region area
   313                 TBool doClear = ETrue;
   324                 TBool doClear = ETrue;
   314                 iCanvasWsGc->EnableUpdateRegion(iFullUpdateRegion, doClear);
   325                 iCanvasWsGc->EnableUpdateRegion(iFullUpdateRegion, doClear);
   315                 iCanvasWsGc->DisableUpdateRegion(); 
   326                 iCanvasWsGc->DisableUpdateRegion(); 
   316                 isFullUpdateRegionCleared = ETrue;
   327                 isFullUpdateRegionCleared = ETrue;
   317                 
       
   318                 // Cause a full redraw for the canvas visual
       
   319                 SetAllBuffersChanged(ETrue);    
       
   320                 ClearAllBufferStatusFlags(EHuiCanvasBufferStatusDrawn);
       
   321                 iShapeRegionClearingPending = EFalse;
   328                 iShapeRegionClearingPending = EFalse;
   322                 }
   329                 }
   323             
       
   324             
       
   325             /* Check if we have buffers that are not yet been drawn (or we render buffer is disabled) */
       
   326             TBool cachePrepared = !HasCommandBuffersWithoutFlags(EHuiCanvasBufferStatusDrawn) || !iCanvasWsGc->IsRenderBufferEnabled();
       
   327 
       
   328             /* Begin draw. If render buffer is used this sets up the render buffer if needed */
       
   329             iCanvasWsGc->BeginActionL(aAction,aDisplayRect,aUser,cachePrepared,iFullUpdateRegion);                   
       
   330 
   330 
   331             #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
   331             #ifdef HUI_DEBUG_PRINT_PERFORMANCE_INTERVAL
   332             if (iCanvasWsGc->IsRenderBufferEnabled())
   332             if (iCanvasWsGc->IsRenderBufferEnabled())
   333                 {
   333                 {
   334                 RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL renderbuffer is ENABLED"));
   334                 RDebug::Print(_L(">> CHuiCanvasWsPainter::HandleBufferL renderbuffer is ENABLED"));
  2243     {
  2243     {
  2244     TBool didRemoveBuffers = EFalse;
  2244     TBool didRemoveBuffers = EFalse;
  2245     TInt originalBufferCount = iCommandBuffers.Count();
  2245     TInt originalBufferCount = iCommandBuffers.Count();
  2246     
  2246     
  2247     RemoveBuffersWithoutRealDrawing();
  2247     RemoveBuffersWithoutRealDrawing();
  2248     RemoveBuffersWithOldDisplayRect();
  2248 
       
  2249     // Remove buffers only with moved display rect and modify the clip region
       
  2250     // of buffers with changed size instead of completely removing all. 
       
  2251     RemoveBuffersWithMovedDisplayRect();
       
  2252     ModifyBuffersWithChangedDisplayRect();
       
  2253     //RemoveBuffersWithOldDisplayRect();
       
  2254     
  2249     RemoveBuffersWithEmptyUpdateRegion();
  2255     RemoveBuffersWithEmptyUpdateRegion();
  2250     RemoveBuffersWithOverlappingUpdateRegion();         
  2256     RemoveBuffersWithOverlappingUpdateRegion();         
  2251     
  2257     
  2252     didRemoveBuffers = (originalBufferCount != iCommandBuffers.Count());    
  2258     didRemoveBuffers = (originalBufferCount != iCommandBuffers.Count());    
  2253     return didRemoveBuffers;
  2259     return didRemoveBuffers;
       
  2260     }
       
  2261 
       
  2262 void CHuiCanvasWsPainter::RemoveBuffersWithMovedDisplayRect()
       
  2263     {
       
  2264     TInt bufferCount = iCommandBuffers.Count();
       
  2265     
       
  2266     TRect canvas = iCanvasVisual->DisplayRect().Round();
       
  2267     for (TInt cb = bufferCount - 1; cb >= 0; cb--)
       
  2268         {
       
  2269         CHuiCanvasCommandBuffer* buffer = iCommandBuffers[cb];
       
  2270         TRect bufRect = buffer->iOriginalDisplayRect.Round();
       
  2271         
       
  2272         // If the visual has moved, delete the old buffer
       
  2273         if (bufRect.iTl != canvas.iTl)
       
  2274             {
       
  2275             DestroyBuffer(cb);
       
  2276             }
       
  2277         }
       
  2278     }
       
  2279 
       
  2280 void CHuiCanvasWsPainter::ModifyBuffersWithChangedDisplayRect()
       
  2281     {
       
  2282     TInt bufferCount = iCommandBuffers.Count();
       
  2283     TRect canvasRect = iCanvasVisual->DisplayRect().Round();
       
  2284     TRegionFix<1> region(canvasRect);
       
  2285     
       
  2286     // If the buffers have different update region than CanvasVisual, clip
       
  2287     // the drawing to canvas visual's & cmdbuffer's updateregions' intersection.
       
  2288     for (TInt cb = 0; cb < bufferCount; cb++)
       
  2289         {
       
  2290         CHuiCanvasCommandBuffer* cmdbuffer = iCommandBuffers[cb];
       
  2291         if (cmdbuffer->iOriginalDisplayRect.Round() != canvasRect)
       
  2292             {
       
  2293             cmdbuffer->iUpdateRegion.Copy(cmdbuffer->iOriginalUpdateRegion);
       
  2294             cmdbuffer->iUpdateRegion.Intersect(region);
       
  2295             cmdbuffer->iUpdateRegion.Tidy();
       
  2296             }
       
  2297         }
  2254     }
  2298     }
  2255 
  2299 
  2256 void CHuiCanvasWsPainter::RemoveBuffersWithoutRealDrawing()
  2300 void CHuiCanvasWsPainter::RemoveBuffersWithoutRealDrawing()
  2257     {
  2301     {
  2258     TInt bufferCount = iCommandBuffers.Count();
  2302     TInt bufferCount = iCommandBuffers.Count();