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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (m_owningLayer.reflectionInfo()->reflectionLayer()->hasCompositedLaye
rMapping()) { | 449 if (m_owningLayer.reflectionInfo()->reflectionLayer()->hasCompositedLaye
rMapping()) { |
450 GraphicsLayer* reflectionLayer = m_owningLayer.reflectionInfo()->ref
lectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); | 450 GraphicsLayer* reflectionLayer = m_owningLayer.reflectionInfo()->ref
lectionLayer()->compositedLayerMapping()->mainGraphicsLayer(); |
451 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); | 451 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); |
452 } | 452 } |
453 } else { | 453 } else { |
454 m_graphicsLayer->setReplicatedByLayer(0); | 454 m_graphicsLayer->setReplicatedByLayer(0); |
455 } | 455 } |
456 | 456 |
457 updateBackgroundColor(); | 457 updateBackgroundColor(); |
458 | 458 |
459 if (isDirectlyCompositedImage()) | 459 if (renderer->isImage()) { |
460 updateImageContents(); | 460 if (isDirectlyCompositedImage()) { |
461 | 461 updateImageContents(); |
462 if (blink::WebLayer* layer = platformLayerForPlugin(renderer)) { | 462 } else if (m_graphicsLayer->hasContentsLayer()) { |
| 463 m_graphicsLayer->setContentsToImage(0); |
| 464 } |
| 465 } else if (blink::WebLayer* layer = platformLayerForPlugin(renderer)) { |
463 m_graphicsLayer->setContentsToPlatformLayer(layer); | 466 m_graphicsLayer->setContentsToPlatformLayer(layer); |
464 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to
HTMLFrameOwnerElement(renderer->node())->contentFrame()) { | 467 } else if (renderer->node() && renderer->node()->isFrameOwnerElement() && to
HTMLFrameOwnerElement(renderer->node())->contentFrame()) { |
465 blink::WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->cont
entFrame()->remotePlatformLayer(); | 468 blink::WebLayer* layer = toHTMLFrameOwnerElement(renderer->node())->cont
entFrame()->remotePlatformLayer(); |
466 if (layer) | 469 if (layer) |
467 m_graphicsLayer->setContentsToPlatformLayer(layer); | 470 m_graphicsLayer->setContentsToPlatformLayer(layer); |
468 } else if (renderer->isVideo()) { | 471 } else if (renderer->isVideo()) { |
469 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer->node()); | 472 HTMLMediaElement* mediaElement = toHTMLMediaElement(renderer->node()); |
470 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(
)); | 473 m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(
)); |
471 } else if (isAcceleratedCanvas(renderer)) { | 474 } else if (isAcceleratedCanvas(renderer)) { |
472 HTMLCanvasElement* canvas = toHTMLCanvasElement(renderer->node()); | 475 HTMLCanvasElement* canvas = toHTMLCanvasElement(renderer->node()); |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 } | 1641 } |
1639 | 1642 |
1640 return false; | 1643 return false; |
1641 } | 1644 } |
1642 | 1645 |
1643 bool CompositedLayerMapping::containsPaintedContent() const | 1646 bool CompositedLayerMapping::containsPaintedContent() const |
1644 { | 1647 { |
1645 if (paintsIntoCompositedAncestor() || m_owningLayer.isReflection()) | 1648 if (paintsIntoCompositedAncestor() || m_owningLayer.isReflection()) |
1646 return false; | 1649 return false; |
1647 | 1650 |
1648 if (isDirectlyCompositedImage()) | 1651 if (renderer()->isImage() && isDirectlyCompositedImage()) |
1649 return false; | 1652 return false; |
1650 | 1653 |
1651 RenderObject* renderObject = renderer(); | 1654 RenderObject* renderObject = renderer(); |
1652 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, | 1655 // FIXME: we could optimize cases where the image, video or canvas is known
to fill the border box entirely, |
1653 // and set background color on the layer in that case, instead of allocating
backing store and painting. | 1656 // and set background color on the layer in that case, instead of allocating
backing store and painting. |
1654 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo
()) | 1657 if (renderObject->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo
()) |
1655 return m_owningLayer.hasBoxDecorationsOrBackground(); | 1658 return m_owningLayer.hasBoxDecorationsOrBackground(); |
1656 | 1659 |
1657 if (m_owningLayer.hasVisibleBoxDecorations()) | 1660 if (m_owningLayer.hasVisibleBoxDecorations()) |
1658 return true; | 1661 return true; |
(...skipping 23 matching lines...) Expand all Loading... |
1682 } | 1685 } |
1683 | 1686 |
1684 // FIXME: it's O(n^2). A better solution is needed. | 1687 // FIXME: it's O(n^2). A better solution is needed. |
1685 return paintsChildren(); | 1688 return paintsChildren(); |
1686 } | 1689 } |
1687 | 1690 |
1688 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations | 1691 // An image can be directly compositing if it's the sole content of the layer, a
nd has no box decorations |
1689 // that require painting. Direct compositing saves backing store. | 1692 // that require painting. Direct compositing saves backing store. |
1690 bool CompositedLayerMapping::isDirectlyCompositedImage() const | 1693 bool CompositedLayerMapping::isDirectlyCompositedImage() const |
1691 { | 1694 { |
| 1695 ASSERT(renderer()->isImage()); |
| 1696 |
1692 RenderObject* renderObject = renderer(); | 1697 RenderObject* renderObject = renderer(); |
1693 | 1698 if (m_owningLayer.hasBoxDecorationsOrBackground() || renderObject->hasClip()
) |
1694 if (!renderObject->isImage() || m_owningLayer.hasBoxDecorationsOrBackground(
) || renderObject->hasClip()) | |
1695 return false; | 1699 return false; |
1696 | 1700 |
1697 RenderImage* imageRenderer = toRenderImage(renderObject); | 1701 RenderImage* imageRenderer = toRenderImage(renderObject); |
1698 if (ImageResource* cachedImage = imageRenderer->cachedImage()) { | 1702 if (ImageResource* cachedImage = imageRenderer->cachedImage()) { |
1699 if (!cachedImage->hasImage()) | 1703 if (!cachedImage->hasImage()) |
1700 return false; | 1704 return false; |
1701 | 1705 |
1702 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1706 Image* image = cachedImage->imageForRenderer(imageRenderer); |
1703 return image->isBitmapImage(); | 1707 return image->isBitmapImage(); |
1704 } | 1708 } |
(...skipping 26 matching lines...) Expand all Loading... |
1731 Image* image = cachedImage->imageForRenderer(imageRenderer); | 1735 Image* image = cachedImage->imageForRenderer(imageRenderer); |
1732 if (!image) | 1736 if (!image) |
1733 return; | 1737 return; |
1734 | 1738 |
1735 // We have to wait until the image is fully loaded before setting it on the
layer. | 1739 // We have to wait until the image is fully loaded before setting it on the
layer. |
1736 if (!cachedImage->isLoaded()) | 1740 if (!cachedImage->isLoaded()) |
1737 return; | 1741 return; |
1738 | 1742 |
1739 // This is a no-op if the layer doesn't have an inner layer for the image. | 1743 // This is a no-op if the layer doesn't have an inner layer for the image. |
1740 m_graphicsLayer->setContentsToImage(image); | 1744 m_graphicsLayer->setContentsToImage(image); |
| 1745 |
| 1746 // Prevent double-drawing: https://bugs.webkit.org/show_bug.cgi?id=58632 |
1741 updateDrawsContent(); | 1747 updateDrawsContent(); |
1742 | 1748 |
1743 // Image animation is "lazy", in that it automatically stops unless someone
is drawing | 1749 // Image animation is "lazy", in that it automatically stops unless someone
is drawing |
1744 // the image. So we have to kick the animation each time; this has the downs
ide that the | 1750 // the image. So we have to kick the animation each time; this has the downs
ide that the |
1745 // image will keep animating, even if its layer is not visible. | 1751 // image will keep animating, even if its layer is not visible. |
1746 image->startAnimation(); | 1752 image->startAnimation(); |
1747 } | 1753 } |
1748 | 1754 |
1749 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const | 1755 FloatPoint3D CompositedLayerMapping::computeTransformOrigin(const IntRect& borde
rBox) const |
1750 { | 1756 { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 #ifndef NDEBUG | 2094 #ifndef NDEBUG |
2089 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. | 2095 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. |
2090 if (Page* page = renderer()->frame()->page()) | 2096 if (Page* page = renderer()->frame()->page()) |
2091 page->setIsPainting(true); | 2097 page->setIsPainting(true); |
2092 #endif | 2098 #endif |
2093 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data"
, InspectorPaintEvent::data(m_owningLayer.renderer(), clip, graphicsLayer)); | 2099 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Paint", "data"
, InspectorPaintEvent::data(m_owningLayer.renderer(), clip, graphicsLayer)); |
2094 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | 2100 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); |
2095 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 2101 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
2096 InspectorInstrumentation::willPaint(m_owningLayer.renderer(), graphicsLayer)
; | 2102 InspectorInstrumentation::willPaint(m_owningLayer.renderer(), graphicsLayer)
; |
2097 | 2103 |
| 2104 setCurrentScreenId(reinterpret_cast<long long>(renderer()->frame()->page()))
; |
| 2105 |
2098 if (graphicsLayer == m_graphicsLayer.get() | 2106 if (graphicsLayer == m_graphicsLayer.get() |
2099 || graphicsLayer == m_foregroundLayer.get() | 2107 || graphicsLayer == m_foregroundLayer.get() |
2100 || graphicsLayer == m_backgroundLayer.get() | 2108 || graphicsLayer == m_backgroundLayer.get() |
2101 || graphicsLayer == m_maskLayer.get() | 2109 || graphicsLayer == m_maskLayer.get() |
2102 || graphicsLayer == m_childClippingMaskLayer.get() | 2110 || graphicsLayer == m_childClippingMaskLayer.get() |
2103 || graphicsLayer == m_scrollingContentsLayer.get() | 2111 || graphicsLayer == m_scrollingContentsLayer.get() |
2104 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2112 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2105 | 2113 |
2106 GraphicsLayerPaintInfo paintInfo; | 2114 GraphicsLayerPaintInfo paintInfo; |
2107 paintInfo.renderLayer = &m_owningLayer; | 2115 paintInfo.renderLayer = &m_owningLayer; |
(...skipping 15 matching lines...) Expand all Loading... |
2123 } else if (graphicsLayer == layerForScrollCorner()) { | 2131 } else if (graphicsLayer == layerForScrollCorner()) { |
2124 const IntRect& scrollCornerAndResizer = m_owningLayer.scrollableArea()->
scrollCornerAndResizerRect(); | 2132 const IntRect& scrollCornerAndResizer = m_owningLayer.scrollableArea()->
scrollCornerAndResizerRect(); |
2125 context.save(); | 2133 context.save(); |
2126 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y
()); | 2134 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y
()); |
2127 IntRect transformedClip = clip; | 2135 IntRect transformedClip = clip; |
2128 transformedClip.moveBy(scrollCornerAndResizer.location()); | 2136 transformedClip.moveBy(scrollCornerAndResizer.location()); |
2129 m_owningLayer.scrollableArea()->paintScrollCorner(&context, IntPoint(),
transformedClip); | 2137 m_owningLayer.scrollableArea()->paintScrollCorner(&context, IntPoint(),
transformedClip); |
2130 m_owningLayer.scrollableArea()->paintResizer(&context, IntPoint(), trans
formedClip); | 2138 m_owningLayer.scrollableArea()->paintResizer(&context, IntPoint(), trans
formedClip); |
2131 context.restore(); | 2139 context.restore(); |
2132 } | 2140 } |
| 2141 |
| 2142 setCurrentScreenId(0); |
| 2143 |
2133 InspectorInstrumentation::didPaint(m_owningLayer.renderer(), graphicsLayer,
&context, clip); | 2144 InspectorInstrumentation::didPaint(m_owningLayer.renderer(), graphicsLayer,
&context, clip); |
2134 #ifndef NDEBUG | 2145 #ifndef NDEBUG |
2135 if (Page* page = renderer()->frame()->page()) | 2146 if (Page* page = renderer()->frame()->page()) |
2136 page->setIsPainting(false); | 2147 page->setIsPainting(false); |
2137 #endif | 2148 #endif |
2138 } | 2149 } |
2139 | 2150 |
2140 bool CompositedLayerMapping::isTrackingRepaints() const | 2151 bool CompositedLayerMapping::isTrackingRepaints() const |
2141 { | 2152 { |
2142 GraphicsLayerClient* client = compositor(); | 2153 GraphicsLayerClient* client = compositor(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2266 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2277 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2267 name = "Scrolling Block Selection Layer"; | 2278 name = "Scrolling Block Selection Layer"; |
2268 } else { | 2279 } else { |
2269 ASSERT_NOT_REACHED(); | 2280 ASSERT_NOT_REACHED(); |
2270 } | 2281 } |
2271 | 2282 |
2272 return name; | 2283 return name; |
2273 } | 2284 } |
2274 | 2285 |
2275 } // namespace WebCore | 2286 } // namespace WebCore |
OLD | NEW |