OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 // Set transform property, if it is not animating. We have to do this here b
ecause the transform | 355 // Set transform property, if it is not animating. We have to do this here b
ecause the transform |
356 // is affected by the layer dimensions. | 356 // is affected by the layer dimensions. |
357 if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(render
er(), CSSPropertyWebkitTransform)) | 357 if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(render
er(), CSSPropertyWebkitTransform)) |
358 updateLayerTransform(renderer()->style()); | 358 updateLayerTransform(renderer()->style()); |
359 | 359 |
360 // Set opacity, if it is not animating. | 360 // Set opacity, if it is not animating. |
361 if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(render
er(), CSSPropertyOpacity)) | 361 if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(render
er(), CSSPropertyOpacity)) |
362 updateLayerOpacity(renderer()->style()); | 362 updateLayerOpacity(renderer()->style()); |
363 | 363 |
364 m_owningLayer->updateVisibilityStatus(); | |
365 m_graphicsLayer->setContentsVisible(m_owningLayer->hasVisibleContent()); | |
366 | |
367 RenderStyle* style = renderer()->style(); | 364 RenderStyle* style = renderer()->style(); |
368 m_graphicsLayer->setPreserves3D(style->transformStyle3D() == TransformStyle3
DPreserve3D && !renderer()->hasReflection()); | 365 m_graphicsLayer->setPreserves3D(style->transformStyle3D() == TransformStyle3
DPreserve3D && !renderer()->hasReflection()); |
369 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa
ceVisibilityVisible); | 366 m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == Backfa
ceVisibilityVisible); |
370 | 367 |
371 RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer(); | 368 RenderLayer* compAncestor = m_owningLayer->ancestorCompositingLayer(); |
372 | 369 |
373 // We compute everything relative to the enclosing compositing layer. | 370 // We compute everything relative to the enclosing compositing layer. |
374 LayoutRect ancestorCompositingBounds; | 371 LayoutRect ancestorCompositingBounds; |
375 if (compAncestor) { | 372 if (compAncestor) { |
376 ASSERT(compAncestor->backing()); | 373 ASSERT(compAncestor->backing()); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // It may have no children, or all its children may be themselves composited. | 782 // It may have no children, or all its children may be themselves composited. |
786 // This is a useful optimization, because it allows us to avoid allocating backi
ng store. | 783 // This is a useful optimization, because it allows us to avoid allocating backi
ng store. |
787 bool RenderLayerBacking::isSimpleContainerCompositingLayer() const | 784 bool RenderLayerBacking::isSimpleContainerCompositingLayer() const |
788 { | 785 { |
789 RenderObject* renderObject = renderer(); | 786 RenderObject* renderObject = renderer(); |
790 if (renderObject->isReplaced() || // replaced objects are not containe
rs | 787 if (renderObject->isReplaced() || // replaced objects are not containe
rs |
791 renderObject->hasMask()) // masks require special treatment | 788 renderObject->hasMask()) // masks require special treatment |
792 return false; | 789 return false; |
793 | 790 |
794 RenderStyle* style = renderObject->style(); | 791 RenderStyle* style = renderObject->style(); |
795 bool isVisible = m_owningLayer->hasVisibleContent(); | |
796 | 792 |
797 // Reject anything that has a border, a border-radius or outline, | 793 // Reject anything that has a border, a border-radius or outline, |
798 // or any background (color or image). | 794 // or any background (color or image). |
799 // FIXME: we could optimize layers for simple backgrounds. | 795 // FIXME: we could optimize layers for simple backgrounds. |
800 if (isVisible && hasBoxDecorationsOrBackground(renderObject)) | 796 if (hasBoxDecorationsOrBackground(renderObject)) |
801 return false; | 797 return false; |
802 | 798 |
803 if (isVisible && m_owningLayer->hasOverflowControls()) | 799 if (m_owningLayer->hasOverflowControls()) |
804 return false; | 800 return false; |
805 | 801 |
806 // If we have got this far and the renderer has no children, then we're ok. | 802 // If we have got this far and the renderer has no children, then we're ok. |
807 if (!renderObject->firstChild()) | 803 if (!renderObject->firstChild()) |
808 return true; | 804 return true; |
809 | 805 |
810 if (renderObject->node() && renderObject->node()->isDocumentNode()) { | 806 if (renderObject->node() && renderObject->node()->isDocumentNode()) { |
811 // Look to see if the root object has a non-simple backgound | 807 // Look to see if the root object has a non-simple backgound |
812 RenderObject* rootObject = renderObject->document()->documentElement()->
renderer(); | 808 RenderObject* rootObject = renderObject->document()->documentElement()->
renderer(); |
813 if (!rootObject) | 809 if (!rootObject) |
(...skipping 11 matching lines...) Expand all Loading... |
825 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body-
>renderer() : 0; | 821 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body-
>renderer() : 0; |
826 if (!bodyObject) | 822 if (!bodyObject) |
827 return false; | 823 return false; |
828 | 824 |
829 style = bodyObject->style(); | 825 style = bodyObject->style(); |
830 | 826 |
831 if (hasBoxDecorationsOrBackgroundImage(style)) | 827 if (hasBoxDecorationsOrBackgroundImage(style)) |
832 return false; | 828 return false; |
833 | 829 |
834 // Check to see if all the body's children are compositing layers. | 830 // Check to see if all the body's children are compositing layers. |
835 if (hasVisibleNonCompositingDescendants()) | 831 if (hasNonCompositingDescendants()) |
836 return false; | 832 return false; |
837 | 833 |
838 return true; | 834 return true; |
839 } | 835 } |
840 | 836 |
841 // Check to see if all the renderer's children are compositing layers. | 837 // Check to see if all the renderer's children are compositing layers. |
842 if (isVisible && hasVisibleNonCompositingDescendants()) | 838 if (hasNonCompositingDescendants()) |
843 return false; | 839 return false; |
844 | 840 |
845 return true; | 841 return true; |
846 } | 842 } |
847 | 843 |
848 // Conservative test for having no rendered children. | 844 // Conservative test for having no rendered children. |
849 bool RenderLayerBacking::hasVisibleNonCompositingDescendants() const | 845 bool RenderLayerBacking::hasNonCompositingDescendants() const |
850 { | 846 { |
851 // Some HTML can cause whitespace text nodes to have renderers, like: | 847 // Some HTML can cause whitespace text nodes to have renderers, like: |
852 // <div> | 848 // <div> |
853 // <img src=...> | 849 // <img src=...> |
854 // </div> | 850 // </div> |
855 // so test for 0x0 RenderTexts here | 851 // so test for 0x0 RenderTexts here |
856 for (RenderObject* child = renderer()->firstChild(); child; child = child->n
extSibling()) { | 852 for (RenderObject* child = renderer()->firstChild(); child; child = child->n
extSibling()) { |
857 if (!child->hasLayer()) { | 853 if (!child->hasLayer()) { |
858 if (child->isRenderInline() || !child->isBox()) | 854 if (child->isRenderInline() || !child->isBox()) |
859 return true; | 855 return true; |
860 | 856 |
861 if (toRenderBox(child)->width() > 0 || toRenderBox(child)->height()
> 0) | 857 if (toRenderBox(child)->width() > 0 || toRenderBox(child)->height()
> 0) |
862 return true; | 858 return true; |
863 } | 859 } |
864 } | 860 } |
865 | 861 |
866 if (Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList())
{ | |
867 size_t listSize = normalFlowList->size(); | |
868 for (size_t i = 0; i < listSize; ++i) { | |
869 RenderLayer* curLayer = normalFlowList->at(i); | |
870 if (!curLayer->isComposited() && curLayer->hasVisibleContent()) | |
871 return true; | |
872 } | |
873 } | |
874 | |
875 if (m_owningLayer->isStackingContext()) { | 862 if (m_owningLayer->isStackingContext()) { |
876 if (!m_owningLayer->hasVisibleDescendant()) | |
877 return false; | |
878 | |
879 // Use the m_hasCompositingDescendant bit to optimize? | 863 // Use the m_hasCompositingDescendant bit to optimize? |
880 if (Vector<RenderLayer*>* negZOrderList = m_owningLayer->negZOrderList()
) { | 864 if (Vector<RenderLayer*>* negZOrderList = m_owningLayer->negZOrderList()
) { |
881 size_t listSize = negZOrderList->size(); | 865 size_t listSize = negZOrderList->size(); |
882 for (size_t i = 0; i < listSize; ++i) { | 866 for (size_t i = 0; i < listSize; ++i) { |
883 RenderLayer* curLayer = negZOrderList->at(i); | 867 RenderLayer* curLayer = negZOrderList->at(i); |
884 if (!curLayer->isComposited() && curLayer->hasVisibleContent()) | 868 if (!curLayer->isComposited()) |
885 return true; | 869 return true; |
886 } | 870 } |
887 } | 871 } |
888 | 872 |
889 if (Vector<RenderLayer*>* posZOrderList = m_owningLayer->posZOrderList()
) { | 873 if (Vector<RenderLayer*>* posZOrderList = m_owningLayer->posZOrderList()
) { |
890 size_t listSize = posZOrderList->size(); | 874 size_t listSize = posZOrderList->size(); |
891 for (size_t i = 0; i < listSize; ++i) { | 875 for (size_t i = 0; i < listSize; ++i) { |
892 RenderLayer* curLayer = posZOrderList->at(i); | 876 RenderLayer* curLayer = posZOrderList->at(i); |
893 if (!curLayer->isComposited() && curLayer->hasVisibleContent()) | 877 if (!curLayer->isComposited()) |
894 return true; | 878 return true; |
895 } | 879 } |
896 } | 880 } |
897 } | 881 } |
898 | 882 |
| 883 if (Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList())
{ |
| 884 size_t listSize = normalFlowList->size(); |
| 885 for (size_t i = 0; i < listSize; ++i) { |
| 886 RenderLayer* curLayer = normalFlowList->at(i); |
| 887 if (!curLayer->isComposited()) |
| 888 return true; |
| 889 } |
| 890 } |
| 891 |
899 return false; | 892 return false; |
900 } | 893 } |
901 | 894 |
902 bool RenderLayerBacking::containsPaintedContent() const | 895 bool RenderLayerBacking::containsPaintedContent() const |
903 { | 896 { |
904 if (isSimpleContainerCompositingLayer() || paintingGoesToWindow() || m_artif
iciallyInflatedBounds || m_owningLayer->isReflection()) | 897 if (isSimpleContainerCompositingLayer() || paintingGoesToWindow() || m_artif
iciallyInflatedBounds || m_owningLayer->isReflection()) |
905 return false; | 898 return false; |
906 | 899 |
907 if (isDirectlyCompositedImage()) | 900 if (isDirectlyCompositedImage()) |
908 return false; | 901 return false; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 | 1458 |
1466 if (m_graphicsLayer->drawsContent()) | 1459 if (m_graphicsLayer->drawsContent()) |
1467 return m_graphicsLayer->usingTiledLayer() ? TiledCompositingLayer : Norm
alCompositingLayer; | 1460 return m_graphicsLayer->usingTiledLayer() ? TiledCompositingLayer : Norm
alCompositingLayer; |
1468 | 1461 |
1469 return ContainerCompositingLayer; | 1462 return ContainerCompositingLayer; |
1470 } | 1463 } |
1471 | 1464 |
1472 } // namespace WebCore | 1465 } // namespace WebCore |
1473 | 1466 |
1474 #endif // USE(ACCELERATED_COMPOSITING) | 1467 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |