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

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

Issue 2698673007: Only create PaintChunks at drawing and foreignLayer boundaries (Closed)
Patch Set: Great expectations Created 3 years, 10 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 PaintChunker_h 5 #ifndef PaintChunker_h
6 #define PaintChunker_h 6 #define PaintChunker_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 "platform/graphics/paint/PaintChunk.h" 10 #include "platform/graphics/paint/PaintChunk.h"
11 #include "platform/graphics/paint/PaintChunkProperties.h" 11 #include "platform/graphics/paint/PaintChunkProperties.h"
12 #include "wtf/Allocator.h" 12 #include "wtf/Allocator.h"
13 #include "wtf/Noncopyable.h" 13 #include "wtf/Noncopyable.h"
14 #include "wtf/Vector.h" 14 #include "wtf/Vector.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 // Accepts information about changes to |PaintChunkProperties| as drawings are 18 // Accepts information about changes to |PaintChunkProperties| as drawings and
19 // accumulated, and produces a series of paint chunks: contiguous ranges of the 19 // foreign layers [1] are accumulated, and produces a series of paint chunks:
20 // display list with identical |PaintChunkProperties|. 20 // contiguous ranges of the display list with identical |PaintChunkProperties|.
21 //
22 // [1] Only drawings and foreign layers are used for compositing (i.e., other
23 // display item types are ignored by PaintArtifactCompositor), so other types
24 // do not create paint chunks as an optimization (see: canBeginOrEndChunk).
21 class PLATFORM_EXPORT PaintChunker final { 25 class PLATFORM_EXPORT PaintChunker final {
22 DISALLOW_NEW(); 26 DISALLOW_NEW();
23 WTF_MAKE_NONCOPYABLE(PaintChunker); 27 WTF_MAKE_NONCOPYABLE(PaintChunker);
24 28
25 public: 29 public:
26 PaintChunker(); 30 PaintChunker();
27 ~PaintChunker(); 31 ~PaintChunker();
28 32
29 bool isInInitialState() const { 33 bool isInInitialState() const {
30 return m_chunks.isEmpty() && m_currentProperties == PaintChunkProperties(); 34 return m_chunks.isEmpty() &&
35 m_currentProperties == PaintChunkProperties() &&
36 m_skippedItemsSinceLastChunk == 0;
31 } 37 }
32 38
33 const PaintChunkProperties& currentPaintChunkProperties() const { 39 const PaintChunkProperties& currentPaintChunkProperties() const {
34 return m_currentProperties; 40 return m_currentProperties;
35 } 41 }
36 void updateCurrentPaintChunkProperties(const PaintChunk::Id*, 42 void updateCurrentPaintChunkProperties(const PaintChunk::Id*,
37 const PaintChunkProperties&); 43 const PaintChunkProperties&);
38 44
39 // Returns true if a new chunk is created. 45 // Returns true if a new chunk is created.
40 bool incrementDisplayItemIndex(const DisplayItem&); 46 bool incrementDisplayItemIndex(const DisplayItem&);
41 // Returns true if the last chunk is removed. 47 // Returns true if the last chunk is removed.
42 bool decrementDisplayItemIndex(); 48 bool decrementDisplayItemIndex();
43 49
50 // Paint chunks are only created/ended at drawing and foreign layer boundaries
51 // with all other types being skipped (see: m_skippedItemsSinceLastChunk).
52 static bool canBeginOrEndChunk(const DisplayItem& item) {
53 return DisplayItem::isDrawingType(item.getType()) ||
54 DisplayItem::isForeignLayerType(item.getType());
55 }
56
44 PaintChunk& paintChunkAt(size_t i) { return m_chunks[i]; } 57 PaintChunk& paintChunkAt(size_t i) { return m_chunks[i]; }
45 size_t lastChunkIndex() const { 58 size_t lastChunkIndex() const {
46 return m_chunks.isEmpty() ? kNotFound : m_chunks.size() - 1; 59 return m_chunks.isEmpty() ? kNotFound : m_chunks.size() - 1;
47 } 60 }
48 PaintChunk& lastChunk() { return m_chunks.back(); } 61 PaintChunk& lastChunk() { return m_chunks.back(); }
49 62
50 PaintChunk& findChunkByDisplayItemIndex(size_t index) { 63 PaintChunk& findChunkByDisplayItemIndex(size_t index) {
51 auto chunk = findChunkInVectorByDisplayItemIndex(m_chunks, index); 64 auto chunk = findChunkInVectorByDisplayItemIndex(m_chunks, index);
52 DCHECK(chunk != m_chunks.end()); 65 DCHECK(chunk != m_chunks.end());
53 return *chunk; 66 return *chunk;
(...skipping 11 matching lines...) Expand all
65 DefaultBehavior = 0, 78 DefaultBehavior = 0,
66 79
67 // Item requires its own paint chunk. 80 // Item requires its own paint chunk.
68 RequiresSeparateChunk, 81 RequiresSeparateChunk,
69 }; 82 };
70 83
71 Vector<PaintChunk> m_chunks; 84 Vector<PaintChunk> m_chunks;
72 Vector<ItemBehavior> m_chunkBehavior; 85 Vector<ItemBehavior> m_chunkBehavior;
73 Optional<PaintChunk::Id> m_currentChunkId; 86 Optional<PaintChunk::Id> m_currentChunkId;
74 PaintChunkProperties m_currentProperties; 87 PaintChunkProperties m_currentProperties;
88 size_t m_skippedItemsSinceLastChunk;
75 }; 89 };
76 90
77 } // namespace blink 91 } // namespace blink
78 92
79 #endif // PaintChunker_h 93 #endif // PaintChunker_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698