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

Side by Side Diff: Source/core/rendering/compositing/CompositingReasonFinder.cpp

Issue 784453003: Initial scroll-blocks-on compositor integration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove unneeded TODO Created 5 years, 11 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/rendering/compositing/CompositingReasonFinder.h" 6 #include "core/rendering/compositing/CompositingReasonFinder.h"
7 7
8 #include "core/CSSPropertyNames.h" 8 #include "core/CSSPropertyNames.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 bool CompositingReasonFinder::isMainFrame() const 42 bool CompositingReasonFinder::isMainFrame() const
43 { 43 {
44 // FIXME: LocalFrame::isMainFrame() is probably better. 44 // FIXME: LocalFrame::isMainFrame() is probably better.
45 return !m_renderView.document().ownerElement(); 45 return !m_renderView.document().ownerElement();
46 } 46 }
47 47
48 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay er) const 48 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay er) const
49 { 49 {
50 ASSERT(potentialCompositingReasonsFromStyle(layer->renderer()) == layer->pot entialCompositingReasonsFromStyle()); 50 ASSERT(potentialCompositingReasonsFromStyle(layer->renderer()) == layer->pot entialCompositingReasonsFromStyle());
51 CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR easons; 51 CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR easons;
52
53 // Apply optimizations for scroll-blocks-on which require comparing style be tween objects.
54 if ((styleDeterminedDirectCompositingReasons & CompositingReasonScrollBlocks On) && !requiresCompositingForScrollBlocksOn(layer->renderer()))
55 styleDeterminedDirectCompositingReasons &= ~CompositingReasonScrollBlock sOn;
56
52 return styleDeterminedDirectCompositingReasons | nonStyleDeterminedDirectRea sons(layer); 57 return styleDeterminedDirectCompositingReasons | nonStyleDeterminedDirectRea sons(layer);
53 } 58 }
54 59
55 // This information doesn't appear to be incorporated into CompositingReasons. 60 // This information doesn't appear to be incorporated into CompositingReasons.
56 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const 61 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const
57 { 62 {
58 // Need this done first to determine overflow. 63 // Need this done first to determine overflow.
59 ASSERT(!m_renderView.needsLayout()); 64 ASSERT(!m_renderView.needsLayout());
60 if (isMainFrame()) 65 if (isMainFrame())
61 return false; 66 return false;
(...skipping 24 matching lines...) Expand all
86 91
87 if (style->hasInlineTransform()) 92 if (style->hasInlineTransform())
88 reasons |= CompositingReasonInlineTransform; 93 reasons |= CompositingReasonInlineTransform;
89 94
90 if (style->transformStyle3D() == TransformStyle3DPreserve3D) 95 if (style->transformStyle3D() == TransformStyle3DPreserve3D)
91 reasons |= CompositingReasonPreserve3DWith3DDescendants; 96 reasons |= CompositingReasonPreserve3DWith3DDescendants;
92 97
93 if (style->hasPerspective()) 98 if (style->hasPerspective())
94 reasons |= CompositingReasonPerspectiveWith3DDescendants; 99 reasons |= CompositingReasonPerspectiveWith3DDescendants;
95 100
101 if (style->hasScrollBlocksOn() && !renderer->isDocumentElement())
102 reasons |= CompositingReasonScrollBlocksOn;
103
96 // If the implementation of createsGroup changes, we need to be aware of tha t in this part of code. 104 // If the implementation of createsGroup changes, we need to be aware of tha t in this part of code.
97 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->hasFil ter() || style->hasBlendMode()) == renderer->createsGroup()); 105 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->hasFil ter() || style->hasBlendMode()) == renderer->createsGroup());
98 106
99 if (style->hasMask()) 107 if (style->hasMask())
100 reasons |= CompositingReasonMaskWithCompositedDescendants; 108 reasons |= CompositingReasonMaskWithCompositedDescendants;
101 109
102 if (style->hasFilter()) 110 if (style->hasFilter())
103 reasons |= CompositingReasonFilterWithCompositedDescendants; 111 reasons |= CompositingReasonFilterWithCompositedDescendants;
104 112
105 // See RenderLayer::updateTransform for an explanation of why we check both. 113 // See RenderLayer::updateTransform for an explanation of why we check both.
106 if (renderer->hasTransformRelatedProperty() && style->hasTransform()) 114 if (renderer->hasTransformRelatedProperty() && style->hasTransform())
107 reasons |= CompositingReasonTransformWithCompositedDescendants; 115 reasons |= CompositingReasonTransformWithCompositedDescendants;
108 116
109 if (renderer->isTransparent()) 117 if (renderer->isTransparent())
110 reasons |= CompositingReasonOpacityWithCompositedDescendants; 118 reasons |= CompositingReasonOpacityWithCompositedDescendants;
111 119
112 if (style->hasBlendMode()) 120 if (style->hasBlendMode())
113 reasons |= CompositingReasonBlendingWithCompositedDescendants; 121 reasons |= CompositingReasonBlendingWithCompositedDescendants;
114 122
115 if (renderer->hasReflection()) 123 if (renderer->hasReflection())
116 reasons |= CompositingReasonReflectionWithCompositedDescendants; 124 reasons |= CompositingReasonReflectionWithCompositedDescendants;
117 125
118 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); 126 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons));
119 return reasons; 127 return reasons;
120 } 128 }
121 129
122 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend erer) const 130 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend erer) const
123 { 131 {
124 // Note that we ask the renderer if it has a transform, because the style ma y have transforms, 132 // Note that we ask the renderer if it has a transform, because the style ma y have transforms,
125 // but the renderer may be an inline that doesn't suppport them. 133 // but the renderer may be an inline that doesn't support them.
126 return renderer->hasTransformRelatedProperty() && renderer->style()->transfo rm().has3DOperation(); 134 return renderer->hasTransformRelatedProperty() && renderer->style()->transfo rm().has3DOperation();
127 } 135 }
128 136
129 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t RenderLayer* layer) const 137 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t RenderLayer* layer) const
130 { 138 {
131 CompositingReasons directReasons = CompositingReasonNone; 139 CompositingReasons directReasons = CompositingReasonNone;
132 RenderObject* renderer = layer->renderer(); 140 RenderObject* renderer = layer->renderer();
133 141
134 if (hasOverflowScrollTrigger()) { 142 if (hasOverflowScrollTrigger()) {
135 if (layer->clipParent()) 143 if (layer->clipParent())
(...skipping 27 matching lines...) Expand all
163 171
164 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const RenderLa yer* layer) const 172 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const RenderLa yer* layer) const
165 { 173 {
166 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) 174 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger))
167 return false; 175 return false;
168 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. 176 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements.
169 // They will stay fixed wrt the container rather than the enclosing frame. 177 // They will stay fixed wrt the container rather than the enclosing frame.
170 return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollabl e(); 178 return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollabl e();
171 } 179 }
172 180
181 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const RenderO bject* renderer) const
182 {
183 // Note that the other requires* functions run at RenderObject::styleDidChan ge time and so can rely
184 // only on the style of their object. This function runs at CompositingRequ irementsUpdater::update
185 // time, and so can consider the style of other objects.
186 RenderStyle* style = renderer->style();
187
188 // We should only get here by CompositingReasonScrollBlocksOn being a potent ial compositing reason.
189 ASSERT(style->hasScrollBlocksOn() && !renderer->isDocumentElement());
190
191 // scroll-blocks-on style is propagated from the document element to the doc ument.
192 ASSERT(!renderer->isRenderView()
193 || !renderer->document().documentElement()
194 || !renderer->document().documentElement()->renderer()
195 || renderer->document().documentElement()->renderer()->style()->scrollBl ocksOn() == style->scrollBlocksOn());
196
197 // Ensure iframes don't get composited unnecessarily.
198 if (renderer->isRenderView()) {
199 if (const FrameView* parentFrame = toRenderView(renderer)->frameView()-> parentFrameView()) {
200 if (const RenderView* parentRenderer = parentFrame->renderView()) {
Ian Vollick 2015/01/06 04:13:51 I'm a bit confused by this, but I'm sure it's just
Rick Byers 2015/01/08 21:08:11 It's the union of all bits set in the containing b
Ian Vollick 2015/01/09 15:17:33 Got it. Thank you for the detailed comment; it rea
201 // Does this frame contain only blocks-on bits already present i n the parent frame?
skobes 2015/01/07 18:49:24 What happens if we have fewer blocks-on bits than
Rick Byers 2015/01/08 21:08:11 No, see the doc and CC side of the patch. Since t
202 if (!(style->scrollBlocksOn() & ~parentRenderer->style()->scroll BlocksOn()))
203 return false;
204 }
205 }
206 return true;
207 }
208
209 // NOTE: Really I only need a new layer if this object contains additional b its from those
210 // set by all objects in it's containing block chain. Such an optimization would avoid layer
211 // explosion in pathological cases like '*' rules. We could consider tracki ng the current
212 // state in CompositingRequirementsUpdater::update or perhaps just apply som e simpler
213 // optimizations here (like testing only against our direct containing block ).
214
215 return true;
173 } 216 }
217
218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698