Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/paint/PaintChunk.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintChunk.h b/third_party/WebKit/Source/platform/graphics/paint/PaintChunk.h |
| index bafb8298ecdc2ba775afed614f996c1d485bfab7..40ff009b0beca9e901de4b84cab3cd5555f51e8d 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/paint/PaintChunk.h |
| +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintChunk.h |
| @@ -6,8 +6,10 @@ |
| #define PaintChunk_h |
| #include "platform/geometry/FloatRect.h" |
| +#include "platform/graphics/paint/DisplayItem.h" |
| #include "platform/graphics/paint/PaintChunkProperties.h" |
| #include "wtf/Allocator.h" |
| +#include "wtf/Optional.h" |
| #include <iosfwd> |
| namespace blink { |
| @@ -21,8 +23,12 @@ namespace blink { |
| struct PaintChunk { |
| DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| PaintChunk() : beginIndex(0), endIndex(0), knownToBeOpaque(false) { } |
| - PaintChunk(unsigned begin, unsigned end, const PaintChunkProperties& props) |
| - : beginIndex(begin), endIndex(end), properties(props), knownToBeOpaque(false) { } |
| + PaintChunk(unsigned begin, unsigned end, const DisplayItem::Id* chunkId, const PaintChunkProperties& props) |
| + : beginIndex(begin), endIndex(end), properties(props), knownToBeOpaque(false) |
| + { |
| + if (chunkId) |
| + id.emplace(*chunkId); |
| + } |
| unsigned size() const |
| { |
| @@ -30,6 +36,24 @@ struct PaintChunk { |
| return endIndex - beginIndex; |
| } |
| + // Check if a new PaintChunk (this) created in the latest paint matches an old |
| + // PaintChunk created in the previous paint. |
| + bool idMatches(const PaintChunk& old) const |
| + { |
| + // A PaintChunk without an id doesn't match any other PaintChunks. |
| + if (!id || !old.id) |
| + return false; |
| + if (*id != *old.id) |
| + return false; |
| +#if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| + CHECK(id->client.isAlive()); |
| +#endif |
| + // A chunk whose client is just created should not match any cached chunk, |
|
pdr.
2016/07/14 22:22:06
I see what you mean about why this is needed, but
Xianzhu
2016/07/14 23:03:24
Chunk ids should be stable even if the contents ch
|
| + // even if it's id equals the old chunk's id (which may happen if this chunk's |
| + // client is just created at the same address of the old chunk's deleted client). |
| + return !id->client.isJustCreated(); |
| + } |
| + |
| // Index of the first drawing in this chunk. |
| unsigned beginIndex; |
| @@ -37,6 +61,9 @@ struct PaintChunk { |
| // |endIndex - beginIndex| drawings in the chunk. |
| unsigned endIndex; |
| + // Identifier of this chunk. If it has a value, it should be unique. |
| + Optional<DisplayItem::Id> id; |
|
pdr.
2016/07/14 22:22:06
Can you add a comment here about what a null value
Xianzhu
2016/07/14 23:03:24
Done.
|
| + |
| // The paint properties which apply to this chunk. |
| PaintChunkProperties properties; |
| @@ -51,6 +78,7 @@ inline bool operator==(const PaintChunk& a, const PaintChunk& b) |
| { |
| return a.beginIndex == b.beginIndex |
| && a.endIndex == b.endIndex |
| + && a.id == b.id |
| && a.properties == b.properties |
| && a.bounds == b.bounds |
| && a.knownToBeOpaque == b.knownToBeOpaque; |