44 #include "Matrix.h" |
44 #include "Matrix.h" |
45 |
45 |
46 |
46 |
47 #include "HuiFxEffect.h" |
47 #include "HuiFxEffect.h" |
48 #include "HuiCmdBufferBrush.h" |
48 #include "HuiCmdBufferBrush.h" |
|
49 #include "huiextension.h" |
|
50 |
|
51 #include "huiwscanvascommands.h" |
49 |
52 |
50 /** Flag to convienintly disable/enable canvas render buffer usage if needed */ |
53 /** Flag to convienintly disable/enable canvas render buffer usage if needed */ |
51 /* Turned to EFalse as DFS77 was having booting problems in wk26 */ |
54 /* Turned to EFalse as DFS77 was having booting problems in wk26 */ |
52 /* Now checked dynamically from CHuiRenderer to allow different behaviour in DFS77 and DFS79 */ |
55 /* Now checked dynamically from CHuiRenderer to allow different behaviour in DFS77 and DFS79 */ |
53 //const TBool KHuiCanvasVisualUseRenderBuffer = EFalse; |
56 //const TBool KHuiCanvasVisualUseRenderBuffer = EFalse; |
91 } |
94 } |
92 |
95 |
93 void CHuiCanvasVisual::ConstructL() |
96 void CHuiCanvasVisual::ConstructL() |
94 { |
97 { |
95 CHuiLayout::ConstructL(); |
98 CHuiLayout::ConstructL(); |
96 |
99 |
|
100 SetFlags(EHuiVisualFlagWserv); |
|
101 |
97 iCanvasVisualData = new (ELeave) THuiCanvasVisualData; |
102 iCanvasVisualData = new (ELeave) THuiCanvasVisualData; |
98 iCanvasVisualData->iCommandSetType = ECommandBufferWs; |
103 iCanvasVisualData->iCommandSetType = ECommandBufferWs; |
99 iCanvasVisualData->iCanvasFlags = 0; |
104 iCanvasVisualData->iCanvasFlags = 0; |
100 iCanvasVisualData->iExternalContentVisual = NULL; |
105 iCanvasVisualData->iExternalContentVisual = NULL; |
101 iCanvasVisualData->iParentCanvas = NULL; |
106 iCanvasVisualData->iParentCanvas = NULL; |
102 iCanvasVisualData->iBackground = NULL; |
107 iCanvasVisualData->iBackground = NULL; |
103 iCanvasVisualData->iCanvasPainter = NULL; |
108 iCanvasVisualData->iCanvasPainter = NULL; |
|
109 iCanvasVisualData->iStoredRenderBuffer = 0; |
104 |
110 |
105 iCanvasVisualData->iBackground = CHuiCanvasBackground::NewL(); |
111 iCanvasVisualData->iBackground = CHuiCanvasBackground::NewL(); |
106 iCanvasVisualData->iBackground->SetVisual(this); |
112 iCanvasVisualData->iBackground->SetVisual(this); |
107 |
113 |
108 iCanvasVisualData->iCanvasPainter = CHuiCanvasWsPainter::NewL(); |
114 iCanvasVisualData->iCanvasPainter = CHuiCanvasWsPainter::NewL(); |
109 iCanvasVisualData->iCanvasPainter->SetVisual(this); |
115 iCanvasVisualData->iCanvasPainter->SetVisual(this); |
110 iCanvasVisualData->iStoredRenderBuffer = 0; |
|
111 |
116 |
112 TBool useCanvasRenderBuffer = CHuiStatic::Renderer().Allows(EHuiRenderPluginAllowVisualPBufferSurfaces); |
117 TBool useCanvasRenderBuffer = CHuiStatic::Renderer().Allows(EHuiRenderPluginAllowVisualPBufferSurfaces); |
113 iCanvasVisualData->iCanvasPainter->EnableRenderBuffer(useCanvasRenderBuffer); |
118 iCanvasVisualData->iCanvasPainter->EnableRenderBuffer(useCanvasRenderBuffer); |
114 |
119 |
115 iCanvasVisualData->iLayerUsesAlphaFlag = EFalse; |
120 iCanvasVisualData->iLayerUsesAlphaFlag = EFalse; |
116 iCanvasVisualData->iLayerExtent = TRect(); |
121 iCanvasVisualData->iLayerExtent = TRect(); |
117 |
122 |
118 // subwindow effects |
123 // subwindow effects |
119 EnableBrushesL(ETrue); |
124 //EnableBrushesL(ETrue); |
120 } |
125 } |
121 |
126 |
122 |
127 |
123 CHuiCanvasVisual::~CHuiCanvasVisual() |
128 CHuiCanvasVisual::~CHuiCanvasVisual() |
124 { |
129 { |
125 FreeRenderBuffer(); |
130 |
126 if(iCanvasVisualData->iExternalContentVisual) |
131 FreeRenderBuffer(); |
127 { |
132 if (iCanvasVisualData) |
128 // Allow the external content visual to be drawn normally |
133 { |
129 iCanvasVisualData->iExternalContentVisual->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
134 if(iCanvasVisualData->iExternalContentVisual) |
130 } |
135 { |
|
136 // Allow the external content visual to be drawn normally |
|
137 iCanvasVisualData->iExternalContentVisual->ClearFlag(EHuiVisualFlagDrawOnlyAsExternalContent); |
|
138 } |
|
139 ClearCommandSet(); |
|
140 if ( iCanvasVisualData->iBackground ) |
|
141 { |
|
142 delete iCanvasVisualData->iBackground; |
|
143 iCanvasVisualData->iBackground = NULL; |
|
144 } |
|
145 if ( iCanvasVisualData->iCanvasPainter ) |
|
146 { |
|
147 delete iCanvasVisualData->iCanvasPainter; |
|
148 iCanvasVisualData->iCanvasPainter = NULL; |
|
149 } |
|
150 |
131 |
151 |
132 if (iCanvasVisualData) |
|
133 { |
|
134 ClearCommandSet(); |
|
135 delete iCanvasVisualData->iBackground; |
|
136 iCanvasVisualData->iBackground = NULL; |
|
137 delete iCanvasVisualData->iCanvasPainter; |
|
138 iCanvasVisualData->iCanvasPainter = NULL; |
|
139 iCanvasVisualData->iExternalContentVisual = NULL; |
152 iCanvasVisualData->iExternalContentVisual = NULL; |
140 |
153 |
141 // Tell parent that we are destructed |
154 // Tell parent that we are destructed |
142 if (iCanvasVisualData->iParentCanvas) |
155 if (iCanvasVisualData->iParentCanvas) |
143 { |
156 { |
297 } |
310 } |
298 return ret; |
311 return ret; |
299 } |
312 } |
300 |
313 |
301 |
314 |
|
315 TBool CHuiCanvasVisual::CanSkipDrawing() const |
|
316 { |
|
317 TBool semiTranparentEffectActive = (Effect() && Effect()->IsSemitransparent()); |
|
318 TBool childWindowEffectActive = (Effect() && EffectIsAppliedToChildren()); |
|
319 TBool invisible = (iOpacity.Now() <= EPSILON && !semiTranparentEffectActive); |
|
320 TBool effectAppliedToSurfacePixels = (Effect() && (Effect()->EffectFlags() & KHuiFxEnableBackgroundInAllLayers)); |
|
321 |
|
322 if( invisible || |
|
323 (!HasCommandBuffers(ETrue /*include children*/) && |
|
324 !childWindowEffectActive && |
|
325 !IsBackgroundDrawingEnabled() && |
|
326 !IsExternalContentDrawingEnabled()&& |
|
327 !IsExternalContentDrawingEnabled(ETrue /*include children*/) && |
|
328 !effectAppliedToSurfacePixels |
|
329 |
|
330 )) |
|
331 { |
|
332 return ETrue; |
|
333 } |
|
334 else |
|
335 { |
|
336 return EFalse; |
|
337 } |
|
338 } |
|
339 |
302 void CHuiCanvasVisual::Draw(CHuiGc& aGc) const |
340 void CHuiCanvasVisual::Draw(CHuiGc& aGc) const |
303 { |
341 { |
304 if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
342 if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
305 { |
343 { |
306 // This is used only as external content visual. Return now if we are not currently drawing |
344 // This is used only as external content visual. Return now if we are not currently drawing |
309 { |
347 { |
310 return; |
348 return; |
311 } |
349 } |
312 } |
350 } |
313 |
351 |
314 TBool semiTranparentEffectActive = (Effect() && Effect()->IsSemitransparent()); |
352 // Optimization |
315 TBool childWindowEffectActive = (Effect() && EffectIsAppliedToChildren()); |
353 if (CanSkipDrawing()) |
316 TBool invisible = (iOpacity.Now() <= EPSILON && !semiTranparentEffectActive); |
354 { |
317 |
|
318 if( invisible || |
|
319 (!HasCommandBuffers(ETrue /*include children*/) && |
|
320 !childWindowEffectActive && |
|
321 !IsBackgroundDrawingEnabled() && |
|
322 !IsExternalContentDrawingEnabled()&& |
|
323 !IsExternalContentDrawingEnabled(ETrue /*include children*/) |
|
324 |
|
325 )) |
|
326 { |
|
327 // This will not be visible due to being completely transparent, or the visual does not actually draw anything |
|
328 |
|
329 // However, the draw should continue, if the effect is possibly manipulating the opacity of the visual. See CHuiFxVisualLayer::Draw. |
|
330 return; |
355 return; |
331 } |
356 } |
332 |
357 |
333 if ((IsDelayedEffectSource() || Freezed())) |
358 if ((IsDelayedEffectSource() || Freezed())) |
334 { |
359 { |
|
360 // Select right draw mode |
|
361 THuiCanvasDrawMode drawMode = (Flags() & EHuiVisualFlagOpaqueHint) ? EHuiCanvasDrawModeNormal : EHuiCanvasDrawModeBlend; |
|
362 |
335 if (StoredRenderBuffer()) |
363 if (StoredRenderBuffer()) |
336 { |
364 { |
337 DrawStoredFullScreenRenderBuffer(aGc); |
365 DrawStoredFullScreenRenderBuffer(drawMode, aGc); |
338 return; |
366 return; |
339 } |
367 } |
340 else if (iCanvasVisualData->iStoredRenderBuffer) |
368 else if (iCanvasVisualData->iStoredRenderBuffer) |
341 { |
369 { |
342 DrawStoredVisualRenderBuffer(); |
370 DrawStoredVisualRenderBuffer(drawMode); |
343 return; |
371 return; |
344 } |
372 } |
345 } |
373 } |
346 |
374 |
347 // If this visual is completely under another visual, then this visual |
375 // If this visual is completely under another visual, then this visual |
381 { |
409 { |
382 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
410 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
383 TBool transparent = EFalse; |
411 TBool transparent = EFalse; |
384 transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent |
412 transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent |
385 transparent |= iOpacity.Now() < 1.0f; // Opacity less than 1.0f -> always transparent |
413 transparent |= iOpacity.Now() < 1.0f; // Opacity less than 1.0f -> always transparent |
386 |
414 |
387 TBool refreshCache = EFalse; |
415 TBool refreshCache = EFalse; |
388 if (EffectIsAppliedToChildren()) |
416 if (EffectIsAppliedToChildren()) |
389 { |
417 { |
390 refreshCache |= ChildTreeChanged(EHuiCanvasFlagExcludeFromParentEffect); |
418 refreshCache |= ChildTreeChanged(EHuiCanvasFlagExcludeFromParentEffect); |
|
419 |
|
420 iCanvasVisualData->iPaintedRegion.Clear(); |
|
421 CollectRecursivePaintedRegion(iCanvasVisualData->iPaintedRegion, EHuiCanvasFlagExcludeFromParentEffect); |
391 } |
422 } |
392 else |
423 else |
393 { |
424 { |
394 refreshCache |= Changed(); |
425 refreshCache |= Changed(); |
395 } |
426 |
396 |
427 iCanvasVisualData->iPaintedRegion.Clear(); |
397 // TODO: We could update this somewhere else, not here everytime |
428 CollectPaintedRegion(iCanvasVisualData->iPaintedRegion, 0); |
398 iCanvasVisualData->iPaintedRegion.Clear(); |
|
399 TInt paintedAreaCount = PaintedAreaCount(); |
|
400 for (TInt i=0; i<paintedAreaCount; i++ ) |
|
401 { |
|
402 iCanvasVisualData->iPaintedRegion.AddRect( CanvasPaintedArea(i).iPaintedRect.Round() ); |
|
403 } |
429 } |
404 |
430 |
405 didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion); |
431 didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion); |
|
432 |
406 } |
433 } |
407 |
434 |
408 if ( !didDrawEffect ) |
435 if ( !didDrawEffect ) |
409 { |
436 { |
410 DrawSelf(aGc, area); |
437 DrawSelf(aGc, area); |
488 { |
515 { |
489 return; |
516 return; |
490 } |
517 } |
491 } |
518 } |
492 |
519 |
493 if ((IsDelayedEffectSource() || Freezed())) |
520 if (IsContentDrawingEnabled() && (IsDelayedEffectSource() || Freezed())) |
494 { |
521 { |
|
522 // Select right draw mode |
|
523 THuiCanvasDrawMode drawMode = (Flags() & EHuiVisualFlagOpaqueHint) ? EHuiCanvasDrawModeNormal : EHuiCanvasDrawModeBlend; |
|
524 |
495 if (StoredRenderBuffer()) |
525 if (StoredRenderBuffer()) |
496 { |
526 { |
497 DrawStoredFullScreenRenderBuffer(aGc); |
527 DrawStoredFullScreenRenderBuffer(drawMode, aGc); |
498 return; |
528 return; |
499 } |
529 } |
500 else if (iCanvasVisualData->iStoredRenderBuffer) |
530 else if (iCanvasVisualData->iStoredRenderBuffer) |
501 { |
531 { |
502 DrawStoredVisualRenderBuffer(); |
532 DrawStoredVisualRenderBuffer(drawMode); |
503 return; |
533 return; |
504 } |
534 } |
505 } |
535 } |
506 |
536 |
507 // Use 'under opaque' hint to optimize drawing. |
537 // Use 'under opaque' hint to optimize drawing. |
588 // Draw child windows, begin |
618 // Draw child windows, begin |
589 TBool afterOthers = EFalse; |
619 TBool afterOthers = EFalse; |
590 const TInt count = Count(); |
620 const TInt count = Count(); |
591 for(TInt i = 0; i < count; ++i) |
621 for(TInt i = 0; i < count; ++i) |
592 { |
622 { |
593 // This cast is not really safe, but dynamic cast is slow |
623 CHuiVisual* visual = iHuiLayoutPrivateData->iChildren[i]; |
594 CHuiCanvasVisual* visual = (CHuiCanvasVisual*) iHuiLayoutPrivateData->iChildren[i]; |
624 |
595 //Ignore inactive child visuals |
625 //Ignore inactive child visuals |
596 if ((visual->Flags()& EHuiVisualFlagInactive)) |
626 if ((visual->Flags()& EHuiVisualFlagInactive)) |
597 { |
627 { |
598 continue; |
628 continue; |
599 } |
629 } |
600 |
630 |
601 if (aIncludeCanvasFlags && !(visual->CanvasFlags()& aIncludeCanvasFlags)) |
631 TInt canvasFlags = 0; |
|
632 if (aIncludeCanvasFlags || aExcludeCanvasFlags) |
|
633 { |
|
634 canvasFlags = visual->QueryCanvasFlags(); |
|
635 } |
|
636 |
|
637 if (aIncludeCanvasFlags && !(canvasFlags & aIncludeCanvasFlags)) |
602 { |
638 { |
603 continue; |
639 continue; |
604 } |
640 } |
605 |
641 |
606 if (aExcludeCanvasFlags && (visual->CanvasFlags()& aExcludeCanvasFlags)) |
642 if (aExcludeCanvasFlags && (canvasFlags & aExcludeCanvasFlags)) |
607 { |
643 { |
608 continue; |
644 continue; |
609 } |
645 } |
610 |
646 |
611 if(visual->Flags() & EHuiVisualFlagDrawAfterOthers) |
647 if(visual->Flags() & EHuiVisualFlagDrawAfterOthers) |
647 } |
683 } |
648 |
684 |
649 return hasChanged; |
685 return hasChanged; |
650 } |
686 } |
651 |
687 |
|
688 // Goes through visual hierarchy and checks if any visual has changed. |
|
689 // This method does not modify any visuals. Parameter is not const |
|
690 // because of CanvasVisual method. |
|
691 TBool CHuiCanvasVisual::RecursiveChildTreeChanged(CHuiVisual* aVisual, TInt aExcludeCanvasFlags) |
|
692 { |
|
693 TBool changed = EFalse; |
|
694 |
|
695 // Check wheter we should include this visual or igonre it. |
|
696 if (aExcludeCanvasFlags) |
|
697 { |
|
698 if ( !(aVisual->Flags() & EHuiVisualFlagInactive) ) |
|
699 { |
|
700 TInt canvasFlags = aVisual->QueryCanvasFlags(); |
|
701 |
|
702 if ( !(canvasFlags & aExcludeCanvasFlags) ) |
|
703 { |
|
704 changed |= aVisual->Changed(); |
|
705 } |
|
706 } |
|
707 } |
|
708 |
|
709 if ( !changed ) |
|
710 { |
|
711 const TInt count = aVisual->Count(); |
|
712 for(TInt i = 0; i < count; ++i) |
|
713 { |
|
714 CHuiVisual* visual = &aVisual->Visual(i); |
|
715 changed |= RecursiveChildTreeChanged( visual, aExcludeCanvasFlags ); |
|
716 if ( changed ) |
|
717 { |
|
718 break; |
|
719 } |
|
720 } |
|
721 } |
|
722 return changed; |
|
723 } |
|
724 |
652 TBool CHuiCanvasVisual::ChildTreeChanged(TInt aExcludeCanvasFlags) const |
725 TBool CHuiCanvasVisual::ChildTreeChanged(TInt aExcludeCanvasFlags) const |
653 { |
726 { |
654 // CHuiLayout::Changed() does not check children. |
727 // CHuiLayout::Changed() does not check children. |
655 // This utility method checks whole child tree below this visual. |
728 // This utility method checks whole child tree below this visual. |
656 TBool changed = EFalse; |
729 return RecursiveChildTreeChanged( |
657 |
730 const_cast<CHuiCanvasVisual*>(this), aExcludeCanvasFlags); |
658 // Check wheter we should include this visual or igonre it. |
731 } |
659 if (aExcludeCanvasFlags) |
|
660 { |
|
661 if (!(iCanvasVisualData->iCanvasFlags & aExcludeCanvasFlags)) |
|
662 { |
|
663 changed |= Changed(); |
|
664 } |
|
665 } |
|
666 |
|
667 const TInt count = Count(); |
|
668 for(TInt i = 0; i < count; ++i) |
|
669 { |
|
670 CHuiCanvasVisual* visual = (CHuiCanvasVisual*) iHuiLayoutPrivateData->iChildren[i]; |
|
671 changed |= visual->ChildTreeChanged(aExcludeCanvasFlags); |
|
672 if (changed) |
|
673 { |
|
674 break; |
|
675 } |
|
676 } |
|
677 return changed; |
|
678 } |
|
679 |
|
680 |
732 |
681 EXPORT_C void CHuiCanvasVisual::ClearChanged() |
733 EXPORT_C void CHuiCanvasVisual::ClearChanged() |
682 { |
734 { |
683 iCanvasVisualData->iCanvasPainter->ClearAllBuffersChanged(); |
735 iCanvasVisualData->iCanvasPainter->ClearAllBuffersChanged(); |
684 CHuiLayout::ClearChanged(); |
736 CHuiLayout::ClearChanged(); |
813 return; |
868 return; |
814 } |
869 } |
815 |
870 |
816 if (aCommandType == ECommandBufferAlf) |
871 if (aCommandType == ECommandBufferAlf) |
817 { |
872 { |
|
873 ClearFlags(EHuiVisualFlagWserv); |
818 delete iCanvasVisualData->iCanvasPainter; |
874 delete iCanvasVisualData->iCanvasPainter; |
819 iCanvasVisualData->iCanvasPainter = NULL; |
875 iCanvasVisualData->iCanvasPainter = NULL; |
820 iCanvasVisualData->iCommandSetType = ECommandBufferAlf; |
876 iCanvasVisualData->iCommandSetType = ECommandBufferAlf; |
821 iCanvasVisualData->iCanvasPainter = CHuiCanvasAlfPainter::NewL(); |
877 iCanvasVisualData->iCanvasPainter = CHuiCanvasAlfPainter::NewL(); |
822 iCanvasVisualData->iCanvasPainter->SetVisual(this); |
878 iCanvasVisualData->iCanvasPainter->SetVisual(this); |
823 } |
879 } |
824 else if (aCommandType == ECommandBufferWs) |
880 else if (aCommandType == ECommandBufferWs) |
825 { |
881 { |
|
882 SetFlags(EHuiVisualFlagWserv); |
826 delete iCanvasVisualData->iCanvasPainter; |
883 delete iCanvasVisualData->iCanvasPainter; |
827 iCanvasVisualData->iCanvasPainter = NULL; |
884 iCanvasVisualData->iCanvasPainter = NULL; |
828 iCanvasVisualData->iCommandSetType = ECommandBufferWs; |
885 iCanvasVisualData->iCommandSetType = ECommandBufferWs; |
829 iCanvasVisualData->iCanvasPainter = CHuiCanvasWsPainter::NewL(); |
886 iCanvasVisualData->iCanvasPainter = CHuiCanvasWsPainter::NewL(); |
830 iCanvasVisualData->iCanvasPainter->SetVisual(this); |
887 iCanvasVisualData->iCanvasPainter->SetVisual(this); |
981 drawContent = EFalse; |
1038 drawContent = EFalse; |
982 } |
1039 } |
983 return drawContent; |
1040 return drawContent; |
984 } |
1041 } |
985 |
1042 |
|
1043 // Goes through visual hierarchy and checks if any visual has external content drawing enabled. |
|
1044 TBool CHuiCanvasVisual::RecursiveIsExternalContentDrawingEnabled(CHuiVisual* aVisual) |
|
1045 { |
|
1046 TBool drawExternalContent = EFalse; |
|
1047 |
|
1048 const TInt count = aVisual->Count(); |
|
1049 for(TInt i = 0; i < count; ++i) |
|
1050 { |
|
1051 CHuiVisual* visual = &aVisual->Visual(i); |
|
1052 drawExternalContent |= visual->QueryExternalContentDrawingEnabled(); |
|
1053 if ( drawExternalContent ) |
|
1054 { |
|
1055 break; |
|
1056 } |
|
1057 |
|
1058 drawExternalContent |= RecursiveIsExternalContentDrawingEnabled( visual ); |
|
1059 if ( drawExternalContent ) |
|
1060 { |
|
1061 break; |
|
1062 } |
|
1063 } |
|
1064 |
|
1065 return drawExternalContent; |
|
1066 } |
|
1067 |
986 TBool CHuiCanvasVisual::IsExternalContentDrawingEnabled(TBool aIncludeChildren) const |
1068 TBool CHuiCanvasVisual::IsExternalContentDrawingEnabled(TBool aIncludeChildren) const |
987 { |
1069 { |
988 TBool drawExternalContent = EFalse; |
1070 TBool drawExternalContent = EFalse; |
989 if (iCanvasVisualData->iExternalContentVisual) |
1071 if (iCanvasVisualData->iExternalContentVisual) |
990 { |
1072 { |
991 drawExternalContent = ETrue; |
1073 drawExternalContent = ETrue; |
992 } |
1074 } |
993 if (aIncludeChildren) |
1075 if (aIncludeChildren && !drawExternalContent) |
994 { |
1076 { |
995 for (TInt i=0; !drawExternalContent && i<Count(); i++) |
1077 drawExternalContent |= RecursiveIsExternalContentDrawingEnabled( |
996 { |
1078 const_cast<CHuiCanvasVisual*>(this)); |
997 CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*) &Visual(i); |
|
998 drawExternalContent |= canvasVisual->IsExternalContentDrawingEnabled(ETrue); |
|
999 } |
|
1000 } |
1079 } |
1001 return drawExternalContent; |
1080 return drawExternalContent; |
1002 } |
1081 } |
1003 |
1082 |
1004 EXPORT_C void CHuiCanvasVisual::SetParentCanvas(CHuiCanvasVisual* aParent) |
1083 EXPORT_C void CHuiCanvasVisual::SetParentCanvas(CHuiCanvasVisual* aParent) |
1152 iCanvasVisualData->iStoredRenderBuffer->InitializeL(content_rb->Size()); |
1238 iCanvasVisualData->iStoredRenderBuffer->InitializeL(content_rb->Size()); |
1153 iCanvasVisualData->iStoredRenderBuffer->Copy(*content_rb); |
1239 iCanvasVisualData->iStoredRenderBuffer->Copy(*content_rb); |
1154 } |
1240 } |
1155 } |
1241 } |
1156 |
1242 |
1157 void CHuiCanvasVisual::DrawStoredVisualRenderBuffer() const |
1243 void CHuiCanvasVisual::DrawStoredVisualRenderBuffer(TInt aCanvasDrawMode) const |
1158 { |
1244 { |
1159 CHuiCanvasGc& gc = CanvasGc(); |
1245 CHuiCanvasGc& gc = CanvasGc(); |
|
1246 CHuiCanvasVisual* visual = NULL; |
|
1247 TBool transparent = EffectiveOpacity() < 1.0f; |
|
1248 gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode); |
|
1249 if (transparent) |
|
1250 { |
|
1251 gc.EnableEffectiveOpacity(ETrue); |
|
1252 visual = gc.Visual(); |
|
1253 gc.SetVisual(*this); |
|
1254 gc.SetDrawMode(EHuiCanvasDrawModeBlend); |
|
1255 } |
1160 THuiRealPoint dest_point = DisplayRect().iTl; |
1256 THuiRealPoint dest_point = DisplayRect().iTl; |
1161 CHuiCanvasRenderBuffer *stored = iCanvasVisualData->iStoredRenderBuffer; |
1257 CHuiCanvasRenderBuffer *stored = iCanvasVisualData->iStoredRenderBuffer; |
|
1258 |
1162 gc.DrawImage(*stored, dest_point); |
1259 gc.DrawImage(*stored, dest_point); |
1163 } |
1260 if (transparent) |
1164 |
1261 { |
1165 void CHuiCanvasVisual::DrawStoredFullScreenRenderBuffer(CHuiGc& aGc) const |
1262 gc.SetVisual(*visual); |
|
1263 gc.EnableEffectiveOpacity(EFalse); |
|
1264 } |
|
1265 } |
|
1266 |
|
1267 void CHuiCanvasVisual::DrawStoredFullScreenRenderBuffer(TInt aCanvasDrawMode, CHuiGc& aGc) const |
1166 { |
1268 { |
1167 if (!Display()) return; |
1269 if (!Display()) return; |
|
1270 if (!iHuiLayoutPrivateData->iGc) |
|
1271 { |
|
1272 CHuiRenderPlugin& renderplugin = CHuiStatic::Renderer(); |
|
1273 // deleted in CHuiLayout destructor or CHuiCanvasVisual::FreeRenderBuffer when not needed anymore |
|
1274 iHuiLayoutPrivateData->iGc = renderplugin.CreateCanvasGcL(); |
|
1275 } |
1168 CHuiCanvasGc& gc = *iHuiLayoutPrivateData->iGc; |
1276 CHuiCanvasGc& gc = *iHuiLayoutPrivateData->iGc; |
1169 gc.SetGc(aGc); |
1277 gc.SetGc(aGc); |
1170 gc.SetDefaults(); |
1278 gc.SetDefaults(); |
1171 gc.PushTransformationMatrix(); |
1279 gc.PushTransformationMatrix(); |
1172 |
1280 |
1180 gc.Scale(1.f, -1.f, 1.f); |
1288 gc.Scale(1.f, -1.f, 1.f); |
1181 } |
1289 } |
1182 |
1290 |
1183 THuiRealPoint dest_point = DisplayRect().iTl; |
1291 THuiRealPoint dest_point = DisplayRect().iTl; |
1184 CHuiCanvasRenderBuffer *stored = StoredRenderBuffer(); |
1292 CHuiCanvasRenderBuffer *stored = StoredRenderBuffer(); |
1185 gc.DrawImage(*stored, dest_point); |
1293 TBool transparent = EffectiveOpacity() < 1.0f; |
1186 |
1294 CHuiCanvasVisual* visual = NULL; |
|
1295 gc.SetDrawMode((THuiCanvasDrawMode)aCanvasDrawMode); |
|
1296 if (transparent) |
|
1297 { |
|
1298 |
|
1299 gc.EnableEffectiveOpacity(ETrue); |
|
1300 visual = gc.Visual(); |
|
1301 gc.SetVisual(*this); |
|
1302 gc.SetDrawMode(EHuiCanvasDrawModeBlend); |
|
1303 } |
|
1304 gc.DrawImage(*stored, dest_point); |
|
1305 if (transparent) |
|
1306 { |
|
1307 gc.SetVisual(*visual); |
|
1308 gc.EnableEffectiveOpacity(EFalse); |
|
1309 } |
1187 gc.PopTransformationMatrix(); |
1310 gc.PopTransformationMatrix(); |
1188 } |
1311 } |
1189 |
1312 |
1190 EXPORT_C void CHuiCanvasVisual::FreeRenderBuffer() |
1313 EXPORT_C void CHuiCanvasVisual::FreeRenderBuffer() |
1191 { |
1314 { |
1193 { |
1316 { |
1194 if (iCanvasVisualData->iStoredRenderBuffer) |
1317 if (iCanvasVisualData->iStoredRenderBuffer) |
1195 { |
1318 { |
1196 delete iCanvasVisualData->iStoredRenderBuffer; |
1319 delete iCanvasVisualData->iStoredRenderBuffer; |
1197 iCanvasVisualData->iStoredRenderBuffer = NULL; |
1320 iCanvasVisualData->iStoredRenderBuffer = NULL; |
1198 } |
1321 delete iHuiLayoutPrivateData->iGc; |
1199 } |
1322 iHuiLayoutPrivateData->iGc = NULL; |
|
1323 } |
|
1324 } |
|
1325 } |
|
1326 |
|
1327 // Goes through visual hierarchy and checks if any visual has command buffers |
|
1328 // or other drawable content. |
|
1329 TBool CHuiCanvasVisual::RecursiveHasCommandBuffers(CHuiVisual* aVisual) |
|
1330 { |
|
1331 TBool hasCommandBuffers = EFalse; |
|
1332 |
|
1333 const TInt count = aVisual->Count(); |
|
1334 for(TInt i = 0; i < count; ++i) |
|
1335 { |
|
1336 CHuiVisual* visual = &aVisual->Visual(i); |
|
1337 // If visual is a canvas one, then QueryHasDrawableContent returns |
|
1338 // HasCommandBuffers(EFalse) |
|
1339 hasCommandBuffers |= visual->QueryHasDrawableContent(); |
|
1340 if ( hasCommandBuffers ) |
|
1341 { |
|
1342 break; |
|
1343 } |
|
1344 |
|
1345 hasCommandBuffers |= RecursiveHasCommandBuffers( visual ); |
|
1346 if ( hasCommandBuffers ) |
|
1347 { |
|
1348 break; |
|
1349 } |
|
1350 } |
|
1351 |
|
1352 return hasCommandBuffers; |
1200 } |
1353 } |
1201 |
1354 |
1202 EXPORT_C TBool CHuiCanvasVisual::HasCommandBuffers(TBool aIncludeChildren) const |
1355 EXPORT_C TBool CHuiCanvasVisual::HasCommandBuffers(TBool aIncludeChildren) const |
1203 { |
1356 { |
1204 TBool hasCommandBuffers = iCanvasVisualData->iCanvasPainter->HasCommandBuffers(); |
1357 TBool hasCommandBuffers = iCanvasVisualData->iCanvasPainter->HasCommandBuffers(); |
1205 if (aIncludeChildren) |
1358 if (aIncludeChildren && !hasCommandBuffers) |
1206 { |
1359 { |
1207 for (TInt i=0; i<Count(); i++) |
1360 // Include children branch - just check if there is something to draw. |
1208 { |
1361 hasCommandBuffers |= RecursiveHasCommandBuffers(const_cast<CHuiCanvasVisual*>(this)); |
1209 CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*) &Visual(i); // Dynamic cast is too slow for us ;) |
|
1210 hasCommandBuffers |= canvasVisual->HasCommandBuffers(aIncludeChildren); |
|
1211 if (hasCommandBuffers) |
|
1212 { |
|
1213 break; |
|
1214 } |
|
1215 } |
|
1216 } |
1362 } |
1217 return hasCommandBuffers; |
1363 return hasCommandBuffers; |
1218 } |
1364 } |
1219 |
1365 |
1220 |
1366 |
1265 aPos.iTl = InnerTopLeft(); |
1411 aPos.iTl = InnerTopLeft(); |
1266 aPos.iBr = aPos.iTl + THuiRealPoint(innerSize.iWidth, innerSize.iHeight) ; |
1412 aPos.iBr = aPos.iTl + THuiRealPoint(innerSize.iWidth, innerSize.iHeight) ; |
1267 return THuiLayoutChildRectLayoutUpdateNeeded; |
1413 return THuiLayoutChildRectLayoutUpdateNeeded; |
1268 } |
1414 } |
1269 |
1415 |
1270 |
1416 void CHuiCanvasVisual::VisualExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
1417 { |
|
1418 if (aExtensionUid == KHuiVisualQueryUid && aExtensionParams && *aExtensionParams) |
|
1419 { |
|
1420 THuiVisualQueryParams* params = static_cast<THuiVisualQueryParams*>(*aExtensionParams); |
|
1421 switch (params->iQueryType) |
|
1422 { |
|
1423 case THuiVisualQueryParams::EQueryCanvasFlags: |
|
1424 params->iValue = CanvasFlags(); |
|
1425 params->iResult = KErrNone; |
|
1426 break; |
|
1427 case THuiVisualQueryParams::EQueryExternalContentDrawingEnabled: |
|
1428 params->iValue = IsExternalContentDrawingEnabled(EFalse); |
|
1429 params->iResult = KErrNone; |
|
1430 break; |
|
1431 case THuiVisualQueryParams::EQueryHasDrawableContent: |
|
1432 params->iValue = HasCommandBuffers(EFalse) || IsBackgroundDrawingEnabled(); |
|
1433 params->iResult = KErrNone; |
|
1434 break; |
|
1435 default: |
|
1436 break; |
|
1437 } |
|
1438 } |
|
1439 else |
|
1440 { |
|
1441 CHuiVisual::VisualExtension(aExtensionUid, aExtensionParams); |
|
1442 } |
|
1443 } |
|
1444 |
|
1445 void CHuiCanvasVisual::CollectPaintedRegion(TRegion& aPaintRegion, TInt aExcludeCanvasFlags) const |
|
1446 { |
|
1447 // Only our own painted areas. |
|
1448 TInt paintedAreaCount = PaintedAreaCount(); |
|
1449 for (TInt i=0; i<paintedAreaCount; i++ ) |
|
1450 { |
|
1451 aPaintRegion.AddRect( CanvasPaintedArea(i).iPaintedRect.Round() ); |
|
1452 } |
|
1453 aPaintRegion.Tidy(); |
|
1454 } |
|
1455 |
|
1456 void CHuiCanvasVisual::CollectRecursivePaintedRegion(TRegion& aRecursivePaintRegion, TInt aExcludeCanvasFlags) const |
|
1457 { |
|
1458 // First our own painted areas... |
|
1459 CollectPaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags); |
|
1460 |
|
1461 // ...then children (and their children). |
|
1462 const TInt count = Count(); |
|
1463 for(TInt i = 0; i < count; ++i) |
|
1464 { |
|
1465 // Check wheter we should include this child visual or ignore it. |
|
1466 if (aExcludeCanvasFlags) |
|
1467 { |
|
1468 CHuiVisual* visual = (CHuiCanvasVisual*)&Visual(i); |
|
1469 if ( !(visual->Flags() & EHuiVisualFlagInactive) ) |
|
1470 { |
|
1471 TInt canvasFlags = visual->QueryCanvasFlags(); |
|
1472 |
|
1473 if ( !(canvasFlags & aExcludeCanvasFlags) ) |
|
1474 { |
|
1475 // If this is marked as Wserv visual, it should be safe to cast. |
|
1476 if (visual->Flags() & EHuiVisualFlagWserv) |
|
1477 { |
|
1478 CHuiCanvasVisual* canvasVisual = (CHuiCanvasVisual*)visual; |
|
1479 canvasVisual->CollectRecursivePaintedRegion(aRecursivePaintRegion, aExcludeCanvasFlags); |
|
1480 } |
|
1481 } |
|
1482 } |
|
1483 } |
|
1484 } |
|
1485 aRecursivePaintRegion.Tidy(); |
|
1486 } |