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

Side by Side Diff: Source/platform/graphics/paint/DisplayItemList.h

Issue 1160763005: Don't cache reflection drawings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix win (which doesn't pack bool bitfields) Created 5 years, 6 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 #ifndef DisplayItemList_h 5 #ifndef DisplayItemList_h
6 #define DisplayItemList_h 6 #define DisplayItemList_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/graphics/paint/DisplayItem.h" 9 #include "platform/graphics/paint/DisplayItem.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
(...skipping 17 matching lines...) Expand all
28 28
29 // These methods are called during paint invalidation. 29 // These methods are called during paint invalidation.
30 void invalidate(DisplayItemClient); 30 void invalidate(DisplayItemClient);
31 void invalidateAll(); 31 void invalidateAll();
32 32
33 // These methods are called during painting. 33 // These methods are called during painting.
34 void add(WTF::PassOwnPtr<DisplayItem>); 34 void add(WTF::PassOwnPtr<DisplayItem>);
35 void beginScope(DisplayItemClient); 35 void beginScope(DisplayItemClient);
36 void endScope(DisplayItemClient); 36 void endScope(DisplayItemClient);
37 37
38 void beginSkippingCache() { ++m_skippingCacheCount; }
39 void endSkippingCache() { ASSERT(m_skippingCacheCount > 0); --m_skippingCach eCount; }
40 bool skippingCache() const { return m_skippingCacheCount; }
41
38 // Must be called when a painting is finished. 42 // Must be called when a painting is finished.
39 void commitNewDisplayItems(); 43 void commitNewDisplayItems();
40 44
41 // Get the paint list generated after the last painting. 45 // Get the paint list generated after the last painting.
42 const DisplayItems& displayItems() const; 46 const DisplayItems& displayItems() const;
43 47
44 bool clientCacheIsValid(DisplayItemClient) const; 48 bool clientCacheIsValid(DisplayItemClient) const;
45 49
46 // Commits the new display items and plays back the updated display items in to the given context. 50 // Commits the new display items and plays back the updated display items in to the given context.
47 void commitNewDisplayItemsAndReplay(GraphicsContext& context) 51 void commitNewDisplayItemsAndReplay(GraphicsContext& context)
48 { 52 {
49 commitNewDisplayItems(); 53 commitNewDisplayItems();
50 replay(context); 54 replay(context);
51 } 55 }
52 56
53 bool displayItemConstructionIsDisabled() const { return m_constructionDisabl ed; } 57 bool displayItemConstructionIsDisabled() const { return m_constructionDisabl ed; }
54 void setDisplayItemConstructionIsDisabled(const bool disable) { m_constructi onDisabled = disable; } 58 void setDisplayItemConstructionIsDisabled(const bool disable) { m_constructi onDisabled = disable; }
55 59
56 #if ENABLE(ASSERT) 60 #if ENABLE(ASSERT)
57 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); } 61 size_t newDisplayItemsSize() const { return m_newDisplayItems.size(); }
58 #endif 62 #endif
59 63
60 #ifndef NDEBUG 64 #ifndef NDEBUG
61 void showDebugData() const; 65 void showDebugData() const;
62 #endif 66 #endif
63 67
64 protected: 68 protected:
65 DisplayItemList() 69 DisplayItemList()
66 : m_validlyCachedClientsDirty(false) 70 : m_validlyCachedClientsDirty(false)
67 , m_constructionDisabled(false) { } 71 , m_constructionDisabled(false)
72 , m_skippingCacheCount(0) { }
68 73
69 private: 74 private:
70 friend class DisplayItemListTest; 75 friend class DisplayItemListTest;
71 friend class DisplayItemListPaintTest; 76 friend class DisplayItemListPaintTest;
72 friend class LayoutObjectDrawingRecorderTest; 77 friend class LayoutObjectDrawingRecorderTest;
73 78
74 void updateValidlyCachedClientsIfNeeded() const; 79 void updateValidlyCachedClientsIfNeeded() const;
75 80
76 #ifndef NDEBUG 81 #ifndef NDEBUG
77 WTF::String displayItemsAsDebugString(const DisplayItems&) const; 82 WTF::String displayItemsAsDebugString(const DisplayItems&) const;
(...skipping 24 matching lines...) Expand all
102 // It's lazily updated in updateValidlyCachedClientsIfNeeded(). 107 // It's lazily updated in updateValidlyCachedClientsIfNeeded().
103 // FIXME: In the future we can replace this with client-side repaint flags 108 // FIXME: In the future we can replace this with client-side repaint flags
104 // to avoid the cost of building and querying the hash table. 109 // to avoid the cost of building and querying the hash table.
105 mutable HashSet<DisplayItemClient> m_validlyCachedClients; 110 mutable HashSet<DisplayItemClient> m_validlyCachedClients;
106 mutable bool m_validlyCachedClientsDirty; 111 mutable bool m_validlyCachedClientsDirty;
107 112
108 // Allow display item construction to be disabled to isolate the costs of co nstruction 113 // Allow display item construction to be disabled to isolate the costs of co nstruction
109 // in performance metrics. 114 // in performance metrics.
110 bool m_constructionDisabled; 115 bool m_constructionDisabled;
111 116
117 int m_skippingCacheCount;
118
112 // Scope ids are allocated per client to ensure that the ids are stable for non-invalidated 119 // Scope ids are allocated per client to ensure that the ids are stable for non-invalidated
113 // clients between frames, so that we can use the id to match new display it ems to cached 120 // clients between frames, so that we can use the id to match new display it ems to cached
114 // display items. 121 // display items.
115 struct Scope { 122 struct Scope {
116 Scope(DisplayItemClient c, int i) : client(c), id(i) { } 123 Scope(DisplayItemClient c, int i) : client(c), id(i) { }
117 DisplayItemClient client; 124 DisplayItemClient client;
118 int id; 125 int id;
119 }; 126 };
120 typedef HashMap<DisplayItemClient, int> ClientScopeIdMap; 127 typedef HashMap<DisplayItemClient, int> ClientScopeIdMap;
121 ClientScopeIdMap m_clientScopeIdMap; 128 ClientScopeIdMap m_clientScopeIdMap;
122 Vector<Scope> m_scopeStack; 129 Vector<Scope> m_scopeStack;
123 130
124 #if ENABLE(ASSERT) 131 #if ENABLE(ASSERT)
125 // This is used to check duplicated ids during add(). We could also check du ring 132 // This is used to check duplicated ids during add(). We could also check du ring
126 // updatePaintList(), but checking during add() helps developer easily find where 133 // updatePaintList(), but checking during add() helps developer easily find where
127 // the duplicated ids are from. 134 // the duplicated ids are from.
128 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; 135 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient;
129 #endif 136 #endif
130 }; 137 };
131 138
132 } // namespace blink 139 } // namespace blink
133 140
134 #endif // DisplayItemList_h 141 #endif // DisplayItemList_h
OLDNEW
« no previous file with comments | « Source/platform/graphics/paint/DisplayItemCacheSkipper.h ('k') | Source/platform/graphics/paint/DisplayItemList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698