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

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: path for re-landing try #2 with removed unnecessary comment 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
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 m_compositedLayerMapping->contentChanged(changeType); 212 m_compositedLayerMapping->contentChanged(changeType);
213 } 213 }
214 214
215 bool RenderLayer::canRender3DTransforms() const 215 bool RenderLayer::canRender3DTransforms() const
216 { 216 {
217 return compositor()->canRender3DTransforms(); 217 return compositor()->canRender3DTransforms();
218 } 218 }
219 219
220 bool RenderLayer::paintsWithFilters() const 220 bool RenderLayer::paintsWithFilters() const
221 { 221 {
222 // FIXME: Eventually there will be more factors than isComposited() to decid e whether or not to render the filter
223 if (!renderer()->hasFilter()) 222 if (!renderer()->hasFilter())
224 return false; 223 return false;
225 224
226 if (!isComposited()) 225 if (compositingState() != PaintsIntoOwnBacking)
227 return true; 226 return true;
228 227
229 if (!m_compositedLayerMapping || !m_compositedLayerMapping->canCompositeFilt ers()) 228 if (!m_compositedLayerMapping || !m_compositedLayerMapping->canCompositeFilt ers())
230 return true; 229 return true;
231 230
232 return false; 231 return false;
233 } 232 }
234 233
235 bool RenderLayer::requiresFullLayerImageForFilters() const 234 bool RenderLayer::requiresFullLayerImageForFilters() const
236 { 235 {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 302 }
304 303
305 repainter().repaintAfterLayout(geometryMap, flags & CheckForRepaint); 304 repainter().repaintAfterLayout(geometryMap, flags & CheckForRepaint);
306 305
307 // Go ahead and update the reflection's position and size. 306 // Go ahead and update the reflection's position and size.
308 if (m_reflection) 307 if (m_reflection)
309 m_reflection->layout(); 308 m_reflection->layout();
310 309
311 // Clear the IsCompositingUpdateRoot flag once we've found the first composi ting layer in this update. 310 // Clear the IsCompositingUpdateRoot flag once we've found the first composi ting layer in this update.
312 bool isUpdateRoot = (flags & IsCompositingUpdateRoot); 311 bool isUpdateRoot = (flags & IsCompositingUpdateRoot);
313 if (isComposited()) 312 if (compositedLayerMapping())
314 flags &= ~IsCompositingUpdateRoot; 313 flags &= ~IsCompositingUpdateRoot;
315 314
316 if (useRegionBasedColumns() && renderer()->isInFlowRenderFlowThread()) { 315 if (useRegionBasedColumns() && renderer()->isInFlowRenderFlowThread()) {
317 updatePagination(); 316 updatePagination();
318 flags |= UpdatePagination; 317 flags |= UpdatePagination;
319 } 318 }
320 319
321 if (renderer()->hasColumns()) 320 if (renderer()->hasColumns())
322 flags |= UpdatePagination; 321 flags |= UpdatePagination;
323 322
324 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) 323 for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
325 child->updateLayerPositions(geometryMap, flags); 324 child->updateLayerPositions(geometryMap, flags);
326 325
327 if ((flags & UpdateCompositingLayers) && isComposited()) { 326 if ((flags & UpdateCompositingLayers) && compositedLayerMapping()) {
328 CompositedLayerMapping::UpdateAfterLayoutFlags updateFlags = CompositedL ayerMapping::CompositingChildrenOnly; 327 CompositedLayerMapping::UpdateAfterLayoutFlags updateFlags = CompositedL ayerMapping::CompositingChildrenOnly;
329 if (flags & NeedsFullRepaintInBacking) 328 if (flags & NeedsFullRepaintInBacking)
330 updateFlags |= CompositedLayerMapping::NeedsFullRepaint; 329 updateFlags |= CompositedLayerMapping::NeedsFullRepaint;
331 if (isUpdateRoot) 330 if (isUpdateRoot)
332 updateFlags |= CompositedLayerMapping::IsUpdateRoot; 331 updateFlags |= CompositedLayerMapping::IsUpdateRoot;
333 compositedLayerMapping()->updateAfterLayout(updateFlags); 332 compositedLayerMapping()->updateAfterLayout(updateFlags);
334 } 333 }
335 334
336 if (geometryMap) 335 if (geometryMap)
337 geometryMap->popMappingsToAncestor(parent()); 336 geometryMap->popMappingsToAncestor(parent());
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 { 835 {
837 const Settings* settings = renderer()->document().settings(); 836 const Settings* settings = renderer()->document().settings();
838 return settings && settings->regionBasedColumnsEnabled(); 837 return settings && settings->regionBasedColumnsEnabled();
839 } 838 }
840 839
841 void RenderLayer::updatePagination() 840 void RenderLayer::updatePagination()
842 { 841 {
843 m_isPaginated = false; 842 m_isPaginated = false;
844 m_enclosingPaginationLayer = 0; 843 m_enclosingPaginationLayer = 0;
845 844
846 if (isComposited() || !parent()) 845 if (compositedLayerMapping() || !parent())
847 return; // FIXME: We will have to deal with paginated compositing layers someday. 846 return; // FIXME: We will have to deal with paginated compositing layers someday.
848 // FIXME: For now the RenderView can't be paginated. Eventually printing will move to a model where it is though. 847 // FIXME: For now the RenderView can't be paginated. Eventually printing will move to a model where it is though.
849 848
850 // The main difference between the paginated booleans for the old column cod e and the new column code 849 // The main difference between the paginated booleans for the old column cod e and the new column code
851 // is that each paginated layer has to paint on its own with the new code. T here is no 850 // is that each paginated layer has to paint on its own with the new code. T here is no
852 // recurring into child layers. This means that the m_isPaginated bits for t he new column code can't just be set on 851 // recurring into child layers. This means that the m_isPaginated bits for t he new column code can't just be set on
853 // "roots" that get split and paint all their descendants. Instead each laye r has to be checked individually and 852 // "roots" that get split and paint all their descendants. Instead each laye r has to be checked individually and
854 // genuinely know if it is going to have to split itself up when painting on ly its contents (and not any other descendant 853 // genuinely know if it is going to have to split itself up when painting on ly its contents (and not any other descendant
855 // layers). We track an enclosingPaginationLayer instead of using a simple b it, since we want to be able to get back 854 // layers). We track an enclosingPaginationLayer instead of using a simple b it, since we want to be able to get back
856 // to that layer easily. 855 // to that layer easily.
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 if (positionedParent->renderer()->hasOverflowClip()) { 1186 if (positionedParent->renderer()->hasOverflowClip()) {
1188 LayoutSize offset = positionedParent->scrolledContentOffset(); 1187 LayoutSize offset = positionedParent->scrolledContentOffset();
1189 localPoint -= offset; 1188 localPoint -= offset;
1190 } 1189 }
1191 1190
1192 if (renderer()->isOutOfFlowPositioned() && positionedParent->renderer()- >isInFlowPositioned() && positionedParent->renderer()->isRenderInline()) { 1191 if (renderer()->isOutOfFlowPositioned() && positionedParent->renderer()- >isInFlowPositioned() && positionedParent->renderer()->isRenderInline()) {
1193 LayoutSize offset = toRenderInline(positionedParent->renderer())->of fsetForInFlowPositionedInline(toRenderBox(renderer())); 1192 LayoutSize offset = toRenderInline(positionedParent->renderer())->of fsetForInFlowPositionedInline(toRenderBox(renderer()));
1194 localPoint += offset; 1193 localPoint += offset;
1195 } 1194 }
1196 } else if (parent()) { 1195 } else if (parent()) {
1197 if (isComposited()) { 1196 if (compositedLayerMapping()) {
1198 // FIXME: Composited layers ignore pagination, so about the best we can do is make sure they're offset into the appropriate column. 1197 // FIXME: Composited layers ignore pagination, so about the best we can do is make sure they're offset into the appropriate column.
1199 // They won't split across columns properly. 1198 // They won't split across columns properly.
1200 LayoutSize columnOffset; 1199 LayoutSize columnOffset;
1201 if (!parent()->renderer()->hasColumns() && parent()->renderer()->isR oot() && renderer()->view()->hasColumns()) 1200 if (!parent()->renderer()->hasColumns() && parent()->renderer()->isR oot() && renderer()->view()->hasColumns())
1202 renderer()->view()->adjustForColumns(columnOffset, localPoint); 1201 renderer()->view()->adjustForColumns(columnOffset, localPoint);
1203 else 1202 else
1204 parent()->renderer()->adjustForColumns(columnOffset, localPoint) ; 1203 parent()->renderer()->adjustForColumns(columnOffset, localPoint) ;
1205 1204
1206 localPoint += columnOffset; 1205 localPoint += columnOffset;
1207 } 1206 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 curr = curr->parent(); 1318 curr = curr->parent();
1320 1319
1321 return curr; 1320 return curr;
1322 } 1321 }
1323 1322
1324 static inline const RenderLayer* compositingContainer(const RenderLayer* layer) 1323 static inline const RenderLayer* compositingContainer(const RenderLayer* layer)
1325 { 1324 {
1326 return layer->isNormalFlowOnly() ? layer->parent() : layer->ancestorStacking Container(); 1325 return layer->isNormalFlowOnly() ? layer->parent() : layer->ancestorStacking Container();
1327 } 1326 }
1328 1327
1328 // FIXME: having two different functions named enclosingCompositingLayer and enc losingCompositingLayerForRepaint
1329 // is error-prone and misleading for reading code that uses these functions - es pecially compounded with
1330 // the includeSelf option. It is very likely that some call sites of this functi on actually mean to use
1331 // enclosingCompositingLayerForRepaint().
1329 RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const 1332 RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const
1330 { 1333 {
1331 if (includeSelf && isComposited()) 1334 if (includeSelf && compositedLayerMapping())
1332 return const_cast<RenderLayer*>(this); 1335 return const_cast<RenderLayer*>(this);
1333 1336
1334 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) { 1337 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) {
1335 if (curr->isComposited()) 1338 if (curr->compositedLayerMapping())
1336 return const_cast<RenderLayer*>(curr); 1339 return const_cast<RenderLayer*>(curr);
1337 } 1340 }
1338 1341
1339 return 0; 1342 return 0;
1340 } 1343 }
1341 1344
1342 RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const 1345 RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const
1343 { 1346 {
1344 if (includeSelf && isComposited() && !compositedLayerMapping()->paintsIntoCo mpositedAncestor()) 1347 if (includeSelf && compositingState() == PaintsIntoOwnBacking)
1345 return const_cast<RenderLayer*>(this); 1348 return const_cast<RenderLayer*>(this);
1346 1349
1347 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) { 1350 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) {
1348 if (curr->isComposited() && !curr->compositedLayerMapping()->paintsIntoC ompositedAncestor()) 1351 if (curr->compositingState() == PaintsIntoOwnBacking)
1349 return const_cast<RenderLayer*>(curr); 1352 return const_cast<RenderLayer*>(curr);
1350 } 1353 }
1351 1354
1352 return 0; 1355 return 0;
1353 } 1356 }
1354 1357
1355 RenderLayer* RenderLayer::ancestorScrollingLayer() const 1358 RenderLayer* RenderLayer::ancestorScrollingLayer() const
1356 { 1359 {
1357 if (!acceleratedCompositingForOverflowScrollEnabled()) 1360 if (!acceleratedCompositingForOverflowScrollEnabled())
1358 return 0; 1361 return 0;
(...skipping 17 matching lines...) Expand all
1376 if (curr->requiresFullLayerImageForFilters()) 1379 if (curr->requiresFullLayerImageForFilters())
1377 return const_cast<RenderLayer*>(curr); 1380 return const_cast<RenderLayer*>(curr);
1378 } 1381 }
1379 1382
1380 return 0; 1383 return 0;
1381 } 1384 }
1382 1385
1383 RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const 1386 RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const
1384 { 1387 {
1385 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 1388 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
1386 if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr-> isComposited() || curr->isRootLayer()) 1389 if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr-> compositingState() == PaintsIntoOwnBacking || curr->isRootLayer())
1387 return const_cast<RenderLayer*>(curr); 1390 return const_cast<RenderLayer*>(curr);
1388 } 1391 }
1389 return 0; 1392 return 0;
1390 } 1393 }
1391 1394
1392 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect) 1395 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect)
1393 { 1396 {
1394 if (rect.isEmpty()) 1397 if (rect.isEmpty())
1395 return; 1398 return;
1396 1399
(...skipping 10 matching lines...) Expand all
1407 // shader can address any ouput pixel. 1410 // shader can address any ouput pixel.
1408 // Note: This is only for output rect, so there's no need to expand the dirty source rect. 1411 // Note: This is only for output rect, so there's no need to expand the dirty source rect.
1409 rectForRepaint.unite(calculateLayerBounds(this)); 1412 rectForRepaint.unite(calculateLayerBounds(this));
1410 } 1413 }
1411 1414
1412 RenderLayer* parentLayer = enclosingFilterRepaintLayer(); 1415 RenderLayer* parentLayer = enclosingFilterRepaintLayer();
1413 ASSERT(parentLayer); 1416 ASSERT(parentLayer);
1414 FloatQuad repaintQuad(rectForRepaint); 1417 FloatQuad repaintQuad(rectForRepaint);
1415 LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, p arentLayer->renderer()).enclosingBoundingBox(); 1418 LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, p arentLayer->renderer()).enclosingBoundingBox();
1416 1419
1417 if (parentLayer->isComposited()) { 1420 if (parentLayer->compositedLayerMapping()) {
1418 parentLayer->setBackingNeedsRepaintInRect(parentLayerRect); 1421 parentLayer->setBackingNeedsRepaintInRect(parentLayerRect);
1419 return; 1422 return;
1420 } 1423 }
1421 1424
1422 if (parentLayer->paintsWithFilters()) { 1425 if (parentLayer->paintsWithFilters()) {
1423 parentLayer->setFilterBackendNeedsRepaintingInRect(parentLayerRect); 1426 parentLayer->setFilterBackendNeedsRepaintingInRect(parentLayerRect);
1424 return; 1427 return;
1425 } 1428 }
1426 1429
1427 if (parentLayer->isRootLayer()) { 1430 if (parentLayer->isRootLayer()) {
(...skipping 10 matching lines...) Expand all
1438 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 1441 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
1439 RenderLayerModelObject* renderer = curr->renderer(); 1442 RenderLayerModelObject* renderer = curr->renderer();
1440 if (renderer->style()->hasFilterOutsets()) 1443 if (renderer->style()->hasFilterOutsets())
1441 return true; 1444 return true;
1442 } 1445 }
1443 return false; 1446 return false;
1444 } 1447 }
1445 1448
1446 RenderLayer* RenderLayer::clippingRootForPainting() const 1449 RenderLayer* RenderLayer::clippingRootForPainting() const
1447 { 1450 {
1448 if (isComposited()) 1451 if (compositedLayerMapping())
1449 return const_cast<RenderLayer*>(this); 1452 return const_cast<RenderLayer*>(this);
1450 1453
1451 const RenderLayer* current = this; 1454 const RenderLayer* current = this;
1452 while (current) { 1455 while (current) {
1453 if (current->isRootLayer()) 1456 if (current->isRootLayer())
1454 return const_cast<RenderLayer*>(current); 1457 return const_cast<RenderLayer*>(current);
1455 1458
1456 current = compositingContainer(current); 1459 current = compositingContainer(current);
1457 ASSERT(current); 1460 ASSERT(current);
1458 if (current->transform() 1461 if (current->transform()
1459 || (current->isComposited() && !current->compositedLayerMapping()->p aintsIntoCompositedAncestor()) 1462 || (current->compositingState() == PaintsIntoOwnBacking)
1460 ) 1463 )
1461 return const_cast<RenderLayer*>(current); 1464 return const_cast<RenderLayer*>(current);
1462 } 1465 }
1463 1466
1464 ASSERT_NOT_REACHED(); 1467 ASSERT_NOT_REACHED();
1465 return 0; 1468 return 0;
1466 } 1469 }
1467 1470
1468 LayoutPoint RenderLayer::absoluteToContents(const LayoutPoint& absolutePoint) co nst 1471 LayoutPoint RenderLayer::absoluteToContents(const LayoutPoint& absolutePoint) co nst
1469 { 1472 {
(...skipping 14 matching lines...) Expand all
1484 { 1487 {
1485 // FIXME: This seems incorrect; why would SVG layers be opaque? 1488 // FIXME: This seems incorrect; why would SVG layers be opaque?
1486 if (renderer()->node() && renderer()->node()->namespaceURI() == SVGNames::sv gNamespaceURI) 1489 if (renderer()->node() && renderer()->node()->namespaceURI() == SVGNames::sv gNamespaceURI)
1487 return false; 1490 return false;
1488 1491
1489 return renderer()->isTransparent() || renderer()->hasMask(); 1492 return renderer()->isTransparent() || renderer()->hasMask();
1490 } 1493 }
1491 1494
1492 RenderLayer* RenderLayer::transparentPaintingAncestor() 1495 RenderLayer* RenderLayer::transparentPaintingAncestor()
1493 { 1496 {
1494 if (isComposited()) 1497 if (compositedLayerMapping())
1495 return 0; 1498 return 0;
1496 1499
1497 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { 1500 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) {
1498 if (curr->isComposited()) 1501 if (curr->compositedLayerMapping())
1499 return 0; 1502 return 0;
1500 if (curr->isTransparent()) 1503 if (curr->isTransparent())
1501 return curr; 1504 return curr;
1502 } 1505 }
1503 return 0; 1506 return 0;
1504 } 1507 }
1505 1508
1506 enum TransparencyClipBoxBehavior { 1509 enum TransparencyClipBoxBehavior {
1507 PaintingTransparencyClipBox, 1510 PaintingTransparencyClipBox,
1508 HitTestingTransparencyClipBox 1511 HitTestingTransparencyClipBox
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 } 1940 }
1938 1941
1939 bool RenderLayer::usesCompositedScrolling() const 1942 bool RenderLayer::usesCompositedScrolling() const
1940 { 1943 {
1941 RenderBox* box = renderBox(); 1944 RenderBox* box = renderBox();
1942 1945
1943 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling 1946 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling
1944 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar))) 1947 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar)))
1945 return false; 1948 return false;
1946 1949
1947 return isComposited() && compositedLayerMapping()->scrollingLayer(); 1950 return compositedLayerMapping() && compositedLayerMapping()->scrollingLayer( );
1948 } 1951 }
1949 1952
1950 bool RenderLayer::needsCompositedScrolling() const 1953 bool RenderLayer::needsCompositedScrolling() const
1951 { 1954 {
1952 if (!compositorDrivenAcceleratedScrollingEnabled()) 1955 if (!compositorDrivenAcceleratedScrollingEnabled())
1953 return needsToBeStackingContainer(); 1956 return needsToBeStackingContainer();
1954 if (FrameView* frameView = renderer()->view()->frameView()) 1957 if (FrameView* frameView = renderer()->view()->frameView())
1955 return frameView->containsScrollableArea(scrollableArea()); 1958 return frameView->containsScrollableArea(scrollableArea());
1956 return false; 1959 return false;
1957 } 1960 }
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 return false; 2571 return false;
2569 } 2572 }
2570 2573
2571 static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P aintLayerFlags paintFlags) 2574 static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P aintLayerFlags paintFlags)
2572 { 2575 {
2573 return layer->renderer()->isRoot() && (paintFlags & RenderLayer::PaintLayerP aintingRootBackgroundOnly); 2576 return layer->renderer()->isRoot() && (paintFlags & RenderLayer::PaintLayerP aintingRootBackgroundOnly);
2574 } 2577 }
2575 2578
2576 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 2579 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
2577 { 2580 {
2578 if (isComposited()) { 2581 if (compositingState() != NotComposited) {
2579 // The updatingControlTints() painting pass goes through compositing lay ers, 2582 // The updatingControlTints() painting pass goes through compositing lay ers,
2580 // but we need to ensure that we don't cache clip rects computed with th e wrong root in this case. 2583 // but we need to ensure that we don't cache clip rects computed with th e wrong root in this case.
2581 if (context->updatingControlTints() || (paintingInfo.paintBehavior & Pai ntBehaviorFlattenCompositingLayers)) { 2584 if (context->updatingControlTints() || (paintingInfo.paintBehavior & Pai ntBehaviorFlattenCompositingLayers)) {
2582 paintFlags |= PaintLayerTemporaryClipRects; 2585 paintFlags |= PaintLayerTemporaryClipRects;
2583 } else if (!compositedLayerMapping()->paintsIntoCompositedAncestor() 2586 } else if (!compositedLayerMapping()->paintsIntoCompositedAncestor()
2584 && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingRefle ction) 2587 && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingRefle ction)
2585 && !paintForFixedRootBackground(this, paintFlags)) { 2588 && !paintForFixedRootBackground(this, paintFlags)) {
2586 // If this RenderLayer should paint into its own backing, that will be done via CompositedLayerMapping::paintIntoLayer(). 2589 // If this RenderLayer should paint into its own backing, that will be done via CompositedLayerMapping::paintIntoLayer().
2587 return; 2590 return;
2588 } 2591 }
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 return pixelSnappedIntRect(localClipRect); 4377 return pixelSnappedIntRect(localClipRect);
4375 } 4378 }
4376 } 4379 }
4377 4380
4378 // FIXME: should probably just pass 'flags' down to descendants. 4381 // FIXME: should probably just pass 'flags' down to descendants.
4379 CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants) | (flags & IncludeCompositedDescendants); 4382 CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants) | (flags & IncludeCompositedDescendants);
4380 4383
4381 const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded(); 4384 const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded();
4382 4385
4383 if (RenderLayer* reflection = reflectionLayer()) { 4386 if (RenderLayer* reflection = reflectionLayer()) {
4384 if (!reflection->isComposited()) { 4387 if (!reflection->compositedLayerMapping()) {
4385 IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags); 4388 IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags);
4386 unionBounds.unite(childUnionBounds); 4389 unionBounds.unite(childUnionBounds);
4387 } 4390 }
4388 } 4391 }
4389 4392
4390 ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size( ))); 4393 ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size( )));
4391 4394
4392 #if !ASSERT_DISABLED 4395 #if !ASSERT_DISABLED
4393 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this)); 4396 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this));
4394 #endif 4397 #endif
4395 4398
4399 // FIXME: Descendants that are composited should not necessarily be skipped, if they don't paint into their own
4400 // separate backing. Instead, they ought to contribute to the bounds of the layer we're trying to compute.
4401 // This applies to all z-order lists below.
4396 if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) { 4402 if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) {
4397 size_t listSize = negZOrderList->size(); 4403 size_t listSize = negZOrderList->size();
4398 for (size_t i = 0; i < listSize; ++i) { 4404 for (size_t i = 0; i < listSize; ++i) {
4399 RenderLayer* curLayer = negZOrderList->at(i); 4405 RenderLayer* curLayer = negZOrderList->at(i);
4400 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4406 if (flags & IncludeCompositedDescendants || !curLayer->compositedLay erMapping()) {
4401 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); 4407 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
4402 unionBounds.unite(childUnionBounds); 4408 unionBounds.unite(childUnionBounds);
4403 } 4409 }
4404 } 4410 }
4405 } 4411 }
4406 4412
4407 if (Vector<RenderLayer*>* posZOrderList = this->posZOrderList()) { 4413 if (Vector<RenderLayer*>* posZOrderList = this->posZOrderList()) {
4408 size_t listSize = posZOrderList->size(); 4414 size_t listSize = posZOrderList->size();
4409 for (size_t i = 0; i < listSize; ++i) { 4415 for (size_t i = 0; i < listSize; ++i) {
4410 RenderLayer* curLayer = posZOrderList->at(i); 4416 RenderLayer* curLayer = posZOrderList->at(i);
4411 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4417 if (flags & IncludeCompositedDescendants || !curLayer->compositedLay erMapping()) {
4412 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); 4418 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
4413 unionBounds.unite(childUnionBounds); 4419 unionBounds.unite(childUnionBounds);
4414 } 4420 }
4415 } 4421 }
4416 } 4422 }
4417 4423
4418 if (Vector<RenderLayer*>* normalFlowList = this->normalFlowList()) { 4424 if (Vector<RenderLayer*>* normalFlowList = this->normalFlowList()) {
4419 size_t listSize = normalFlowList->size(); 4425 size_t listSize = normalFlowList->size();
4420 for (size_t i = 0; i < listSize; ++i) { 4426 for (size_t i = 0; i < listSize; ++i) {
4421 RenderLayer* curLayer = normalFlowList->at(i); 4427 RenderLayer* curLayer = normalFlowList->at(i);
4422 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4428 if (flags & IncludeCompositedDescendants || !curLayer->compositedLay erMapping()) {
4423 IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, d escendantFlags); 4429 IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, d escendantFlags);
4424 unionBounds.unite(curAbsBounds); 4430 unionBounds.unite(curAbsBounds);
4425 } 4431 }
4426 } 4432 }
4427 } 4433 }
4428 4434
4429 // FIXME: We can optimize the size of the composited layers, by not enlargin g 4435 // FIXME: We can optimize the size of the composited layers, by not enlargin g
4430 // filtered areas with the outsets if we know that the filter is going to re nder in hardware. 4436 // filtered areas with the outsets if we know that the filter is going to re nder in hardware.
4431 // https://bugs.webkit.org/show_bug.cgi?id=81239 4437 // https://bugs.webkit.org/show_bug.cgi?id=81239
4432 if (flags & IncludeLayerFilterOutsets) 4438 if (flags & IncludeLayerFilterOutsets)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4465 if (typeToClear == AllClipRectTypes) 4471 if (typeToClear == AllClipRectTypes)
4466 m_clipRectsCache = nullptr; 4472 m_clipRectsCache = nullptr;
4467 else { 4473 else {
4468 ASSERT(typeToClear < NumCachedClipRectsTypes); 4474 ASSERT(typeToClear < NumCachedClipRectsTypes);
4469 RefPtr<ClipRects> dummy; 4475 RefPtr<ClipRects> dummy;
4470 m_clipRectsCache->setClipRects(typeToClear, RespectOverflowClip, dummy); 4476 m_clipRectsCache->setClipRects(typeToClear, RespectOverflowClip, dummy);
4471 m_clipRectsCache->setClipRects(typeToClear, IgnoreOverflowClip, dummy); 4477 m_clipRectsCache->setClipRects(typeToClear, IgnoreOverflowClip, dummy);
4472 } 4478 }
4473 } 4479 }
4474 4480
4481 CompositingState RenderLayer::compositingState() const
4482 {
4483 // This is computed procedurally so there is no redundant state variable tha t
4484 // can get out of sync from the real actual compositing state.
4485
4486 if (!m_compositedLayerMapping)
4487 return NotComposited;
4488
4489 if (m_compositedLayerMapping && compositedLayerMapping()->paintsIntoComposit edAncestor())
4490 return HasOwnBackingButPaintsIntoAncestor;
4491
4492 ASSERT(m_compositedLayerMapping);
4493 return PaintsIntoOwnBacking;
4494 }
4495
4475 CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping() 4496 CompositedLayerMapping* RenderLayer::ensureCompositedLayerMapping()
4476 { 4497 {
4477 if (!m_compositedLayerMapping) { 4498 if (!m_compositedLayerMapping) {
4478 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(this)); 4499 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(this));
4479 compositor()->layerBecameComposited(this); 4500 compositor()->layerBecameComposited(this);
4480 4501
4481 updateOrRemoveFilterEffectRenderer(); 4502 updateOrRemoveFilterEffectRenderer();
4482 4503
4483 if (RuntimeEnabledFeatures::cssCompositingEnabled()) 4504 if (RuntimeEnabledFeatures::cssCompositingEnabled())
4484 compositedLayerMapping()->setBlendMode(m_blendMode); 4505 compositedLayerMapping()->setBlendMode(m_blendMode);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4526 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForVertical Scrollbar() : 0; 4547 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForVertical Scrollbar() : 0;
4527 } 4548 }
4528 4549
4529 GraphicsLayer* RenderLayer::layerForScrollCorner() const 4550 GraphicsLayer* RenderLayer::layerForScrollCorner() const
4530 { 4551 {
4531 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForScrollCo rner() : 0; 4552 return m_compositedLayerMapping ? m_compositedLayerMapping->layerForScrollCo rner() : 0;
4532 } 4553 }
4533 4554
4534 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const 4555 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const
4535 { 4556 {
4536 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || !isComposited()); 4557 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking);
4537 } 4558 }
4538 4559
4539 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const 4560 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
4540 { 4561 {
4541 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 4562 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
4542 return false; 4563 return false;
4543 4564
4544 if (paintsWithTransparency(PaintBehaviorNormal)) 4565 if (paintsWithTransparency(PaintBehaviorNormal))
4545 return false; 4566 return false;
4546 4567
(...skipping 30 matching lines...) Expand all
4577 || listBackgroundIsKnownToBeOpaqueInRect(normalFlowList(), localRect); 4598 || listBackgroundIsKnownToBeOpaqueInRect(normalFlowList(), localRect);
4578 } 4599 }
4579 4600
4580 bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer *>* list, const LayoutRect& localRect) const 4601 bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer *>* list, const LayoutRect& localRect) const
4581 { 4602 {
4582 if (!list || list->isEmpty()) 4603 if (!list || list->isEmpty())
4583 return false; 4604 return false;
4584 4605
4585 for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); ite r != list->rend(); ++iter) { 4606 for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); ite r != list->rend(); ++iter) {
4586 const RenderLayer* childLayer = *iter; 4607 const RenderLayer* childLayer = *iter;
4587 if (childLayer->isComposited()) 4608 if (childLayer->compositedLayerMapping())
4588 continue; 4609 continue;
4589 4610
4590 if (!childLayer->canUseConvertToLayerCoords()) 4611 if (!childLayer->canUseConvertToLayerCoords())
4591 continue; 4612 continue;
4592 4613
4593 LayoutPoint childOffset; 4614 LayoutPoint childOffset;
4594 LayoutRect childLocalRect(localRect); 4615 LayoutRect childLocalRect(localRect);
4595 childLayer->convertToLayerCoords(this, childOffset); 4616 childLayer->convertToLayerCoords(this, childOffset);
4596 childLocalRect.moveBy(-childOffset); 4617 childLocalRect.moveBy(-childOffset);
4597 4618
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4834 4855
4835 void RenderLayer::repaintIncludingDescendants() 4856 void RenderLayer::repaintIncludingDescendants()
4836 { 4857 {
4837 renderer()->repaint(); 4858 renderer()->repaint();
4838 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) 4859 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling())
4839 curr->repaintIncludingDescendants(); 4860 curr->repaintIncludingDescendants();
4840 } 4861 }
4841 4862
4842 void RenderLayer::setBackingNeedsRepaint() 4863 void RenderLayer::setBackingNeedsRepaint()
4843 { 4864 {
4844 ASSERT(isComposited()); 4865 ASSERT(compositedLayerMapping());
4845 compositedLayerMapping()->setContentsNeedDisplay(); 4866 compositedLayerMapping()->setContentsNeedDisplay();
4846 } 4867 }
4847 4868
4848 void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r) 4869 void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r)
4849 { 4870 {
4850 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here, 4871 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here,
4851 // so assert but check that the layer is composited. 4872 // so assert but check that the layer is composited.
4852 ASSERT(isComposited()); 4873 ASSERT(compositedLayerMapping());
4853 if (!isComposited()) { 4874 if (!compositedLayerMapping()) {
4854 // If we're trying to repaint the placeholder document layer, propagate the 4875 // If we're trying to repaint the placeholder document layer, propagate the
4855 // repaint to the native view system. 4876 // repaint to the native view system.
4856 LayoutRect absRect(r); 4877 LayoutRect absRect(r);
4857 LayoutPoint delta; 4878 LayoutPoint delta;
4858 convertToLayerCoords(root(), delta); 4879 convertToLayerCoords(root(), delta);
4859 absRect.moveBy(delta); 4880 absRect.moveBy(delta);
4860 4881
4861 RenderView* view = renderer()->view(); 4882 RenderView* view = renderer()->view();
4862 if (view) 4883 if (view)
4863 view->repaintViewRectangle(absRect); 4884 view->repaintViewRectangle(absRect);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
5060 5081
5061 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const 5082 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
5062 { 5083 {
5063 ASSERT(newStyle); 5084 ASSERT(newStyle);
5064 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip()); 5085 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip());
5065 } 5086 }
5066 5087
5067 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const 5088 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const
5068 { 5089 {
5069 ASSERT(newStyle); 5090 ASSERT(newStyle);
5070 return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->ov erflowX()) && ancestorStackingContainer()->hasCompositingDescendant(); 5091 return !compositedLayerMapping() && oldStyle && (oldStyle->overflowX() != ne wStyle->overflowX()) && ancestorStackingContainer()->hasCompositingDescendant();
5071 } 5092 }
5072 5093
5073 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const 5094 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const
5074 { 5095 {
5075 if (!hasOrHadFilters(oldStyle, newStyle)) 5096 if (!hasOrHadFilters(oldStyle, newStyle))
5076 return false; 5097 return false;
5077 5098
5078 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) { 5099 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) {
5079 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers. 5100 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers.
5080 // All of the layers above us should have been promoted to compositing l ayers already. 5101 // All of the layers above us should have been promoted to compositing l ayers already.
(...skipping 23 matching lines...) Expand all
5104 } 5125 }
5105 5126
5106 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) 5127 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle)
5107 { 5128 {
5108 if (!hasOrHadFilters(oldStyle, newStyle)) 5129 if (!hasOrHadFilters(oldStyle, newStyle))
5109 return; 5130 return;
5110 5131
5111 updateOrRemoveFilterClients(); 5132 updateOrRemoveFilterClients();
5112 // During an accelerated animation, both WebKit and the compositor animate p roperties. 5133 // During an accelerated animation, both WebKit and the compositor animate p roperties.
5113 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. 5134 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation.
5114 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); 5135 bool shouldUpdateFilters = compositedLayerMapping() && !renderer()->animatio n()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter );
5115 if (shouldUpdateFilters) 5136 if (shouldUpdateFilters)
5116 compositedLayerMapping()->updateFilters(renderer()->style()); 5137 compositedLayerMapping()->updateFilters(renderer()->style());
5117 updateOrRemoveFilterEffectRenderer(); 5138 updateOrRemoveFilterEffectRenderer();
5118 } 5139 }
5119 5140
5120 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) 5141 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
5121 { 5142 {
5122 updateIsNormalFlowOnly(); 5143 updateIsNormalFlowOnly();
5123 5144
5124 if (m_scrollableArea) 5145 if (m_scrollableArea)
(...skipping 25 matching lines...) Expand all
5150 if (paintsWithFilters()) 5171 if (paintsWithFilters())
5151 didPaintWithFilters = true; 5172 didPaintWithFilters = true;
5152 updateFilters(oldStyle, renderer()->style()); 5173 updateFilters(oldStyle, renderer()->style());
5153 5174
5154 const RenderStyle* newStyle = renderer()->style(); 5175 const RenderStyle* newStyle = renderer()->style();
5155 if (compositor()->updateLayerCompositingState(this) 5176 if (compositor()->updateLayerCompositingState(this)
5156 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle) 5177 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle)
5157 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) 5178 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle)
5158 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters)) 5179 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters))
5159 compositor()->setCompositingLayersNeedRebuild(); 5180 compositor()->setCompositingLayersNeedRebuild();
5160 else if (isComposited()) 5181 else if (compositedLayerMapping())
5161 compositedLayerMapping()->updateGraphicsLayerGeometry(); 5182 compositedLayerMapping()->updateGraphicsLayerGeometry();
5162 } 5183 }
5163 5184
5164 void RenderLayer::updateScrollableAreaSet(bool hasOverflow) 5185 void RenderLayer::updateScrollableAreaSet(bool hasOverflow)
5165 { 5186 {
5166 Frame* frame = renderer()->frame(); 5187 Frame* frame = renderer()->frame();
5167 if (!frame) 5188 if (!frame)
5168 return; 5189 return;
5169 5190
5170 FrameView* frameView = frame->view(); 5191 FrameView* frameView = frame->view();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
5555 } 5576 }
5556 } 5577 }
5557 5578
5558 void showLayerTree(const WebCore::RenderObject* renderer) 5579 void showLayerTree(const WebCore::RenderObject* renderer)
5559 { 5580 {
5560 if (!renderer) 5581 if (!renderer)
5561 return; 5582 return;
5562 showLayerTree(renderer->enclosingLayer()); 5583 showLayerTree(renderer->enclosingLayer());
5563 } 5584 }
5564 #endif 5585 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698