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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.h

Issue 2116693002: PaintChunk::id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CommitOnTheWay
Patch Set: Give PaintChunks ids Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 DisplayItemClient_h 5 #ifndef DisplayItemClient_h
6 #define DisplayItemClient_h 6 #define DisplayItemClient_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/geometry/LayoutRect.h" 9 #include "platform/geometry/LayoutRect.h"
10 #include "platform/graphics/PaintInvalidationReason.h" 10 #include "platform/graphics/PaintInvalidationReason.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 m_cacheGenerationOrInvalidationReason.invalidate(reason); 56 m_cacheGenerationOrInvalidationReason.invalidate(reason);
57 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 57 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
58 // Clear should-keep-alive of DisplayItemClients in a subsequence if thi s 58 // Clear should-keep-alive of DisplayItemClients in a subsequence if thi s
59 // object is a subsequence. 59 // object is a subsequence.
60 endShouldKeepAliveAllClients(this); 60 endShouldKeepAliveAllClients(this);
61 #endif 61 #endif
62 } 62 }
63 63
64 PaintInvalidationReason getPaintInvalidationReason() const { return m_cacheG enerationOrInvalidationReason.getPaintInvalidationReason(); } 64 PaintInvalidationReason getPaintInvalidationReason() const { return m_cacheG enerationOrInvalidationReason.getPaintInvalidationReason(); }
65 65
66 bool isJustCreated() const { return m_cacheGenerationOrInvalidationReason.is JustCreated(); }
67
66 private: 68 private:
67 friend class PaintController; 69 friend class PaintController;
68 70
69 // Holds a unique cache generation id of DisplayItemClients and PaintControl lers, 71 // Holds a unique cache generation id of DisplayItemClients and PaintControl lers,
70 // or PaintInvalidationReason if the DisplayItemClient or PaintController is 72 // or PaintInvalidationReason if the DisplayItemClient or PaintController is
71 // invalidated. 73 // invalidated.
72 // 74 //
73 // A paint controller sets its cache generation to DisplayItemCacheGeneratio n::next() 75 // A paint controller sets its cache generation to DisplayItemCacheGeneratio n::next()
74 // at the end of each commitNewDisplayItems, and updates the cache generatio n of each 76 // at the end of each commitNewDisplayItems, and updates the cache generatio n of each
75 // client with cached drawings by calling DisplayItemClient::setDisplayItems Cached(). 77 // client with cached drawings by calling DisplayItemClient::setDisplayItems Cached().
76 // A display item is treated as validly cached in a paint controller if its cache generation 78 // A display item is treated as validly cached in a paint controller if its cache generation
77 // matches the paint controller's cache generation. 79 // matches the paint controller's cache generation.
78 // 80 //
79 // SPv1 only: If a display item is painted on multiple paint controllers, be cause cache 81 // SPv1 only: If a display item is painted on multiple paint controllers, be cause cache
80 // generations are unique, the client's cache generation matches the last pa int controller 82 // generations are unique, the client's cache generation matches the last pa int controller
81 // only. The client will be treated as invalid on other paint controllers re gardless if 83 // only. The client will be treated as invalid on other paint controllers re gardless if
82 // it's validly cached by these paint controllers. The situation is very rar e (about 0.07% 84 // it's validly cached by these paint controllers. The situation is very rar e (about 0.07%
83 // clients were painted on multiple paint controllers) so the performance pe nalty is trivial. 85 // clients were painted on multiple paint controllers) so the performance pe nalty is trivial.
84 class CacheGenerationOrInvalidationReason { 86 class CacheGenerationOrInvalidationReason {
85 DISALLOW_NEW(); 87 DISALLOW_NEW();
86 public: 88 public:
87 CacheGenerationOrInvalidationReason() { invalidate(); } 89 CacheGenerationOrInvalidationReason() : m_value(kJustCreated) { }
88 90
89 void invalidate(PaintInvalidationReason reason = PaintInvalidationFull) { m_value = static_cast<ValueType>(reason); } 91 void invalidate(PaintInvalidationReason reason = PaintInvalidationFull) { m_value = static_cast<ValueType>(reason); }
90 92
91 static CacheGenerationOrInvalidationReason next() 93 static CacheGenerationOrInvalidationReason next()
92 { 94 {
93 // In case the value overflowed in the previous call. 95 // In case the value overflowed in the previous call.
94 if (s_nextGeneration < kFirstValidGeneration) 96 if (s_nextGeneration < kFirstValidGeneration)
95 s_nextGeneration = kFirstValidGeneration; 97 s_nextGeneration = kFirstValidGeneration;
96 return CacheGenerationOrInvalidationReason(s_nextGeneration++); 98 return CacheGenerationOrInvalidationReason(s_nextGeneration++);
97 } 99 }
98 100
99 bool matches(const CacheGenerationOrInvalidationReason& other) const 101 bool matches(const CacheGenerationOrInvalidationReason& other) const
100 { 102 {
101 return m_value >= kFirstValidGeneration && other.m_value >= kFirstVa lidGeneration && m_value == other.m_value; 103 return m_value >= kFirstValidGeneration && other.m_value >= kFirstVa lidGeneration && m_value == other.m_value;
102 } 104 }
103 105
104 PaintInvalidationReason getPaintInvalidationReason() const 106 PaintInvalidationReason getPaintInvalidationReason() const
105 { 107 {
106 return m_value < kFirstValidGeneration ? static_cast<PaintInvalidati onReason>(m_value) : PaintInvalidationNone; 108 return m_value < kJustCreated ? static_cast<PaintInvalidationReason> (m_value) : PaintInvalidationNone;
107 } 109 }
108 110
111 bool isJustCreated() const { return m_value == kJustCreated; }
112
109 private: 113 private:
110 typedef uint32_t ValueType; 114 typedef uint32_t ValueType;
111 explicit CacheGenerationOrInvalidationReason(ValueType value) : m_value( value) { } 115 explicit CacheGenerationOrInvalidationReason(ValueType value) : m_value( value) { }
112 116
113 static const ValueType kFirstValidGeneration = static_cast<ValueType>(Pa intInvalidationReasonMax) + 1; 117 static const ValueType kJustCreated = static_cast<ValueType>(PaintInvali dationReasonMax) + 1;
118 static const ValueType kFirstValidGeneration = static_cast<ValueType>(Pa intInvalidationReasonMax) + 2;
114 static ValueType s_nextGeneration; 119 static ValueType s_nextGeneration;
115 ValueType m_value; 120 ValueType m_value;
116 }; 121 };
117 122
118 bool displayItemsAreCached(CacheGenerationOrInvalidationReason other) const { return m_cacheGenerationOrInvalidationReason.matches(other); } 123 bool displayItemsAreCached(CacheGenerationOrInvalidationReason other) const { return m_cacheGenerationOrInvalidationReason.matches(other); }
119 void setDisplayItemsCached(CacheGenerationOrInvalidationReason cacheGenerati on) const { m_cacheGenerationOrInvalidationReason = cacheGeneration; } 124 void setDisplayItemsCached(CacheGenerationOrInvalidationReason cacheGenerati on) const { m_cacheGenerationOrInvalidationReason = cacheGeneration; }
120 125
121 mutable CacheGenerationOrInvalidationReason m_cacheGenerationOrInvalidationR eason; 126 mutable CacheGenerationOrInvalidationReason m_cacheGenerationOrInvalidationR eason;
122 }; 127 };
123 128
124 inline bool operator==(const DisplayItemClient& client1, const DisplayItemClient & client2) { return &client1 == &client2; } 129 inline bool operator==(const DisplayItemClient& client1, const DisplayItemClient & client2) { return &client1 == &client2; }
125 inline bool operator!=(const DisplayItemClient& client1, const DisplayItemClient & client2) { return &client1 != &client2; } 130 inline bool operator!=(const DisplayItemClient& client1, const DisplayItemClient & client2) { return &client1 != &client2; }
126 131
127 } // namespace blink 132 } // namespace blink
128 133
129 #endif // DisplayItemClient_h 134 #endif // DisplayItemClient_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698