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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 | 560 |
561 compositingBoundsRelativeToCompositedAncestor = localBounds; | 561 compositingBoundsRelativeToCompositedAncestor = localBounds; |
562 compositingBoundsRelativeToCompositedAncestor.moveBy(snappedOffsetFromCompos
itedAncestor); | 562 compositingBoundsRelativeToCompositedAncestor.moveBy(snappedOffsetFromCompos
itedAncestor); |
563 } | 563 } |
564 | 564 |
565 void CompositedLayerMapping::updateSquashingLayerGeometry(const LayoutPoint& off
setFromCompositedAncestor, const IntPoint& graphicsLayerParentLocation, const Re
nderLayer& referenceLayer, | 565 void CompositedLayerMapping::updateSquashingLayerGeometry(const LayoutPoint& off
setFromCompositedAncestor, const IntPoint& graphicsLayerParentLocation, const Re
nderLayer& referenceLayer, |
566 Vector<GraphicsLayerPaintInfo>& layers, GraphicsLayer* squashingLayer, Layou
tPoint* offsetFromTransformedAncestor, Vector<RenderLayer*>& layersNeedingPaintI
nvalidation) | 566 Vector<GraphicsLayerPaintInfo>& layers, GraphicsLayer* squashingLayer, Layou
tPoint* offsetFromTransformedAncestor, Vector<RenderLayer*>& layersNeedingPaintI
nvalidation) |
567 { | 567 { |
568 if (!squashingLayer) | 568 if (!squashingLayer) |
569 return; | 569 return; |
570 ASSERT(compositor()->layerSquashingEnabled()); | |
571 | 570 |
572 LayoutPoint offsetFromReferenceLayerToParentGraphicsLayer(offsetFromComposit
edAncestor); | 571 LayoutPoint offsetFromReferenceLayerToParentGraphicsLayer(offsetFromComposit
edAncestor); |
573 offsetFromReferenceLayerToParentGraphicsLayer.moveBy(-graphicsLayerParentLoc
ation); | 572 offsetFromReferenceLayerToParentGraphicsLayer.moveBy(-graphicsLayerParentLoc
ation); |
574 | 573 |
575 // FIXME: Cache these offsets. | 574 // FIXME: Cache these offsets. |
576 LayoutPoint referenceOffsetFromTransformedAncestor = referenceLayer.computeO
ffsetFromTransformedAncestor(); | 575 LayoutPoint referenceOffsetFromTransformedAncestor = referenceLayer.computeO
ffsetFromTransformedAncestor(); |
577 | 576 |
578 LayoutRect totalSquashBounds; | 577 LayoutRect totalSquashBounds; |
579 for (size_t i = 0; i < layers.size(); ++i) { | 578 for (size_t i = 0; i < layers.size(); ++i) { |
580 LayoutRect squashedBounds = layers[i].renderLayer->boundingBoxForComposi
ting(); | 579 LayoutRect squashedBounds = layers[i].renderLayer->boundingBoxForComposi
ting(); |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 | 1057 |
1059 if (m_layerForHorizontalScrollbar) | 1058 if (m_layerForHorizontalScrollbar) |
1060 m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get(
)); | 1059 m_overflowControlsHostLayer->addChild(m_layerForHorizontalScrollbar.get(
)); |
1061 if (m_layerForVerticalScrollbar) | 1060 if (m_layerForVerticalScrollbar) |
1062 m_overflowControlsHostLayer->addChild(m_layerForVerticalScrollbar.get())
; | 1061 m_overflowControlsHostLayer->addChild(m_layerForVerticalScrollbar.get())
; |
1063 if (m_layerForScrollCorner) | 1062 if (m_layerForScrollCorner) |
1064 m_overflowControlsHostLayer->addChild(m_layerForScrollCorner.get()); | 1063 m_overflowControlsHostLayer->addChild(m_layerForScrollCorner.get()); |
1065 | 1064 |
1066 // The squashing containment layer, if it exists, becomes a no-op parent. | 1065 // The squashing containment layer, if it exists, becomes a no-op parent. |
1067 if (m_squashingLayer) { | 1066 if (m_squashingLayer) { |
1068 ASSERT(compositor()->layerSquashingEnabled()); | |
1069 ASSERT((m_ancestorClippingLayer && !m_squashingContainmentLayer) || (!m_
ancestorClippingLayer && m_squashingContainmentLayer)); | 1067 ASSERT((m_ancestorClippingLayer && !m_squashingContainmentLayer) || (!m_
ancestorClippingLayer && m_squashingContainmentLayer)); |
1070 | 1068 |
1071 if (m_squashingContainmentLayer) { | 1069 if (m_squashingContainmentLayer) { |
1072 m_squashingContainmentLayer->removeAllChildren(); | 1070 m_squashingContainmentLayer->removeAllChildren(); |
1073 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); | 1071 m_squashingContainmentLayer->addChild(m_graphicsLayer.get()); |
1074 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); | 1072 m_squashingContainmentLayer->addChild(m_squashingLayer.get()); |
1075 } else { | 1073 } else { |
1076 // The ancestor clipping layer is already set up and has m_graphicsL
ayer under it. | 1074 // The ancestor clipping layer is already set up and has m_graphicsL
ayer under it. |
1077 m_ancestorClippingLayer->addChild(m_squashingLayer.get()); | 1075 m_ancestorClippingLayer->addChild(m_squashingLayer.get()); |
1078 } | 1076 } |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 | 1614 |
1617 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay
er(m_owningLayer)) | 1615 if (ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLay
er(m_owningLayer)) |
1618 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g
et(), clipParent); | 1616 scrollingCoordinator->updateClipParentForGraphicsLayer(m_graphicsLayer.g
et(), clipParent); |
1619 } | 1617 } |
1620 | 1618 |
1621 bool CompositedLayerMapping::updateSquashingLayers(bool needsSquashingLayers) | 1619 bool CompositedLayerMapping::updateSquashingLayers(bool needsSquashingLayers) |
1622 { | 1620 { |
1623 bool layersChanged = false; | 1621 bool layersChanged = false; |
1624 | 1622 |
1625 if (needsSquashingLayers) { | 1623 if (needsSquashingLayers) { |
1626 ASSERT(compositor()->layerSquashingEnabled()); | |
1627 | |
1628 if (!m_squashingLayer) { | 1624 if (!m_squashingLayer) { |
1629 m_squashingLayer = createGraphicsLayer(CompositingReasonLayerForSqua
shingContents); | 1625 m_squashingLayer = createGraphicsLayer(CompositingReasonLayerForSqua
shingContents); |
1630 m_squashingLayer->setDrawsContent(true); | 1626 m_squashingLayer->setDrawsContent(true); |
1631 layersChanged = true; | 1627 layersChanged = true; |
1632 } | 1628 } |
1633 | 1629 |
1634 if (m_ancestorClippingLayer) { | 1630 if (m_ancestorClippingLayer) { |
1635 if (m_squashingContainmentLayer) { | 1631 if (m_squashingContainmentLayer) { |
1636 m_squashingContainmentLayer->removeFromParent(); | 1632 m_squashingContainmentLayer->removeFromParent(); |
1637 m_squashingContainmentLayer = nullptr; | 1633 m_squashingContainmentLayer = nullptr; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 context->setDeviceScaleFactor(deviceScaleFactor); | 2081 context->setDeviceScaleFactor(deviceScaleFactor); |
2086 | 2082 |
2087 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { | 2083 if (paintInfo.renderLayer->compositingState() != PaintsIntoGroupedBacking) { |
2088 // FIXME: GraphicsLayers need a way to split for RenderRegions. | 2084 // FIXME: GraphicsLayers need a way to split for RenderRegions. |
2089 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe
haviorNormal, paintInfo.renderLayer->subpixelAccumulation()); | 2085 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe
haviorNormal, paintInfo.renderLayer->subpixelAccumulation()); |
2090 LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintin
gInfo, paintLayerFlags); | 2086 LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, paintin
gInfo, paintLayerFlags); |
2091 | 2087 |
2092 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) | 2088 if (paintInfo.renderLayer->containsDirtyOverlayScrollbars()) |
2093 LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, pai
ntingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars); | 2089 LayerPainter(*paintInfo.renderLayer).paintLayerContents(context, pai
ntingInfo, paintLayerFlags | PaintLayerPaintingOverlayScrollbars); |
2094 } else { | 2090 } else { |
2095 ASSERT(compositor()->layerSquashingEnabled()); | |
2096 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe
haviorNormal, paintInfo.renderLayer->subpixelAccumulation()); | 2091 LayerPaintingInfo paintingInfo(paintInfo.renderLayer, dirtyRect, PaintBe
haviorNormal, paintInfo.renderLayer->subpixelAccumulation()); |
2097 | 2092 |
2098 // RenderLayer::paintLayer assumes that the caller clips to the passed r
ect. Squashed layers need to do this clipping in software, | 2093 // RenderLayer::paintLayer assumes that the caller clips to the passed r
ect. Squashed layers need to do this clipping in software, |
2099 // since there is no graphics layer to clip them precisely. Furthermore,
in some cases we squash layers that need clipping in software | 2094 // since there is no graphics layer to clip them precisely. Furthermore,
in some cases we squash layers that need clipping in software |
2100 // from clipping ancestors (see CompositedLayerMapping::localClipRectFor
SquashedLayer()). | 2095 // from clipping ancestors (see CompositedLayerMapping::localClipRectFor
SquashedLayer()). |
2101 context->save(); | 2096 context->save(); |
2102 dirtyRect.intersect(paintInfo.localClipRectForSquashedLayer); | 2097 dirtyRect.intersect(paintInfo.localClipRectForSquashedLayer); |
2103 context->clip(dirtyRect); | 2098 context->clip(dirtyRect); |
2104 LayerPainter(*paintInfo.renderLayer).paintLayer(context, paintingInfo, p
aintLayerFlags); | 2099 LayerPainter(*paintInfo.renderLayer).paintLayer(context, paintingInfo, p
aintLayerFlags); |
2105 context->restore(); | 2100 context->restore(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2160 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2166 | 2161 |
2167 GraphicsLayerPaintInfo paintInfo; | 2162 GraphicsLayerPaintInfo paintInfo; |
2168 paintInfo.renderLayer = &m_owningLayer; | 2163 paintInfo.renderLayer = &m_owningLayer; |
2169 paintInfo.compositedBounds = compositedBounds(); | 2164 paintInfo.compositedBounds = compositedBounds(); |
2170 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); | 2165 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); |
2171 | 2166 |
2172 // We have to use the same root as for hit testing, because both methods
can compute and cache clipRects. | 2167 // We have to use the same root as for hit testing, because both methods
can compute and cache clipRects. |
2173 doPaintTask(paintInfo, paintLayerFlags, &context, clip); | 2168 doPaintTask(paintInfo, paintLayerFlags, &context, clip); |
2174 } else if (graphicsLayer == m_squashingLayer.get()) { | 2169 } else if (graphicsLayer == m_squashingLayer.get()) { |
2175 ASSERT(compositor()->layerSquashingEnabled()); | |
2176 for (size_t i = 0; i < m_squashedLayers.size(); ++i) | 2170 for (size_t i = 0; i < m_squashedLayers.size(); ++i) |
2177 doPaintTask(m_squashedLayers[i], paintLayerFlags, &context, clip); | 2171 doPaintTask(m_squashedLayers[i], paintLayerFlags, &context, clip); |
2178 } else if (graphicsLayer == layerForHorizontalScrollbar()) { | 2172 } else if (graphicsLayer == layerForHorizontalScrollbar()) { |
2179 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co
ntext, clip); | 2173 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co
ntext, clip); |
2180 } else if (graphicsLayer == layerForVerticalScrollbar()) { | 2174 } else if (graphicsLayer == layerForVerticalScrollbar()) { |
2181 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont
ext, clip); | 2175 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont
ext, clip); |
2182 } else if (graphicsLayer == layerForScrollCorner()) { | 2176 } else if (graphicsLayer == layerForScrollCorner()) { |
2183 const IntRect& scrollCornerAndResizer = m_owningLayer.scrollableArea()->
scrollCornerAndResizerRect(); | 2177 const IntRect& scrollCornerAndResizer = m_owningLayer.scrollableArea()->
scrollCornerAndResizerRect(); |
2184 context.save(); | 2178 context.save(); |
2185 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y
()); | 2179 context.translate(-scrollCornerAndResizer.x(), -scrollCornerAndResizer.y
()); |
(...skipping 30 matching lines...) Expand all Loading... |
2216 | 2210 |
2217 IntRect CompositedLayerMapping::pixelSnappedCompositedBounds() const | 2211 IntRect CompositedLayerMapping::pixelSnappedCompositedBounds() const |
2218 { | 2212 { |
2219 LayoutRect bounds = m_compositedBounds; | 2213 LayoutRect bounds = m_compositedBounds; |
2220 bounds.move(m_owningLayer.subpixelAccumulation()); | 2214 bounds.move(m_owningLayer.subpixelAccumulation()); |
2221 return pixelSnappedIntRect(bounds); | 2215 return pixelSnappedIntRect(bounds); |
2222 } | 2216 } |
2223 | 2217 |
2224 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* squashe
dLayer, const RenderLayer& owningLayer, size_t nextSquashedLayerIndex) | 2218 bool CompositedLayerMapping::updateSquashingLayerAssignment(RenderLayer* squashe
dLayer, const RenderLayer& owningLayer, size_t nextSquashedLayerIndex) |
2225 { | 2219 { |
2226 ASSERT(compositor()->layerSquashingEnabled()); | |
2227 | |
2228 GraphicsLayerPaintInfo paintInfo; | 2220 GraphicsLayerPaintInfo paintInfo; |
2229 paintInfo.renderLayer = squashedLayer; | 2221 paintInfo.renderLayer = squashedLayer; |
2230 // NOTE: composited bounds are updated elsewhere | 2222 // NOTE: composited bounds are updated elsewhere |
2231 // NOTE: offsetFromRenderer is updated elsewhere | 2223 // NOTE: offsetFromRenderer is updated elsewhere |
2232 | 2224 |
2233 // Change tracking on squashing layers: at the first sign of something chang
ed, just invalidate the layer. | 2225 // Change tracking on squashing layers: at the first sign of something chang
ed, just invalidate the layer. |
2234 // FIXME: Perhaps we can find a tighter more clever mechanism later. | 2226 // FIXME: Perhaps we can find a tighter more clever mechanism later. |
2235 bool updatedAssignment = false; | 2227 bool updatedAssignment = false; |
2236 if (nextSquashedLayerIndex < m_squashedLayers.size()) { | 2228 if (nextSquashedLayerIndex < m_squashedLayers.size()) { |
2237 if (paintInfo.renderLayer != m_squashedLayers[nextSquashedLayerIndex].re
nderLayer) { | 2229 if (paintInfo.renderLayer != m_squashedLayers[nextSquashedLayerIndex].re
nderLayer) { |
(...skipping 22 matching lines...) Expand all Loading... |
2260 } | 2252 } |
2261 | 2253 |
2262 if (layerIndex == kNotFound) | 2254 if (layerIndex == kNotFound) |
2263 return; | 2255 return; |
2264 | 2256 |
2265 m_squashedLayers.remove(layerIndex); | 2257 m_squashedLayers.remove(layerIndex); |
2266 } | 2258 } |
2267 | 2259 |
2268 void CompositedLayerMapping::finishAccumulatingSquashingLayers(size_t nextSquash
edLayerIndex) | 2260 void CompositedLayerMapping::finishAccumulatingSquashingLayers(size_t nextSquash
edLayerIndex) |
2269 { | 2261 { |
2270 ASSERT(compositor()->layerSquashingEnabled()); | |
2271 | |
2272 // Any additional squashed RenderLayers in the array no longer exist, and re
moving invalidates the squashingLayer contents. | 2262 // Any additional squashed RenderLayers in the array no longer exist, and re
moving invalidates the squashingLayer contents. |
2273 if (nextSquashedLayerIndex < m_squashedLayers.size()) | 2263 if (nextSquashedLayerIndex < m_squashedLayers.size()) |
2274 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size()
- nextSquashedLayerIndex); | 2264 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size()
- nextSquashedLayerIndex); |
2275 } | 2265 } |
2276 | 2266 |
2277 String CompositedLayerMapping::debugName(const GraphicsLayer* graphicsLayer) | 2267 String CompositedLayerMapping::debugName(const GraphicsLayer* graphicsLayer) |
2278 { | 2268 { |
2279 String name; | 2269 String name; |
2280 if (graphicsLayer == m_graphicsLayer.get()) { | 2270 if (graphicsLayer == m_graphicsLayer.get()) { |
2281 name = m_owningLayer.debugName(); | 2271 name = m_owningLayer.debugName(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2304 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2315 name = "Scrolling Block Selection Layer"; | 2305 name = "Scrolling Block Selection Layer"; |
2316 } else { | 2306 } else { |
2317 ASSERT_NOT_REACHED(); | 2307 ASSERT_NOT_REACHED(); |
2318 } | 2308 } |
2319 | 2309 |
2320 return name; | 2310 return name; |
2321 } | 2311 } |
2322 | 2312 |
2323 } // namespace blink | 2313 } // namespace blink |
OLD | NEW |