OLD | NEW |
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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // Returns true if a new chunk is created. | 33 // Returns true if a new chunk is created. |
34 bool incrementDisplayItemIndex(const DisplayItem&); | 34 bool incrementDisplayItemIndex(const DisplayItem&); |
35 // Returns true if the last chunk is removed. | 35 // Returns true if the last chunk is removed. |
36 bool decrementDisplayItemIndex(); | 36 bool decrementDisplayItemIndex(); |
37 | 37 |
38 PaintChunk& paintChunkAt(size_t i) { return m_chunks[i]; } | 38 PaintChunk& paintChunkAt(size_t i) { return m_chunks[i]; } |
39 size_t lastChunkIndex() const { return m_chunks.isEmpty() ? kNotFound : m_ch
unks.size() - 1; } | 39 size_t lastChunkIndex() const { return m_chunks.isEmpty() ? kNotFound : m_ch
unks.size() - 1; } |
40 PaintChunk& lastChunk() { return m_chunks.last(); } | 40 PaintChunk& lastChunk() { return m_chunks.last(); } |
41 | 41 |
| 42 PaintChunk& findChunkByDisplayItemIndex(size_t index) |
| 43 { |
| 44 auto chunk = findChunkInVectorByDisplayItemIndex(m_chunks, index); |
| 45 DCHECK(chunk != m_chunks.end()); |
| 46 return *chunk; |
| 47 } |
| 48 |
42 void clear(); | 49 void clear(); |
43 | 50 |
44 // Releases the generated paint chunk list and resets the state of this | 51 // Releases the generated paint chunk list and resets the state of this |
45 // object. | 52 // object. |
46 Vector<PaintChunk> releasePaintChunks(); | 53 Vector<PaintChunk> releasePaintChunks(); |
47 | 54 |
48 private: | 55 private: |
49 enum ItemBehavior { | 56 enum ItemBehavior { |
50 // Can be combined with adjacent items when building chunks. | 57 // Can be combined with adjacent items when building chunks. |
51 DefaultBehavior = 0, | 58 DefaultBehavior = 0, |
52 | 59 |
53 // Item requires its own paint chunk. | 60 // Item requires its own paint chunk. |
54 RequiresSeparateChunk, | 61 RequiresSeparateChunk, |
55 }; | 62 }; |
56 | 63 |
57 Vector<PaintChunk> m_chunks; | 64 Vector<PaintChunk> m_chunks; |
58 Vector<ItemBehavior> m_chunkBehavior; | 65 Vector<ItemBehavior> m_chunkBehavior; |
59 Optional<PaintChunk::Id> m_currentChunkId; | 66 Optional<PaintChunk::Id> m_currentChunkId; |
60 PaintChunkProperties m_currentProperties; | 67 PaintChunkProperties m_currentProperties; |
61 }; | 68 }; |
62 | 69 |
63 } // namespace blink | 70 } // namespace blink |
64 | 71 |
65 #endif // PaintChunker_h | 72 #endif // PaintChunker_h |
OLD | NEW |