310 } |
310 } |
311 return ret; |
311 return ret; |
312 } |
312 } |
313 |
313 |
314 |
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 |
315 void CHuiCanvasVisual::Draw(CHuiGc& aGc) const |
340 void CHuiCanvasVisual::Draw(CHuiGc& aGc) const |
316 { |
341 { |
317 if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
342 if (Flags() & EHuiVisualFlagDrawOnlyAsExternalContent) |
318 { |
343 { |
319 // 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 |
322 { |
347 { |
323 return; |
348 return; |
324 } |
349 } |
325 } |
350 } |
326 |
351 |
327 TBool semiTranparentEffectActive = (Effect() && Effect()->IsSemitransparent()); |
352 // Optimization |
328 TBool childWindowEffectActive = (Effect() && EffectIsAppliedToChildren()); |
353 if (CanSkipDrawing()) |
329 TBool invisible = (iOpacity.Now() <= EPSILON && !semiTranparentEffectActive); |
354 { |
330 |
|
331 if( invisible || |
|
332 (!HasCommandBuffers(ETrue /*include children*/) && |
|
333 !childWindowEffectActive && |
|
334 !IsBackgroundDrawingEnabled() && |
|
335 !IsExternalContentDrawingEnabled()&& |
|
336 !IsExternalContentDrawingEnabled(ETrue /*include children*/) |
|
337 |
|
338 )) |
|
339 { |
|
340 // This will not be visible due to being completely transparent, or the visual does not actually draw anything |
|
341 |
|
342 // However, the draw should continue, if the effect is possibly manipulating the opacity of the visual. See CHuiFxVisualLayer::Draw. |
|
343 return; |
355 return; |
344 } |
356 } |
345 |
357 |
346 if ((IsDelayedEffectSource() || Freezed())) |
358 if ((IsDelayedEffectSource() || Freezed())) |
347 { |
359 { |
397 { |
409 { |
398 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
410 // Note that EHuiVisualFlagOpaqueHint improves performance a lot in cached effect drawing |
399 TBool transparent = EFalse; |
411 TBool transparent = EFalse; |
400 transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent |
412 transparent |= (!(Flags() & EHuiVisualFlagOpaqueHint)); // Does not have opaque hint -> always transparent |
401 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 |
402 |
414 |
403 TBool refreshCache = EFalse; |
415 TBool refreshCache = EFalse; |
404 if (EffectIsAppliedToChildren()) |
416 if (EffectIsAppliedToChildren()) |
405 { |
417 { |
406 refreshCache |= ChildTreeChanged(EHuiCanvasFlagExcludeFromParentEffect); |
418 refreshCache |= ChildTreeChanged(EHuiCanvasFlagExcludeFromParentEffect); |
|
419 |
|
420 iCanvasVisualData->iPaintedRegion.Clear(); |
|
421 CollectRecursivePaintedRegion(iCanvasVisualData->iPaintedRegion, EHuiCanvasFlagExcludeFromParentEffect); |
407 } |
422 } |
408 else |
423 else |
409 { |
424 { |
410 refreshCache |= Changed(); |
425 refreshCache |= Changed(); |
411 } |
426 |
412 |
427 iCanvasVisualData->iPaintedRegion.Clear(); |
413 // TODO: We could update this somewhere else, not here everytime |
428 CollectPaintedRegion(iCanvasVisualData->iPaintedRegion, 0); |
414 iCanvasVisualData->iPaintedRegion.Clear(); |
|
415 TInt paintedAreaCount = PaintedAreaCount(); |
|
416 for (TInt i=0; i<paintedAreaCount; i++ ) |
|
417 { |
|
418 iCanvasVisualData->iPaintedRegion.AddRect( CanvasPaintedArea(i).iPaintedRect.Round() ); |
|
419 } |
429 } |
420 |
430 |
421 didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion); |
431 didDrawEffect = Effect()->CachedDraw(aGc, area, refreshCache, !transparent, iCanvasVisualData->iPaintedRegion); |
|
432 |
422 } |
433 } |
423 |
434 |
424 if ( !didDrawEffect ) |
435 if ( !didDrawEffect ) |
425 { |
436 { |
426 DrawSelf(aGc, area); |
437 DrawSelf(aGc, area); |
1415 case THuiVisualQueryParams::EQueryExternalContentDrawingEnabled: |
1427 case THuiVisualQueryParams::EQueryExternalContentDrawingEnabled: |
1416 params->iValue = IsExternalContentDrawingEnabled(EFalse); |
1428 params->iValue = IsExternalContentDrawingEnabled(EFalse); |
1417 params->iResult = KErrNone; |
1429 params->iResult = KErrNone; |
1418 break; |
1430 break; |
1419 case THuiVisualQueryParams::EQueryHasDrawableContent: |
1431 case THuiVisualQueryParams::EQueryHasDrawableContent: |
1420 params->iValue = HasCommandBuffers(EFalse); |
1432 params->iValue = HasCommandBuffers(EFalse) || IsBackgroundDrawingEnabled(); |
1421 params->iResult = KErrNone; |
1433 params->iResult = KErrNone; |
1422 break; |
1434 break; |
1423 default: |
1435 default: |
1424 break; |
1436 break; |
1425 } |
1437 } |
1427 else |
1439 else |
1428 { |
1440 { |
1429 CHuiVisual::VisualExtension(aExtensionUid, aExtensionParams); |
1441 CHuiVisual::VisualExtension(aExtensionUid, aExtensionParams); |
1430 } |
1442 } |
1431 } |
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 } |