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

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

Issue 59063003: Don't coerce pointers to compositor layer mappings to booleans. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaaaase Created 7 years, 1 month 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) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 IntRect visibleRect = m_containerLayer ? IntRect(IntPoint(), frameView->cont entsSize()) : frameView->visibleContentRect(); 296 IntRect visibleRect = m_containerLayer ? IntRect(IntPoint(), frameView->cont entsSize()) : frameView->visibleContentRect();
297 if (rootLayer->visibleRectChangeRequiresFlush(visibleRect)) { 297 if (rootLayer->visibleRectChangeRequiresFlush(visibleRect)) {
298 if (Page* page = this->page()) 298 if (Page* page = this->page())
299 page->chrome().client().scheduleCompositingLayerFlush(); 299 page->chrome().client().scheduleCompositingLayerFlush();
300 } 300 }
301 } 301 }
302 302
303 bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const 303 bool RenderLayerCompositor::hasAnyAdditionalCompositedLayers(const RenderLayer* rootLayer) const
304 { 304 {
305 return m_compositedLayerCount > (rootLayer->compositedLayerMapping() ? 1 : 0 ); 305 return m_compositedLayerCount > (rootLayer->compositingState() == PaintsInto OwnBacking ? 1 : 0);
306 } 306 }
307 307
308 void RenderLayerCompositor::updateCompositingRequirementsState() 308 void RenderLayerCompositor::updateCompositingRequirementsState()
309 { 309 {
310 if (!m_needsUpdateCompositingRequirementsState) 310 if (!m_needsUpdateCompositingRequirementsState)
311 return; 311 return;
312 312
313 TRACE_EVENT0("blink_rendering,comp-scroll", "RenderLayerCompositor::updateCo mpositingRequirementsState"); 313 TRACE_EVENT0("blink_rendering,comp-scroll", "RenderLayerCompositor::updateCo mpositingRequirementsState");
314 314
315 m_needsUpdateCompositingRequirementsState = false; 315 m_needsUpdateCompositingRequirementsState = false;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // Update the hierarchy of the compositing layers. 446 // Update the hierarchy of the compositing layers.
447 Vector<GraphicsLayer*> childList; 447 Vector<GraphicsLayer*> childList;
448 { 448 {
449 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree"); 449 TRACE_EVENT0("blink_rendering", "RenderLayerCompositor::rebuildCompo sitingLayerTree");
450 rebuildCompositingLayerTree(updateRoot, childList, 0); 450 rebuildCompositingLayerTree(updateRoot, childList, 0);
451 } 451 }
452 452
453 // Host the document layer in the RenderView's root layer. 453 // Host the document layer in the RenderView's root layer.
454 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) { 454 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isMainFra me()) {
455 RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->docu ment()); 455 RenderVideo* video = findFullscreenVideoRenderer(&m_renderView->docu ment());
456 if (video) { 456 if (video && video->compositingState() == PaintsIntoOwnBacking) {
457 CompositedLayerMapping* compositedLayerMapping = video->composit edLayerMapping(); 457 childList.clear();
458 if (compositedLayerMapping) { 458 childList.append(video->compositedLayerMapping()->mainGraphicsLa yer());
459 childList.clear();
460 childList.append(compositedLayerMapping->mainGraphicsLayer() );
461 }
462 } 459 }
463 } 460 }
464 // Even when childList is empty, don't drop out of compositing mode if t here are 461 // Even when childList is empty, don't drop out of compositing mode if t here are
465 // composited layers that we didn't hit in our traversal (e.g. because o f visibility:hidden). 462 // composited layers that we didn't hit in our traversal (e.g. because o f visibility:hidden).
466 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot) ) 463 if (childList.isEmpty() && !hasAnyAdditionalCompositedLayers(updateRoot) )
467 destroyRootLayer(); 464 destroyRootLayer();
468 else 465 else
469 m_rootContentLayer->setChildren(childList); 466 m_rootContentLayer->setChildren(childList);
470 } else if (needGeometryUpdate) { 467 } else if (needGeometryUpdate) {
471 // We just need to do a geometry update. This is only used for position: fixed scrolling; 468 // We just need to do a geometry update. This is only used for position: fixed scrolling;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 bool compositedLayerMappingChanged = false; 511 bool compositedLayerMappingChanged = false;
515 RenderLayer::ViewportConstrainedNotCompositedReason viewportConstrainedNotCo mpositedReason = RenderLayer::NoNotCompositedReason; 512 RenderLayer::ViewportConstrainedNotCompositedReason viewportConstrainedNotCo mpositedReason = RenderLayer::NoNotCompositedReason;
516 requiresCompositingForPosition(layer->renderer(), layer, &viewportConstraine dNotCompositedReason); 513 requiresCompositingForPosition(layer->renderer(), layer, &viewportConstraine dNotCompositedReason);
517 514
518 // FIXME: It would be nice to directly use the layer's compositing reason, 515 // FIXME: It would be nice to directly use the layer's compositing reason,
519 // but allocateOrClearCompositedLayerMapping also gets called without having updated compositing 516 // but allocateOrClearCompositedLayerMapping also gets called without having updated compositing
520 // requirements fully. 517 // requirements fully.
521 if (needsToBeComposited(layer)) { 518 if (needsToBeComposited(layer)) {
522 enableCompositingMode(); 519 enableCompositingMode();
523 520
524 if (!layer->compositedLayerMapping()) { 521 if (layer->compositingState() == NotComposited) {
shawnsingh 2013/11/05 10:20:27 I strongly prefer these ones to use hasCompositedL
Ian Vollick 2013/11/08 03:35:12 Done.
525 // If we need to repaint, do so before allocating the compositedLaye rMapping 522 // If we need to repaint, do so before allocating the compositedLaye rMapping
526 if (shouldRepaint == CompositingChangeRepaintNow) 523 if (shouldRepaint == CompositingChangeRepaintNow)
527 repaintOnCompositingChange(layer); 524 repaintOnCompositingChange(layer);
528 525
529 layer->ensureCompositedLayerMapping(); 526 layer->ensureCompositedLayerMapping();
530 compositedLayerMappingChanged = true; 527 compositedLayerMappingChanged = true;
531 528
532 // At this time, the ScrollingCooridnator only supports the top-leve l frame. 529 // At this time, the ScrollingCooridnator only supports the top-leve l frame.
533 if (layer->isRootLayer() && !isMainFrame()) { 530 if (layer->isRootLayer() && !isMainFrame()) {
534 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling Coordinator()) 531 if (ScrollingCoordinator* scrollingCoordinator = this->scrolling Coordinator())
535 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi ew->frameView()); 532 scrollingCoordinator->frameViewRootLayerDidChange(m_renderVi ew->frameView());
536 } 533 }
537 534
538 // This layer and all of its descendants have cached repaints rects that are relative to 535 // This layer and all of its descendants have cached repaints rects that are relative to
539 // the repaint container, so change when compositing changes; we nee d to update them here. 536 // the repaint container, so change when compositing changes; we nee d to update them here.
540 if (layer->parent()) 537 if (layer->parent())
541 layer->repainter().computeRepaintRectsIncludingDescendants(); 538 layer->repainter().computeRepaintRectsIncludingDescendants();
542 } 539 }
543 540
544 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt rinsicReasons()) 541 if (layer->compositedLayerMapping()->updateRequiresOwnBackingStoreForInt rinsicReasons())
545 compositedLayerMappingChanged = true; 542 compositedLayerMappingChanged = true;
546 } else { 543 } else {
547 if (layer->compositedLayerMapping()) { 544 if (layer->compositingState() != NotComposited) {
shawnsingh 2013/11/05 10:20:27 Ditto same as previous comment here.
Ian Vollick 2013/11/08 03:35:12 Done.
548 // If we're removing the compositedLayerMapping from a reflection, c lear the source GraphicsLayer's pointer to 545 // If we're removing the compositedLayerMapping from a reflection, c lear the source GraphicsLayer's pointer to
549 // its replica GraphicsLayer. In practice this should never happen b ecause reflectee and reflection 546 // its replica GraphicsLayer. In practice this should never happen b ecause reflectee and reflection
550 // are both either composited, or not composited. 547 // are both either composited, or not composited.
551 if (layer->isReflection()) { 548 if (layer->isReflection()) {
552 RenderLayer* sourceLayer = toRenderLayerModelObject(layer->rende rer()->parent())->layer(); 549 RenderLayer* sourceLayer = toRenderLayerModelObject(layer->rende rer()->parent())->layer();
553 if (CompositedLayerMapping* compositedLayerMapping = sourceLayer ->compositedLayerMapping()) { 550 if (sourceLayer->compositingState() != NotComposited) {
554 ASSERT(compositedLayerMapping->mainGraphicsLayer()->replicaL ayer() == layer->compositedLayerMapping()->mainGraphicsLayer()); 551 ASSERT(compositedLayerMapping->mainGraphicsLayer()->replicaL ayer() == layer->compositedLayerMapping()->mainGraphicsLayer());
555 compositedLayerMapping->mainGraphicsLayer()->setReplicatedBy Layer(0); 552 sourceLayer->compositedLayerMapping()->mainGraphicsLayer()-> setReplicatedByLayer(0);
556 } 553 }
557 } 554 }
558 555
559 removeViewportConstrainedLayer(layer); 556 removeViewportConstrainedLayer(layer);
560 557
561 layer->clearCompositedLayerMapping(); 558 layer->clearCompositedLayerMapping();
562 compositedLayerMappingChanged = true; 559 compositedLayerMappingChanged = true;
563 560
564 // This layer and all of its descendants have cached repaints rects that are relative to 561 // This layer and all of its descendants have cached repaints rects that are relative to
565 // the repaint container, so change when compositing changes; we nee d to update them here. 562 // the repaint container, so change when compositing changes; we nee d to update them here.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 return compositedLayerMappingChanged || nonCompositedReasonChanged; 594 return compositedLayerMappingChanged || nonCompositedReasonChanged;
598 } 595 }
599 596
600 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer, Comp ositingChangeRepaint shouldRepaint) 597 bool RenderLayerCompositor::updateLayerCompositingState(RenderLayer* layer, Comp ositingChangeRepaint shouldRepaint)
601 { 598 {
602 updateDirectCompositingReasons(layer); 599 updateDirectCompositingReasons(layer);
603 bool layerChanged = allocateOrClearCompositedLayerMapping(layer, shouldRepai nt); 600 bool layerChanged = allocateOrClearCompositedLayerMapping(layer, shouldRepai nt);
604 601
605 // See if we need content or clipping layers. Methods called here should ass ume 602 // See if we need content or clipping layers. Methods called here should ass ume
606 // that the compositing state of descendant layers has not been updated yet. 603 // that the compositing state of descendant layers has not been updated yet.
607 if (layer->compositedLayerMapping() && layer->compositedLayerMapping()->upda teGraphicsLayerConfiguration()) 604 if (layer->compositingState() == PaintsIntoOwnBacking && layer->compositedLa yerMapping()->updateGraphicsLayerConfiguration())
608 layerChanged = true; 605 layerChanged = true;
609 606
610 return layerChanged; 607 return layerChanged;
611 } 608 }
612 609
613 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer) 610 void RenderLayerCompositor::repaintOnCompositingChange(RenderLayer* layer)
614 { 611 {
615 // If the renderer is not attached yet, no need to repaint. 612 // If the renderer is not attached yet, no need to repaint.
616 if (layer->renderer() != m_renderView && !layer->renderer()->parent()) 613 if (layer->renderer() != m_renderView && !layer->renderer()->parent())
617 return; 614 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 return layer->calculateLayerBounds(ancestorLayer, 0, flags); 653 return layer->calculateLayerBounds(ancestorLayer, 0, flags);
657 } 654 }
658 655
659 void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/) 656 void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/)
660 { 657 {
661 setCompositingLayersNeedRebuild(); 658 setCompositingLayersNeedRebuild();
662 } 659 }
663 660
664 void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child) 661 void RenderLayerCompositor::layerWillBeRemoved(RenderLayer* parent, RenderLayer* child)
665 { 662 {
666 if (!child->compositedLayerMapping() || parent->renderer()->documentBeingDes troyed()) 663 if (child->compositingState() != PaintsIntoOwnBacking || parent->renderer()- >documentBeingDestroyed())
shawnsingh 2013/11/05 10:20:27 or HasOwnBackingButPaintsIntoAncestor...
667 return; 664 return;
668 665
669 removeViewportConstrainedLayer(child); 666 removeViewportConstrainedLayer(child);
670 repaintInCompositedAncestor(child, child->compositedLayerMapping()->composit edBounds()); 667 repaintInCompositedAncestor(child, child->compositedLayerMapping()->composit edBounds());
671 668
672 setCompositingParent(child, 0); 669 setCompositingParent(child, 0);
673 setCompositingLayersNeedRebuild(); 670 setCompositingLayersNeedRebuild();
674 } 671 }
675 672
676 RenderLayer* RenderLayerCompositor::enclosingNonStackingClippingLayer(const Rend erLayer* layer) const 673 RenderLayer* RenderLayerCompositor::enclosingNonStackingClippingLayer(const Rend erLayer* layer) const
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 975 }
979 976
980 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer) 977 void RenderLayerCompositor::setCompositingParent(RenderLayer* childLayer, Render Layer* parentLayer)
981 { 978 {
982 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer ); 979 ASSERT(!parentLayer || childLayer->ancestorCompositingLayer() == parentLayer );
983 ASSERT(childLayer->compositedLayerMapping()); 980 ASSERT(childLayer->compositedLayerMapping());
984 981
985 // It's possible to be called with a parent that isn't yet composited when w e're doing 982 // It's possible to be called with a parent that isn't yet composited when w e're doing
986 // partial updates as required by painting or hit testing. Just bail in that case; 983 // partial updates as required by painting or hit testing. Just bail in that case;
987 // we'll do a full layer update soon. 984 // we'll do a full layer update soon.
988 if (!parentLayer || !parentLayer->compositedLayerMapping()) 985 if (!parentLayer || parentLayer->compositingState() != PaintsIntoOwnBacking)
shawnsingh 2013/11/05 10:20:27 and again....
989 return; 986 return;
990 987
991 if (parentLayer) { 988 if (parentLayer) {
992 GraphicsLayer* hostingLayer = parentLayer->compositedLayerMapping()->par entForSublayers(); 989 GraphicsLayer* hostingLayer = parentLayer->compositedLayerMapping()->par entForSublayers();
993 GraphicsLayer* hostedLayer = childLayer->compositedLayerMapping()->child ForSuperlayers(); 990 GraphicsLayer* hostedLayer = childLayer->compositedLayerMapping()->child ForSuperlayers();
994 991
995 hostingLayer->addChild(hostedLayer); 992 hostingLayer->addChild(hostedLayer);
996 } else { 993 } else {
997 childLayer->compositedLayerMapping()->childForSuperlayers()->removeFromP arent(); 994 childLayer->compositedLayerMapping()->childForSuperlayers()->removeFromP arent();
998 } 995 }
(...skipping 26 matching lines...) Expand all
1025 // Used for gathering UMA data about the effect on memory usage of promoting all layers 1022 // Used for gathering UMA data about the effect on memory usage of promoting all layers
1026 // that have a webkit-transition on opacity or transform and intersect the v iewport. 1023 // that have a webkit-transition on opacity or transform and intersect the v iewport.
1027 static double pixelsWithoutPromotingAllTransitions = 0.0; 1024 static double pixelsWithoutPromotingAllTransitions = 0.0;
1028 static double pixelsAddedByPromotingAllTransitions = 0.0; 1025 static double pixelsAddedByPromotingAllTransitions = 0.0;
1029 1026
1030 if (!depth) { 1027 if (!depth) {
1031 pixelsWithoutPromotingAllTransitions = 0.0; 1028 pixelsWithoutPromotingAllTransitions = 0.0;
1032 pixelsAddedByPromotingAllTransitions = 0.0; 1029 pixelsAddedByPromotingAllTransitions = 0.0;
1033 } 1030 }
1034 1031
1035 CompositedLayerMapping* currentCompositedLayerMapping = layer->compositedLay erMapping(); 1032 CompositedLayerMappingPtr currentCompositedLayerMapping = layer->compositedL ayerMapping();
1036 if (currentCompositedLayerMapping) { 1033 if (layer->compositingState() == PaintsIntoOwnBacking) {
1037 // The compositing state of all our children has been updated already, s o now 1034 // The compositing state of all our children has been updated already, s o now
1038 // we can compute and cache the composited bounds for this layer. 1035 // we can compute and cache the composited bounds for this layer.
1039 currentCompositedLayerMapping->updateCompositedBounds(); 1036 currentCompositedLayerMapping->updateCompositedBounds();
1040 1037
1041 if (layer->reflectionInfo()) { 1038 if (layer->reflectionInfo()) {
1042 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLa yer(); 1039 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLa yer();
1043 if (reflectionLayer->compositedLayerMapping()) 1040 if (reflectionLayer->compositingState() == PaintsIntoOwnBacking)
1044 reflectionLayer->compositedLayerMapping()->updateCompositedBound s(); 1041 reflectionLayer->compositedLayerMapping()->updateCompositedBound s();
1045 } 1042 }
1046 1043
1047 currentCompositedLayerMapping->updateGraphicsLayerConfiguration(); 1044 currentCompositedLayerMapping->updateGraphicsLayerConfiguration();
1048 currentCompositedLayerMapping->updateGraphicsLayerGeometry(); 1045 currentCompositedLayerMapping->updateGraphicsLayerGeometry();
1049 1046
1050 if (!layer->parent()) 1047 if (!layer->parent())
1051 updateRootLayerPosition(); 1048 updateRootLayerPosition();
1052 1049
1053 if (currentCompositedLayerMapping->hasUnpositionedOverflowControlsLayers ()) 1050 if (currentCompositedLayerMapping->hasUnpositionedOverflowControlsLayers ())
1054 layer->scrollableArea()->positionOverflowControls(); 1051 layer->scrollableArea()->positionOverflowControls();
1055 1052
1056 pixelsWithoutPromotingAllTransitions += layer->size().height() * layer-> size().width(); 1053 pixelsWithoutPromotingAllTransitions += layer->size().height() * layer-> size().width();
1057 } else { 1054 } else {
1058 if ((layer->renderer()->style()->transitionForProperty(CSSPropertyOpacit y) || 1055 if ((layer->renderer()->style()->transitionForProperty(CSSPropertyOpacit y) ||
1059 layer->renderer()->style()->transitionForProperty(CSSPropertyWebkit Transform)) && 1056 layer->renderer()->style()->transitionForProperty(CSSPropertyWebkit Transform)) &&
1060 m_renderView->viewRect().intersects(layer->absoluteBoundingBox())) 1057 m_renderView->viewRect().intersects(layer->absoluteBoundingBox()))
1061 pixelsAddedByPromotingAllTransitions += layer->size().height() * lay er->size().width(); 1058 pixelsAddedByPromotingAllTransitions += layer->size().height() * lay er->size().width();
1062 } 1059 }
1063 1060
1064 // If this layer has a compositedLayerMapping, then that is where we place s ubsequent children GraphicsLayers. 1061 // If this layer has a compositedLayerMapping, then that is where we place s ubsequent children GraphicsLayers.
1065 // Otherwise children continue to append to the child list of the enclosing layer. 1062 // Otherwise children continue to append to the child list of the enclosing layer.
1066 Vector<GraphicsLayer*> layerChildren; 1063 Vector<GraphicsLayer*> layerChildren;
1067 Vector<GraphicsLayer*>& childList = currentCompositedLayerMapping ? layerChi ldren : childLayersOfEnclosingLayer; 1064 Vector<GraphicsLayer*>& childList = layer->compositingState() != NotComposit ed ? layerChildren : childLayersOfEnclosingLayer;
1068 1065
1069 #if !ASSERT_DISABLED 1066 #if !ASSERT_DISABLED
1070 LayerListMutationDetector mutationChecker(layer->stackingNode()); 1067 LayerListMutationDetector mutationChecker(layer->stackingNode());
1071 #endif 1068 #endif
1072 1069
1073 if (layer->stackingNode()->isStackingContainer()) { 1070 if (layer->stackingNode()->isStackingContainer()) {
1074 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren); 1071 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), Negativ eZOrderChildren);
1075 while (RenderLayerStackingNode* curNode = iterator.next()) 1072 while (RenderLayerStackingNode* curNode = iterator.next())
1076 rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1); 1073 rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1);
1077 1074
1078 // If a negative z-order child is compositing, we get a foreground layer which needs to get parented. 1075 // If a negative z-order child is compositing, we get a foreground layer which needs to get parented.
1079 if (currentCompositedLayerMapping && currentCompositedLayerMapping->fore groundLayer()) 1076 if (layer->compositingState() != NotComposited && currentCompositedLayer Mapping->foregroundLayer())
1080 childList.append(currentCompositedLayerMapping->foregroundLayer()); 1077 childList.append(currentCompositedLayerMapping->foregroundLayer());
1081 } 1078 }
1082 1079
1083 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren); 1080 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), NormalFlowC hildren | PositiveZOrderChildren);
1084 while (RenderLayerStackingNode* curNode = iterator.next()) 1081 while (RenderLayerStackingNode* curNode = iterator.next())
1085 rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1); 1082 rebuildCompositingLayerTree(curNode->layer(), childList, depth + 1);
1086 1083
1087 if (currentCompositedLayerMapping) { 1084 if (layer->compositingState() != NotComposited) {
1088 bool parented = false; 1085 bool parented = false;
1089 if (layer->renderer()->isRenderPart()) 1086 if (layer->renderer()->isRenderPart())
1090 parented = parentFrameContentLayers(toRenderPart(layer->renderer())) ; 1087 parented = parentFrameContentLayers(toRenderPart(layer->renderer())) ;
1091 1088
1092 if (!parented) 1089 if (!parented)
1093 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay erChildren); 1090 currentCompositedLayerMapping->parentForSublayers()->setChildren(lay erChildren);
1094 1091
1095 // If the layer has a clipping layer the overflow controls layers will b e siblings of the clipping layer. 1092 // If the layer has a clipping layer the overflow controls layers will b e siblings of the clipping layer.
1096 // Otherwise, the overflow control layers are normal children. 1093 // Otherwise, the overflow control layers are normal children.
1097 if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompos itedLayerMapping->hasScrollingLayer()) { 1094 if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompos itedLayerMapping->hasScrollingLayer()) {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 return 0; 1257 return 0;
1261 } 1258 }
1262 1259
1263 bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer) 1260 bool RenderLayerCompositor::parentFrameContentLayers(RenderPart* renderer)
1264 { 1261 {
1265 RenderLayerCompositor* innerCompositor = frameContentsCompositor(renderer); 1262 RenderLayerCompositor* innerCompositor = frameContentsCompositor(renderer);
1266 if (!innerCompositor || !innerCompositor->inCompositingMode() || innerCompos itor->rootLayerAttachment() != RootLayerAttachedViaEnclosingFrame) 1263 if (!innerCompositor || !innerCompositor->inCompositingMode() || innerCompos itor->rootLayerAttachment() != RootLayerAttachedViaEnclosingFrame)
1267 return false; 1264 return false;
1268 1265
1269 RenderLayer* layer = renderer->layer(); 1266 RenderLayer* layer = renderer->layer();
1270 if (!layer->compositedLayerMapping()) 1267 if (layer->compositingState() != PaintsIntoOwnBacking)
1271 return false; 1268 return false;
1272 1269
1273 CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerMappi ng(); 1270 CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLayerMap ping();
1274 GraphicsLayer* hostingLayer = compositedLayerMapping->parentForSublayers(); 1271 GraphicsLayer* hostingLayer = compositedLayerMapping->parentForSublayers();
1275 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer(); 1272 GraphicsLayer* rootLayer = innerCompositor->rootGraphicsLayer();
1276 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r ootLayer) { 1273 if (hostingLayer->children().size() != 1 || hostingLayer->children()[0] != r ootLayer) {
1277 hostingLayer->removeAllChildren(); 1274 hostingLayer->removeAllChildren();
1278 hostingLayer->addChild(rootLayer); 1275 hostingLayer->addChild(rootLayer);
1279 } 1276 }
1280 return true; 1277 return true;
1281 } 1278 }
1282 1279
1283 // This just updates layer geometry without changing the hierarchy. 1280 // This just updates layer geometry without changing the hierarchy.
1284 void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer) 1281 void RenderLayerCompositor::updateLayerTreeGeometry(RenderLayer* layer)
1285 { 1282 {
1286 if (CompositedLayerMapping* compositedLayerMapping = layer->compositedLayerM apping()) { 1283 if (layer->compositingState() == PaintsIntoOwnBacking) {
1284 CompositedLayerMappingPtr compositedLayerMapping = layer->compositedLaye rMapping();
1287 // The compositing state of all our children has been updated already, s o now 1285 // The compositing state of all our children has been updated already, s o now
1288 // we can compute and cache the composited bounds for this layer. 1286 // we can compute and cache the composited bounds for this layer.
1289 compositedLayerMapping->updateCompositedBounds(); 1287 compositedLayerMapping->updateCompositedBounds();
1290 1288
1291 if (layer->reflectionInfo()) { 1289 if (layer->reflectionInfo()) {
1292 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLa yer(); 1290 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflectionLa yer();
1293 if (reflectionLayer->compositedLayerMapping()) 1291 if (reflectionLayer->compositingState() == PaintsIntoOwnBacking)
1294 reflectionLayer->compositedLayerMapping()->updateCompositedBound s(); 1292 reflectionLayer->compositedLayerMapping()->updateCompositedBound s();
1295 } 1293 }
1296 1294
1297 compositedLayerMapping->updateGraphicsLayerConfiguration(); 1295 compositedLayerMapping->updateGraphicsLayerConfiguration();
1298 compositedLayerMapping->updateGraphicsLayerGeometry(); 1296 compositedLayerMapping->updateGraphicsLayerGeometry();
1299 1297
1300 if (!layer->parent()) 1298 if (!layer->parent())
1301 updateRootLayerPosition(); 1299 updateRootLayerPosition();
1302 } 1300 }
1303 1301
1304 #if !ASSERT_DISABLED 1302 #if !ASSERT_DISABLED
1305 LayerListMutationDetector mutationChecker(layer->stackingNode()); 1303 LayerListMutationDetector mutationChecker(layer->stackingNode());
1306 #endif 1304 #endif
1307 1305
1308 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren ); 1306 RenderLayerStackingNodeIterator iterator(*layer->stackingNode(), AllChildren );
1309 while (RenderLayerStackingNode* curNode = iterator.next()) 1307 while (RenderLayerStackingNode* curNode = iterator.next())
1310 updateLayerTreeGeometry(curNode->layer()); 1308 updateLayerTreeGeometry(curNode->layer());
1311 } 1309 }
1312 1310
1313 // Recurs down the RenderLayer tree until its finds the compositing descendants of compositingAncestor and updates their geometry. 1311 // Recurs down the RenderLayer tree until its finds the compositing descendants of compositingAncestor and updates their geometry.
1314 void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayerStack ingNode* compositingAncestor, RenderLayer* layer, bool compositedChildrenOnly) 1312 void RenderLayerCompositor::updateCompositingDescendantGeometry(RenderLayerStack ingNode* compositingAncestor, RenderLayer* layer, bool compositedChildrenOnly)
1315 { 1313 {
1316 if (layer->stackingNode() != compositingAncestor) { 1314 if (layer->stackingNode() != compositingAncestor) {
1317 if (CompositedLayerMapping* compositedLayerMapping = layer->compositedLa yerMapping()) { 1315 if (layer->compositingState() == PaintsIntoOwnBacking) {
1316 CompositedLayerMappingPtr compositedLayerMapping = layer->composited LayerMapping();
1318 compositedLayerMapping->updateCompositedBounds(); 1317 compositedLayerMapping->updateCompositedBounds();
1319 1318
1320 if (layer->reflectionInfo()) { 1319 if (layer->reflectionInfo()) {
1321 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflecti onLayer(); 1320 RenderLayer* reflectionLayer = layer->reflectionInfo()->reflecti onLayer();
1322 if (reflectionLayer->compositedLayerMapping()) 1321 if (reflectionLayer->compositingState() == PaintsIntoOwnBacking)
1323 reflectionLayer->compositedLayerMapping()->updateCompositedB ounds(); 1322 reflectionLayer->compositedLayerMapping()->updateCompositedB ounds();
1324 } 1323 }
1325 1324
1326 compositedLayerMapping->updateGraphicsLayerGeometry(); 1325 compositedLayerMapping->updateGraphicsLayerGeometry();
1327 if (compositedChildrenOnly) 1326 if (compositedChildrenOnly)
1328 return; 1327 return;
1329 } 1328 }
1330 } 1329 }
1331 1330
1332 if (layer->reflectionInfo()) 1331 if (layer->reflectionInfo())
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 1412
1414 detachRootLayer(); 1413 detachRootLayer();
1415 } 1414 }
1416 } 1415 }
1417 1416
1418 void RenderLayerCompositor::clearMappingForRenderLayerIncludingDescendants(Rende rLayer* layer) 1417 void RenderLayerCompositor::clearMappingForRenderLayerIncludingDescendants(Rende rLayer* layer)
1419 { 1418 {
1420 if (!layer) 1419 if (!layer)
1421 return; 1420 return;
1422 1421
1423 if (layer->compositedLayerMapping()) { 1422 if (layer->compositingState() == PaintsIntoOwnBacking) {
1424 removeViewportConstrainedLayer(layer); 1423 removeViewportConstrainedLayer(layer);
1425 layer->clearCompositedLayerMapping(); 1424 layer->clearCompositedLayerMapping();
1426 } 1425 }
1427 1426
1428 for (RenderLayer* currLayer = layer->firstChild(); currLayer; currLayer = cu rrLayer->nextSibling()) 1427 for (RenderLayer* currLayer = layer->firstChild(); currLayer; currLayer = cu rrLayer->nextSibling())
1429 clearMappingForRenderLayerIncludingDescendants(currLayer); 1428 clearMappingForRenderLayerIncludingDescendants(currLayer);
1430 } 1429 }
1431 1430
1432 void RenderLayerCompositor::clearMappingForAllRenderLayers() 1431 void RenderLayerCompositor::clearMappingForAllRenderLayers()
1433 { 1432 {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 return directReasons; 1524 return directReasons;
1526 } 1525 }
1527 1526
1528 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips, 1527 // Return true if the given layer has some ancestor in the RenderLayer hierarchy that clips,
1529 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented 1528 // up to the enclosing compositing ancestor. This is required because compositin g layers are parented
1530 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy. 1529 // according to the z-order hierarchy, yet clipping goes down the renderer hiera rchy.
1531 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy, 1530 // Thus, a RenderLayer can be clipped by a RenderLayer that is an ancestor in th e renderer hierarchy,
1532 // but a sibling in the z-order hierarchy. 1531 // but a sibling in the z-order hierarchy.
1533 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const 1532 bool RenderLayerCompositor::clippedByAncestor(const RenderLayer* layer) const
1534 { 1533 {
1535 if (!layer->compositedLayerMapping() || !layer->parent()) 1534 if (layer->compositingState() != PaintsIntoOwnBacking || !layer->parent())
1536 return false; 1535 return false;
1537 1536
1538 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer(); 1537 const RenderLayer* compositingAncestor = layer->ancestorCompositingLayer();
1539 if (!compositingAncestor) 1538 if (!compositingAncestor)
1540 return false; 1539 return false;
1541 1540
1542 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(), 1541 // If the compositingAncestor clips, that will be taken care of by clipsComp ositingDescendants(),
1543 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot), 1542 // so we only care about clipping between its first child that is our ancest or (the computeClipRoot),
1544 // and layer. 1543 // and layer.
1545 const RenderLayer* computeClipRoot = 0; 1544 const RenderLayer* computeClipRoot = 0;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 bool composite = renderer->isEmbeddedObject() && toRenderEmbeddedObject(rend erer)->allowsAcceleratedCompositing(); 1629 bool composite = renderer->isEmbeddedObject() && toRenderEmbeddedObject(rend erer)->allowsAcceleratedCompositing();
1631 if (!composite) 1630 if (!composite)
1632 return false; 1631 return false;
1633 1632
1634 // FIXME: this seems bogus. If we don't know the layout position/size of the plugin yet, would't that be handled elsewhere? 1633 // FIXME: this seems bogus. If we don't know the layout position/size of the plugin yet, would't that be handled elsewhere?
1635 m_needsToRecomputeCompositingRequirements = true; 1634 m_needsToRecomputeCompositingRequirements = true;
1636 1635
1637 RenderWidget* pluginRenderer = toRenderWidget(renderer); 1636 RenderWidget* pluginRenderer = toRenderWidget(renderer);
1638 // If we can't reliably know the size of the plugin yet, don't change compos iting state. 1637 // If we can't reliably know the size of the plugin yet, don't change compos iting state.
1639 if (pluginRenderer->needsLayout()) 1638 if (pluginRenderer->needsLayout())
1640 return pluginRenderer->hasLayer() && pluginRenderer->layer()->composited LayerMapping(); 1639 return pluginRenderer->hasLayer() && pluginRenderer->layer()->compositin gState() != NotComposited;
1641 1640
1642 // Don't go into compositing mode if height or width are zero, or size is 1x 1. 1641 // Don't go into compositing mode if height or width are zero, or size is 1x 1.
1643 IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect()); 1642 IntRect contentBox = pixelSnappedIntRect(pluginRenderer->contentBoxRect());
1644 return contentBox.height() * contentBox.width() > 1; 1643 return contentBox.height() * contentBox.width() > 1;
1645 } 1644 }
1646 1645
1647 bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer) const 1646 bool RenderLayerCompositor::requiresCompositingForFrame(RenderObject* renderer) const
1648 { 1647 {
1649 if (!renderer->isRenderPart()) 1648 if (!renderer->isRenderPart())
1650 return false; 1649 return false;
1651 1650
1652 RenderPart* frameRenderer = toRenderPart(renderer); 1651 RenderPart* frameRenderer = toRenderPart(renderer);
1653 1652
1654 if (!frameRenderer->requiresAcceleratedCompositing()) 1653 if (!frameRenderer->requiresAcceleratedCompositing())
1655 return false; 1654 return false;
1656 1655
1657 // FIXME: this seems bogus. If we don't know the layout position/size of the frame yet, wouldn't that be handled elsehwere? 1656 // FIXME: this seems bogus. If we don't know the layout position/size of the frame yet, wouldn't that be handled elsehwere?
1658 m_needsToRecomputeCompositingRequirements = true; 1657 m_needsToRecomputeCompositingRequirements = true;
1659 1658
1660 RenderLayerCompositor* innerCompositor = frameContentsCompositor(frameRender er); 1659 RenderLayerCompositor* innerCompositor = frameContentsCompositor(frameRender er);
1661 if (!innerCompositor) 1660 if (!innerCompositor)
1662 return false; 1661 return false;
1663 1662
1664 // If we can't reliably know the size of the iframe yet, don't change compos iting state. 1663 // If we can't reliably know the size of the iframe yet, don't change compos iting state.
1665 if (renderer->needsLayout()) 1664 if (renderer->needsLayout())
1666 return frameRenderer->hasLayer() && frameRenderer->layer()->compositedLa yerMapping(); 1665 return frameRenderer->hasLayer() && frameRenderer->layer()->compositingS tate() != NotComposited;
1667 1666
1668 // Don't go into compositing mode if height or width are zero. 1667 // Don't go into compositing mode if height or width are zero.
1669 IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect()); 1668 IntRect contentBox = pixelSnappedIntRect(frameRenderer->contentBoxRect());
1670 return contentBox.height() * contentBox.width() > 0; 1669 return contentBox.height() * contentBox.width() > 0;
1671 } 1670 }
1672 1671
1673 bool RenderLayerCompositor::requiresCompositingForBackfaceVisibilityHidden(Rende rObject* renderer) const 1672 bool RenderLayerCompositor::requiresCompositingForBackfaceVisibilityHidden(Rende rObject* renderer) const
1674 { 1673 {
1675 return canRender3DTransforms() && renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; 1674 return canRender3DTransforms() && renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden;
1676 } 1675 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 1825
1827 if (!hasScrollableAncestor) { 1826 if (!hasScrollableAncestor) {
1828 if (viewportConstrainedNotCompositedReason) 1827 if (viewportConstrainedNotCompositedReason)
1829 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForUnscrollableAncestors; 1828 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForUnscrollableAncestors;
1830 return false; 1829 return false;
1831 } 1830 }
1832 1831
1833 // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done. 1832 // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done.
1834 if (!m_inPostLayoutUpdate) { 1833 if (!m_inPostLayoutUpdate) {
1835 m_needsToRecomputeCompositingRequirements = true; 1834 m_needsToRecomputeCompositingRequirements = true;
1836 return layer->compositedLayerMapping(); 1835 return layer->compositingState() != NotComposited;
1837 } 1836 }
1838 1837
1839 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescend ant(); 1838 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescend ant();
1840 if (!paintsContent) { 1839 if (!paintsContent) {
1841 if (viewportConstrainedNotCompositedReason) 1840 if (viewportConstrainedNotCompositedReason)
1842 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNoVisibleContent; 1841 *viewportConstrainedNotCompositedReason = RenderLayer::NotComposited ForNoVisibleContent;
1843 return false; 1842 return false;
1844 } 1843 }
1845 1844
1846 // Fixed position elements that are invisible in the current view don't get their own layer. 1845 // Fixed position elements that are invisible in the current view don't get their own layer.
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 2311
2313 static bool isRootmostFixedOrStickyLayer(RenderLayer* layer) 2312 static bool isRootmostFixedOrStickyLayer(RenderLayer* layer)
2314 { 2313 {
2315 if (layer->renderer()->isStickyPositioned()) 2314 if (layer->renderer()->isStickyPositioned())
2316 return true; 2315 return true;
2317 2316
2318 if (layer->renderer()->style()->position() != FixedPosition) 2317 if (layer->renderer()->style()->position() != FixedPosition)
2319 return false; 2318 return false;
2320 2319
2321 for (RenderLayerStackingNode* stackingContainerNode = layer->stackingNode()- >ancestorStackingContainerNode(); stackingContainerNode; stackingContainerNode = stackingContainerNode->ancestorStackingContainerNode()) { 2320 for (RenderLayerStackingNode* stackingContainerNode = layer->stackingNode()- >ancestorStackingContainerNode(); stackingContainerNode; stackingContainerNode = stackingContainerNode->ancestorStackingContainerNode()) {
2322 if (stackingContainerNode->layer()->compositedLayerMapping() && stacking ContainerNode->layer()->renderer()->style()->position() == FixedPosition) 2321 if (stackingContainerNode->layer()->compositingState() == PaintsIntoOwnB acking && stackingContainerNode->layer()->renderer()->style()->position() == Fix edPosition)
2323 return false; 2322 return false;
2324 } 2323 }
2325 2324
2326 return true; 2325 return true;
2327 } 2326 }
2328 2327
2329 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer) 2328 void RenderLayerCompositor::updateViewportConstraintStatus(RenderLayer* layer)
2330 { 2329 {
2331 if (isRootmostFixedOrStickyLayer(layer)) 2330 if (isRootmostFixedOrStickyLayer(layer))
2332 addViewportConstrainedLayer(layer); 2331 addViewportConstrainedLayer(layer);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 } else if (graphicsLayer == m_scrollLayer.get()) { 2447 } else if (graphicsLayer == m_scrollLayer.get()) {
2449 name = "Frame Scrolling Layer"; 2448 name = "Frame Scrolling Layer";
2450 } else { 2449 } else {
2451 ASSERT_NOT_REACHED(); 2450 ASSERT_NOT_REACHED();
2452 } 2451 }
2453 2452
2454 return name; 2453 return name;
2455 } 2454 }
2456 2455
2457 } // namespace WebCore 2456 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698