blob: dcf6d0607f7cdb31ba67b4358286f30e4f8dd73a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// 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/PaintController.h"
#include "wtf/OwnPtr.h"
namespace blink {
// When slimming paint ships we can remove this SkPicture abstraction and
// rely on PaintController here.
class SkPictureBuilder {
WTF_MAKE_NONCOPYABLE(SkPictureBuilder);
STACK_ALLOCATED();
public:
SkPictureBuilder(const FloatRect& bounds, SkMetaData* metaData = 0, GraphicsContext* containingContext = 0)
: m_bounds(bounds)
{
GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled;
if (containingContext && containingContext->contextDisabled())
disabledMode = GraphicsContext::FullyDisabled;
m_paintController = PaintController::create();
m_paintController->beginSkippingCache();
m_context = adoptPtr(new GraphicsContext(*m_paintController, disabledMode, metaData));
if (containingContext) {
m_context->setDeviceScaleFactor(containingContext->deviceScaleFactor());
m_context->setPrinting(containingContext->printing());
}
}
GraphicsContext& context() { return *m_context; }
PassRefPtr<const SkPicture> endRecording()
{
m_context->beginRecording(m_bounds);
m_paintController->endSkippingCache();
m_paintController->commitNewDisplayItems();
m_paintController->paintArtifact().replay(*m_context);
return m_context->endRecording();
}
private:
OwnPtr<PaintController> m_paintController;
OwnPtr<GraphicsContext> m_context;
FloatRect m_bounds;
};
} // namespace blink
#endif // SkPictureBuilder_h
|