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

Side by Side Diff: Source/core/rendering/RenderLayerBacking.cpp

Issue 16688004: Large canvas does not honor containing div's border radius (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Replaced explicit baselines with NeedsRebaseline Created 7 years, 3 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return false; 133 return false;
134 134
135 // If there is no background, there is nothing to support. 135 // If there is no background, there is nothing to support.
136 if (!renderer->style()->hasBackground()) 136 if (!renderer->style()->hasBackground())
137 return true; 137 return true;
138 138
139 // Simple background that is contained within the contents rect. 139 // Simple background that is contained within the contents rect.
140 return contentsRect(renderer).contains(backgroundRect(renderer)); 140 return contentsRect(renderer).contains(backgroundRect(renderer));
141 } 141 }
142 142
143 static inline bool isAcceleratedContents(RenderObject* renderer)
144 {
145 return isAcceleratedCanvas(renderer)
146 || (renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->al lowsAcceleratedCompositing())
147 || renderer->isVideo();
148 }
149
143 // Get the scrolling coordinator in a way that works inside RenderLayerBacking's destructor. 150 // Get the scrolling coordinator in a way that works inside RenderLayerBacking's destructor.
144 static ScrollingCoordinator* scrollingCoordinatorFromLayer(RenderLayer* layer) 151 static ScrollingCoordinator* scrollingCoordinatorFromLayer(RenderLayer* layer)
145 { 152 {
146 Page* page = layer->renderer()->frame()->page(); 153 Page* page = layer->renderer()->frame()->page();
147 if (!page) 154 if (!page)
148 return 0; 155 return 0;
149 156
150 return page->scrollingCoordinator(); 157 return page->scrollingCoordinator();
151 } 158 }
152 159
(...skipping 17 matching lines...) Expand all
170 createPrimaryGraphicsLayer(); 177 createPrimaryGraphicsLayer();
171 } 178 }
172 179
173 RenderLayerBacking::~RenderLayerBacking() 180 RenderLayerBacking::~RenderLayerBacking()
174 { 181 {
175 updateClippingLayers(false, false, false); 182 updateClippingLayers(false, false, false);
176 updateOverflowControlsLayers(false, false, false); 183 updateOverflowControlsLayers(false, false, false);
177 updateForegroundLayer(false); 184 updateForegroundLayer(false);
178 updateBackgroundLayer(false); 185 updateBackgroundLayer(false);
179 updateMaskLayer(false); 186 updateMaskLayer(false);
187 updateClippingMaskLayers(false);
180 updateScrollingLayers(false); 188 updateScrollingLayers(false);
181 destroyGraphicsLayers(); 189 destroyGraphicsLayers();
182 } 190 }
183 191
184 PassOwnPtr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(CompositingRea sons reasons) 192 PassOwnPtr<GraphicsLayer> RenderLayerBacking::createGraphicsLayer(CompositingRea sons reasons)
185 { 193 {
186 GraphicsLayerFactory* graphicsLayerFactory = 0; 194 GraphicsLayerFactory* graphicsLayerFactory = 0;
187 if (Page* page = renderer()->frame()->page()) 195 if (Page* page = renderer()->frame()->page())
188 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory(); 196 graphicsLayerFactory = page->chrome().client().graphicsLayerFactory();
189 197
(...skipping 25 matching lines...) Expand all
215 { 223 {
216 if (m_graphicsLayer) 224 if (m_graphicsLayer)
217 m_graphicsLayer->removeFromParent(); 225 m_graphicsLayer->removeFromParent();
218 226
219 m_ancestorClippingLayer = nullptr; 227 m_ancestorClippingLayer = nullptr;
220 m_graphicsLayer = nullptr; 228 m_graphicsLayer = nullptr;
221 m_foregroundLayer = nullptr; 229 m_foregroundLayer = nullptr;
222 m_backgroundLayer = nullptr; 230 m_backgroundLayer = nullptr;
223 m_childContainmentLayer = nullptr; 231 m_childContainmentLayer = nullptr;
224 m_maskLayer = nullptr; 232 m_maskLayer = nullptr;
233 m_childClippingMaskLayer = nullptr;
225 234
226 m_scrollingLayer = nullptr; 235 m_scrollingLayer = nullptr;
227 m_scrollingContentsLayer = nullptr; 236 m_scrollingContentsLayer = nullptr;
228 } 237 }
229 238
230 void RenderLayerBacking::updateOpacity(const RenderStyle* style) 239 void RenderLayerBacking::updateOpacity(const RenderStyle* style)
231 { 240 {
232 m_graphicsLayer->setOpacity(compositingOpacity(style->opacity())); 241 m_graphicsLayer->setOpacity(compositingOpacity(style->opacity()));
233 } 242 }
234 243
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 444
436 updateScrollParent(scrollParent); 445 updateScrollParent(scrollParent);
437 updateClipParent(m_owningLayer->clipParent()); 446 updateClipParent(m_owningLayer->clipParent());
438 447
439 if (layerConfigChanged) 448 if (layerConfigChanged)
440 updateInternalHierarchy(); 449 updateInternalHierarchy();
441 450
442 if (updateMaskLayer(renderer->hasMask())) 451 if (updateMaskLayer(renderer->hasMask()))
443 m_graphicsLayer->setMaskLayer(m_maskLayer.get()); 452 m_graphicsLayer->setMaskLayer(m_maskLayer.get());
444 453
454 bool needsChildClippingMask = renderer->style()->hasBorderRadius() && isAcce leratedContents(renderer);
455 if (updateClippingMaskLayers(needsChildClippingMask))
456 m_graphicsLayer->setContentsClippingMaskLayer(m_childClippingMaskLayer.g et());
457
445 if (m_owningLayer->hasReflection()) { 458 if (m_owningLayer->hasReflection()) {
446 if (m_owningLayer->reflectionLayer()->backing()) { 459 if (m_owningLayer->reflectionLayer()->backing()) {
447 GraphicsLayer* reflectionLayer = m_owningLayer->reflectionLayer()->b acking()->graphicsLayer(); 460 GraphicsLayer* reflectionLayer = m_owningLayer->reflectionLayer()->b acking()->graphicsLayer();
448 m_graphicsLayer->setReplicatedByLayer(reflectionLayer); 461 m_graphicsLayer->setReplicatedByLayer(reflectionLayer);
449 } 462 }
450 } else 463 } else
451 m_graphicsLayer->setReplicatedByLayer(0); 464 m_graphicsLayer->setReplicatedByLayer(0);
452 465
453 updateBackgroundColor(isSimpleContainerCompositingLayer()); 466 updateBackgroundColor(isSimpleContainerCompositingLayer());
454 467
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 m_maskLayer = nullptr; 1106 m_maskLayer = nullptr;
1094 layerChanged = true; 1107 layerChanged = true;
1095 } 1108 }
1096 1109
1097 if (layerChanged) 1110 if (layerChanged)
1098 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer()); 1111 m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
1099 1112
1100 return layerChanged; 1113 return layerChanged;
1101 } 1114 }
1102 1115
1116 bool RenderLayerBacking::updateClippingMaskLayers(bool needsChildClippingMaskLay er)
1117 {
1118 bool layerChanged = false;
1119 if (needsChildClippingMaskLayer) {
1120 if (!m_childClippingMaskLayer) {
1121 m_childClippingMaskLayer = createGraphicsLayer(CompositingReasonLaye rForMask);
1122 m_childClippingMaskLayer->setDrawsContent(true);
1123 m_childClippingMaskLayer->setPaintingPhase(GraphicsLayerPaintChildCl ippingMask);
1124 layerChanged = true;
1125 }
1126 } else if (m_childClippingMaskLayer) {
1127 m_childClippingMaskLayer = nullptr;
1128 layerChanged = true;
1129 }
1130 return layerChanged;
1131 }
1132
1103 bool RenderLayerBacking::updateScrollingLayers(bool needsScrollingLayers) 1133 bool RenderLayerBacking::updateScrollingLayers(bool needsScrollingLayers)
1104 { 1134 {
1105 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m _owningLayer); 1135 ScrollingCoordinator* scrollingCoordinator = scrollingCoordinatorFromLayer(m _owningLayer);
1106 1136
1107 bool layerChanged = false; 1137 bool layerChanged = false;
1108 if (needsScrollingLayers) { 1138 if (needsScrollingLayers) {
1109 if (!m_scrollingLayer) { 1139 if (!m_scrollingLayer) {
1110 // Outer layer which corresponds with the scroll view. 1140 // Outer layer which corresponds with the scroll view.
1111 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForClip ); 1141 m_scrollingLayer = createGraphicsLayer(CompositingReasonLayerForClip );
1112 m_scrollingLayer->setDrawsContent(false); 1142 m_scrollingLayer->setDrawsContent(false);
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 1578
1549 if (m_foregroundLayer && m_foregroundLayer->drawsContent()) 1579 if (m_foregroundLayer && m_foregroundLayer->drawsContent())
1550 m_foregroundLayer->setNeedsDisplay(); 1580 m_foregroundLayer->setNeedsDisplay();
1551 1581
1552 if (m_backgroundLayer && m_backgroundLayer->drawsContent()) 1582 if (m_backgroundLayer && m_backgroundLayer->drawsContent())
1553 m_backgroundLayer->setNeedsDisplay(); 1583 m_backgroundLayer->setNeedsDisplay();
1554 1584
1555 if (m_maskLayer && m_maskLayer->drawsContent()) 1585 if (m_maskLayer && m_maskLayer->drawsContent())
1556 m_maskLayer->setNeedsDisplay(); 1586 m_maskLayer->setNeedsDisplay();
1557 1587
1588 if (m_childClippingMaskLayer && m_childClippingMaskLayer->drawsContent())
1589 m_childClippingMaskLayer->setNeedsDisplay();
1590
1558 if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent()) 1591 if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent())
1559 m_scrollingContentsLayer->setNeedsDisplay(); 1592 m_scrollingContentsLayer->setNeedsDisplay();
1560 } 1593 }
1561 1594
1562 // r is in the coordinate space of the layer's render object 1595 // r is in the coordinate space of the layer's render object
1563 void RenderLayerBacking::setContentsNeedDisplayInRect(const IntRect& r) 1596 void RenderLayerBacking::setContentsNeedDisplayInRect(const IntRect& r)
1564 { 1597 {
1565 ASSERT(!paintsIntoCompositedAncestor()); 1598 ASSERT(!paintsIntoCompositedAncestor());
1566 1599
1567 if (m_graphicsLayer && m_graphicsLayer->drawsContent()) { 1600 if (m_graphicsLayer && m_graphicsLayer->drawsContent()) {
(...skipping 14 matching lines...) Expand all
1582 layerDirtyRect.move(-m_backgroundLayer->offsetFromRenderer()); 1615 layerDirtyRect.move(-m_backgroundLayer->offsetFromRenderer());
1583 m_backgroundLayer->setNeedsDisplayInRect(layerDirtyRect); 1616 m_backgroundLayer->setNeedsDisplayInRect(layerDirtyRect);
1584 } 1617 }
1585 1618
1586 if (m_maskLayer && m_maskLayer->drawsContent()) { 1619 if (m_maskLayer && m_maskLayer->drawsContent()) {
1587 IntRect layerDirtyRect = r; 1620 IntRect layerDirtyRect = r;
1588 layerDirtyRect.move(-m_maskLayer->offsetFromRenderer()); 1621 layerDirtyRect.move(-m_maskLayer->offsetFromRenderer());
1589 m_maskLayer->setNeedsDisplayInRect(layerDirtyRect); 1622 m_maskLayer->setNeedsDisplayInRect(layerDirtyRect);
1590 } 1623 }
1591 1624
1625 if (m_childClippingMaskLayer && m_childClippingMaskLayer->drawsContent()) {
1626 IntRect layerDirtyRect = r;
1627 layerDirtyRect.move(-m_childClippingMaskLayer->offsetFromRenderer());
1628 m_childClippingMaskLayer->setNeedsDisplayInRect(layerDirtyRect);
1629 }
1630
1592 if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent()) { 1631 if (m_scrollingContentsLayer && m_scrollingContentsLayer->drawsContent()) {
1593 IntRect layerDirtyRect = r; 1632 IntRect layerDirtyRect = r;
1594 layerDirtyRect.move(-m_scrollingContentsLayer->offsetFromRenderer()); 1633 layerDirtyRect.move(-m_scrollingContentsLayer->offsetFromRenderer());
1595 m_scrollingContentsLayer->setNeedsDisplayInRect(layerDirtyRect); 1634 m_scrollingContentsLayer->setNeedsDisplayInRect(layerDirtyRect);
1596 } 1635 }
1597 } 1636 }
1598 1637
1599 void RenderLayerBacking::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Graphics Context* context, 1638 void RenderLayerBacking::doPaintTask(GraphicsLayerPaintInfo& paintInfo, Graphics Context* context,
1600 const IntRect& clip) // In the coords of rootLayer. 1639 const IntRect& clip) // In the coords of rootLayer.
1601 { 1640 {
1602 if (paintsIntoCompositedAncestor()) { 1641 if (paintsIntoCompositedAncestor()) {
1603 ASSERT_NOT_REACHED(); 1642 ASSERT_NOT_REACHED();
1604 return; 1643 return;
1605 } 1644 }
1606 1645
1607 FontCachePurgePreventer fontCachePurgePreventer; 1646 FontCachePurgePreventer fontCachePurgePreventer;
1608 1647
1609 RenderLayer::PaintLayerFlags paintFlags = 0; 1648 RenderLayer::PaintLayerFlags paintFlags = 0;
1610 if (paintInfo.paintingPhase & GraphicsLayerPaintBackground) 1649 if (paintInfo.paintingPhase & GraphicsLayerPaintBackground)
1611 paintFlags |= RenderLayer::PaintLayerPaintingCompositingBackgroundPhase; 1650 paintFlags |= RenderLayer::PaintLayerPaintingCompositingBackgroundPhase;
1612 if (paintInfo.paintingPhase & GraphicsLayerPaintForeground) 1651 if (paintInfo.paintingPhase & GraphicsLayerPaintForeground)
1613 paintFlags |= RenderLayer::PaintLayerPaintingCompositingForegroundPhase; 1652 paintFlags |= RenderLayer::PaintLayerPaintingCompositingForegroundPhase;
1614 if (paintInfo.paintingPhase & GraphicsLayerPaintMask) 1653 if (paintInfo.paintingPhase & GraphicsLayerPaintMask)
1615 paintFlags |= RenderLayer::PaintLayerPaintingCompositingMaskPhase; 1654 paintFlags |= RenderLayer::PaintLayerPaintingCompositingMaskPhase;
1655 if (paintInfo.paintingPhase & GraphicsLayerPaintChildClippingMask)
1656 paintFlags |= RenderLayer::PaintLayerPaintingChildClippingMaskPhase;
1616 if (paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents) 1657 if (paintInfo.paintingPhase & GraphicsLayerPaintOverflowContents)
1617 paintFlags |= RenderLayer::PaintLayerPaintingOverflowContents; 1658 paintFlags |= RenderLayer::PaintLayerPaintingOverflowContents;
1618 if (paintInfo.paintingPhase & GraphicsLayerPaintCompositedScroll) 1659 if (paintInfo.paintingPhase & GraphicsLayerPaintCompositedScroll)
1619 paintFlags |= RenderLayer::PaintLayerPaintingCompositingScrollingPhase; 1660 paintFlags |= RenderLayer::PaintLayerPaintingCompositingScrollingPhase;
1620 1661
1621 if (paintInfo.isBackgroundLayer) 1662 if (paintInfo.isBackgroundLayer)
1622 paintFlags |= (RenderLayer::PaintLayerPaintingRootBackgroundOnly | Rende rLayer::PaintLayerPaintingCompositingForegroundPhase); // Need PaintLayerPaintin gCompositingForegroundPhase to walk child layers. 1663 paintFlags |= (RenderLayer::PaintLayerPaintingRootBackgroundOnly | Rende rLayer::PaintLayerPaintingCompositingForegroundPhase); // Need PaintLayerPaintin gCompositingForegroundPhase to walk child layers.
1623 else if (compositor()->fixedRootBackgroundLayer()) 1664 else if (compositor()->fixedRootBackgroundLayer())
1624 paintFlags |= RenderLayer::PaintLayerPaintingSkipRootBackground; 1665 paintFlags |= RenderLayer::PaintLayerPaintingSkipRootBackground;
1625 1666
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 { 1722 {
1682 #ifndef NDEBUG 1723 #ifndef NDEBUG
1683 if (Page* page = renderer()->frame()->page()) 1724 if (Page* page = renderer()->frame()->page())
1684 page->setIsPainting(true); 1725 page->setIsPainting(true);
1685 #endif 1726 #endif
1686 1727
1687 if (graphicsLayer == m_graphicsLayer.get() 1728 if (graphicsLayer == m_graphicsLayer.get()
1688 || graphicsLayer == m_foregroundLayer.get() 1729 || graphicsLayer == m_foregroundLayer.get()
1689 || graphicsLayer == m_backgroundLayer.get() 1730 || graphicsLayer == m_backgroundLayer.get()
1690 || graphicsLayer == m_maskLayer.get() 1731 || graphicsLayer == m_maskLayer.get()
1732 || graphicsLayer == m_childClippingMaskLayer.get()
1691 || graphicsLayer == m_scrollingContentsLayer.get()) { 1733 || graphicsLayer == m_scrollingContentsLayer.get()) {
1692 1734
1693 GraphicsLayerPaintInfo paintInfo; 1735 GraphicsLayerPaintInfo paintInfo;
1694 paintInfo.renderLayer = m_owningLayer; 1736 paintInfo.renderLayer = m_owningLayer;
1695 paintInfo.compositedBounds = compositedBounds(); 1737 paintInfo.compositedBounds = compositedBounds();
1696 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer(); 1738 paintInfo.offsetFromRenderer = graphicsLayer->offsetFromRenderer();
1697 paintInfo.paintingPhase = paintingPhase; 1739 paintInfo.paintingPhase = paintingPhase;
1698 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer); 1740 paintInfo.isBackgroundLayer = (graphicsLayer == m_backgroundLayer);
1699 1741
1700 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 1742 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 double backingMemory; 1998 double backingMemory;
1957 1999
1958 // m_ancestorClippingLayer and m_childContainmentLayer are just used for mas king or containment, so have no backing. 2000 // m_ancestorClippingLayer and m_childContainmentLayer are just used for mas king or containment, so have no backing.
1959 backingMemory = m_graphicsLayer->backingStoreMemoryEstimate(); 2001 backingMemory = m_graphicsLayer->backingStoreMemoryEstimate();
1960 if (m_foregroundLayer) 2002 if (m_foregroundLayer)
1961 backingMemory += m_foregroundLayer->backingStoreMemoryEstimate(); 2003 backingMemory += m_foregroundLayer->backingStoreMemoryEstimate();
1962 if (m_backgroundLayer) 2004 if (m_backgroundLayer)
1963 backingMemory += m_backgroundLayer->backingStoreMemoryEstimate(); 2005 backingMemory += m_backgroundLayer->backingStoreMemoryEstimate();
1964 if (m_maskLayer) 2006 if (m_maskLayer)
1965 backingMemory += m_maskLayer->backingStoreMemoryEstimate(); 2007 backingMemory += m_maskLayer->backingStoreMemoryEstimate();
2008 if (m_childClippingMaskLayer)
2009 backingMemory += m_childClippingMaskLayer->backingStoreMemoryEstimate();
1966 2010
1967 if (m_scrollingContentsLayer) 2011 if (m_scrollingContentsLayer)
1968 backingMemory += m_scrollingContentsLayer->backingStoreMemoryEstimate(); 2012 backingMemory += m_scrollingContentsLayer->backingStoreMemoryEstimate();
1969 2013
1970 if (m_layerForHorizontalScrollbar) 2014 if (m_layerForHorizontalScrollbar)
1971 backingMemory += m_layerForHorizontalScrollbar->backingStoreMemoryEstima te(); 2015 backingMemory += m_layerForHorizontalScrollbar->backingStoreMemoryEstima te();
1972 2016
1973 if (m_layerForVerticalScrollbar) 2017 if (m_layerForVerticalScrollbar)
1974 backingMemory += m_layerForVerticalScrollbar->backingStoreMemoryEstimate (); 2018 backingMemory += m_layerForVerticalScrollbar->backingStoreMemoryEstimate ();
1975 2019
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2051 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2008 name = "Scrolling Contents Layer"; 2052 name = "Scrolling Contents Layer";
2009 } else { 2053 } else {
2010 ASSERT_NOT_REACHED(); 2054 ASSERT_NOT_REACHED();
2011 } 2055 }
2012 2056
2013 return name; 2057 return name;
2014 } 2058 }
2015 2059
2016 } // namespace WebCore 2060 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerBacking.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698