Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: Source/core/rendering/compositing/CompositedLayerMapping.cpp

Issue 178013003: Drop background color optimization for composited layers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Don't use do-while. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (m_owningLayer->renderer()->containingBlock()->enclosingLayer() != m_owni ngLayer->ancestorScrollingLayer()) 338 if (m_owningLayer->renderer()->containingBlock()->enclosingLayer() != m_owni ngLayer->ancestorScrollingLayer())
339 return true; 339 return true;
340 340
341 return false; 341 return false;
342 } 342 }
343 343
344 void CompositedLayerMapping::updateCompositedBounds() 344 void CompositedLayerMapping::updateCompositedBounds()
345 { 345 {
346 // We need to know if we draw content in order to update our bounds (this ha s an effect 346 // We need to know if we draw content in order to update our bounds (this ha s an effect
347 // on whether or not descendands will paint into our backing). Update this v alue now. 347 // on whether or not descendands will paint into our backing). Update this v alue now.
348 updateDrawsContent(isSimpleContainerCompositingLayer()); 348 updateDrawsContent();
349 349
350 LayoutRect layerBounds = compositor()->calculateCompositedBounds(m_owningLay er, m_owningLayer); 350 LayoutRect layerBounds = compositor()->calculateCompositedBounds(m_owningLay er, m_owningLayer);
351 351
352 // Clip to the size of the document or enclosing overflow-scroll layer. 352 // Clip to the size of the document or enclosing overflow-scroll layer.
353 // If this or an ancestor is transformed, we can't currently compute the cor rect rect to intersect with. 353 // If this or an ancestor is transformed, we can't currently compute the cor rect rect to intersect with.
354 // We'd need RenderObject::convertContainerToLocalQuad(), which doesn't yet exist. 354 // We'd need RenderObject::convertContainerToLocalQuad(), which doesn't yet exist.
355 if (shouldClipCompositedBounds()) { 355 if (shouldClipCompositedBounds()) {
356 RenderView* view = m_owningLayer->renderer()->view(); 356 RenderView* view = m_owningLayer->renderer()->view();
357 RenderLayer* rootLayer = view->layer(); 357 RenderLayer* rootLayer = view->layer();
358 358
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 if (m_owningLayer->reflectionInfo()) { 507 if (m_owningLayer->reflectionInfo()) {
508 if (m_owningLayer->reflectionInfo()->reflectionLayer()->hasCompositedLay erMapping()) { 508 if (m_owningLayer->reflectionInfo()->reflectionLayer()->hasCompositedLay erMapping()) {
509 GraphicsLayer* reflectionLayer = m_owningLayer->reflectionInfo()->re flectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); 509 GraphicsLayer* reflectionLayer = m_owningLayer->reflectionInfo()->re flectionLayer()->compositedLayerMapping()->mainGraphicsLayer();
510 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); 510 m_graphicsLayer->setReplicatedByLayer(reflectionLayer);
511 } 511 }
512 } else { 512 } else {
513 m_graphicsLayer->setReplicatedByLayer(0); 513 m_graphicsLayer->setReplicatedByLayer(0);
514 } 514 }
515 515
516 updateBackgroundColor(isSimpleContainerCompositingLayer()); 516 updateBackgroundColor();
517 517
518 if (isDirectlyCompositedImage()) 518 if (isDirectlyCompositedImage())
519 updateImageContents(); 519 updateImageContents();
520 520
521 if (renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->allows AcceleratedCompositing()) { 521 if (renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->allows AcceleratedCompositing()) {
522 PluginView* pluginView = toPluginView(toRenderWidget(renderer)->widget() ); 522 PluginView* pluginView = toPluginView(toRenderWidget(renderer)->widget() );
523 m_graphicsLayer->setContentsToPlatformLayer(pluginView->platformLayer()) ; 523 m_graphicsLayer->setContentsToPlatformLayer(pluginView->platformLayer()) ;
524 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to HTMLFrameOwnerElement(renderer->node())->contentFrame()) { 524 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to HTMLFrameOwnerElement(renderer->node())->contentFrame()) {
525 blink::WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->cont entFrame()->remotePlatformLayer(); 525 blink::WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->cont entFrame()->remotePlatformLayer();
526 if (layer) 526 if (layer)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 624
625 // Set transform property, if it is not animating. We have to do this here b ecause the transform 625 // Set transform property, if it is not animating. We have to do this here b ecause the transform
626 // is affected by the layer dimensions. 626 // is affected by the layer dimensions.
627 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransform )) 627 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransform ))
628 updateTransform(renderer()->style()); 628 updateTransform(renderer()->style());
629 629
630 // Set opacity, if it is not animating. 630 // Set opacity, if it is not animating.
631 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity)) 631 if (!hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity))
632 updateOpacity(renderer()->style()); 632 updateOpacity(renderer()->style());
633 633
634 bool isSimpleContainer = isSimpleContainerCompositingLayer();
635
636 m_owningLayer->updateDescendantDependentFlags(); 634 m_owningLayer->updateDescendantDependentFlags();
637 635
638 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a nd its non-compositing 636 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a nd its non-compositing
639 // descendants. So, the visibility flag for m_graphicsLayer should be true i f there are any 637 // descendants. So, the visibility flag for m_graphicsLayer should be true i f there are any
640 // non-compositing visible layers. 638 // non-compositing visible layers.
641 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo mpositingDescendantLayers(); 639 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo mpositingDescendantLayers();
642 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i sVideo()) { 640 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && renderer()->i sVideo()) {
643 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node()); 641 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer()->node());
644 if (mediaElement->isFullscreen()) 642 if (mediaElement->isFullscreen())
645 contentsVisible = false; 643 contentsVisible = false;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 841
844 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping 842 // We can't make this call in RenderLayerCompositor::allocateOrClearComposit edLayerMapping
845 // since it depends on whether compAncestor draws content, which gets update d later. 843 // since it depends on whether compAncestor draws content, which gets update d later.
846 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor); 844 updateRequiresOwnBackingStoreForAncestorReasons(compAncestor);
847 845
848 if (RuntimeEnabledFeatures::cssCompositingEnabled()) { 846 if (RuntimeEnabledFeatures::cssCompositingEnabled()) {
849 updateLayerBlendMode(style); 847 updateLayerBlendMode(style);
850 updateIsRootForIsolatedGroup(); 848 updateIsRootForIsolatedGroup();
851 } 849 }
852 850
853 updateContentsRect(isSimpleContainer); 851 updateContentsRect();
854 updateBackgroundColor(isSimpleContainer); 852 updateBackgroundColor();
855 updateDrawsContent(isSimpleContainer); 853 updateDrawsContent();
856 updateContentsOpaque(); 854 updateContentsOpaque();
857 updateAfterWidgetResize(); 855 updateAfterWidgetResize();
858 updateRenderingContext(); 856 updateRenderingContext();
859 updateShouldFlattenTransform(); 857 updateShouldFlattenTransform();
860 updateChildrenTransform(); 858 updateChildrenTransform();
861 registerScrollingLayers(); 859 registerScrollingLayers();
862 860
863 updateCompositingReasons(); 861 updateCompositingReasons();
864 } 862 }
865 863
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 928
931 if (m_ancestorClippingLayer) 929 if (m_ancestorClippingLayer)
932 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ; 930 m_squashingContainmentLayer->addChild(m_ancestorClippingLayer.get()) ;
933 else 931 else
934 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); 932 m_squashingContainmentLayer->addChild(m_graphicsLayer.get());
935 933
936 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); 934 m_squashingContainmentLayer->addChild(m_squashingLayer.get());
937 } 935 }
938 } 936 }
939 937
940 void CompositedLayerMapping::updateContentsRect(bool isSimpleContainer) 938 void CompositedLayerMapping::updateContentsRect()
941 { 939 {
942 LayoutRect contentsRect; 940 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox()));
943 if (isSimpleContainer && renderer()->hasBackground())
944 contentsRect = backgroundBox();
945 else
946 contentsRect = contentsBox();
947
948 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsRect));
949 } 941 }
950 942
951 void CompositedLayerMapping::updateDrawsContent(bool isSimpleContainer) 943 void CompositedLayerMapping::updateDrawsContent()
952 { 944 {
953 if (m_scrollingLayer) { 945 if (m_scrollingLayer) {
954 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere. 946 // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere.
955 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint. 947 // m_graphicsLayer only needs backing store if the non-scrolling parts ( background, outlines, borders, shadows etc) need to paint.
956 // m_scrollingLayer never has backing store. 948 // m_scrollingLayer never has backing store.
957 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint. 949 // m_scrollingContentsLayer only needs backing store if the scrolled con tents need to paint.
958 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent() && m_owningLayer->hasBoxDecorationsOrBackground(); 950 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent() && m_owningLayer->hasBoxDecorationsOrBackground();
959 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); 951 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent);
960 952
961 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() && (renderer()->hasBackground() || paintsChildren()); 953 bool hasScrollingPaintedContent = m_owningLayer->hasVisibleContent() && (renderer()->hasBackground() || paintsChildren());
962 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent); 954 m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent);
963 return; 955 return;
964 } 956 }
965 957
966 bool hasPaintedContent = containsPaintedContent(isSimpleContainer); 958 bool hasPaintedContent = containsPaintedContent();
967 if (hasPaintedContent && isAcceleratedCanvas(renderer())) { 959 if (hasPaintedContent && isAcceleratedCanvas(renderer())) {
968 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext(); 960 CanvasRenderingContext* context = toHTMLCanvasElement(renderer()->node() )->renderingContext();
969 // Content layer may be null if context is lost. 961 // Content layer may be null if context is lost.
970 if (blink::WebLayer* contentLayer = context->platformLayer()) { 962 if (blink::WebLayer* contentLayer = context->platformLayer()) {
971 Color bgColor(Color::transparent); 963 Color bgColor(Color::transparent);
972 if (contentLayerSupportsDirectBackgroundComposition(renderer())) { 964 if (contentLayerSupportsDirectBackgroundComposition(renderer())) {
973 bgColor = rendererBackgroundColor(); 965 bgColor = rendererBackgroundColor();
974 hasPaintedContent = false; 966 hasPaintedContent = false;
975 } 967 }
976 contentLayer->setBackgroundColor(bgColor.rgb()); 968 contentLayer->setBackgroundColor(bgColor.rgb());
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 1482
1491 Color CompositedLayerMapping::rendererBackgroundColor() const 1483 Color CompositedLayerMapping::rendererBackgroundColor() const
1492 { 1484 {
1493 RenderObject* backgroundRenderer = renderer(); 1485 RenderObject* backgroundRenderer = renderer();
1494 if (backgroundRenderer->isRoot()) 1486 if (backgroundRenderer->isRoot())
1495 backgroundRenderer = backgroundRenderer->rendererForRootBackground(); 1487 backgroundRenderer = backgroundRenderer->rendererForRootBackground();
1496 1488
1497 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor); 1489 return backgroundRenderer->resolveColor(CSSPropertyBackgroundColor);
1498 } 1490 }
1499 1491
1500 void CompositedLayerMapping::updateBackgroundColor(bool isSimpleContainer) 1492 void CompositedLayerMapping::updateBackgroundColor()
1501 { 1493 {
1502 Color backgroundColor = rendererBackgroundColor(); 1494 m_graphicsLayer->setBackgroundColor(rendererBackgroundColor());
1503 if (isSimpleContainer) {
1504 m_graphicsLayer->setContentsToSolidColor(backgroundColor);
1505 m_graphicsLayer->setBackgroundColor(Color::transparent);
1506 } else {
1507 m_graphicsLayer->setContentsToSolidColor(Color::transparent);
1508 m_graphicsLayer->setBackgroundColor(backgroundColor);
1509 }
1510 }
1511
1512 static bool supportsDirectBoxDecorationsComposition(const RenderObject* renderer )
1513 {
1514 if (renderer->hasClip())
1515 return false;
1516
1517 if (hasBoxDecorationsOrBackgroundImage(renderer->style()))
1518 return false;
1519
1520 // FIXME: we should be able to allow backgroundComposite; However since this is not a common use case it has been deferred for now.
1521 if (renderer->style()->backgroundComposite() != CompositeSourceOver)
1522 return false;
1523
1524 if (renderer->style()->backgroundClip() == TextFillBox)
1525 return false;
1526
1527 return true;
1528 }
1529
1530 bool CompositedLayerMapping::paintsBoxDecorations() const
1531 {
1532 if (!m_owningLayer->hasVisibleBoxDecorations())
1533 return false;
1534
1535 if (!supportsDirectBoxDecorationsComposition(renderer()))
1536 return true;
1537
1538 return false;
1539 } 1495 }
1540 1496
1541 bool CompositedLayerMapping::paintsChildren() const 1497 bool CompositedLayerMapping::paintsChildren() const
1542 { 1498 {
1543 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen derers()) 1499 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRen derers())
1544 return true; 1500 return true;
1545 1501
1546 if (hasVisibleNonCompositingDescendantLayers()) 1502 if (hasVisibleNonCompositingDescendantLayers())
1547 return true; 1503 return true;
1548 1504
1549 return false; 1505 return false;
1550 } 1506 }
1551 1507
1552 static bool isCompositedPlugin(RenderObject* renderer) 1508 static bool isCompositedPlugin(RenderObject* renderer)
1553 { 1509 {
1554 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all owsAcceleratedCompositing(); 1510 return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->all owsAcceleratedCompositing();
1555 } 1511 }
1556 1512
1557 // A "simple container layer" is a RenderLayer which has no visible content to r ender.
1558 // It may have no children, or all its children may be themselves composited.
1559 // This is a useful optimization, because it allows us to avoid allocating backi ng store.
1560 bool CompositedLayerMapping::isSimpleContainerCompositingLayer() const
1561 {
1562 RenderObject* renderObject = renderer();
1563 if (renderObject->hasMask()) // masks require special treatment
1564 return false;
1565
1566 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject))
1567 return false;
1568
1569 if (paintsBoxDecorations() || paintsChildren())
1570 return false;
1571
1572 if (renderObject->isRenderRegion())
1573 return false;
1574
1575 if (renderObject->node() && renderObject->node()->isDocumentNode()) {
1576 // Look to see if the root object has a non-simple background
1577 RenderObject* rootObject = renderObject->document().documentElement() ? renderObject->document().documentElement()->renderer() : 0;
1578 if (!rootObject)
1579 return false;
1580
1581 RenderStyle* style = rootObject->style();
1582
1583 // Reject anything that has a border, a border-radius or outline,
1584 // or is not a simple background (no background, or solid color).
1585 if (hasBoxDecorationsOrBackgroundImage(style))
1586 return false;
1587
1588 // Now look at the body's renderer.
1589 HTMLElement* body = renderObject->document().body();
1590 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body- >renderer() : 0;
1591 if (!bodyObject)
1592 return false;
1593
1594 style = bodyObject->style();
1595
1596 if (hasBoxDecorationsOrBackgroundImage(style))
1597 return false;
1598 }
1599
1600 return true;
1601 }
1602
1603 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent) 1513 static bool hasVisibleNonCompositingDescendant(RenderLayer* parent)
1604 { 1514 {
1605 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512. 1515 // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512.
1606 parent->stackingNode()->updateLayerListsIfNeeded(); 1516 parent->stackingNode()->updateLayerListsIfNeeded();
1607 1517
1608 #if !ASSERT_DISABLED 1518 #if !ASSERT_DISABLED
1609 LayerListMutationDetector mutationChecker(parent->stackingNode()); 1519 LayerListMutationDetector mutationChecker(parent->stackingNode());
1610 #endif 1520 #endif
1611 1521
1612 RenderLayerStackingNodeIterator normalFlowIterator(*parent->stackingNode(), NormalFlowChildren); 1522 RenderLayerStackingNodeIterator normalFlowIterator(*parent->stackingNode(), NormalFlowChildren);
(...skipping 19 matching lines...) Expand all
1632 } 1542 }
1633 1543
1634 // FIXME: By name the implementation is correct. But the code that uses this fun ction means something 1544 // FIXME: By name the implementation is correct. But the code that uses this fun ction means something
1635 // very slightly different - the implementation needs to also include composited descendants that 1545 // very slightly different - the implementation needs to also include composited descendants that
1636 // don't paint into their own backing, and instead paint into this backing. 1546 // don't paint into their own backing, and instead paint into this backing.
1637 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const 1547 bool CompositedLayerMapping::hasVisibleNonCompositingDescendantLayers() const
1638 { 1548 {
1639 return hasVisibleNonCompositingDescendant(m_owningLayer); 1549 return hasVisibleNonCompositingDescendant(m_owningLayer);
1640 } 1550 }
1641 1551
1642 bool CompositedLayerMapping::containsPaintedContent(bool isSimpleContainer) cons t 1552 bool CompositedLayerMapping::containsPaintedContent() const
1643 { 1553 {
1644 if (isSimpleContainer || paintsIntoCompositedAncestor() || m_artificiallyInf latedBounds || m_owningLayer->isReflection()) 1554 if (paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owni ngLayer->isReflection())
1645 return false; 1555 return false;
1646 1556
1647 if (isDirectlyCompositedImage()) 1557 if (isDirectlyCompositedImage())
1648 return false; 1558 return false;
1649 1559
1560 RenderObject* renderObject = renderer();
1650 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely, 1561 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
1651 // and set background color on the layer in that case, instead of allocating backing store and painting. 1562 // and set background color on the layer in that case, instead of allocating backing store and painting.
1652 if (renderer()->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo() ) 1563 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo ())
1653 return m_owningLayer->hasBoxDecorationsOrBackground(); 1564 return m_owningLayer->hasBoxDecorationsOrBackground();
1654 1565
1655 return true; 1566 if (m_owningLayer->hasVisibleBoxDecorations())
1567 return true;
1568
1569 if (renderObject->hasMask()) // masks require special treatment
1570 return true;
1571
1572 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject))
1573 return true;
1574
1575 if (renderObject->isRenderRegion())
1576 return true;
1577
1578 if (renderObject->node() && renderObject->node()->isDocumentNode() && render Object->document().documentElement()) {
1579 // Look to see if the root object has a non-simple background
1580 RenderObject* rootObject = renderObject->document().documentElement()->r enderer();
1581 RenderStyle* style = rootObject->style();
1582
1583 // Reject anything that has a border, a border-radius or outline,
1584 // or is not a simple background (no background, or solid color).
1585 if (hasBoxDecorationsOrBackgroundImage(style))
1586 return true;
1587
1588 // Now look at the body's renderer.
1589 HTMLElement* body = renderObject->document().body();
1590 RenderObject* bodyObject = (body && body->hasLocalName(bodyTag)) ? body- >renderer() : 0;
1591 if (bodyObject) {
1592 style = bodyObject->style();
1593 if (hasBoxDecorationsOrBackgroundImage(style))
1594 return true;
1595 }
1596 }
1597
1598 // FIXME: it's O(n^2). A better solution is needed.
1599 if (paintsChildren())
alokp 2014/02/28 22:57:53 nit: return paintsChildren()
1600 return true;
1601
1602 return false;
1656 } 1603 }
1657 1604
1658 // An image can be directly compositing if it's the sole content of the layer, a nd has no box decorations 1605 // An image can be directly compositing if it's the sole content of the layer, a nd has no box decorations
1659 // that require painting. Direct compositing saves backing store. 1606 // that require painting. Direct compositing saves backing store.
1660 bool CompositedLayerMapping::isDirectlyCompositedImage() const 1607 bool CompositedLayerMapping::isDirectlyCompositedImage() const
1661 { 1608 {
1662 RenderObject* renderObject = renderer(); 1609 RenderObject* renderObject = renderer();
1663 1610
1664 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground () || renderObject->hasClip()) 1611 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground () || renderObject->hasClip())
1665 return false; 1612 return false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 Image* image = cachedImage->imageForRenderer(imageRenderer); 1648 Image* image = cachedImage->imageForRenderer(imageRenderer);
1702 if (!image) 1649 if (!image)
1703 return; 1650 return;
1704 1651
1705 // We have to wait until the image is fully loaded before setting it on the layer. 1652 // We have to wait until the image is fully loaded before setting it on the layer.
1706 if (!cachedImage->isLoaded()) 1653 if (!cachedImage->isLoaded())
1707 return; 1654 return;
1708 1655
1709 // This is a no-op if the layer doesn't have an inner layer for the image. 1656 // This is a no-op if the layer doesn't have an inner layer for the image.
1710 m_graphicsLayer->setContentsToImage(image); 1657 m_graphicsLayer->setContentsToImage(image);
1711 bool isSimpleContainer = false; 1658 updateDrawsContent();
1712 updateDrawsContent(isSimpleContainer);
1713 1659
1714 // Image animation is "lazy", in that it automatically stops unless someone is drawing 1660 // Image animation is "lazy", in that it automatically stops unless someone is drawing
1715 // the image. So we have to kick the animation each time; this has the downs ide that the 1661 // the image. So we have to kick the animation each time; this has the downs ide that the
1716 // image will keep animating, even if its layer is not visible. 1662 // image will keep animating, even if its layer is not visible.
1717 image->startAnimation(); 1663 image->startAnimation();
1718 } 1664 }
1719 1665
1720 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde rBox) const 1666 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde rBox) const
1721 { 1667 {
1722 RenderStyle* style = renderer()->style(); 1668 RenderStyle* style = renderer()->style();
(...skipping 26 matching lines...) Expand all
1749 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y()); 1695 return LayoutSize(-m_compositedBounds.x(), -m_compositedBounds.y());
1750 } 1696 }
1751 1697
1752 LayoutRect CompositedLayerMapping::contentsBox() const 1698 LayoutRect CompositedLayerMapping::contentsBox() const
1753 { 1699 {
1754 LayoutRect contentsBox = contentsRect(renderer()); 1700 LayoutRect contentsBox = contentsRect(renderer());
1755 contentsBox.move(contentOffsetInCompostingLayer()); 1701 contentsBox.move(contentOffsetInCompostingLayer());
1756 return contentsBox; 1702 return contentsBox;
1757 } 1703 }
1758 1704
1759 IntRect CompositedLayerMapping::backgroundBox() const
1760 {
1761 LayoutRect backgroundBox = backgroundRect(renderer());
1762 backgroundBox.move(contentOffsetInCompostingLayer());
1763 return pixelSnappedIntRect(backgroundBox);
1764 }
1765
1766 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const 1705 GraphicsLayer* CompositedLayerMapping::parentForSublayers() const
1767 { 1706 {
1768 if (m_scrollingContentsLayer) 1707 if (m_scrollingContentsLayer)
1769 return m_scrollingContentsLayer.get(); 1708 return m_scrollingContentsLayer.get();
1770 1709
1771 if (m_childContainmentLayer) 1710 if (m_childContainmentLayer)
1772 return m_childContainmentLayer.get(); 1711 return m_childContainmentLayer.get();
1773 1712
1774 if (m_childTransformLayer) 1713 if (m_childTransformLayer)
1775 return m_childTransformLayer.get(); 1714 return m_childTransformLayer.get();
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2102 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2164 name = "Scrolling Contents Layer"; 2103 name = "Scrolling Contents Layer";
2165 } else { 2104 } else {
2166 ASSERT_NOT_REACHED(); 2105 ASSERT_NOT_REACHED();
2167 } 2106 }
2168 2107
2169 return name; 2108 return name;
2170 } 2109 }
2171 2110
2172 } // namespace WebCore 2111 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/compositing/CompositedLayerMapping.h ('k') | Source/platform/graphics/GraphicsLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698