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 PaintChunk_h | 5 #ifndef PaintChunk_h |
6 #define PaintChunk_h | 6 #define PaintChunk_h |
7 | 7 |
8 #include "platform/geometry/FloatRect.h" | 8 #include "platform/geometry/FloatRect.h" |
9 #include "platform/graphics/paint/DisplayItem.h" | 9 #include "platform/graphics/paint/DisplayItem.h" |
10 #include "platform/graphics/paint/PaintChunkProperties.h" | 10 #include "platform/graphics/paint/PaintChunkProperties.h" |
11 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
12 #include "wtf/Optional.h" | 12 #include "wtf/Optional.h" |
13 #include <iosfwd> | 13 #include <iosfwd> |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 // A contiguous sequence of drawings with common paint properties. | 17 // A contiguous sequence of drawings with common paint properties. |
18 // | 18 // |
19 // This is expected to be owned by the paint artifact which also owns the | 19 // This is expected to be owned by the paint artifact which also owns the |
20 // related drawings. | 20 // related drawings. |
21 // | 21 // |
22 // This is a Slimming Paint v2 class. | 22 // This is a Slimming Paint v2 class. |
23 struct PaintChunk { | 23 struct PaintChunk { |
24 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 24 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
25 PaintChunk() : beginIndex(0), endIndex(0), knownToBeOpaque(false) { } | 25 PaintChunk() : beginIndex(0), endIndex(0), knownToBeOpaque(false) { } |
26 PaintChunk(unsigned begin, unsigned end, const DisplayItem::Id* chunkId, con
st PaintChunkProperties& props) | 26 PaintChunk(size_t begin, size_t end, const DisplayItem::Id* chunkId, const P
aintChunkProperties& props) |
27 : beginIndex(begin), endIndex(end), properties(props), knownToBeOpaque(f
alse) | 27 : beginIndex(begin), endIndex(end), properties(props), knownToBeOpaque(f
alse) |
28 { | 28 { |
29 if (chunkId) | 29 if (chunkId) |
30 id.emplace(*chunkId); | 30 id.emplace(*chunkId); |
31 } | 31 } |
32 | 32 |
33 unsigned size() const | 33 size_t size() const |
34 { | 34 { |
35 ASSERT(endIndex >= beginIndex); | 35 ASSERT(endIndex >= beginIndex); |
36 return endIndex - beginIndex; | 36 return endIndex - beginIndex; |
37 } | 37 } |
38 | 38 |
39 // Check if a new PaintChunk (this) created in the latest paint matches an o
ld | 39 // Check if a new PaintChunk (this) created in the latest paint matches an o
ld |
40 // PaintChunk created in the previous paint. | 40 // PaintChunk created in the previous paint. |
41 bool matches(const PaintChunk& old) const | 41 bool matches(const PaintChunk& old) const |
42 { | 42 { |
43 // A PaintChunk without an id doesn't match any other PaintChunks. | 43 // A PaintChunk without an id doesn't match any other PaintChunks. |
44 if (!id || !old.id) | 44 if (!id || !old.id) |
45 return false; | 45 return false; |
46 if (*id != *old.id) | 46 if (*id != *old.id) |
47 return false; | 47 return false; |
48 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 48 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
49 CHECK(id->client.isAlive()); | 49 CHECK(id->client.isAlive()); |
50 #endif | 50 #endif |
51 // A chunk whose client is just created should not match any cached chun
k, | 51 // A chunk whose client is just created should not match any cached chun
k, |
52 // even if it's id equals the old chunk's id (which may happen if this c
hunk's | 52 // even if it's id equals the old chunk's id (which may happen if this c
hunk's |
53 // client is just created at the same address of the old chunk's deleted
client). | 53 // client is just created at the same address of the old chunk's deleted
client). |
54 return !id->client.isJustCreated(); | 54 return !id->client.isJustCreated(); |
55 } | 55 } |
56 | 56 |
57 // Index of the first drawing in this chunk. | 57 // Index of the first drawing in this chunk. |
58 unsigned beginIndex; | 58 size_t beginIndex; |
59 | 59 |
60 // Index of the first drawing not in this chunk, so that there are | 60 // Index of the first drawing not in this chunk, so that there are |
61 // |endIndex - beginIndex| drawings in the chunk. | 61 // |endIndex - beginIndex| drawings in the chunk. |
62 unsigned endIndex; | 62 size_t endIndex; |
63 | 63 |
64 // Identifier of this chunk. If it has a value, it should be unique. | 64 // Identifier of this chunk. If it has a value, it should be unique. |
65 // It's used to match a new chunk to a cached old chunk to track changes of
chunk | 65 // It's used to match a new chunk to a cached old chunk to track changes of
chunk |
66 // contents, so the id should be stable across document cycles. | 66 // contents, so the id should be stable across document cycles. |
67 // If the contents of the chunk can't be cached (e.g. it's created when Pain
tController | 67 // If the contents of the chunk can't be cached (e.g. it's created when Pain
tController |
68 // is skipping cache, normally because display items can't be uniquely ident
ified), | 68 // is skipping cache, normally because display items can't be uniquely ident
ified), |
69 // id is nullopt so that the chunk won't match any other chunk. | 69 // id is nullopt so that the chunk won't match any other chunk. |
70 using Id = DisplayItem::Id; | 70 using Id = DisplayItem::Id; |
71 Optional<Id> id; | 71 Optional<Id> id; |
72 | 72 |
(...skipping 22 matching lines...) Expand all Loading... |
95 return !(a == b); | 95 return !(a == b); |
96 } | 96 } |
97 | 97 |
98 // Redeclared here to avoid ODR issues. | 98 // Redeclared here to avoid ODR issues. |
99 // See platform/testing/PaintPrinters.h. | 99 // See platform/testing/PaintPrinters.h. |
100 void PrintTo(const PaintChunk&, std::ostream*); | 100 void PrintTo(const PaintChunk&, std::ostream*); |
101 | 101 |
102 } // namespace blink | 102 } // namespace blink |
103 | 103 |
104 #endif // PaintChunk_h | 104 #endif // PaintChunk_h |
OLD | NEW |