Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/paint/DisplayItems.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItems.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItems.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5c3ce1589675e89e208d6819a10f3fec61c75ba3 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItems.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef DisplayItems_h |
| +#define DisplayItems_h |
| + |
| +#include "platform/graphics/ContiguousContainer.h" |
| +#include "platform/graphics/paint/DisplayItem.h" |
| +#include "platform/graphics/paint/Transform3DDisplayItem.h" |
| +#include "wtf/Alignment.h" |
| +#include "wtf/Assertions.h" |
| + |
| +#ifndef NDEBUG |
| +#include "wtf/text/WTFString.h" |
| +#endif |
| + |
| +namespace blink { |
| + |
| +// kDisplayItemAlignment must be a multiple of alignof(derived display item) for |
| +// each derived display item; the ideal value is the least common multiple. |
| +// Currently the limiting factor is TransformtionMatrix (in |
|
wkorman
2015/10/09 04:45:50
Transformtion -> Transformation
|
| +// BeginTransform3DDisplayItem), which requests 16-byte alignment. |
| +static const size_t kDisplayItemAlignment = WTF_ALIGN_OF(BeginTransform3DDisplayItem); |
| +static const size_t kMaximumDisplayItemSize = sizeof(BeginTransform3DDisplayItem); |
| + |
| +// A container for a list of display items. |
| +class DisplayItems : public ContiguousContainer<DisplayItem, kDisplayItemAlignment> { |
|
pdr.
2015/10/09 03:57:51
What do you think about expanding this class a bit
pdr.
2015/10/13 18:30:32
This is kind of high-level but I'd like your thoug
|
| +public: |
| + DisplayItems(size_t initialSizeBytes) |
| + : ContiguousContainer(kMaximumDisplayItemSize, initialSizeBytes) {} |
| + |
| + DisplayItem& appendByMoving(DisplayItem& item) |
| + { |
| +#ifndef NDEBUG |
| + WTF::String originalDebugString = item.asDebugString(); |
| +#endif |
| + ASSERT(item.isValid()); |
| + DisplayItem& result = ContiguousContainer::appendByMoving(item, item.derivedSize()); |
| + // ContiguousContainer::appendByMoving() called in-place constructor on item, which invalidated it. |
| + ASSERT(!item.isValid()); |
| +#ifndef NDEBUG |
| + // Save original debug string in the old item to help debugging. |
| + item.setClientDebugString(originalDebugString); |
| +#endif |
| + return result; |
| + } |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // DisplayItems_h |