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

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

Issue 1089293002: Add PictureRecorder for sp/non-sp recording without an existing context (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix endRecording mistake Created 5 years, 8 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
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/paint/SkPictureBuilder.h
diff --git a/Source/platform/graphics/paint/SkPictureBuilder.h b/Source/platform/graphics/paint/SkPictureBuilder.h
new file mode 100644
index 0000000000000000000000000000000000000000..fd81a5211f89cdf9eb75ee1372cc345cf2995d06
--- /dev/null
+++ b/Source/platform/graphics/paint/SkPictureBuilder.h
@@ -0,0 +1,48 @@
+// 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 SkPictureBuilder_h
+#define SkPictureBuilder_h
+
+#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/paint/DisplayItemList.h"
+#include "wtf/OwnPtr.h"
+
+namespace blink {
+
+// When slimming paint ships we can remove this SkPicture abstraction and
+// rely on DisplayItemList here.
+class SkPictureBuilder {
+ WTF_MAKE_NONCOPYABLE(SkPictureBuilder);
+ STACK_ALLOCATED();
+public:
+ SkPictureBuilder(const FloatRect& bounds)
+ {
+ if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ m_displayItemList = DisplayItemList::create();
+ m_context = adoptPtr(new GraphicsContext(m_displayItemList.get()));
+ } else {
+ m_context = GraphicsContext::deprecatedCreateWithCanvas(nullptr);
+ }
+ m_context->beginRecording(bounds);
+ }
+
+ GraphicsContext& context() { return *m_context; }
+
+ PassRefPtr<const SkPicture> endRecording()
+ {
+ if (m_displayItemList)
+ m_displayItemList->commitNewDisplayItemsAndReplay(*m_context);
+ return m_context->endRecording();
+ }
+
+private:
+ OwnPtr<DisplayItemList> m_displayItemList;
+ OwnPtr<GraphicsContext> m_context;
+};
+
+} // namespace blink
+
+#endif // SkPictureBuilder_h
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698