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

Side by Side Diff: sky/engine/core/rendering/RenderLayer.cpp

Issue 768493002: Get rid of CompositingState. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix incorrect case. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 { 524 {
525 if (stackingNode()->isNormalFlowOnly()) 525 if (stackingNode()->isNormalFlowOnly())
526 return parent(); 526 return parent();
527 if (RenderLayerStackingNode* ancestorStackingNode = stackingNode()->ancestor StackingContextNode()) 527 if (RenderLayerStackingNode* ancestorStackingNode = stackingNode()->ancestor StackingContextNode())
528 return ancestorStackingNode->layer(); 528 return ancestorStackingNode->layer();
529 return 0; 529 return 0;
530 } 530 }
531 531
532 bool RenderLayer::isPaintInvalidationContainer() const 532 bool RenderLayer::isPaintInvalidationContainer() const
533 { 533 {
534 return compositingState() == PaintsIntoOwnBacking || compositingState() == P aintsIntoGroupedBacking; 534 // FIXME(sky): Remove
535 return false;
535 } 536 }
536 537
537 // Note: enclosingCompositingLayer does not include squashed layers. Compositing stacking children of squashed layers 538 // Note: enclosingCompositingLayer does not include squashed layers. Compositing stacking children of squashed layers
538 // receive graphics layers that are parented to the compositing ancestor of the squashed layer. 539 // receive graphics layers that are parented to the compositing ancestor of the squashed layer.
539 RenderLayer* RenderLayer::enclosingLayerWithCompositedLayerMapping(IncludeSelfOr Not includeSelf) const 540 RenderLayer* RenderLayer::enclosingLayerWithCompositedLayerMapping(IncludeSelfOr Not includeSelf) const
540 { 541 {
541 // FIXME(sky): Remove 542 // FIXME(sky): Remove
542 return 0; 543 return 0;
543 } 544 }
544 545
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 return oldChild; 791 return oldChild;
791 } 792 }
792 793
793 void RenderLayer::removeOnlyThisLayer() 794 void RenderLayer::removeOnlyThisLayer()
794 { 795 {
795 if (!m_parent) 796 if (!m_parent)
796 return; 797 return;
797 798
798 m_clipper.clearClipRectsIncludingDescendants(); 799 m_clipper.clearClipRectsIncludingDescendants();
799 800
800 // For querying RenderLayer::compositingState()
801 // Eager invalidation here is correct, since we are invalidating with respec t to the previous frame's
802 // compositing state when removing the layer.
803 DisableCompositingQueryAsserts disabler;
804 paintInvalidator().paintInvalidationIncludingNonCompositingDescendants(); 801 paintInvalidator().paintInvalidationIncludingNonCompositingDescendants();
805 802
806 RenderLayer* nextSib = nextSibling(); 803 RenderLayer* nextSib = nextSibling();
807 804
808 // Now walk our kids and reattach them to our parent. 805 // Now walk our kids and reattach them to our parent.
809 RenderLayer* current = m_first; 806 RenderLayer* current = m_first;
810 while (current) { 807 while (current) {
811 RenderLayer* next = current->nextSibling(); 808 RenderLayer* next = current->nextSibling();
812 removeChild(current); 809 removeChild(current);
813 m_parent->addChild(current, nextSib); 810 m_parent->addChild(current, nextSib);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 930 }
934 931
935 bool RenderLayer::hasOverflowControls() const 932 bool RenderLayer::hasOverflowControls() const
936 { 933 {
937 return m_scrollableArea && m_scrollableArea->hasScrollbar(); 934 return m_scrollableArea && m_scrollableArea->hasScrollbar();
938 } 935 }
939 936
940 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot, PaintLayerFlags paintFl ags) 937 void RenderLayer::paint(GraphicsContext* context, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot, PaintLayerFlags paintFl ags)
941 { 938 {
942 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot); 939 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot);
943 if (shouldPaintLayerInSoftwareMode(paintingInfo, paintFlags)) 940 paintLayer(context, paintingInfo, paintFlags);
944 paintLayer(context, paintingInfo, paintFlags);
945 } 941 }
946 942
947 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutR ect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot) 943 void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutR ect& damageRect, PaintBehavior paintBehavior, RenderObject* paintingRoot)
948 { 944 {
949 if (!m_containsDirtyOverlayScrollbars) 945 if (!m_containsDirtyOverlayScrollbars)
950 return; 946 return;
951 947
952 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot); 948 LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBeha vior, LayoutSize(), paintingRoot);
953 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars); 949 paintLayer(context, paintingInfo, PaintLayerPaintingOverlayScrollbars);
954 950
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 { 1009 {
1014 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC. 1010 // Avoid painting descendants of the root layer when stylesheets haven't loa ded. This eliminates FOUC.
1015 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document 1011 // It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
1016 // will do a full paintInvalidationForWholeRenderer(). 1012 // will do a full paintInvalidationForWholeRenderer().
1017 if (layer->renderer()->document().didLayoutWithPendingStylesheets() && !laye r->isRootLayer() && !layer->renderer()->isDocumentElement()) 1013 if (layer->renderer()->document().didLayoutWithPendingStylesheets() && !laye r->isRootLayer() && !layer->renderer()->isDocumentElement())
1018 return true; 1014 return true;
1019 1015
1020 return false; 1016 return false;
1021 } 1017 }
1022 1018
1023 static bool paintForFixedRootBackground(const RenderLayer* layer, PaintLayerFlag s paintFlags)
1024 {
1025 return layer->renderer()->isDocumentElement() && (paintFlags & PaintLayerPai ntingRootBackgroundOnly);
1026 }
1027
1028 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const RenderObject* renderer) 1019 static ShouldRespectOverflowClip shouldRespectOverflowClip(PaintLayerFlags paint Flags, const RenderObject* renderer)
1029 { 1020 {
1030 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && renderer->hasClipPath())) ? IgnoreOverf lowClip : RespectOverflowClip; 1021 return (paintFlags & PaintLayerPaintingOverflowContents || (paintFlags & Pai ntLayerPaintingChildClippingMaskPhase && renderer->hasClipPath())) ? IgnoreOverf lowClip : RespectOverflowClip;
1031 } 1022 }
1032 1023
1033 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 1024 void RenderLayer::paintLayer(GraphicsContext* context, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
1034 { 1025 {
1035 // https://code.google.com/p/chromium/issues/detail?id=343772
1036 DisableCompositingQueryAsserts disabler;
1037
1038 if (compositingState() != NotComposited) {
1039 if (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers) {
1040 // FIXME: ok, but what about PaintBehaviorFlattenCompositingLayers? That's for printing.
1041 // FIXME: why isn't the code here global, as opposed to being set on each paintLayer() call?
1042 paintFlags |= PaintLayerUncachedClipRects;
1043 }
1044 }
1045
1046 // Non self-painting leaf layers don't need to be painted as their renderer( ) should properly paint itself. 1026 // Non self-painting leaf layers don't need to be painted as their renderer( ) should properly paint itself.
1047 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 1027 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
1048 return; 1028 return;
1049 1029
1050 if (shouldSuppressPaintingLayer(this)) 1030 if (shouldSuppressPaintingLayer(this))
1051 return; 1031 return;
1052 1032
1053 // If this layer is totally invisible then there is nothing to paint. 1033 // If this layer is totally invisible then there is nothing to paint.
1054 if (!renderer()->opacity()) 1034 if (!renderer()->opacity())
1055 return; 1035 return;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 1118
1139 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !renderer()->isRend erView() && !renderer()->isDocumentElement()) 1119 if (paintFlags & PaintLayerPaintingRootBackgroundOnly && !renderer()->isRend erView() && !renderer()->isDocumentElement())
1140 return; 1120 return;
1141 1121
1142 // Ensure our lists are up-to-date. 1122 // Ensure our lists are up-to-date.
1143 m_stackingNode->updateLayerListsIfNeeded(); 1123 m_stackingNode->updateLayerListsIfNeeded();
1144 1124
1145 LayoutPoint offsetFromRoot; 1125 LayoutPoint offsetFromRoot;
1146 convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot); 1126 convertToLayerCoords(paintingInfo.rootLayer, offsetFromRoot);
1147 1127
1148 if (compositingState() == PaintsIntoOwnBacking)
1149 offsetFromRoot.move(subpixelAccumulation());
1150
1151 LayoutRect rootRelativeBounds; 1128 LayoutRect rootRelativeBounds;
1152 bool rootRelativeBoundsComputed = false; 1129 bool rootRelativeBoundsComputed = false;
1153 1130
1154 // Apply clip-path to context. 1131 // Apply clip-path to context.
1155 GraphicsContextStateSaver clipStateSaver(*context, false); 1132 GraphicsContextStateSaver clipStateSaver(*context, false);
1156 RenderStyle* style = renderer()->style(); 1133 RenderStyle* style = renderer()->style();
1157 1134
1158 // Clip-path, like border radius, must not be applied to the contents of a c omposited-scrolling container. 1135 // Clip-path, like border radius, must not be applied to the contents of a c omposited-scrolling container.
1159 // It must, however, still be applied to the mask layer, so that the composi tor can properly mask the 1136 // It must, however, still be applied to the mask layer, so that the composi tor can properly mask the
1160 // scrolling contents and scrollbars. 1137 // scrolling contents and scrollbars.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 stateSaver.save(); 1308 stateSaver.save();
1332 context->concatCTM(transform.toAffineTransform()); 1309 context->concatCTM(transform.toAffineTransform());
1333 } 1310 }
1334 1311
1335 // Now do a paint with the root layer shifted to be us. 1312 // Now do a paint with the root layer shifted to be us.
1336 LayerPaintingInfo transformedPaintingInfo(this, enclosingIntRect(transform.i nverse().mapRect(paintingInfo.paintDirtyRect)), paintingInfo.paintBehavior, 1313 LayerPaintingInfo transformedPaintingInfo(this, enclosingIntRect(transform.i nverse().mapRect(paintingInfo.paintDirtyRect)), paintingInfo.paintBehavior,
1337 adjustedSubPixelAccumulation, paintingInfo.paintingRoot); 1314 adjustedSubPixelAccumulation, paintingInfo.paintingRoot);
1338 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags ); 1315 paintLayerContentsAndReflection(context, transformedPaintingInfo, paintFlags );
1339 } 1316 }
1340 1317
1341 bool RenderLayer::shouldPaintLayerInSoftwareMode(const LayerPaintingInfo& painti ngInfo, PaintLayerFlags paintFlags)
1342 {
1343 DisableCompositingQueryAsserts disabler;
1344
1345 return compositingState() == NotComposited
1346 || compositingState() == HasOwnBackingButPaintsIntoAncestor
1347 || (paintingInfo.paintBehavior & PaintBehaviorFlattenCompositingLayers)
1348 || paintForFixedRootBackground(this, paintFlags);
1349 }
1350
1351 void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte xt, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags) 1318 void RenderLayer::paintChildren(unsigned childrenToVisit, GraphicsContext* conte xt, const LayerPaintingInfo& paintingInfo, PaintLayerFlags paintFlags)
1352 { 1319 {
1353 if (!hasSelfPaintingLayerDescendant()) 1320 if (!hasSelfPaintingLayerDescendant())
1354 return; 1321 return;
1355 1322
1356 #if ENABLE(ASSERT) 1323 #if ENABLE(ASSERT)
1357 LayerListMutationDetector mutationChecker(m_stackingNode.get()); 1324 LayerListMutationDetector mutationChecker(m_stackingNode.get());
1358 #endif 1325 #endif
1359 1326
1360 RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit); 1327 RenderLayerStackingNodeIterator iterator(*m_stackingNode, childrenToVisit);
1361 while (RenderLayerStackingNode* child = iterator.next()) { 1328 while (RenderLayerStackingNode* child = iterator.next()) {
1362 RenderLayer* childLayer = child->layer(); 1329 child->layer()->paintLayer(context, paintingInfo, paintFlags);
1363 // If this RenderLayer should paint into its own backing or a grouped ba cking, that will be done via CompositedLayerMapping::paintContents()
1364 // and CompositedLayerMapping::doPaintTask().
1365 if (!childLayer->shouldPaintLayerInSoftwareMode(paintingInfo, paintFlags ))
1366 continue;
1367
1368 childLayer->paintLayer(context, paintingInfo, paintFlags);
1369 } 1330 }
1370 } 1331 }
1371 1332
1372 void RenderLayer::collectFragments(LayerFragments& fragments, const RenderLayer* rootLayer, const LayoutRect& dirtyRect, 1333 void RenderLayer::collectFragments(LayerFragments& fragments, const RenderLayer* rootLayer, const LayoutRect& dirtyRect,
1373 ClipRectsCacheSlot clipRectsCacheSlot, ShouldRespectOverflowClip respectOver flowClip, const LayoutPoint* offsetFromRoot, 1334 ClipRectsCacheSlot clipRectsCacheSlot, ShouldRespectOverflowClip respectOver flowClip, const LayoutPoint* offsetFromRoot,
1374 const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox) 1335 const LayoutSize& subPixelAccumulation, const LayoutRect* layerBoundingBox)
1375 { 1336 {
1376 // For unpaginated layers, there is only one fragment. 1337 // For unpaginated layers, there is only one fragment.
1377 LayerFragment fragment; 1338 LayerFragment fragment;
1378 ClipRectsContext clipRectsContext(rootLayer, clipRectsCacheSlot, subPixelAcc umulation); 1339 ClipRectsContext clipRectsContext(rootLayer, clipRectsCacheSlot, subPixelAcc umulation);
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 static void expandRectForReflectionAndStackingChildren(const RenderLayer* ancest orLayer, RenderLayer::CalculateBoundsOptions options, LayoutRect& result) 2017 static void expandRectForReflectionAndStackingChildren(const RenderLayer* ancest orLayer, RenderLayer::CalculateBoundsOptions options, LayoutRect& result)
2057 { 2018 {
2058 ASSERT(ancestorLayer->stackingNode()->isStackingContext() || !ancestorLayer- >stackingNode()->hasPositiveZOrderList()); 2019 ASSERT(ancestorLayer->stackingNode()->isStackingContext() || !ancestorLayer- >stackingNode()->hasPositiveZOrderList());
2059 2020
2060 #if ENABLE(ASSERT) 2021 #if ENABLE(ASSERT)
2061 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(ancestorL ayer)->stackingNode()); 2022 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(ancestorL ayer)->stackingNode());
2062 #endif 2023 #endif
2063 2024
2064 RenderLayerStackingNodeIterator iterator(*ancestorLayer->stackingNode(), All Children); 2025 RenderLayerStackingNodeIterator iterator(*ancestorLayer->stackingNode(), All Children);
2065 while (RenderLayerStackingNode* node = iterator.next()) { 2026 while (RenderLayerStackingNode* node = iterator.next()) {
2066 // Here we exclude both directly composited layers and squashing layers
2067 // because those RenderLayers don't paint into the graphics layer
2068 // for this RenderLayer. For example, the bounds of squashed RenderLayer s
2069 // will be included in the computation of the appropriate squashing
2070 // GraphicsLayer.
2071 if (options != RenderLayer::ApplyBoundsChickenEggHacks && node->layer()- >compositingState() != NotComposited)
2072 continue;
2073 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer, opt ions)); 2027 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer, opt ions));
2074 } 2028 }
2075 } 2029 }
2076 2030
2077 LayoutRect RenderLayer::physicalBoundingBoxIncludingReflectionAndStackingChildre n(const RenderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const 2031 LayoutRect RenderLayer::physicalBoundingBoxIncludingReflectionAndStackingChildre n(const RenderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const
2078 { 2032 {
2079 LayoutPoint origin; 2033 LayoutPoint origin;
2080 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); 2034 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin);
2081 2035
2082 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); 2036 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 } 2105 }
2152 2106
2153 bool RenderLayer::clipsCompositingDescendantsWithBorderRadius() const 2107 bool RenderLayer::clipsCompositingDescendantsWithBorderRadius() const
2154 { 2108 {
2155 // FIXME(sky): Remove 2109 // FIXME(sky): Remove
2156 return false; 2110 return false;
2157 } 2111 }
2158 2112
2159 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const 2113 bool RenderLayer::paintsWithTransform(PaintBehavior paintBehavior) const
2160 { 2114 {
2161 return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayer s) || compositingState() != PaintsIntoOwnBacking); 2115 // FIXME(sky): Remove
2116 return transform();
2162 } 2117 }
2163 2118
2164 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const 2119 bool RenderLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
2165 { 2120 {
2166 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) 2121 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
2167 return false; 2122 return false;
2168 2123
2169 if (paintsWithTransparency(PaintBehaviorNormal)) 2124 if (paintsWithTransparency(PaintBehaviorNormal))
2170 return false; 2125 return false;
2171 2126
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2363 } 2318 }
2364 2319
2365 void RenderLayer::filterNeedsPaintInvalidation() 2320 void RenderLayer::filterNeedsPaintInvalidation()
2366 { 2321 {
2367 } 2322 }
2368 2323
2369 void RenderLayer::setShouldDoFullPaintInvalidationIncludingNonCompositingDescend ants() 2324 void RenderLayer::setShouldDoFullPaintInvalidationIncludingNonCompositingDescend ants()
2370 { 2325 {
2371 renderer()->setShouldDoFullPaintInvalidation(true); 2326 renderer()->setShouldDoFullPaintInvalidation(true);
2372 2327
2373 // Disable for reading compositingState() in isPaintInvalidationContainer() below.
2374 DisableCompositingQueryAsserts disabler;
2375
2376 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) { 2328 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) {
2377 if (!child->isPaintInvalidationContainer()) 2329 if (!child->isPaintInvalidationContainer())
2378 child->setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants(); 2330 child->setShouldDoFullPaintInvalidationIncludingNonCompositingDescen dants();
2379 } 2331 }
2380 } 2332 }
2381 2333
2382 DisableCompositingQueryAsserts::DisableCompositingQueryAsserts() 2334 DisableCompositingQueryAsserts::DisableCompositingQueryAsserts()
2383 : m_disabler(gCompositingQueryMode, CompositingQueriesAreAllowed) { } 2335 : m_disabler(gCompositingQueryMode, CompositingQueriesAreAllowed) { }
2384 2336
2385 } // namespace blink 2337 } // namespace blink
(...skipping 10 matching lines...) Expand all
2396 } 2348 }
2397 } 2349 }
2398 2350
2399 void showLayerTree(const blink::RenderObject* renderer) 2351 void showLayerTree(const blink::RenderObject* renderer)
2400 { 2352 {
2401 if (!renderer) 2353 if (!renderer)
2402 return; 2354 return;
2403 showLayerTree(renderer->enclosingLayer()); 2355 showLayerTree(renderer->enclosingLayer());
2404 } 2356 }
2405 #endif 2357 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698