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

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 first round of reviewer comments 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_backing->contentChanged(changeType); 210 m_backing->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_backing || !m_backing->canCompositeFilters()) 226 if (!m_backing || !m_backing->canCompositeFilters())
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 (backing())
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) && backing()) {
326 RenderLayerBacking::UpdateAfterLayoutFlags updateFlags = RenderLayerBack ing::CompositingChildrenOnly; 325 RenderLayerBacking::UpdateAfterLayoutFlags updateFlags = RenderLayerBack ing::CompositingChildrenOnly;
327 if (flags & NeedsFullRepaintInBacking) 326 if (flags & NeedsFullRepaintInBacking)
328 updateFlags |= RenderLayerBacking::NeedsFullRepaint; 327 updateFlags |= RenderLayerBacking::NeedsFullRepaint;
329 if (isUpdateRoot) 328 if (isUpdateRoot)
330 updateFlags |= RenderLayerBacking::IsUpdateRoot; 329 updateFlags |= RenderLayerBacking::IsUpdateRoot;
331 backing()->updateAfterLayout(updateFlags); 330 backing()->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 (backing() || !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 (backing()) {
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 functio ns - especially compounded with
1281 // the includeSelf option.
Julien - ping for review 2013/10/03 20:08:36 Nit: We usually don't align FIXMEs in Blink.
shawnsingh 2013/10/07 11:45:04 Done
1280 RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const 1282 RenderLayer* RenderLayer::enclosingCompositingLayer(bool includeSelf) const
1281 { 1283 {
1282 if (includeSelf && isComposited()) 1284 if (includeSelf && backing())
1283 return const_cast<RenderLayer*>(this); 1285 return const_cast<RenderLayer*>(this);
1284 1286
1285 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) { 1287 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) {
1286 if (curr->isComposited()) 1288 if (curr->backing())
1287 return const_cast<RenderLayer*>(curr); 1289 return const_cast<RenderLayer*>(curr);
1288 } 1290 }
1289 1291
1290 return 0; 1292 return 0;
1291 } 1293 }
1292 1294
1293 RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const 1295 RenderLayer* RenderLayer::enclosingCompositingLayerForRepaint(bool includeSelf) const
1294 { 1296 {
1295 if (includeSelf && isComposited() && !backing()->paintsIntoCompositedAncesto r()) 1297 if (includeSelf && compositingState() == PaintsIntoOwnBacking)
1296 return const_cast<RenderLayer*>(this); 1298 return const_cast<RenderLayer*>(this);
1297 1299
1298 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) { 1300 for (const RenderLayer* curr = compositingContainer(this); curr; curr = comp ositingContainer(curr)) {
1299 if (curr->isComposited() && !curr->backing()->paintsIntoCompositedAncest or()) 1301 if (curr->compositingState() == PaintsIntoOwnBacking)
1300 return const_cast<RenderLayer*>(curr); 1302 return const_cast<RenderLayer*>(curr);
1301 } 1303 }
1302 1304
1303 return 0; 1305 return 0;
1304 } 1306 }
1305 1307
1306 RenderLayer* RenderLayer::ancestorScrollingLayer() const 1308 RenderLayer* RenderLayer::ancestorScrollingLayer() const
1307 { 1309 {
1308 if (!acceleratedCompositingForOverflowScrollEnabled()) 1310 if (!acceleratedCompositingForOverflowScrollEnabled())
1309 return 0; 1311 return 0;
(...skipping 17 matching lines...) Expand all
1327 if (curr->requiresFullLayerImageForFilters()) 1329 if (curr->requiresFullLayerImageForFilters())
1328 return const_cast<RenderLayer*>(curr); 1330 return const_cast<RenderLayer*>(curr);
1329 } 1331 }
1330 1332
1331 return 0; 1333 return 0;
1332 } 1334 }
1333 1335
1334 RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const 1336 RenderLayer* RenderLayer::enclosingFilterRepaintLayer() const
1335 { 1337 {
1336 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 1338 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
1337 if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr-> isComposited() || curr->isRootLayer()) 1339 if ((curr != this && curr->requiresFullLayerImageForFilters()) || curr-> compositingState() == PaintsIntoOwnBacking || curr->isRootLayer())
1338 return const_cast<RenderLayer*>(curr); 1340 return const_cast<RenderLayer*>(curr);
1339 } 1341 }
1340 return 0; 1342 return 0;
1341 } 1343 }
1342 1344
1343 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect) 1345 void RenderLayer::setFilterBackendNeedsRepaintingInRect(const LayoutRect& rect)
1344 { 1346 {
1345 if (rect.isEmpty()) 1347 if (rect.isEmpty())
1346 return; 1348 return;
1347 1349
(...skipping 10 matching lines...) Expand all
1358 // shader can address any ouput pixel. 1360 // 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. 1361 // Note: This is only for output rect, so there's no need to expand the dirty source rect.
1360 rectForRepaint.unite(calculateLayerBounds(this)); 1362 rectForRepaint.unite(calculateLayerBounds(this));
1361 } 1363 }
1362 1364
1363 RenderLayer* parentLayer = enclosingFilterRepaintLayer(); 1365 RenderLayer* parentLayer = enclosingFilterRepaintLayer();
1364 ASSERT(parentLayer); 1366 ASSERT(parentLayer);
1365 FloatQuad repaintQuad(rectForRepaint); 1367 FloatQuad repaintQuad(rectForRepaint);
1366 LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, p arentLayer->renderer()).enclosingBoundingBox(); 1368 LayoutRect parentLayerRect = renderer()->localToContainerQuad(repaintQuad, p arentLayer->renderer()).enclosingBoundingBox();
1367 1369
1368 if (parentLayer->isComposited()) { 1370 if (parentLayer->backing()) {
1369 parentLayer->setBackingNeedsRepaintInRect(parentLayerRect); 1371 parentLayer->setBackingNeedsRepaintInRect(parentLayerRect);
1370 return; 1372 return;
1371 } 1373 }
1372 1374
1373 if (parentLayer->paintsWithFilters()) { 1375 if (parentLayer->paintsWithFilters()) {
1374 parentLayer->setFilterBackendNeedsRepaintingInRect(parentLayerRect); 1376 parentLayer->setFilterBackendNeedsRepaintingInRect(parentLayerRect);
1375 return; 1377 return;
1376 } 1378 }
1377 1379
1378 if (parentLayer->isRootLayer()) { 1380 if (parentLayer->isRootLayer()) {
(...skipping 10 matching lines...) Expand all
1389 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { 1391 for (const RenderLayer* curr = this; curr; curr = curr->parent()) {
1390 RenderLayerModelObject* renderer = curr->renderer(); 1392 RenderLayerModelObject* renderer = curr->renderer();
1391 if (renderer->style()->hasFilterOutsets()) 1393 if (renderer->style()->hasFilterOutsets())
1392 return true; 1394 return true;
1393 } 1395 }
1394 return false; 1396 return false;
1395 } 1397 }
1396 1398
1397 RenderLayer* RenderLayer::clippingRootForPainting() const 1399 RenderLayer* RenderLayer::clippingRootForPainting() const
1398 { 1400 {
1399 if (isComposited()) 1401 if (backing())
1400 return const_cast<RenderLayer*>(this); 1402 return const_cast<RenderLayer*>(this);
1401 1403
1402 const RenderLayer* current = this; 1404 const RenderLayer* current = this;
1403 while (current) { 1405 while (current) {
1404 if (current->isRootLayer()) 1406 if (current->isRootLayer())
1405 return const_cast<RenderLayer*>(current); 1407 return const_cast<RenderLayer*>(current);
1406 1408
1407 current = compositingContainer(current); 1409 current = compositingContainer(current);
1408 ASSERT(current); 1410 ASSERT(current);
1409 if (current->transform() 1411 if (current->transform()
1410 || (current->isComposited() && !current->backing()->paintsIntoCompos itedAncestor()) 1412 || (current->backing() && !current->backing()->paintsIntoCompositedA ncestor())
1411 ) 1413 )
1412 return const_cast<RenderLayer*>(current); 1414 return const_cast<RenderLayer*>(current);
1413 } 1415 }
1414 1416
1415 ASSERT_NOT_REACHED(); 1417 ASSERT_NOT_REACHED();
1416 return 0; 1418 return 0;
1417 } 1419 }
1418 1420
1419 LayoutPoint RenderLayer::absoluteToContents(const LayoutPoint& absolutePoint) co nst 1421 LayoutPoint RenderLayer::absoluteToContents(const LayoutPoint& absolutePoint) co nst
1420 { 1422 {
(...skipping 14 matching lines...) Expand all
1435 { 1437 {
1436 // FIXME: This seems incorrect; why would SVG layers be opaque? 1438 // FIXME: This seems incorrect; why would SVG layers be opaque?
1437 if (renderer()->node() && renderer()->node()->namespaceURI() == SVGNames::sv gNamespaceURI) 1439 if (renderer()->node() && renderer()->node()->namespaceURI() == SVGNames::sv gNamespaceURI)
1438 return false; 1440 return false;
1439 1441
1440 return renderer()->isTransparent() || renderer()->hasMask(); 1442 return renderer()->isTransparent() || renderer()->hasMask();
1441 } 1443 }
1442 1444
1443 RenderLayer* RenderLayer::transparentPaintingAncestor() 1445 RenderLayer* RenderLayer::transparentPaintingAncestor()
1444 { 1446 {
1445 if (isComposited()) 1447 if (backing())
Julien - ping for review 2013/10/03 20:08:36 This gets called from RenderLayer::beginTransparen
shawnsingh 2013/10/07 11:45:04 This is a confusing one, and for the sake of movin
1446 return 0; 1448 return 0;
1447 1449
1448 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) { 1450 for (RenderLayer* curr = parent(); curr; curr = curr->parent()) {
1449 if (curr->isComposited()) 1451 if (curr->backing())
1450 return 0; 1452 return 0;
1451 if (curr->isTransparent()) 1453 if (curr->isTransparent())
1452 return curr; 1454 return curr;
1453 } 1455 }
1454 return 0; 1456 return 0;
1455 } 1457 }
1456 1458
1457 enum TransparencyClipBoxBehavior { 1459 enum TransparencyClipBoxBehavior {
1458 PaintingTransparencyClipBox, 1460 PaintingTransparencyClipBox,
1459 HitTestingTransparencyClipBox 1461 HitTestingTransparencyClipBox
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 } 1880 }
1879 1881
1880 bool RenderLayer::usesCompositedScrolling() const 1882 bool RenderLayer::usesCompositedScrolling() const
1881 { 1883 {
1882 RenderBox* box = renderBox(); 1884 RenderBox* box = renderBox();
1883 1885
1884 // Scroll form controls on the main thread so they exhibit correct touch scr oll event bubbling 1886 // 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))) 1887 if (box && (box->isIntristicallyScrollable(VerticalScrollbar) || box->isIntr isticallyScrollable(HorizontalScrollbar)))
1886 return false; 1888 return false;
1887 1889
1888 return isComposited() && backing()->scrollingLayer(); 1890 return backing() && backing()->scrollingLayer();
1889 } 1891 }
1890 1892
1891 bool RenderLayer::needsCompositedScrolling() const 1893 bool RenderLayer::needsCompositedScrolling() const
1892 { 1894 {
1893 if (!compositorDrivenAcceleratedScrollingEnabled()) 1895 if (!compositorDrivenAcceleratedScrollingEnabled())
1894 return needsToBeStackingContainer(); 1896 return needsToBeStackingContainer();
1895 if (FrameView* frameView = renderer()->view()->frameView()) 1897 if (FrameView* frameView = renderer()->view()->frameView())
1896 return frameView->containsScrollableArea(scrollableArea()); 1898 return frameView->containsScrollableArea(scrollableArea());
1897 return false; 1899 return false;
1898 } 1900 }
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 return false; 2509 return false;
2508 } 2510 }
2509 2511
2510 static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P aintLayerFlags paintFlags) 2512 static bool paintForFixedRootBackground(const RenderLayer* layer, RenderLayer::P aintLayerFlags paintFlags)
2511 { 2513 {
2512 return layer->renderer()->isRoot() && (paintFlags & RenderLayer::PaintLayerP aintingRootBackgroundOnly); 2514 return layer->renderer()->isRoot() && (paintFlags & RenderLayer::PaintLayerP aintingRootBackgroundOnly);
2513 } 2515 }
2514 2516
2515 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 2517 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
2516 { 2518 {
2517 if (isComposited()) { 2519 if (backing()) {
2518 // The updatingControlTints() painting pass goes through compositing lay ers, 2520 // The updatingControlTints() painting pass goes through compositing lay ers,
2519 // but we need to ensure that we don't cache clip rects computed with th e wrong root in this case. 2521 // but we need to ensure that we don't cache clip rects computed with th e wrong root in this case.
2520 if (context->updatingControlTints() || (paintingInfo.paintBehavior & Pai ntBehaviorFlattenCompositingLayers)) { 2522 if (context->updatingControlTints() || (paintingInfo.paintBehavior & Pai ntBehaviorFlattenCompositingLayers)) {
2521 paintFlags |= PaintLayerTemporaryClipRects; 2523 paintFlags |= PaintLayerTemporaryClipRects;
2522 } else if (!backing()->paintsIntoCompositedAncestor() 2524 } else if (!backing()->paintsIntoCompositedAncestor()
2523 && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingRefle ction) 2525 && !shouldDoSoftwarePaint(this, paintFlags & PaintLayerPaintingRefle ction)
2524 && !paintForFixedRootBackground(this, paintFlags)) { 2526 && !paintForFixedRootBackground(this, paintFlags)) {
2525 // If this RenderLayer should paint into its backing, that will be d one via RenderLayerBacking::paintIntoLayer(). 2527 // If this RenderLayer should paint into its backing, that will be d one via RenderLayerBacking::paintIntoLayer().
2526 return; 2528 return;
2527 } 2529 }
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
4305 return pixelSnappedIntRect(localClipRect); 4307 return pixelSnappedIntRect(localClipRect);
4306 } 4308 }
4307 } 4309 }
4308 4310
4309 // FIXME: should probably just pass 'flags' down to descendants. 4311 // FIXME: should probably just pass 'flags' down to descendants.
4310 CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants) | (flags & IncludeCompositedDescendants); 4312 CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants) | (flags & IncludeCompositedDescendants);
4311 4313
4312 const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded(); 4314 const_cast<RenderLayer*>(this)->updateLayerListsIfNeeded();
4313 4315
4314 if (RenderLayer* reflection = reflectionLayer()) { 4316 if (RenderLayer* reflection = reflectionLayer()) {
4315 if (!reflection->isComposited()) { 4317 if (!reflection->backing()) {
4316 IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags); 4318 IntRect childUnionBounds = reflection->calculateLayerBounds(this, 0, descendantFlags);
4317 unionBounds.unite(childUnionBounds); 4319 unionBounds.unite(childUnionBounds);
4318 } 4320 }
4319 } 4321 }
4320 4322
4321 ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size( ))); 4323 ASSERT(isStackingContainer() || (!posZOrderList() || !posZOrderList()->size( )));
4322 4324
4323 #if !ASSERT_DISABLED 4325 #if !ASSERT_DISABLED
4324 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this)); 4326 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(this));
4325 #endif 4327 #endif
4326 4328
4327 if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) { 4329 if (Vector<RenderLayer*>* negZOrderList = this->negZOrderList()) {
4328 size_t listSize = negZOrderList->size(); 4330 size_t listSize = negZOrderList->size();
4329 for (size_t i = 0; i < listSize; ++i) { 4331 for (size_t i = 0; i < listSize; ++i) {
4330 RenderLayer* curLayer = negZOrderList->at(i); 4332 RenderLayer* curLayer = negZOrderList->at(i);
4331 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4333 if (flags & IncludeCompositedDescendants || !curLayer->backing()) {
4332 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); 4334 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
4333 unionBounds.unite(childUnionBounds); 4335 unionBounds.unite(childUnionBounds);
4334 } 4336 }
4335 } 4337 }
4336 } 4338 }
4337 4339
4338 if (Vector<RenderLayer*>* posZOrderList = this->posZOrderList()) { 4340 if (Vector<RenderLayer*>* posZOrderList = this->posZOrderList()) {
4339 size_t listSize = posZOrderList->size(); 4341 size_t listSize = posZOrderList->size();
4340 for (size_t i = 0; i < listSize; ++i) { 4342 for (size_t i = 0; i < listSize; ++i) {
4341 RenderLayer* curLayer = posZOrderList->at(i); 4343 RenderLayer* curLayer = posZOrderList->at(i);
4342 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4344 if (flags & IncludeCompositedDescendants || !curLayer->backing()) {
4343 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags); 4345 IntRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
4344 unionBounds.unite(childUnionBounds); 4346 unionBounds.unite(childUnionBounds);
4345 } 4347 }
4346 } 4348 }
4347 } 4349 }
4348 4350
4349 if (Vector<RenderLayer*>* normalFlowList = this->normalFlowList()) { 4351 if (Vector<RenderLayer*>* normalFlowList = this->normalFlowList()) {
4350 size_t listSize = normalFlowList->size(); 4352 size_t listSize = normalFlowList->size();
4351 for (size_t i = 0; i < listSize; ++i) { 4353 for (size_t i = 0; i < listSize; ++i) {
4352 RenderLayer* curLayer = normalFlowList->at(i); 4354 RenderLayer* curLayer = normalFlowList->at(i);
4353 if (flags & IncludeCompositedDescendants || !curLayer->isComposited( )) { 4355 if (flags & IncludeCompositedDescendants || !curLayer->backing()) {
4354 IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, d escendantFlags); 4356 IntRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, d escendantFlags);
4355 unionBounds.unite(curAbsBounds); 4357 unionBounds.unite(curAbsBounds);
4356 } 4358 }
4357 } 4359 }
4358 } 4360 }
4359 4361
4360 // FIXME: We can optimize the size of the composited layers, by not enlargin g 4362 // FIXME: We can optimize the size of the composited layers, by not enlargin g
4361 // filtered areas with the outsets if we know that the filter is going to re nder in hardware. 4363 // filtered areas with the outsets if we know that the filter is going to re nder in hardware.
4362 // https://bugs.webkit.org/show_bug.cgi?id=81239 4364 // https://bugs.webkit.org/show_bug.cgi?id=81239
4363 if (flags & IncludeLayerFilterOutsets) 4365 if (flags & IncludeLayerFilterOutsets)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4396 if (typeToClear == AllClipRectTypes) 4398 if (typeToClear == AllClipRectTypes)
4397 m_clipRectsCache = nullptr; 4399 m_clipRectsCache = nullptr;
4398 else { 4400 else {
4399 ASSERT(typeToClear < NumCachedClipRectsTypes); 4401 ASSERT(typeToClear < NumCachedClipRectsTypes);
4400 RefPtr<ClipRects> dummy; 4402 RefPtr<ClipRects> dummy;
4401 m_clipRectsCache->setClipRects(typeToClear, RespectOverflowClip, dummy); 4403 m_clipRectsCache->setClipRects(typeToClear, RespectOverflowClip, dummy);
4402 m_clipRectsCache->setClipRects(typeToClear, IgnoreOverflowClip, dummy); 4404 m_clipRectsCache->setClipRects(typeToClear, IgnoreOverflowClip, dummy);
4403 } 4405 }
4404 } 4406 }
4405 4407
4408 CompositingState RenderLayer::compositingState() const
4409 {
4410 // This is computed procedurally so there is no redundant state variable tha t
4411 // can get out of sync from the real actual compositing state.
4412
4413 if (!m_backing)
4414 return NotComposited;
4415
4416 if (m_backing && backing()->paintsIntoCompositedAncestor())
4417 return HasOwnBackingButPaintsIntoAncestor;
4418
4419 ASSERT(m_backing);
4420 return PaintsIntoOwnBacking;
4421 }
Julien - ping for review 2013/10/03 20:08:36 The PaintsIntoGroupBacking state is never reached
shawnsingh 2013/10/07 11:45:04 OK, removed for now.
4422
4406 RenderLayerBacking* RenderLayer::ensureBacking() 4423 RenderLayerBacking* RenderLayer::ensureBacking()
4407 { 4424 {
4408 if (!m_backing) { 4425 if (!m_backing) {
4409 m_backing = adoptPtr(new RenderLayerBacking(this)); 4426 m_backing = adoptPtr(new RenderLayerBacking(this));
4410 compositor()->layerBecameComposited(this); 4427 compositor()->layerBecameComposited(this);
4411 4428
4412 updateOrRemoveFilterEffectRenderer(); 4429 updateOrRemoveFilterEffectRenderer();
4413 4430
4414 if (RuntimeEnabledFeatures::cssCompositingEnabled()) 4431 if (RuntimeEnabledFeatures::cssCompositingEnabled())
4415 backing()->setBlendMode(m_blendMode); 4432 backing()->setBlendMode(m_blendMode);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4457 return m_backing ? m_backing->layerForVerticalScrollbar() : 0; 4474 return m_backing ? m_backing->layerForVerticalScrollbar() : 0;
4458 } 4475 }
4459 4476
4460 GraphicsLayer* RenderLayer::layerForScrollCorner() const 4477 GraphicsLayer* RenderLayer::layerForScrollCorner() const
4461 { 4478 {
4462 return m_backing ? m_backing->layerForScrollCorner() : 0; 4479 return m_backing ? m_backing->layerForScrollCorner() : 0;
4463 } 4480 }
4464 4481
4465 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const 4482 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const
4466 { 4483 {
4467 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || !isComposited()); 4484 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking);
4468 } 4485 }
4469 4486
4470 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const 4487 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
4471 { 4488 {
4472 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 4489 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
4473 return false; 4490 return false;
4474 4491
4475 if (paintsWithTransparency(PaintBehaviorNormal)) 4492 if (paintsWithTransparency(PaintBehaviorNormal))
4476 return false; 4493 return false;
4477 4494
(...skipping 30 matching lines...) Expand all
4508 || listBackgroundIsKnownToBeOpaqueInRect(normalFlowList(), localRect); 4525 || listBackgroundIsKnownToBeOpaqueInRect(normalFlowList(), localRect);
4509 } 4526 }
4510 4527
4511 bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer *>* list, const LayoutRect& localRect) const 4528 bool RenderLayer::listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer *>* list, const LayoutRect& localRect) const
4512 { 4529 {
4513 if (!list || list->isEmpty()) 4530 if (!list || list->isEmpty())
4514 return false; 4531 return false;
4515 4532
4516 for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); ite r != list->rend(); ++iter) { 4533 for (Vector<RenderLayer*>::const_reverse_iterator iter = list->rbegin(); ite r != list->rend(); ++iter) {
4517 const RenderLayer* childLayer = *iter; 4534 const RenderLayer* childLayer = *iter;
4518 if (childLayer->isComposited()) 4535 if (childLayer->backing())
4519 continue; 4536 continue;
4520 4537
4521 if (!childLayer->canUseConvertToLayerCoords()) 4538 if (!childLayer->canUseConvertToLayerCoords())
4522 continue; 4539 continue;
4523 4540
4524 LayoutPoint childOffset; 4541 LayoutPoint childOffset;
4525 LayoutRect childLocalRect(localRect); 4542 LayoutRect childLocalRect(localRect);
4526 childLayer->convertToLayerCoords(this, childOffset); 4543 childLayer->convertToLayerCoords(this, childOffset);
4527 childLocalRect.moveBy(-childOffset); 4544 childLocalRect.moveBy(-childOffset);
4528 4545
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4765 4782
4766 void RenderLayer::repaintIncludingDescendants() 4783 void RenderLayer::repaintIncludingDescendants()
4767 { 4784 {
4768 renderer()->repaint(); 4785 renderer()->repaint();
4769 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling()) 4786 for (RenderLayer* curr = firstChild(); curr; curr = curr->nextSibling())
4770 curr->repaintIncludingDescendants(); 4787 curr->repaintIncludingDescendants();
4771 } 4788 }
4772 4789
4773 void RenderLayer::setBackingNeedsRepaint() 4790 void RenderLayer::setBackingNeedsRepaint()
4774 { 4791 {
4775 ASSERT(isComposited()); 4792 ASSERT(backing());
4776 backing()->setContentsNeedDisplay(); 4793 backing()->setContentsNeedDisplay();
4777 } 4794 }
4778 4795
4779 void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r) 4796 void RenderLayer::setBackingNeedsRepaintInRect(const LayoutRect& r)
4780 { 4797 {
4781 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here, 4798 // https://bugs.webkit.org/show_bug.cgi?id=61159 describes an unreproducible crash here,
4782 // so assert but check that the layer is composited. 4799 // so assert but check that the layer is composited.
4783 ASSERT(isComposited()); 4800 ASSERT(backing());
4784 if (!isComposited()) { 4801 if (!backing()) {
4785 // If we're trying to repaint the placeholder document layer, propagate the 4802 // If we're trying to repaint the placeholder document layer, propagate the
4786 // repaint to the native view system. 4803 // repaint to the native view system.
4787 LayoutRect absRect(r); 4804 LayoutRect absRect(r);
4788 LayoutPoint delta; 4805 LayoutPoint delta;
4789 convertToLayerCoords(root(), delta); 4806 convertToLayerCoords(root(), delta);
4790 absRect.moveBy(delta); 4807 absRect.moveBy(delta);
4791 4808
4792 RenderView* view = renderer()->view(); 4809 RenderView* view = renderer()->view();
4793 if (view) 4810 if (view)
4794 view->repaintViewRectangle(absRect); 4811 view->repaintViewRectangle(absRect);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 5007
4991 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const 5008 inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
4992 { 5009 {
4993 ASSERT(newStyle); 5010 ASSERT(newStyle);
4994 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip()); 5011 return oldStyle && (oldStyle->clip() != newStyle->clip() || oldStyle->hasCli p() != newStyle->hasClip());
4995 } 5012 }
4996 5013
4997 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const 5014 inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderSt yle* oldStyle, const RenderStyle* newStyle) const
4998 { 5015 {
4999 ASSERT(newStyle); 5016 ASSERT(newStyle);
5000 return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->ov erflowX()) && ancestorStackingContainer()->hasCompositingDescendant(); 5017 return !backing() && oldStyle && (oldStyle->overflowX() != newStyle->overflo wX()) && ancestorStackingContainer()->hasCompositingDescendant();
5001 } 5018 }
5002 5019
5003 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const 5020 inline bool RenderLayer::needsCompositingLayersRebuiltForFilters(const RenderSty le* oldStyle, const RenderStyle* newStyle, bool didPaintWithFilters) const
5004 { 5021 {
5005 if (!hasOrHadFilters(oldStyle, newStyle)) 5022 if (!hasOrHadFilters(oldStyle, newStyle))
5006 return false; 5023 return false;
5007 5024
5008 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) { 5025 if (renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(rendere r(), CSSPropertyWebkitFilter)) {
5009 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers. 5026 // When the compositor is performing the filter animation, we shouldn't touch the compositing layers.
5010 // All of the layers above us should have been promoted to compositing l ayers already. 5027 // All of the layers above us should have been promoted to compositing l ayers already.
(...skipping 23 matching lines...) Expand all
5034 } 5051 }
5035 5052
5036 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) 5053 void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle)
5037 { 5054 {
5038 if (!hasOrHadFilters(oldStyle, newStyle)) 5055 if (!hasOrHadFilters(oldStyle, newStyle))
5039 return; 5056 return;
5040 5057
5041 updateOrRemoveFilterClients(); 5058 updateOrRemoveFilterClients();
5042 // During an accelerated animation, both WebKit and the compositor animate p roperties. 5059 // During an accelerated animation, both WebKit and the compositor animate p roperties.
5043 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation. 5060 // However, WebKit shouldn't ask the compositor to update its filters if the compositor is performing the animation.
5044 bool shouldUpdateFilters = isComposited() && !renderer()->animation()->isRun ningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter); 5061 bool shouldUpdateFilters = backing() && !renderer()->animation()->isRunningA cceleratedAnimationOnRenderer(renderer(), CSSPropertyWebkitFilter);
5045 if (shouldUpdateFilters) 5062 if (shouldUpdateFilters)
5046 backing()->updateFilters(renderer()->style()); 5063 backing()->updateFilters(renderer()->style());
5047 updateOrRemoveFilterEffectRenderer(); 5064 updateOrRemoveFilterEffectRenderer();
5048 } 5065 }
5049 5066
5050 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle) 5067 void RenderLayer::styleChanged(StyleDifference, const RenderStyle* oldStyle)
5051 { 5068 {
5052 updateIsNormalFlowOnly(); 5069 updateIsNormalFlowOnly();
5053 5070
5054 if (m_scrollableArea) 5071 if (m_scrollableArea)
(...skipping 25 matching lines...) Expand all
5080 if (paintsWithFilters()) 5097 if (paintsWithFilters())
5081 didPaintWithFilters = true; 5098 didPaintWithFilters = true;
5082 updateFilters(oldStyle, renderer()->style()); 5099 updateFilters(oldStyle, renderer()->style());
5083 5100
5084 const RenderStyle* newStyle = renderer()->style(); 5101 const RenderStyle* newStyle = renderer()->style();
5085 if (compositor()->updateLayerCompositingState(this) 5102 if (compositor()->updateLayerCompositingState(this)
5086 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle) 5103 || needsCompositingLayersRebuiltForClip(oldStyle, newStyle)
5087 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle) 5104 || needsCompositingLayersRebuiltForOverflow(oldStyle, newStyle)
5088 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters)) 5105 || needsCompositingLayersRebuiltForFilters(oldStyle, newStyle, didPaintW ithFilters))
5089 compositor()->setCompositingLayersNeedRebuild(); 5106 compositor()->setCompositingLayersNeedRebuild();
5090 else if (isComposited()) 5107 else if (backing())
5091 backing()->updateGraphicsLayerGeometry(); 5108 backing()->updateGraphicsLayerGeometry();
5092 } 5109 }
5093 5110
5094 void RenderLayer::updateScrollableAreaSet(bool hasOverflow) 5111 void RenderLayer::updateScrollableAreaSet(bool hasOverflow)
5095 { 5112 {
5096 Frame* frame = renderer()->frame(); 5113 Frame* frame = renderer()->frame();
5097 if (!frame) 5114 if (!frame)
5098 return; 5115 return;
5099 5116
5100 FrameView* frameView = frame->view(); 5117 FrameView* frameView = frame->view();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
5485 } 5502 }
5486 } 5503 }
5487 5504
5488 void showLayerTree(const WebCore::RenderObject* renderer) 5505 void showLayerTree(const WebCore::RenderObject* renderer)
5489 { 5506 {
5490 if (!renderer) 5507 if (!renderer)
5491 return; 5508 return;
5492 showLayerTree(renderer->enclosingLayer()); 5509 showLayerTree(renderer->enclosingLayer());
5493 } 5510 }
5494 #endif 5511 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698