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

Unified Diff: third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp

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/PaintArtifact.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..04d5ebdb1a386eeb486970471ccc9344fe8afcb9
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.cpp
@@ -0,0 +1,56 @@
+// 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.
+
+#include "config.h"
+#include "platform/graphics/paint/PaintArtifact.h"
+
+#include "platform/TraceEvent.h"
+
+namespace blink {
+
+PaintArtifact::PaintArtifact()
+ : m_displayItems(0)
+{
+}
+
+PaintArtifact::~PaintArtifact()
+{
+}
+
+void PaintArtifact::reset()
+{
+ m_displayItems.clear();
+ m_paintChunks.clear();
+}
+
+void PaintArtifact::update(DisplayItems& updatedDisplayItems, Vector<PaintChunk> updatedPaintChunks)
+{
+ // TODO(jbroman): This can be expressed more clearly once std::move is
+ // available.
+ m_displayItems.clear();
+ m_displayItems.swap(updatedDisplayItems);
+ m_paintChunks.swap(updatedPaintChunks);
+}
+
+size_t PaintArtifact::approximateUnsharedMemoryUsage() const
+{
+ return sizeof(*this) + m_displayItems.memoryUsageInBytes()
+ + m_paintChunks.capacity() * sizeof(m_paintChunks[0]);
+}
+
+void PaintArtifact::replay(GraphicsContext& graphicsContext) const
+{
+ TRACE_EVENT0("blink,benchmark", "PaintArtifact::replay");
+ for (const DisplayItem& displayItem : m_displayItems)
+ displayItem.replay(graphicsContext);
+}
+
+void PaintArtifact::appendToWebDisplayItemList(WebDisplayItemList* list) const
+{
+ TRACE_EVENT0("blink,benchmark", "PaintArtifact::appendToWebDisplayItemList");
+ for (const DisplayItem& displayItem : m_displayItems)
+ displayItem.appendToWebDisplayItemList(list);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698