Chromium Code Reviews| 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/PaintChunkProperties.h" | 10 #include "platform/graphics/paint/PaintChunkProperties.h" |
| 10 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
| 12 #include "wtf/Optional.h" | |
| 11 #include <iosfwd> | 13 #include <iosfwd> |
| 12 | 14 |
| 13 namespace blink { | 15 namespace blink { |
| 14 | 16 |
| 15 // A contiguous sequence of drawings with common paint properties. | 17 // A contiguous sequence of drawings with common paint properties. |
| 16 // | 18 // |
| 17 // 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 |
| 18 // related drawings. | 20 // related drawings. |
| 19 // | 21 // |
| 20 // This is a Slimming Paint v2 class. | 22 // This is a Slimming Paint v2 class. |
| 21 struct PaintChunk { | 23 struct PaintChunk { |
| 22 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 24 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 23 PaintChunk() : beginIndex(0), endIndex(0), knownToBeOpaque(false) { } | 25 PaintChunk() : beginIndex(0), endIndex(0), knownToBeOpaque(false) { } |
| 24 PaintChunk(unsigned begin, unsigned end, const PaintChunkProperties& props) | 26 PaintChunk(unsigned begin, unsigned end, const DisplayItem::Id* chunkId, con st PaintChunkProperties& props) |
|
pdr.
2016/07/13 23:31:34
Since this is just for foreign layers, foreignLaye
Xianzhu
2016/07/14 04:53:09
The ids are not just for foreign layers, but for a
| |
| 25 : beginIndex(begin), endIndex(end), properties(props), knownToBeOpaque(f alse) { } | 27 : beginIndex(begin), endIndex(end), properties(props), knownToBeOpaque(f alse) |
| 28 { | |
| 29 if (chunkId) | |
| 30 id.emplace(*chunkId); | |
| 31 } | |
| 26 | 32 |
| 27 unsigned size() const | 33 unsigned size() const |
| 28 { | 34 { |
| 29 ASSERT(endIndex >= beginIndex); | 35 ASSERT(endIndex >= beginIndex); |
| 30 return endIndex - beginIndex; | 36 return endIndex - beginIndex; |
| 31 } | 37 } |
| 32 | 38 |
| 39 // Check if a new PaintChunk created in the latest paint matches an old Pain tChunk | |
| 40 // created in the previous paint. | |
| 41 bool idMatches(const PaintChunk& other) const | |
|
pdr.
2016/07/13 23:31:34
Is this used/tested? The need for isJustCreated is
Xianzhu
2016/07/14 04:53:09
Added PaintChunkTest.* for this method.
The isJus
| |
| 42 { | |
| 43 // A PaintChunk without an id doesn't match any other PaintChunks. | |
| 44 if (!id || !other.id) | |
| 45 return false; | |
| 46 if (*id != *other.id) | |
| 47 return false; | |
| 48 // If the client is just created, it's actually a new client. The client | |
| 49 // of this or the other PaintChunk was allocated at the same address and has | |
| 50 // been deleted. | |
| 51 return !id->client.isJustCreated(); | |
| 52 } | |
| 53 | |
| 33 // Index of the first drawing in this chunk. | 54 // Index of the first drawing in this chunk. |
| 34 unsigned beginIndex; | 55 unsigned beginIndex; |
| 35 | 56 |
| 36 // Index of the first drawing not in this chunk, so that there are | 57 // Index of the first drawing not in this chunk, so that there are |
| 37 // |endIndex - beginIndex| drawings in the chunk. | 58 // |endIndex - beginIndex| drawings in the chunk. |
| 38 unsigned endIndex; | 59 unsigned endIndex; |
| 39 | 60 |
| 61 // Identifier of this chunk. If it has a value, it should be unique. | |
| 62 Optional<DisplayItem::Id> id; | |
| 63 | |
| 40 // The paint properties which apply to this chunk. | 64 // The paint properties which apply to this chunk. |
| 41 PaintChunkProperties properties; | 65 PaintChunkProperties properties; |
| 42 | 66 |
| 43 // The total bounds of this paint chunk's contents. | 67 // The total bounds of this paint chunk's contents. |
| 44 FloatRect bounds; | 68 FloatRect bounds; |
| 45 | 69 |
| 46 // True if the bounds are filled entirely with opaque contents. | 70 // True if the bounds are filled entirely with opaque contents. |
| 47 bool knownToBeOpaque; | 71 bool knownToBeOpaque; |
| 48 }; | 72 }; |
| 49 | 73 |
| 50 inline bool operator==(const PaintChunk& a, const PaintChunk& b) | 74 inline bool operator==(const PaintChunk& a, const PaintChunk& b) |
| 51 { | 75 { |
| 52 return a.beginIndex == b.beginIndex | 76 return a.beginIndex == b.beginIndex |
| 53 && a.endIndex == b.endIndex | 77 && a.endIndex == b.endIndex |
| 78 && a.id == b.id | |
| 54 && a.properties == b.properties | 79 && a.properties == b.properties |
| 55 && a.bounds == b.bounds | 80 && a.bounds == b.bounds |
| 56 && a.knownToBeOpaque == b.knownToBeOpaque; | 81 && a.knownToBeOpaque == b.knownToBeOpaque; |
| 57 } | 82 } |
| 58 | 83 |
| 59 inline bool operator!=(const PaintChunk& a, const PaintChunk& b) | 84 inline bool operator!=(const PaintChunk& a, const PaintChunk& b) |
| 60 { | 85 { |
| 61 return !(a == b); | 86 return !(a == b); |
| 62 } | 87 } |
| 63 | 88 |
| 64 // Redeclared here to avoid ODR issues. | 89 // Redeclared here to avoid ODR issues. |
| 65 // See platform/testing/PaintPrinters.h. | 90 // See platform/testing/PaintPrinters.h. |
| 66 void PrintTo(const PaintChunk&, std::ostream*); | 91 void PrintTo(const PaintChunk&, std::ostream*); |
| 67 | 92 |
| 68 } // namespace blink | 93 } // namespace blink |
| 69 | 94 |
| 70 #endif // PaintChunk_h | 95 #endif // PaintChunk_h |
| OLD | NEW |