Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
include
core
SkPictureRecorder.h
Go to the documentation of this file.
1
/*
2
* Copyright 2014 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#ifndef SkPictureRecorder_DEFINED
9
#define SkPictureRecorder_DEFINED
10
11
#include "
include/core/SkRect.h
"
12
#include "
include/core/SkRefCnt.h
"
13
#include "
include/core/SkScalar.h
"
14
#include "
include/private/base/SkAPI.h
"
15
16
#include <memory>
17
18
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
19
namespace
android
{
20
class
Picture
;
21
};
22
#endif
23
24
class
SkBBHFactory
;
25
class
SkBBoxHierarchy
;
26
class
SkCanvas
;
27
class
SkDrawable
;
28
class
SkPicture
;
29
class
SkRecord
;
30
class
SkRecorder
;
31
32
class
SK_API
SkPictureRecorder
{
33
public
:
34
SkPictureRecorder
();
35
~SkPictureRecorder
();
36
37
/** Returns the canvas that records the drawing commands.
38
@param bounds the cull rect used when recording this picture. Any drawing the falls outside
39
of this rect is undefined, and may be drawn or it may not.
40
@param bbh optional acceleration structure
41
@param recordFlags optional flags that control recording.
42
@return the canvas.
43
*/
44
SkCanvas
* beginRecording(
const
SkRect
& bounds,
sk_sp<SkBBoxHierarchy>
bbh);
45
46
SkCanvas
* beginRecording(
const
SkRect
& bounds,
SkBBHFactory
*
bbhFactory
=
nullptr
);
47
48
SkCanvas
*
beginRecording
(
SkScalar
width
,
SkScalar
height
,
49
SkBBHFactory
*
bbhFactory
=
nullptr
) {
50
return
this->beginRecording(
SkRect::MakeWH
(
width
,
height
),
bbhFactory
);
51
}
52
53
/** Returns the recording canvas if one is active, or NULL if recording is
54
not active. This does not alter the refcnt on the canvas (if present).
55
*/
56
SkCanvas
* getRecordingCanvas();
57
58
/**
59
* Signal that the caller is done recording. This invalidates the canvas returned by
60
* beginRecording/getRecordingCanvas. Ownership of the object is passed to the caller, who
61
* must call unref() when they are done using it.
62
*
63
* The returned picture is immutable. If during recording drawables were added to the canvas,
64
* these will have been "drawn" into a recording canvas, so that this resulting picture will
65
* reflect their current state, but will not contain a live reference to the drawables
66
* themselves.
67
*/
68
sk_sp<SkPicture>
finishRecordingAsPicture();
69
70
/**
71
* Signal that the caller is done recording, and update the cull rect to use for bounding
72
* box hierarchy (BBH) generation. The behavior is the same as calling
73
* finishRecordingAsPicture(), except that this method updates the cull rect initially passed
74
* into beginRecording.
75
* @param cullRect the new culling rectangle to use as the overall bound for BBH generation
76
* and subsequent culling operations.
77
* @return the picture containing the recorded content.
78
*/
79
sk_sp<SkPicture>
finishRecordingAsPictureWithCull(
const
SkRect
& cullRect);
80
81
/**
82
* Signal that the caller is done recording. This invalidates the canvas returned by
83
* beginRecording/getRecordingCanvas. Ownership of the object is passed to the caller, who
84
* must call unref() when they are done using it.
85
*
86
* Unlike finishRecordingAsPicture(), which returns an immutable picture, the returned drawable
87
* may contain live references to other drawables (if they were added to the recording canvas)
88
* and therefore this drawable will reflect the current state of those nested drawables anytime
89
* it is drawn or a new picture is snapped from it (by calling drawable->makePictureSnapshot()).
90
*/
91
sk_sp<SkDrawable>
finishRecordingAsDrawable();
92
93
private
:
94
void
reset
();
95
96
/** Replay the current (partially recorded) operation stream into
97
canvas. This call doesn't close the current recording.
98
*/
99
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
100
friend
class
android::Picture;
101
#endif
102
friend
class
SkPictureRecorderReplayTester
;
// for unit testing
103
void
partialReplay(
SkCanvas
* canvas)
const
;
104
105
bool
fActivelyRecording;
106
SkRect
fCullRect;
107
sk_sp<SkBBoxHierarchy>
fBBH;
108
std::unique_ptr<SkRecorder> fRecorder;
109
sk_sp<SkRecord>
fRecord;
110
111
SkPictureRecorder
(
SkPictureRecorder
&&) =
delete
;
112
SkPictureRecorder
& operator=(
SkPictureRecorder
&&) =
delete
;
113
};
114
115
#endif
reset
m reset()
SkAPI.h
SK_API
#define SK_API
Definition
SkAPI.h:35
SkRect.h
SkRefCnt.h
SkScalar.h
SkBBHFactory
Definition
SkBBHFactory.h:48
SkBBoxHierarchy
Definition
SkBBHFactory.h:20
SkCanvas
Definition
SkCanvas.h:106
SkDrawable
Definition
SkDrawable.h:37
SkPictureRecorderReplayTester
Definition
PictureTest.cpp:168
SkPictureRecorder
Definition
SkPictureRecorder.h:32
SkPictureRecorder::beginRecording
SkCanvas * beginRecording(SkScalar width, SkScalar height, SkBBHFactory *bbhFactory=nullptr)
Definition
SkPictureRecorder.h:48
SkPicture
Definition
SkPicture.h:44
SkRecord
Definition
SkRecord.h:32
SkRecorder
Definition
SkRecorder.h:77
sk_sp
Definition
SkRefCnt.h:220
SkScalar
float SkScalar
Definition
extension.cpp:12
bbhFactory
SkRTreeFactory bbhFactory
Definition
picture.cpp:14
android
Definition
BitmapRegionDecoder.cpp:14
skgpu::graphite::PrecompileShaders::Picture
SK_API sk_sp< PrecompileShader > Picture()
Definition
FactoryFunctions.cpp:548
height
int32_t height
Definition
serialization_callbacks.cc:1
width
int32_t width
Definition
serialization_callbacks.cc:0
SkRect
Definition
extension.cpp:13
SkRect::MakeWH
static constexpr SkRect MakeWH(float w, float h)
Definition
SkRect.h:609
Generated on Fri Apr 26 2024 06:16:10 for Flutter Engine by
1.9.8