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

Side by Side Diff: sky/engine/core/rendering/compositing/CompositingReasonFinder.cpp

Issue 758843004: Delete most of rendering/compositing. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sky/engine/config.h"
6 #include "sky/engine/core/rendering/compositing/CompositingReasonFinder.h"
7
8 #include "gen/sky/core/CSSPropertyNames.h"
9 #include "sky/engine/core/dom/Document.h"
10 #include "sky/engine/core/frame/FrameView.h"
11 #include "sky/engine/core/frame/Settings.h"
12 #include "sky/engine/core/page/Page.h"
13 #include "sky/engine/core/rendering/RenderView.h"
14 #include "sky/engine/core/rendering/compositing/RenderLayerCompositor.h"
15
16 namespace blink {
17
18 CompositingReasonFinder::CompositingReasonFinder(RenderView& renderView)
19 : m_renderView(renderView)
20 , m_compositingTriggers(static_cast<CompositingTriggerFlags>(AllCompositingT riggers))
21 {
22 updateTriggers();
23 }
24
25 void CompositingReasonFinder::updateTriggers()
26 {
27 m_compositingTriggers = 0;
28
29 Settings& settings = m_renderView.document().page()->settings();
30 if (settings.preferCompositingToLCDTextEnabled()) {
31 m_compositingTriggers |= ScrollableInnerFrameTrigger;
32 m_compositingTriggers |= OverflowScrollTrigger;
33 }
34 }
35
36 bool CompositingReasonFinder::hasOverflowScrollTrigger() const
37 {
38 return m_compositingTriggers & OverflowScrollTrigger;
39 }
40
41 CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* lay er) const
42 {
43 ASSERT(potentialCompositingReasonsFromStyle(layer->renderer()) == layer->pot entialCompositingReasonsFromStyle());
44 CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR easons;
45 return styleDeterminedDirectCompositingReasons | nonStyleDeterminedDirectRea sons(layer);
46 }
47
48 // This information doesn't appear to be incorporated into CompositingReasons.
49 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const
50 {
51 // FIXME(sky)
52 return false;
53 }
54
55 CompositingReasons CompositingReasonFinder::potentialCompositingReasonsFromStyle (RenderObject* renderer) const
56 {
57 CompositingReasons reasons = CompositingReasonNone;
58
59 RenderStyle* style = renderer->style();
60
61 if (requiresCompositingForTransform(renderer))
62 reasons |= CompositingReason3DTransform;
63
64 if (style->backfaceVisibility() == BackfaceVisibilityHidden)
65 reasons |= CompositingReasonBackfaceVisibilityHidden;
66
67 if (requiresCompositingForAnimation(style))
68 reasons |= CompositingReasonActiveAnimation;
69
70 if (style->hasWillChangeCompositingHint() && !style->subtreeWillChangeConten ts())
71 reasons |= CompositingReasonWillChangeCompositingHint;
72
73 if (style->hasInlineTransform())
74 reasons |= CompositingReasonInlineTransform;
75
76 if (style->transformStyle3D() == TransformStyle3DPreserve3D)
77 reasons |= CompositingReasonPreserve3DWith3DDescendants;
78
79 if (style->hasPerspective())
80 reasons |= CompositingReasonPerspectiveWith3DDescendants;
81
82 // If the implementation of createsGroup changes, we need to be aware of tha t in this part of code.
83 ASSERT((renderer->isTransparent() || renderer->hasMask() || renderer->hasFil ter()) == renderer->createsGroup());
84
85 if (style->hasMask())
86 reasons |= CompositingReasonMaskWithCompositedDescendants;
87
88 if (style->hasFilter())
89 reasons |= CompositingReasonFilterWithCompositedDescendants;
90
91 // See RenderLayer::updateTransform for an explanation of why we check both.
92 if (renderer->hasTransform() && style->hasTransform())
93 reasons |= CompositingReasonTransformWithCompositedDescendants;
94
95 if (renderer->isTransparent())
96 reasons |= CompositingReasonOpacityWithCompositedDescendants;
97
98 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons));
99 return reasons;
100 }
101
102 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend erer) const
103 {
104 // Note that we ask the renderer if it has a transform, because the style ma y have transforms,
105 // but the renderer may be an inline that doesn't suppport them.
106 return renderer->hasTransform() && renderer->style()->transform().has3DOpera tion();
107 }
108
109 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t RenderLayer* layer) const
110 {
111 CompositingReasons directReasons = CompositingReasonNone;
112 RenderObject* renderer = layer->renderer();
113
114 if (hasOverflowScrollTrigger()) {
115 if (layer->clipParent())
116 directReasons |= CompositingReasonOutOfFlowClipping;
117
118 if (const RenderLayer* scrollingAncestor = layer->ancestorScrollingLayer ()) {
119 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollPa rent())
120 directReasons |= CompositingReasonOverflowScrollingParent;
121 }
122
123 if (layer->needsCompositedScrolling())
124 directReasons |= CompositingReasonOverflowScrollingTouch;
125 }
126
127 directReasons |= renderer->additionalCompositingReasons();
128
129 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons));
130 return directReasons;
131 }
132
133 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style ) const
134 {
135 if (style->subtreeWillChangeContents())
136 return style->isRunningAnimationOnCompositor();
137
138 return style->shouldCompositeForCurrentAnimations();
139 }
140
141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698