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

Unified Diff: Source/platform/graphics/paint/DisplayItemListPictureRecorder.h

Issue 1048223002: Add DisplayItemListPictureRecorder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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: Source/platform/graphics/paint/DisplayItemListPictureRecorder.h
diff --git a/Source/platform/graphics/paint/DisplayItemListPictureRecorder.h b/Source/platform/graphics/paint/DisplayItemListPictureRecorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..80091e18ae6e88219aa09e6f9b90812f98b81dfa
--- /dev/null
+++ b/Source/platform/graphics/paint/DisplayItemListPictureRecorder.h
@@ -0,0 +1,60 @@
+// 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 DisplayItemListPictureRecorder_h
+#define DisplayItemListPictureRecorder_h
+
+#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/paint/DisplayItemList.h"
+#include "wtf/OwnPtr.h"
+
+namespace blink {
+
+class DisplayItemListPictureRecorder {
+ WTF_MAKE_NONCOPYABLE(DisplayItemListPictureRecorder);
+ STACK_ALLOCATED();
+public:
+ DisplayItemListPictureRecorder(const FloatRect& bounds)
+ : m_displayItemList(RuntimeEnabledFeatures::slimmingPaintEnabled() ? DisplayItemList::create() : nullptr)
+ , m_context(nullptr, m_displayItemList.get())
+#if ENABLE(ASSERT)
+ , m_recordingEnded(false)
+#endif
+ {
+ m_context.beginRecording(bounds);
+ }
+
+ ~DisplayItemListPictureRecorder()
+ {
+ ASSERT(m_recordingEnded);
+ }
+
+ GraphicsContext& context() { return m_context; }
+
+ PassRefPtr<const SkPicture> endRecording()
+ {
+#if ENABLE(ASSERT)
+ ASSERT(!m_recordingEnded);
+ m_recordingEnded = true;
+#endif
+
+ if (m_displayItemList)
+ m_displayItemList->replay(&m_context);
+
+ return m_context.endRecording();
+ }
+
+private:
+ OwnPtr<DisplayItemList> m_displayItemList;
+ GraphicsContext m_context;
+
+#if ENABLE(ASSERT)
+ bool m_recordingEnded;
+#endif
+};
+
+} // namespace blink
+
+#endif // DisplayItemListPictureRecorder_h

Powered by Google App Engine
This is Rietveld 408576698