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.
5 #ifndef SkPictureBuilder_h
6 #define SkPictureBuilder_h
8 #include "platform/RuntimeEnabledFeatures.h"
9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/paint/DisplayItemList.h"
11 #include "wtf/OwnPtr.h"
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
);
21 SkPictureBuilder(const FloatRect
& bounds
, SkMetaData
* metaData
= 0, GraphicsContext
* containingContext
= 0)
24 GraphicsContext::DisabledMode disabledMode
= GraphicsContext::NothingDisabled
;
25 if (containingContext
&& containingContext
->contextDisabled())
26 disabledMode
= GraphicsContext::FullyDisabled
;
28 m_displayItemList
= DisplayItemList::create();
29 m_context
= adoptPtr(new GraphicsContext(m_displayItemList
.get(), disabledMode
, metaData
));
31 if (containingContext
) {
32 m_context
->setDeviceScaleFactor(containingContext
->deviceScaleFactor());
33 m_context
->setPrinting(containingContext
->printing());
37 GraphicsContext
& context() { return *m_context
; }
39 PassRefPtr
<const SkPicture
> endRecording()
41 m_context
->beginRecording(m_bounds
);
42 m_displayItemList
->commitNewDisplayItemsAndReplay(*m_context
);
43 return m_context
->endRecording();
47 OwnPtr
<DisplayItemList
> m_displayItemList
;
48 OwnPtr
<GraphicsContext
> m_context
;
54 #endif // SkPictureBuilder_h