Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItems.h

Issue 1396783003: Factor PaintArtifact out of DisplayItemList. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@const-replay
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698