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

Side by Side Diff: sky/engine/core/rendering/style/StyleDifference.h

Issue 851033002: Simplify the paint invalidation bits. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: add one more check 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
« no previous file with comments | « sky/engine/core/rendering/style/RenderStyle.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef SKY_ENGINE_CORE_RENDERING_STYLE_STYLEDIFFERENCE_H_ 5 #ifndef SKY_ENGINE_CORE_RENDERING_STYLE_STYLEDIFFERENCE_H_
6 #define SKY_ENGINE_CORE_RENDERING_STYLE_STYLEDIFFERENCE_H_ 6 #define SKY_ENGINE_CORE_RENDERING_STYLE_STYLEDIFFERENCE_H_
7 7
8 #include "sky/engine/wtf/Assertions.h" 8 #include "sky/engine/wtf/Assertions.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 class StyleDifference { 12 class StyleDifference {
13 public: 13 public:
14 enum PropertyDifference { 14 enum PropertyDifference {
15 TransformChanged = 1 << 0, 15 TransformChanged = 1 << 0,
16 OpacityChanged = 1 << 1, 16 OpacityChanged = 1 << 1,
17 ZIndexChanged = 1 << 2, 17 ZIndexChanged = 1 << 2,
18 FilterChanged = 1 << 3, 18 FilterChanged = 1 << 3,
19 // The object needs to issue paint invalidations if it contains text or properties dependent on color (e.g., border or outline).
20 TextOrColorChanged = 1 << 4,
21 }; 19 };
22 20
23 StyleDifference() 21 StyleDifference()
24 : m_paintInvalidationType(NoPaintInvalidation) 22 : m_needsPaintInvalidation(false)
25 , m_layoutType(NoLayout) 23 , m_layoutType(NoLayout)
26 , m_propertySpecificDifferences(0) 24 , m_propertySpecificDifferences(0)
27 { } 25 { }
28 26
29 bool hasDifference() const { return m_paintInvalidationType || m_layoutType || m_propertySpecificDifferences; } 27 bool needsPaintInvalidation() const { return m_needsPaintInvalidation; }
30 28 void setNeedsPaintInvalidation()
31 bool hasAtMostPropertySpecificDifferences(unsigned propertyDifferences) cons t
32 { 29 {
33 return !m_paintInvalidationType && !m_layoutType && !(m_propertySpecific Differences & ~propertyDifferences); 30 m_needsPaintInvalidation = true;
34 } 31 }
35 32
36 bool needsPaintInvalidation() const { return m_paintInvalidationType != NoPa intInvalidation; }
37 void clearNeedsPaintInvalidation() { m_paintInvalidationType = NoPaintInvali dation; }
38
39 // The object just needs to issue paint invalidations.
40 bool needsPaintInvalidationObject() const { return m_paintInvalidationType = = PaintInvalidationObject; }
41 void setNeedsPaintInvalidationObject()
42 {
43 ASSERT(!needsPaintInvalidationLayer());
44 m_paintInvalidationType = PaintInvalidationObject;
45 }
46
47 // The layer and its descendant layers need to issue paint invalidations.
48 bool needsPaintInvalidationLayer() const { return m_paintInvalidationType == PaintInvalidationLayer; }
49 void setNeedsPaintInvalidationLayer() { m_paintInvalidationType = PaintInval idationLayer; }
50
51 bool needsLayout() const { return m_layoutType != NoLayout; } 33 bool needsLayout() const { return m_layoutType != NoLayout; }
52 void clearNeedsLayout() { m_layoutType = NoLayout; } 34 void clearNeedsLayout() { m_layoutType = NoLayout; }
53 35
54 // The offset of this positioned object has been updated. 36 // The offset of this positioned object has been updated.
55 bool needsPositionedMovementLayout() const { return m_layoutType == Position edMovement; } 37 bool needsPositionedMovementLayout() const { return m_layoutType == Position edMovement; }
56 void setNeedsPositionedMovementLayout() 38 void setNeedsPositionedMovementLayout()
57 { 39 {
58 ASSERT(!needsFullLayout()); 40 ASSERT(!needsFullLayout());
59 m_layoutType = PositionedMovement; 41 m_layoutType = PositionedMovement;
60 } 42 }
61 43
62 bool needsFullLayout() const { return m_layoutType == FullLayout; } 44 bool needsFullLayout() const { return m_layoutType == FullLayout; }
63 void setNeedsFullLayout() { m_layoutType = FullLayout; } 45 void setNeedsFullLayout() { m_layoutType = FullLayout; }
64 46
65 bool transformChanged() const { return m_propertySpecificDifferences & Trans formChanged; } 47 bool transformChanged() const { return m_propertySpecificDifferences & Trans formChanged; }
66 void setTransformChanged() { m_propertySpecificDifferences |= TransformChang ed; } 48 void setTransformChanged() { m_propertySpecificDifferences |= TransformChang ed; }
67 49
68 bool opacityChanged() const { return m_propertySpecificDifferences & Opacity Changed; } 50 bool opacityChanged() const { return m_propertySpecificDifferences & Opacity Changed; }
69 void setOpacityChanged() { m_propertySpecificDifferences |= OpacityChanged; } 51 void setOpacityChanged() { m_propertySpecificDifferences |= OpacityChanged; }
70 52
71 bool zIndexChanged() const { return m_propertySpecificDifferences & ZIndexCh anged; } 53 bool zIndexChanged() const { return m_propertySpecificDifferences & ZIndexCh anged; }
72 void setZIndexChanged() { m_propertySpecificDifferences |= ZIndexChanged; } 54 void setZIndexChanged() { m_propertySpecificDifferences |= ZIndexChanged; }
73 55
74 bool filterChanged() const { return m_propertySpecificDifferences & FilterCh anged; } 56 bool filterChanged() const { return m_propertySpecificDifferences & FilterCh anged; }
75 void setFilterChanged() { m_propertySpecificDifferences |= FilterChanged; } 57 void setFilterChanged() { m_propertySpecificDifferences |= FilterChanged; }
76 58
77 bool textOrColorChanged() const { return m_propertySpecificDifferences & Tex tOrColorChanged; }
78 void setTextOrColorChanged() { m_propertySpecificDifferences |= TextOrColorC hanged; }
79
80 private: 59 private:
81 enum PaintInvalidationType { 60 unsigned m_needsPaintInvalidation : 1;
82 NoPaintInvalidation = 0,
83 PaintInvalidationObject,
84 PaintInvalidationLayer
85 };
86 unsigned m_paintInvalidationType : 2;
87 61
88 enum LayoutType { 62 enum LayoutType {
89 NoLayout = 0, 63 NoLayout = 0,
90 PositionedMovement, 64 PositionedMovement,
91 FullLayout 65 FullLayout
92 }; 66 };
93 unsigned m_layoutType : 2; 67 unsigned m_layoutType : 2;
94 68
95 unsigned m_propertySpecificDifferences : 5; 69 unsigned m_propertySpecificDifferences : 5;
96 }; 70 };
97 71
98 } // namespace blink 72 } // namespace blink
99 73
100 #endif // SKY_ENGINE_CORE_RENDERING_STYLE_STYLEDIFFERENCE_H_ 74 #endif // SKY_ENGINE_CORE_RENDERING_STYLE_STYLEDIFFERENCE_H_
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/style/RenderStyle.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698