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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SkPictureBuilder_h
6 #define SkPictureBuilder_h
7
8 #include "platform/RuntimeEnabledFeatures.h"
9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/paint/DisplayItemList.h"
11 #include "wtf/OwnPtr.h"
12
13 namespace blink {
14
15 // When slimming paint ships we can remove this SkPicture abstraction and
16 // rely on DisplayItemList here.
17 class SkPictureBuilder {
18 WTF_MAKE_NONCOPYABLE(SkPictureBuilder);
19 STACK_ALLOCATED();
20 public:
21 SkPictureBuilder(const FloatRect& bounds)
22 {
23 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
24 m_displayItemList = DisplayItemList::create();
25 m_context = adoptPtr(new GraphicsContext(m_displayItemList.get()));
26 } else {
27 m_context = GraphicsContext::deprecatedCreateWithCanvas(nullptr);
28 }
29 m_context->beginRecording(bounds);
30 }
31
32 GraphicsContext& context() { return *m_context; }
33
34 PassRefPtr<const SkPicture> endRecording()
35 {
36 if (m_displayItemList)
37 m_displayItemList->commitNewDisplayItemsAndReplay(*m_context);
38 return m_context->endRecording();
39 }
40
41 private:
42 OwnPtr<DisplayItemList> m_displayItemList;
43 OwnPtr<GraphicsContext> m_context;
44 };
45
46 } // namespace blink
47
48 #endif // SkPictureBuilder_h
OLDNEW
« 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