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

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

Issue 24921002: Make compositingState explicit (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed second round of reviewer feedback Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 m_compositedLayerMapping->contentChanged(changeType); 210 m_compositedLayerMapping->contentChanged(changeType);
211 } 211 }
212 212
213 bool RenderLayer::canRender3DTransforms() const 213 bool RenderLayer::canRender3DTransforms() const
214 { 214 {
215 return compositor()->canRender3DTransforms(); 215 return compositor()->canRender3DTransforms();
216 } 216 }
217 217
218 bool RenderLayer::paintsWithFilters() const 218 bool RenderLayer::paintsWithFilters() const
219 { 219 {
220 // FIXME: Eventually there will be more factors than isComposited() to decid e whether or not to render the filter
221 if (!renderer()->hasFilter()) 220 if (!renderer()->hasFilter())
222 return false; 221 return false;
223 222
224 if (!isComposited()) 223 if (compositingState() != PaintsIntoOwnBacking)
225 return true; 224 return true;
226 225
227 if (!m_compositedLayerMapping || !m_compositedLayerMapping->canCompositeFilt ers()) 226 if (!m_compositedLayerMapping || !m_compositedLayerMapping->canCompositeFilt ers())
228 return true; 227 return true;
229 228
230 return false; 229 return false;
231 } 230 }
232 231
233 bool RenderLayer::requiresFullLayerImageForFilters() const 232 bool RenderLayer::requiresFullLayerImageForFilters() const
234 { 233 {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 300 }
302 301
303 repainter().repaintAfterLayout(geometryMap, flags & CheckForRepaint); 302 repainter().repaintAfterLayout(geometryMap, flags & CheckForRepaint);
304 303
305 // Go ahead and update the reflection's position and size. 304 // Go ahead and update the reflection's position and size.
306 if (m_reflection) 305 if (m_reflection)
307 m_reflection->layout(); 306 m_reflection->layout();
308 307
309 // Clear the IsCompositingUpdateRoot flag once we've found the first composi ting layer in this update. 308 // Clear the IsCompositingUpdateRoot flag once we've found the first composi ting layer in this update.
310 bool isUpdateRoot = (flags & IsCompositingUpdateRoot); 309 bool isUpdateRoot = (flags & IsCompositingUpdateRoot);
311 if (isComposited()) 310 if (compositedLayerMapping())
312 flags &= ~IsCompositingUpdateRoot; 311 flags &= ~IsCompositingUpdateRoot;
313 312
314 if (useRegionBasedColumns() && renderer()->isInFlowRenderFlowThread()) { 313 if (useRegionBasedColumns() && renderer()->isInFlowRenderFlowThread()) {
315 updatePagination(); 314 updatePagination();
316 flags |= UpdatePagination; 315 flags |= UpdatePagination;
317 } 316 }
318 317
319 if (renderer()->hasColumns()) 318 if (renderer()->hasColumns())
320 flags |= UpdatePagination; 319 flags |= UpdatePagination;
321 320
322 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) 321 for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
323 child->updateLayerPositions(geometryMap, flags); 322 child->updateLayerPositions(geometryMap, flags);
324 323
325 if ((flags & UpdateCompositingLayers) && isComposited()) { 324 if ((flags & UpdateCompositingLayers) && compositedLayerMapping()) {
326 CompositedLayerMapping::UpdateAfterLayoutFlags updateFlags = CompositedL ayerMapping::CompositingChildrenOnly; 325 CompositedLayerMapping::UpdateAfterLayoutFlags updateFlags = CompositedL ayerMapping::CompositingChildrenOnly;
327 if (flags & NeedsFullRepaintInBacking) 326 if (flags & NeedsFullRepaintInBacking)
328 updateFlags |= CompositedLayerMapping::NeedsFullRepaint; 327 updateFlags |= CompositedLayerMapping::NeedsFullRepaint;
329 if (isUpdateRoot) 328 if (isUpdateRoot)
330 updateFlags |= CompositedLayerMapping::IsUpdateRoot; 329 updateFlags |= CompositedLayerMapping::IsUpdateRoot;
331 compositedLayerMapping()->updateAfterLayout(updateFlags); 330 compositedLayerMapping()->updateAfterLayout(updateFlags);
332 } 331 }
333 332
334 if (geometryMap) 333 if (geometryMap)
335 geometryMap->popMappingsToAncestor(parent()); 334 geometryMap->popMappingsToAncestor(parent());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 { 827 {
829 const Settings* settings = renderer()->document().settings(); 828 const Settings* settings = renderer()->document().settings();
830 return settings && settings->regionBasedColumnsEnabled(); 829 return settings && settings->regionBasedColumnsEnabled();
831 } 830 }
832 831
833 void RenderLayer::updatePagination() 832 void RenderLayer::updatePagination()
834 { 833 {
835 m_isPaginated = false; 834 m_isPaginated = false;
836 m_enclosingPaginationLayer = 0; 835 m_enclosingPaginationLayer = 0;
837 836
838 if (isComposited() || !parent()) 837 if (compositedLayerMapping() || !parent())
839 return; // FIXME: We will have to deal with paginated compositing layers someday. 838 return; // FIXME: We will have to deal with paginated compositing layers someday.
840 // FIXME: For now the RenderView can't be paginated. Eventually printing will move to a model where it is though. 839 // FIXME: For now the RenderView can't be paginated. Eventually printing will move to a model where it is though.
841 840
842 // The main difference between the paginated booleans for the old column cod e and the new column code 841 // The main difference between the paginated booleans for the old column cod e and the new column code
843 // is that each paginated layer has to paint on its own with the new code. T here is no 842 // is that each paginated layer has to paint on its own with the new code. T here is no
844 // recurring into child layers. This means that the m_isPaginated bits for t he new column code can't just be set on 843 // recurring into child layers. This means that the m_isPaginated bits for t he new column code can't just be set on
845 // "roots" that get split and paint all their descendants. Instead each laye r has to be checked individually and 844 // "roots" that get split and paint all their descendants. Instead each laye r has to be checked individually and
846 // genuinely know if it is going to have to split itself up when painting on ly its contents (and not any other descendant 845 // genuinely know if it is going to have to split itself up when painting on ly its contents (and not any other descendant
847 // layers). We track an enclosingPaginationLayer instead of using a simple b it, since we want to be able to get back 846 // layers). We track an enclosingPaginationLayer instead of using a simple b it, since we want to be able to get back
848 // to that layer easily. 847 // to that layer easily.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 if (positionedParent->renderer()->hasOverflowClip()) { 1137 if (positionedParent->renderer()->hasOverflowClip()) {
1139 LayoutSize offset = positionedParent->scrolledContentOffset(); 1138 LayoutSize offset = positionedParent->scrolledContentOffset();
1140 localPoint -= offset; 1139 localPoint -= offset;
1141 } 1140 }
1142 1141
1143 if (renderer()->isOutOfFlowPositioned() && positionedParent->renderer()- >isInFlowPositioned() && positionedParent->renderer()->isRenderInline()) { 1142 if (renderer()->isOutOfFlowPositioned() && positionedParent->renderer()- >isInFlowPositioned() && positionedParent->renderer()->isRenderInline()) {
1144 LayoutSize offset = toRenderInline(positionedParent->renderer())->of fsetForInFlowPositionedInline(toRenderBox(renderer())); 1143 LayoutSize offset = toRenderInline(positionedParent->renderer())->of fsetForInFlowPositionedInline(toRenderBox(renderer()));
1145 localPoint += offset; 1144 localPoint += offset;
1146 } 1145 }
1147 } else if (parent()) { 1146 } else if (parent()) {
1148 if (isComposited()) { 1147 if (compositedLayerMapping()) {
1149 // FIXME: Composited layers ignore pagination, so about the best we can do is make sure they're offset into the appropriate column. 1148 // FIXME: Composited layers ignore pagination, so about the best we can do is make sure they're offset into the appropriate column.
1150 // They won't split across columns properly. 1149 // They won't split across columns properly.
1151 LayoutSize columnOffset; 1150 LayoutSize columnOffset;
1152 if (!parent()->renderer()->hasColumns() && parent()->renderer()->isR oot() && renderer()->view()->hasColumns()) 1151 if (!parent()->renderer()->hasColumns() && parent()->renderer()->isR oot() && renderer()->view()->hasColumns())
1153 renderer()->view()->adjustForColumns(columnOffset, localPoint); 1152 renderer()->view()->adjustForColumns(columnOffset, localPoint);
1154 else 1153 else
1155 parent()->renderer()->adjustForColumns(columnOffset, localPoint) ; 1154 parent()->renderer()->adjustForColumns(columnOffset, localPoint) ;
1156 1155
1157 localPoint += columnOffset; 1156 localPoint += columnOffset;
1158 } 1157 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 curr = curr->parent(); 1269 curr = curr->parent();
1271 1270
1272 return curr; 1271 return curr;
1273 } 1272 }
1274 1273
1275 static inline const RenderLayer* compositingContainer(const RenderLayer* layer) 1274 static inline const RenderLayer* compositingContainer(const RenderLayer* layer)
1276 { 1275 {
1277 return layer->isNormalFlowOnly() ? layer->parent() : layer->ancestorStacking Container(); 1276 return layer->isNormalFlowOnly() ? layer->parent() : layer->ancestorStacking Container();
1278 } 1277 }
1279 1278
1279 // FIXME: having two different functions named enclosingCompositingLayer and enc losingCompositingLayerForRepaint
1280 // is error-prone and misleading for reading code that uses these functions - es pecially compounded with
1281 // the includeSelf option. It is very likely that some call sites of this functi on actually mean to use
1282 // enclosingCompositingLayerForRepaint().
1280 RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const 1283 RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const
1281 { 1284 {
1282 if (includeSelf && isComposited()) 1285 if (includeSelf && compositedLayerMapping())
1283 return const_cast<RenderLayer*>(this); 1286 return const_cast<RenderLayer*>(this);
1284 1287
1285 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) { 1288 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) {
1286 if (curr->isComposited()) 1289 if (curr->compositedLayerMapping())
1287 return const_cast<RenderLayer*>(curr); 1290 return const_cast<RenderLayer*>(curr);
1288 } 1291 }
1289 1292
1290 return 0; 1293 return 0;
1291 } 1294 }
1292 1295
1293 RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const 1296 RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const
1294 { 1297 {
1295 if (includeSelf && isComposited() && !compositedLayerMapping()->paintsIntoCo mpositedAncestor()) 1298 if (includeSelf && compositingState() == PaintsIntoOwnBacking)
1296 return const_cast<RenderLayer*>(this); 1299 return const_cast<RenderLayer*>(this);
1297 1300
1298 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) { 1301 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) {
1299 if (curr->isComposited() && !curr->compositedLayerMapping()->paintsIntoC ompositedAncestor()) 1302 if (curr->compositingState() == PaintsIntoOwnBacking)
1300 return const_cast<RenderLayer*>(curr); 1303 return const_cast<RenderLayer*>(curr);
1301 } 1304 }
1302 1305
1303 return 0; 1306 return 0;
1304 } 1307 }
1305 1308
1306 RenderLayer* RenderLayer::ancestorScrollingLayer() const 1309 RenderLayer* RenderLayer::ancestorScrollingLayer() const
1307 { 1310 {
1308 if (!acceleratedCompositingForOverflowScrollEnabled()) 1311 if (!acceleratedCompositingForOverflowScrollEnabled())
1309 return 0; 1312 return 0;
(...skipping 17 matching lines...) Expand all
1327 if (curr->requiresFullLayerImageForFilters()) 1330 if (curr->requiresFullLayerImageForFilters())
1328 return const_cast<RenderLayer*>(curr); 1331 return const_cast<RenderLayer*>(curr);
1329 } 1332 }
1330 1333
1331 return 0; 1334 return 0;
1332 } 1335 }
1333 1336
1334 RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const 1337 RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const
1335 { 1338 {
1336 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 1339 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
1337 if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr-> isComposited() || curr->isRootLayer()) 1340 if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr-> compositingState() == PaintsIntoOwnBacking || curr->isRootLayer())
1338 return const_cast<RenderLayer*>(curr); 1341 return const_cast<RenderLayer*>(curr);
1339 } 1342 }
1340 return 0; 1343 return 0;
1341 } 1344 }
1342 1345
1343 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect) 1346 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect)
1344 { 1347 {
1345 if (rect.isEmpty()) 1348 if (rect.isEmpty())
1346 return; 1349 return;
1347 1350
(...skipping 10 matching lines...) Expand all
1358 // shader can address any ouput pixel. 1361 // shader can address any ouput pixel.
1359 // Note: This is only for output rect, so there's no need to expand the dirty source rect. 1362 // Note: This is only for output rect, so there's no need to expand the dirty source rect.
1360 rectForRepaint.unite(calculateLayerBounds(this)); 1363 rectForRepaint.unite(calculateLayerBounds(this));
1361 } 1364 }
1362 1365
1363 RenderLayer* parentLayer = enclosingFilterRepaintLayer(); 1366 RenderLayer* parentLayer = enclosingFilterRepaintLayer();
1364 ASSERT(parentLayer); 1367 ASSERT(parentLayer);
1365 FloatQuad repaintQuad(rectForRepaint); 1368 FloatQuad repaintQuad(rectForRepaint);
1366 LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, p arentLayer->renderer()).enclosingBoundingBox(); 1369 LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, p arentLayer->renderer()).enclosingBoundingBox();
1367 1370
1368 if (parentLayer->isComposited()) { 1371 if (parentLayer->compositedLayerMapping()) {
1369 parentLayer->setBackingNeedsRepaintInRect(parentLayerRect); 1372 parentLayer->setBackingNeedsRepaintInRect(parentLayerRect);
1370 return; 1373 return;
1371 } 1374 }
1372 1375
1373 if (parentLayer->paintsWithFilters()) { 1376 if (parentLayer->paintsWithFilters()) {
1374 parentLayer->setFilterBackendNeedsRepaintingInRect(parentLayerRect); 1377 parentLayer->setFilterBackendNeedsRepaintingInRect(parentLayerRect);
1375 return; 1378 return;
1376 } 1379 }
1377 1380
1378 if (parentLayer->isRootLayer()) { 1381 if (parentLayer->isRootLayer()) {
(...skipping 10 matching lines...) Expand all
1389 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 1392 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
1390 RenderLayerModelObject* renderer = curr->renderer(); 1393 RenderLayerModelObject* renderer = curr->renderer();
1391 if (renderer->style()->hasFilterOutsets()) 1394 if (renderer->style()->hasFilterOutsets())
1392 return true; 1395 return true;
1393 } 1396 }
1394 return false; 1397 return false;
1395 } 1398 }
1396 1399
1397 RenderLayer* RenderLayer::clippingRootForPainting() const 1400 RenderLayer* RenderLayer::clippingRootForPainting() const
1398 { 1401 {
1399 if (isComposited()) 1402 if (compositedLayerMapping())
1400 return const_cast<RenderLayer*>(this); 1403 return const_cast<RenderLayer*>(this);
1401 1404
1402 const RenderLayer* current = this; 1405 const RenderLayer* current = this;
1403 while (current) { 1406 while (current) {
1404 if (current->isRootLayer()) 1407 if (current->isRootLayer())
1405 return const_cast<RenderLayer*>(current); 1408 return const_cast<RenderLayer*>(current);
1406 1409
1407 current = compositingContainer(current); 1410 current = compositingContainer(current);
1408 ASSERT(current); 1411 ASSERT(current);
1409 if (current->transform() 1412 if (current->transform()
1410 || (current->isComposited() && !current->compositedLayerMapping()->p aintsIntoCompositedAncestor()) 1413 || (current->compositingState() == PaintsIntoOwnBacking)
1411 ) 1414 )
1412 return const_cast<RenderLayer*>(current); 1415 return const_cast<RenderLayer*>(current);
1413 } 1416 }
1414 1417
1415 ASSERT_NOT_REACHED(); 1418 ASSERT_NOT_REACHED();
1416 return 0; 1419 return 0;
1417 } 1420 }
1418 1421
1419 LayoutPoint RenderLayer::absoluteToContents(const LayoutPoint& absolutePoint) co nst 1422 LayoutPoint RenderLayer::absoluteToContents(const LayoutPoint& absolutePoint) co nst
1420 { 1423 {
(...skipping 14 matching lines...) Expand all
1435 { 1438 {
1436 // FIXME: This seems incorrect; why would SVG layers be opaque? 1439 // FIXME: This seems incorrect; why would SVG layers be opaque?
1437 if (renderer()->node() && renderer()->node()->namespaceURI() == SVGNames::sv gNamespaceURI) 1440 if (renderer()->node() && renderer()->node()->namespaceURI() == SVGNames::sv gNamespaceURI)
1438 return false; 1441 return false;
1439 1442
1440 return renderer()->isTransparent() || renderer()->hasMask(); 1443 return renderer()->isTransparent() || renderer()->hasMask();
1441 } 1444 }
1442 1445
1443 RenderLayer* RenderLayer::transparentPaintingAncestor() 1446 RenderLayer* RenderLayer::transparentPaintingAncestor()
1444 { 1447 {
1445 if (isComposited()) 1448 if (compositedLayerMapping())
1446 return 0; 1449 return 0;
1447 1450
1448 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { 1451 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) {
1449 if (curr->isComposited()) 1452 if (curr->compositedLayerMapping())
1450 return 0; 1453 return 0;
1451 if (curr->isTransparent()) 1454 if (curr->isTransparent())
1452 return curr; 1455 return curr;
1453 } 1456 }
1454 return 0; 1457 return 0;
1455 } 1458 }
1456 1459
1457 enum TransparencyClipBoxBehavior { 1460 enum TransparencyClipBoxBehavior {
1458 PaintingTransparencyClipBox, 1461 PaintingTransparencyClipBox,
1459 HitTestingTransparencyClipBox 1462 HitTestingTransparencyClipBox
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 } 1881 }
1879 1882
1880 bool RenderLayer::usesCompositedScrolling() const 1883 bool RenderLayer::usesCompositedScrolling() const
1881 { 1884 {
1882 RenderBox* box = renderBox(); 1885 RenderBox* box = renderBox();
1883 1886
1884 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling 1887 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling
1885 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar))) 1888 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar)))
1886 return false; 1889 return false;
1887 1890
1888 return isComposited() && compositedLayerMapping()->scrollingLayer(); 1891 return compositedLayerMapping() && compositedLayerMapping()->scrollingLayer( );
1889 } 1892 }
1890 1893
1891 bool RenderLayer::needsCompositedScrolling() const 1894 bool RenderLayer::needsCompositedScrolling() const
1892 { 1895 {
1893 if (!compositorDrivenAcceleratedScrollingEnabled()) 1896 if (!compositorDrivenAcceleratedScrollingEnabled())
1894 return needsToBeStackingContainer(); 1897 return needsToBeStackingContainer();
1895 if (FrameView* frameView = renderer()->view()->frameView()) 1898 if (FrameView* frameView = renderer()->view()->frameView())
1896 return frameView->containsScrollableArea(scrollableArea()); 1899 return frameView->containsScrollableArea(scrollableArea());
1897 return false; 1900 return false;
1898 } 1901 }
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 return false; 2512 return false;
2510 } 2513 }
2511 2514
2512 static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P aintLayerFlags paintFlags) 2515 static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P aintLayerFlags paintFlags)
2513 { 2516 {
2514 return layer->renderer()->isRoot() && (paintFlags & RenderLayer::PaintLayerP aintingRootBackgroundOnly); 2517 return layer->renderer()->isRoot() && (paintFlags & RenderLayer::PaintLayerP aintingRootBackgroundOnly);
2515 } 2518 }
2516 2519
2517 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 2520 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
2518 { 2521 {
2519 if (isComposited()) { 2522 if (compositingState() != NotComposited) {
2520 // The updatingControlTints() painting pass goes through compositing lay ers, 2523 // The updatingControlTints() painting pass goes through compositing lay ers,
2521 // but we need to ensure that we don't cache clip rects computed with th e wrong root in this case. 2524 // but we need to ensure that we don't cache clip rects computed with th e wrong root in this case.
2522 if (context->updatingControlTints() || (paintingInfo.paintBehavior & Pai ntBehaviorFlattenCompositingLayers)) { 2525 if (context->updatingControlTints() || (paintingInfo.paintBehavior & Pai ntBehaviorFlattenCompositingLayers)) {
2523 paintFlags |= PaintLayerTemporaryClipRects; 2526 paintFlags |= PaintLayerTemporaryClipRects;
2524 } else if (!compositedLayerMapping()->paintsIntoCompositedAncestor() 2527 } else if (!compositedLayerMapping()->paintsIntoCompositedAncestor()
2525 && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingRefle ction) 2528 && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingRefle ction)
2526 && !paintForFixedRootBackground(this, paintFlags)) { 2529 && !paintForFixedRootBackground(this, paintFlags)) {
2527 // If this RenderLayer should paint into its own backing, that will be done via CompositedLayerMapping::paintIntoLayer(). 2530 // If this RenderLayer should paint into its own backing, that will be done via CompositedLayerMapping::paintIntoLayer().
2528 return; 2531 return;
2529 } 2532 }
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
4309 return pixelSnappedIntRect(localClipRect); 4312 return pixelSnappedIntRect(localClipRect);
4310 } 4313 }
4311 } 4314 }
4312 4315
4313 // FIXME: should probably just pass 'flags' down to descendants. 4316 // FIXME: should probably just pass 'flags' down to descendants.
4314 CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants) | (flags & IncludeCompositedDescendants); 4317 CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants) | (flags & IncludeCompositedDescendants);
4315 4318
4316 const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded(); 4319 const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded();
4317 4320
4318 if (RenderLayer* reflection = reflectionLayer()) { 4321 if (RenderLayer* reflection = reflectionLayer()) {
4319 if (!reflection->isComposited()) { 4322 if (!reflection->compositedLayerMapping()) {
4320 IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags); 4323 IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags);
4321 unionBounds.unite(childUnionBounds); 4324 unionBounds.unite(childUnionBounds);
4322 } 4325 }
4323 } 4326 }
4324 4327
4325 ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size( ))); 4328 ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size( )));
4326 4329
4327 #if !ASSERT_DISABLED 4330 #if !ASSERT_DISABLED
4328 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this)); 4331 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this));
4329 #endif 4332 #endif
4330 4333
4334 // FIXME: Descendants that are composited should not necessarily be skipped, if they don't paint into their own
4335 // separate backing. Instead, they ought to contribute to the bounds of the layer we're trying to compute.
4336 // This applies to all z-order lists below.
4331 if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) { 4337 if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) {
4332 size_t listSize = negZOrderList->size(); 4338 size_t listSize = negZOrderList->size();
4333 for (size_t i = 0; i < listSize; ++i) { 4339 for (size_t i = 0; i < listSize; ++i) {
4334 RenderLayer* curLayer = negZOrderList->at(i); 4340 RenderLayer* curLayer = negZOrderList->at(i);
4335 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4341 if (flags & IncludeCompositedDescendants || !curLayer->compositedLay erMapping()) {
4336 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); 4342 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
4337 unionBounds.unite(childUnionBounds); 4343 unionBounds.unite(childUnionBounds);
4338 } 4344 }
4339 } 4345 }
4340 } 4346 }
4341 4347
4342 if (Vector<RenderLayer*>* posZOrderList = this->posZOrderList()) { 4348 if (Vector<RenderLayer*>* posZOrderList = this->posZOrderList()) {
4343 size_t listSize = posZOrderList->size(); 4349 size_t listSize = posZOrderList->size();
4344 for (size_t i = 0; i < listSize; ++i) { 4350 for (size_t i = 0; i < listSize; ++i) {
4345 RenderLayer* curLayer = posZOrderList->at(i); 4351 RenderLayer* curLayer = posZOrderList->at(i);
4346 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4352 if (flags & IncludeCompositedDescendants || !curLayer->compositedLay erMapping()) {
4347 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); 4353 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
4348 unionBounds.unite(childUnionBounds); 4354 unionBounds.unite(childUnionBounds);
4349 } 4355 }
4350 } 4356 }
4351 } 4357 }
4352 4358
4353 if (Vector<RenderLayer*>* normalFlowList = this->normalFlowList()) { 4359 if (Vector<RenderLayer*>* normalFlowList = this->normalFlowList()) {
4354 size_t listSize = normalFlowList->size(); 4360 size_t listSize = normalFlowList->size();
4355 for (size_t i = 0; i < listSize; ++i) { 4361 for (size_t i = 0; i < listSize; ++i) {
4356 RenderLayer* curLayer = normalFlowList->at(i); 4362 RenderLayer* curLayer = normalFlowList->at(i);
4357 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4363 if (flags & IncludeCompositedDescendants || !curLayer->compositedLay erMapping()) {
4358 IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, d escendantFlags); 4364 IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, d escendantFlags);
4359 unionBounds.unite(curAbsBounds); 4365 unionBounds.unite(curAbsBounds);
4360 } 4366 }
4361 } 4367 }
4362 } 4368 }
4363 4369
4364 // FIXME: We can optimize the size of the composited layers, by not enlargin g 4370 // FIXME: We can optimize the size of the composited layers, by not enlargin g
4365 // filtered areas with the outsets if we know that the filter is going to re nder in hardware. 4371 // filtered areas with the outsets if we know that the filter is going to re nder in hardware.
4366 // https://bugs.webkit.org/show_bug.cgi?id=81239 4372 // https://bugs.webkit.org/show_bug.cgi?id=81239
4367 if (flags & IncludeLayerFilterOutsets) 4373 if (flags & IncludeLayerFilterOutsets)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4400 if (typeToClear == AllClipRectTypes) 4406 if (typeToClear == AllClipRectTypes)
4401 m_clipRectsCache = nullptr; 4407 m_clipRectsCache = nullptr;
4402 else { 4408 else {
4403 ASSERT(typeToClear < NumCachedClipRectsTypes); 4409 ASSERT(typeToClear < NumCachedClipRectsTypes);
4404 RefPtr<ClipRects> dummy; 4410 RefPtr<ClipRects> dummy;
4405 m_clipRectsCache->setClipRects(typeToClear, RespectOverflowClip, dummy); 4411 m_clipRectsCache->setClipRects(typeToClear, RespectOverflowClip, dummy);
4406 m_clipRectsCache->setClipRects(typeToClear, IgnoreOverflowClip, dummy); 4412 m_clipRectsCache->setClipRects(typeToClear, IgnoreOverflowClip, dummy);
4407 } 4413 }
4408 } 4414 }
4409 4415
4416 CompositingState RenderLayer::compositingState() const
4417 {
4418 // This is computed procedurally so there is no redundant state variable tha t
4419 // can get out of sync from the real actual compositing state.
4420
4421 if (!m_compositedLayerMapping)
4422 return NotComposited;
4423
4424 if (m_compositedLayerMapping && compositedLayerMapping()->paintsIntoComposit edAncestor())
4425 return HasOwnBackingButPaintsIntoAncestor;
4426
4427 ASSERT(m_compositedLayerMapping);
4428 return PaintsIntoOwnBacking;
4429 }
4430
4410 CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping() 4431 CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping()
4411 { 4432 {
4412 if (!m_compositedLayerMapping) { 4433 if (!m_compositedLayerMapping) {
4413 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(this)); 4434 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(this));
4414 compositor()->layerBecameComposited(this); 4435 compositor()->layerBecameComposited(this);
4415 4436
4416 updateOrRemoveFilterEffectRenderer(); 4437 updateOrRemoveFilterEffectRenderer();
4417 4438
4418 if (RuntimeEnabledFeatures::cssCompositingEnabled()) 4439 if (RuntimeEnabledFeatures::cssCompositingEnabled())
4419 compositedLayerMapping()->setBlendMode(m_blendMode); 4440 compositedLayerMapping()->setBlendMode(m_blendMode);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4461 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForVertical Scrollbar() : 0; 4482 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForVertical Scrollbar() : 0;
4462 } 4483 }
4463 4484
4464 GraphicsLayer* RenderLayer::layerForScrollCorner() const 4485 GraphicsLayer* RenderLayer::layerForScrollCorner() const
4465 { 4486 {
4466 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForScrollCo rner() : 0; 4487 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForScrollCo rner() : 0;
4467 } 4488 }
4468 4489
4469 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const 4490 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const
4470 { 4491 {
4471 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || !isComposited()); 4492 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking);
4472 } 4493 }
4473 4494
4474 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const 4495 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
4475 { 4496 {
4476 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 4497 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
4477 return false; 4498 return false;
4478 4499
4479 if (paintsWithTransparency(PaintBehaviorNormal)) 4500 if (paintsWithTransparency(PaintBehaviorNormal))
4480 return false; 4501 return false;
4481 4502
(...skipping 30 matching lines...) Expand all
4512 || listBackgroundIsKnownToBeOpaqueInRect(normalFlowList(), localRect); 4533 || listBackgroundIsKnownToBeOpaqueInRect(normalFlowList(), localRect);
4513 } 4534 }
4514 4535
4515 bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer *>* list, const LayoutRect& localRect) const 4536 bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer *>* list, const LayoutRect& localRect) const
4516 { 4537 {
4517 if (!list || list->isEmpty()) 4538 if (!list || list->isEmpty())
4518 return false; 4539 return false;
4519 4540
4520 for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); ite r != list->rend(); ++iter) { 4541 for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); ite r != list->rend(); ++iter) {
4521 const RenderLayer* childLayer = *iter; 4542 const RenderLayer* childLayer = *iter;
4522 if (childLayer->isComposited()) 4543 if (childLayer->compositedLayerMapping())
4523 continue; 4544 continue;
4524 4545
4525 if (!childLayer->canUseConvertToLayerCoords()) 4546 if (!childLayer->canUseConvertToLayerCoords())
4526 continue; 4547 continue;
4527 4548
4528 LayoutPoint childOffset; 4549 LayoutPoint childOffset;
4529 LayoutRect childLocalRect(localRect); 4550 LayoutRect childLocalRect(localRect);
4530 childLayer->convertToLayerCoords(this, childOffset); 4551 childLayer->convertToLayerCoords(this, childOffset);
4531 childLocalRect.moveBy(-childOffset); 4552 childLocalRect.moveBy(-childOffset);
4532 4553
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4769 4790
4770 void RenderLayer::repaintIncludingDescendants() 4791 void RenderLayer::repaintIncludingDescendants()
4771 { 4792 {
4772 renderer()->repaint(); 4793 renderer()->repaint();
4773 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) 4794 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling())
4774 curr->repaintIncludingDescendants(); 4795 curr->repaintIncludingDescendants();
4775 } 4796 }
4776 4797
4777 void RenderLayer::setBackingNeedsRepaint() 4798 void RenderLayer::setBackingNeedsRepaint()
4778 { 4799 {
4779 ASSERT(isComposited()); 4800 ASSERT(compositedLayerMapping());
4780 compositedLayerMapping()->setContentsNeedDisplay(); 4801 compositedLayerMapping()->setContentsNeedDisplay();
4781 } 4802 }
4782 4803
4783 void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r) 4804 void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r)
4784 { 4805 {
4785 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here, 4806 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here,
4786 // so assert but check that the layer is composited. 4807 // so assert but check that the layer is composited.
4787 ASSERT(isComposited()); 4808 ASSERT(compositedLayerMapping());
4788 if (!isComposited()) { 4809 if (!compositedLayerMapping()) {
4789 // If we're trying to repaint the placeholder document layer, propagate the 4810 // If we're trying to repaint the placeholder document layer, propagate the
4790 // repaint to the native view system. 4811 // repaint to the native view system.
4791 LayoutRect absRect(r); 4812 LayoutRect absRect(r);
4792 LayoutPoint delta; 4813 LayoutPoint delta;
4793 convertToLayerCoords(root(), delta); 4814 convertToLayerCoords(root(), delta);
4794 absRect.moveBy(delta); 4815 absRect.moveBy(delta);
4795 4816
4796 RenderView* view = renderer()->view(); 4817 RenderView* view = renderer()->view();
4797 if (view) 4818 if (view)
4798 view->repaintViewRectangle(absRect); 4819 view->repaintViewRectangle(absRect);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
4995 5016
4996 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const 5017 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
4997 { 5018 {
4998 ASSERT(newStyle); 5019 ASSERT(newStyle);
4999 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip()); 5020 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip());
5000 } 5021 }
5001 5022
5002 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const 5023 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const
5003 { 5024 {
5004 ASSERT(newStyle); 5025 ASSERT(newStyle);
5005 return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->ov erflowX()) && ancestorStackingContainer()->hasCompositingDescendant(); 5026 return !compositedLayerMapping() && oldStyle && (oldStyle->overflowX() != ne wStyle->overflowX()) && ancestorStackingContainer()->hasCompositingDescendant();
5006 } 5027 }
5007 5028
5008 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const 5029 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const
5009 { 5030 {
5010 if (!hasOrHadFilters(oldStyle, newStyle)) 5031 if (!hasOrHadFilters(oldStyle, newStyle))
5011 return false; 5032 return false;
5012 5033
5013 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) { 5034 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) {
5014 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers. 5035 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers.
5015 // All of the layers above us should have been promoted to compositing l ayers already. 5036 // All of the layers above us should have been promoted to compositing l ayers already.
(...skipping 23 matching lines...) Expand all
5039 } 5060 }
5040 5061
5041 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) 5062 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle)
5042 { 5063 {
5043 if (!hasOrHadFilters(oldStyle, newStyle)) 5064 if (!hasOrHadFilters(oldStyle, newStyle))
5044 return; 5065 return;
5045 5066
5046 updateOrRemoveFilterClients(); 5067 updateOrRemoveFilterClients();
5047 // During an accelerated animation, both WebKit and the compositor animate p roperties. 5068 // During an accelerated animation, both WebKit and the compositor animate p roperties.
5048 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. 5069 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation.
5049 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); 5070 bool shouldUpdateFilters = compositedLayerMapping() && !renderer()->animatio n()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter );
5050 if (shouldUpdateFilters) 5071 if (shouldUpdateFilters)
5051 compositedLayerMapping()->updateFilters(renderer()->style()); 5072 compositedLayerMapping()->updateFilters(renderer()->style());
5052 updateOrRemoveFilterEffectRenderer(); 5073 updateOrRemoveFilterEffectRenderer();
5053 } 5074 }
5054 5075
5055 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) 5076 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
5056 { 5077 {
5057 updateIsNormalFlowOnly(); 5078 updateIsNormalFlowOnly();
5058 5079
5059 if (m_scrollableArea) 5080 if (m_scrollableArea)
(...skipping 25 matching lines...) Expand all
5085 if (paintsWithFilters()) 5106 if (paintsWithFilters())
5086 didPaintWithFilters = true; 5107 didPaintWithFilters = true;
5087 updateFilters(oldStyle, renderer()->style()); 5108 updateFilters(oldStyle, renderer()->style());
5088 5109
5089 const RenderStyle* newStyle = renderer()->style(); 5110 const RenderStyle* newStyle = renderer()->style();
5090 if (compositor()->updateLayerCompositingState(this) 5111 if (compositor()->updateLayerCompositingState(this)
5091 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle) 5112 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle)
5092 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) 5113 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle)
5093 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters)) 5114 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters))
5094 compositor()->setCompositingLayersNeedRebuild(); 5115 compositor()->setCompositingLayersNeedRebuild();
5095 else if (isComposited()) 5116 else if (compositedLayerMapping())
5096 compositedLayerMapping()->updateGraphicsLayerGeometry(); 5117 compositedLayerMapping()->updateGraphicsLayerGeometry();
5097 } 5118 }
5098 5119
5099 void RenderLayer::updateScrollableAreaSet(bool hasOverflow) 5120 void RenderLayer::updateScrollableAreaSet(bool hasOverflow)
5100 { 5121 {
5101 Frame* frame = renderer()->frame(); 5122 Frame* frame = renderer()->frame();
5102 if (!frame) 5123 if (!frame)
5103 return; 5124 return;
5104 5125
5105 FrameView* frameView = frame->view(); 5126 FrameView* frameView = frame->view();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
5490 } 5511 }
5491 } 5512 }
5492 5513
5493 void showLayerTree(const WebCore::RenderObject* renderer) 5514 void showLayerTree(const WebCore::RenderObject* renderer)
5494 { 5515 {
5495 if (!renderer) 5516 if (!renderer)
5496 return; 5517 return;
5497 showLayerTree(renderer->enclosingLayer()); 5518 showLayerTree(renderer->enclosingLayer());
5498 } 5519 }
5499 #endif 5520 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698