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

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

Issue 2385123003: Rewrap comments to 80 columns in Source/platform/graphics/paint/. (Closed)
Patch Set: Resync Created 4 years, 2 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"
11 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
12 #include "wtf/text/WTFString.h" 12 #include "wtf/text/WTFString.h"
13 13
14 #define CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS DCHECK_IS_ON() 14 #define CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS DCHECK_IS_ON()
15 15
16 namespace blink { 16 namespace blink {
17 17
18 // The class for objects that can be associated with display items. 18 // The class for objects that can be associated with display items. A
19 // A DisplayItemClient object should live at least longer than the document cycl e 19 // DisplayItemClient object should live at least longer than the document cycle
20 // in which its display items are created during painting. 20 // in which its display items are created during painting. After the document
21 // After the document cycle, a pointer/reference to DisplayItemClient should be 21 // cycle, a pointer/reference to DisplayItemClient should be no longer
22 // no longer dereferenced unless we can make sure the client is still valid. 22 // dereferenced unless we can make sure the client is still valid.
23 class PLATFORM_EXPORT DisplayItemClient { 23 class PLATFORM_EXPORT DisplayItemClient {
24 public: 24 public:
25 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 25 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
26 DisplayItemClient(); 26 DisplayItemClient();
27 virtual ~DisplayItemClient(); 27 virtual ~DisplayItemClient();
28 28
29 // Tests if this DisplayItemClient object has been created and has not been de leted yet. 29 // Tests if this DisplayItemClient object has been created and has not been
30 // deleted yet.
30 bool isAlive() const; 31 bool isAlive() const;
31 32
32 // Called when any DisplayItem of this DisplayItemClient is added into PaintCo ntroller 33 // Called when any DisplayItem of this DisplayItemClient is added into
33 // using PaintController::createAndAppend() or into a cached subsequence. 34 // PaintController using PaintController::createAndAppend() or into a cached
35 // subsequence.
34 void beginShouldKeepAlive(const void* owner) const; 36 void beginShouldKeepAlive(const void* owner) const;
35 37
36 // Called when the DisplayItemClient is sure that it can safely die before its owners 38 // Called when the DisplayItemClient is sure that it can safely die before its
37 // have chance to remove it from the aliveness control. 39 // owners have chance to remove it from the aliveness control.
38 void endShouldKeepAlive() const; 40 void endShouldKeepAlive() const;
39 41
40 // Clears all should-keep-alive DisplayItemClients of a PaintController. Calle d after 42 // Clears all should-keep-alive DisplayItemClients of a PaintController.
41 // PaintController commits new display items or the subsequence owner is inval idated. 43 // Called after PaintController commits new display items or the subsequence
44 // owner is invalidated.
42 static void endShouldKeepAliveAllClients(const void* owner); 45 static void endShouldKeepAliveAllClients(const void* owner);
43 static void endShouldKeepAliveAllClients(); 46 static void endShouldKeepAliveAllClients();
44 #else 47 #else
45 virtual ~DisplayItemClient() {} 48 virtual ~DisplayItemClient() {}
46 #endif 49 #endif
47 50
48 virtual String debugName() const = 0; 51 virtual String debugName() const = 0;
49 52
50 // The visual rect of this DisplayItemClient, in object space of the object th at owns the GraphicsLayer, i.e. 53 // The visual rect of this DisplayItemClient, in the object space of the
51 // offset by offsetFromLayoutObjectWithSubpixelAccumulation(). 54 // object that owns the GraphicsLayer, i.e. offset by
55 // offsetFromLayoutObjectWithSubpixelAccumulation().
52 virtual LayoutRect visualRect() const = 0; 56 virtual LayoutRect visualRect() const = 0;
53 57
54 void setDisplayItemsUncached( 58 void setDisplayItemsUncached(
55 PaintInvalidationReason reason = PaintInvalidationFull) const { 59 PaintInvalidationReason reason = PaintInvalidationFull) const {
56 m_cacheGenerationOrInvalidationReason.invalidate(reason); 60 m_cacheGenerationOrInvalidationReason.invalidate(reason);
57 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 61 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
58 // Clear should-keep-alive of DisplayItemClients in a subsequence if this 62 // Clear should-keep-alive of DisplayItemClients in a subsequence if this
59 // object is a subsequence. 63 // object is a subsequence.
60 endShouldKeepAliveAllClients(this); 64 endShouldKeepAliveAllClients(this);
61 #endif 65 #endif
62 } 66 }
63 67
64 PaintInvalidationReason getPaintInvalidationReason() const { 68 PaintInvalidationReason getPaintInvalidationReason() const {
65 return m_cacheGenerationOrInvalidationReason.getPaintInvalidationReason(); 69 return m_cacheGenerationOrInvalidationReason.getPaintInvalidationReason();
66 } 70 }
67 71
68 // A client is considered "just created" if its display items have never been committed. 72 // A client is considered "just created" if its display items have never been
73 // committed.
69 bool isJustCreated() const { 74 bool isJustCreated() const {
70 return m_cacheGenerationOrInvalidationReason.isJustCreated(); 75 return m_cacheGenerationOrInvalidationReason.isJustCreated();
71 } 76 }
72 void clearIsJustCreated() const { 77 void clearIsJustCreated() const {
73 m_cacheGenerationOrInvalidationReason.clearIsJustCreated(); 78 m_cacheGenerationOrInvalidationReason.clearIsJustCreated();
74 } 79 }
75 80
76 private: 81 private:
77 friend class FakeDisplayItemClient; 82 friend class FakeDisplayItemClient;
78 friend class PaintController; 83 friend class PaintController;
79 84
80 // Holds a unique cache generation id of DisplayItemClients and PaintControlle rs, 85 // Holds a unique cache generation id of DisplayItemClients and
81 // or PaintInvalidationReason if the DisplayItemClient or PaintController is 86 // PaintControllers, or PaintInvalidationReason if the DisplayItemClient or
82 // invalidated. 87 // PaintController is invalidated.
83 // 88 //
84 // A paint controller sets its cache generation to DisplayItemCacheGeneration: :next() 89 // A paint controller sets its cache generation to
85 // at the end of each commitNewDisplayItems, and updates the cache generation of each 90 // DisplayItemCacheGeneration::next() at the end of each
86 // client with cached drawings by calling DisplayItemClient::setDisplayItemsCa ched(). 91 // commitNewDisplayItems, and updates the cache generation of each client with
87 // A display item is treated as validly cached in a paint controller if its ca che generation 92 // cached drawings by calling DisplayItemClient::setDisplayItemsCached(). A
88 // matches the paint controller's cache generation. 93 // display item is treated as validly cached in a paint controller if its
94 // cache generation matches the paint controller's cache generation.
89 // 95 //
90 // SPv1 only: If a display item is painted on multiple paint controllers, beca use cache 96 // SPv1 only: If a display item is painted on multiple paint controllers,
91 // generations are unique, the client's cache generation matches the last pain t controller 97 // because cache generations are unique, the client's cache generation matches
92 // only. The client will be treated as invalid on other paint controllers rega rdless if 98 // the last paint controller only. The client will be treated as invalid on
93 // it's validly cached by these paint controllers. The situation is very rare (about 0.07% 99 // other paint controllers regardless if it's validly cached by these paint
94 // clients were painted on multiple paint controllers) so the performance pena lty is trivial. 100 // controllers. This situation is very rare (about 0.07% of clients were
101 // painted on multiple paint controllers) so the performance penalty is
102 // trivial.
95 class PLATFORM_EXPORT CacheGenerationOrInvalidationReason { 103 class PLATFORM_EXPORT CacheGenerationOrInvalidationReason {
96 DISALLOW_NEW(); 104 DISALLOW_NEW();
97 105
98 public: 106 public:
99 CacheGenerationOrInvalidationReason() : m_value(kJustCreated) {} 107 CacheGenerationOrInvalidationReason() : m_value(kJustCreated) {}
100 108
101 void invalidate(PaintInvalidationReason reason = PaintInvalidationFull) { 109 void invalidate(PaintInvalidationReason reason = PaintInvalidationFull) {
102 if (m_value != kJustCreated) 110 if (m_value != kJustCreated)
103 m_value = static_cast<ValueType>(reason); 111 m_value = static_cast<ValueType>(reason);
104 } 112 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return &client1 == &client2; 164 return &client1 == &client2;
157 } 165 }
158 inline bool operator!=(const DisplayItemClient& client1, 166 inline bool operator!=(const DisplayItemClient& client1,
159 const DisplayItemClient& client2) { 167 const DisplayItemClient& client2) {
160 return &client1 != &client2; 168 return &client1 != &client2;
161 } 169 }
162 170
163 } // namespace blink 171 } // namespace blink
164 172
165 #endif // DisplayItemClient_h 173 #endif // DisplayItemClient_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698