| 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 if (m_owningLayer.reflectionInfo()->reflectionLayer()->hasCompositedLaye
rMapping()) { | 450 if (m_owningLayer.reflectionInfo()->reflectionLayer()->hasCompositedLaye
rMapping()) { |
| 451 GraphicsLayer* reflectionLayer = m_owningLayer.reflectionInfo()->ref
lectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); | 451 GraphicsLayer* reflectionLayer = m_owningLayer.reflectionInfo()->ref
lectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); |
| 452 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); | 452 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); |
| 453 } | 453 } |
| 454 } else { | 454 } else { |
| 455 m_graphicsLayer->setReplicatedByLayer(0); | 455 m_graphicsLayer->setReplicatedByLayer(0); |
| 456 } | 456 } |
| 457 | 457 |
| 458 updateBackgroundColor(); | 458 updateBackgroundColor(); |
| 459 | 459 |
| 460 if (isDirectlyCompositedImage()) | 460 if (renderer->isImage() && isDirectlyCompositedImage()) |
| 461 updateImageContents(); | 461 updateImageContents(); |
| 462 | 462 |
| 463 if (WebLayer* layer = platformLayerForPlugin(renderer)) { | 463 if (WebLayer* layer = platformLayerForPlugin(renderer)) { |
| 464 m_graphicsLayer->setContentsToPlatformLayer(layer); | 464 m_graphicsLayer->setContentsToPlatformLayer(layer); |
| 465 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to
HTMLFrameOwnerElement(renderer->node())->contentFrame()) { | 465 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to
HTMLFrameOwnerElement(renderer->node())->contentFrame()) { |
| 466 WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->contentFram
e()->remotePlatformLayer(); | 466 WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->contentFram
e()->remotePlatformLayer(); |
| 467 if (layer) | 467 if (layer) |
| 468 m_graphicsLayer->setContentsToPlatformLayer(layer); | 468 m_graphicsLayer->setContentsToPlatformLayer(layer); |
| 469 } else if (renderer->isVideo()) { | 469 } else if (renderer->isVideo()) { |
| 470 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer->node()); | 470 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer->node()); |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 return false; | 1693 return false; |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 bool CompositedLayerMapping::containsPaintedContent() const | 1696 bool CompositedLayerMapping::containsPaintedContent() const |
| 1697 { | 1697 { |
| 1698 if (paintsIntoCompositedAncestor() || m_owningLayer.isReflection()) | 1698 if (paintsIntoCompositedAncestor() || m_owningLayer.isReflection()) |
| 1699 return false; | 1699 return false; |
| 1700 | 1700 |
| 1701 if (isDirectlyCompositedImage()) | 1701 if (renderer()->isImage() && isDirectlyCompositedImage()) |
| 1702 return false; | 1702 return false; |
| 1703 | 1703 |
| 1704 RenderObject* renderObject = renderer(); | 1704 RenderObject* renderObject = renderer(); |
| 1705 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, | 1705 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, |
| 1706 // and set background color on the layer in that case, instead of allocating
backing store and painting. | 1706 // and set background color on the layer in that case, instead of allocating
backing store and painting. |
| 1707 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo
()) | 1707 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo
()) |
| 1708 return m_owningLayer.hasBoxDecorationsOrBackground(); | 1708 return m_owningLayer.hasBoxDecorationsOrBackground(); |
| 1709 | 1709 |
| 1710 if (m_owningLayer.hasVisibleBoxDecorations()) | 1710 if (m_owningLayer.hasVisibleBoxDecorations()) |
| 1711 return true; | 1711 return true; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1735 } | 1735 } |
| 1736 | 1736 |
| 1737 // FIXME: it's O(n^2). A better solution is needed. | 1737 // FIXME: it's O(n^2). A better solution is needed. |
| 1738 return paintsChildren(); | 1738 return paintsChildren(); |
| 1739 } | 1739 } |
| 1740 | 1740 |
| 1741 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations | 1741 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations |
| 1742 // that require painting. Direct compositing saves backing store. | 1742 // that require painting. Direct compositing saves backing store. |
| 1743 bool CompositedLayerMapping::isDirectlyCompositedImage() const | 1743 bool CompositedLayerMapping::isDirectlyCompositedImage() const |
| 1744 { | 1744 { |
| 1745 ASSERT(renderer()->isImage()); |
| 1746 |
| 1745 RenderObject* renderObject = renderer(); | 1747 RenderObject* renderObject = renderer(); |
| 1746 | 1748 if (m_owningLayer.hasBoxDecorationsOrBackground() || renderObject->hasClip()
) |
| 1747 if (!renderObject->isImage() || m_owningLayer.hasBoxDecorationsOrBackground(
) || renderObject->hasClip()) | |
| 1748 return false; | 1749 return false; |
| 1749 | 1750 |
| 1750 RenderImage* imageRenderer = toRenderImage(renderObject); | 1751 RenderImage* imageRenderer = toRenderImage(renderObject); |
| 1751 if (ImageResource* cachedImage = imageRenderer->cachedImage()) { | 1752 if (ImageResource* cachedImage = imageRenderer->cachedImage()) { |
| 1752 if (!cachedImage->hasImage()) | 1753 if (!cachedImage->hasImage()) |
| 1753 return false; | 1754 return false; |
| 1754 | 1755 |
| 1755 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1756 Image* image = cachedImage->imageForRenderer(imageRenderer); |
| 1756 return image->isBitmapImage(); | 1757 return image->isBitmapImage(); |
| 1757 } | 1758 } |
| 1758 | 1759 |
| 1759 return false; | 1760 return false; |
| 1760 } | 1761 } |
| 1761 | 1762 |
| 1762 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) | 1763 void CompositedLayerMapping::contentChanged(ContentChangeType changeType) |
| 1763 { | 1764 { |
| 1764 if ((changeType == ImageChanged) && isDirectlyCompositedImage()) { | 1765 if ((changeType == ImageChanged) && renderer()->isImage() && isDirectlyCompo
sitedImage()) { |
| 1765 updateImageContents(); | 1766 updateImageContents(); |
| 1766 return; | 1767 return; |
| 1767 } | 1768 } |
| 1768 | 1769 |
| 1769 if (changeType == CanvasChanged && isAcceleratedCanvas(renderer())) { | 1770 if (changeType == CanvasChanged && isAcceleratedCanvas(renderer())) { |
| 1770 m_graphicsLayer->setContentsNeedsDisplay(); | 1771 m_graphicsLayer->setContentsNeedsDisplay(); |
| 1771 return; | 1772 return; |
| 1772 } | 1773 } |
| 1773 } | 1774 } |
| 1774 | 1775 |
| 1775 void CompositedLayerMapping::updateImageContents() | 1776 void CompositedLayerMapping::updateImageContents() |
| 1776 { | 1777 { |
| 1777 ASSERT(renderer()->isImage()); | 1778 ASSERT(renderer()->isImage()); |
| 1778 RenderImage* imageRenderer = toRenderImage(renderer()); | 1779 RenderImage* imageRenderer = toRenderImage(renderer()); |
| 1779 | 1780 |
| 1780 ImageResource* cachedImage = imageRenderer->cachedImage(); | 1781 ImageResource* cachedImage = imageRenderer->cachedImage(); |
| 1781 if (!cachedImage) | 1782 if (!cachedImage) |
| 1782 return; | 1783 return; |
| 1783 | 1784 |
| 1784 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1785 Image* image = cachedImage->imageForRenderer(imageRenderer); |
| 1785 if (!image) | 1786 if (!image) |
| 1786 return; | 1787 return; |
| 1787 | 1788 |
| 1788 // We have to wait until the image is fully loaded before setting it on the
layer. | 1789 // We have to wait until the image is fully loaded before setting it on the
layer. |
| 1789 if (!cachedImage->isLoaded()) | 1790 if (!cachedImage->isLoaded()) |
| 1790 return; | 1791 return; |
| 1791 | 1792 |
| 1792 // This is a no-op if the layer doesn't have an inner layer for the image. | 1793 // This is a no-op if the layer doesn't have an inner layer for the image. |
| 1793 m_graphicsLayer->setContentsToImage(image); | 1794 m_graphicsLayer->setContentsToImage(image); |
| 1795 |
| 1796 // Prevent double-drawing: https://bugs.webkit.org/show_bug.cgi?id=58632 |
| 1794 updateDrawsContent(); | 1797 updateDrawsContent(); |
| 1795 | 1798 |
| 1796 // Image animation is "lazy", in that it automatically stops unless someone
is drawing | 1799 // Image animation is "lazy", in that it automatically stops unless someone
is drawing |
| 1797 // the image. So we have to kick the animation each time; this has the downs
ide that the | 1800 // the image. So we have to kick the animation each time; this has the downs
ide that the |
| 1798 // image will keep animating, even if its layer is not visible. | 1801 // image will keep animating, even if its layer is not visible. |
| 1799 image->startAnimation(); | 1802 image->startAnimation(); |
| 1800 } | 1803 } |
| 1801 | 1804 |
| 1802 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const | 1805 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const |
| 1803 { | 1806 { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2281 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
| 2279 name = "Scrolling Block Selection Layer"; | 2282 name = "Scrolling Block Selection Layer"; |
| 2280 } else { | 2283 } else { |
| 2281 ASSERT_NOT_REACHED(); | 2284 ASSERT_NOT_REACHED(); |
| 2282 } | 2285 } |
| 2283 | 2286 |
| 2284 return name; | 2287 return name; |
| 2285 } | 2288 } |
| 2286 | 2289 |
| 2287 } // namespace blink | 2290 } // namespace blink |
| OLD | NEW |