Flutter Engine
The Flutter Engine
third_party
skia
bench
RecordingBench.cpp
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
#include "
bench/RecordingBench.h
"
9
10
#include "
include/core/SkBBHFactory.h
"
11
#include "
include/core/SkData.h
"
12
#include "
include/core/SkPictureRecorder.h
"
13
14
PictureCentricBench::PictureCentricBench
(
const
char
*
name
,
const
SkPicture
* pic) :
fName
(
name
) {
15
// Flatten the source picture in case it's trivially nested (useless for timing).
16
SkPictureRecorder
rec;
17
pic->
playback
(rec.
beginRecording
(pic->
cullRect
(),
nullptr
/*,
18
SkPictureRecorder::kPlaybackDrawPicture_RecordFlag*/
));
19
fSrc
= rec.
finishRecordingAsPicture
();
20
}
21
22
const
char
*
PictureCentricBench::onGetName
() {
23
return
fName
.
c_str
();
24
}
25
26
bool
PictureCentricBench::isSuitableFor
(
Backend
backend
) {
27
return
backend
==
Backend::kNonRendering
;
28
}
29
30
SkISize
PictureCentricBench::onGetSize
() {
31
return
SkISize::Make
(
SkScalarCeilToInt
(
fSrc
->
cullRect
().
width
()),
32
SkScalarCeilToInt
(
fSrc
->
cullRect
().
height
()));
33
}
34
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36
37
RecordingBench::RecordingBench
(
const
char
*
name
,
const
SkPicture
* pic,
bool
useBBH)
38
:
INHERITED
(
name
, pic)
39
, fUseBBH(useBBH)
40
{}
41
42
void
RecordingBench::onDraw
(
int
loops,
SkCanvas
*) {
43
SkRTreeFactory
factory;
44
SkPictureRecorder
recorder;
45
while
(loops --> 0) {
46
fSrc
->
playback
(recorder.
beginRecording
(
fSrc
->
cullRect
(), fUseBBH ? &factory :
nullptr
));
47
(void)recorder.
finishRecordingAsPicture
();
48
}
49
}
50
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52
#include "
include/core/SkSerialProcs.h
"
53
54
DeserializePictureBench::DeserializePictureBench
(
const
char
*
name
,
sk_sp<SkData>
data
)
55
:
fName
(
name
)
56
, fEncodedPicture(
std
::move(
data
))
57
{}
58
59
const
char
*
DeserializePictureBench::onGetName
() {
60
return
fName.
c_str
();
61
}
62
63
bool
DeserializePictureBench::isSuitableFor
(
Backend
backend
) {
64
return
backend
==
Backend::kNonRendering
;
65
}
66
67
SkISize
DeserializePictureBench::onGetSize
() {
68
return
SkISize::Make
(128, 128);
69
}
70
71
void
DeserializePictureBench::onDraw
(
int
loops,
SkCanvas
*) {
72
for
(
int
i
= 0;
i
< loops; ++
i
) {
73
SkPicture::MakeFromData
(fEncodedPicture.
get
());
74
}
75
}
backend
const char * backend
Definition:
CommonFlagsConfig.cpp:42
fName
const char * fName
Definition:
FontCacheBench.cpp:71
RecordingBench.h
SkBBHFactory.h
SkData.h
SkPictureRecorder.h
SkScalarCeilToInt
#define SkScalarCeilToInt(x)
Definition:
SkScalar.h:36
SkSerialProcs.h
Benchmark::Backend
Backend
Definition:
Benchmark.h:44
Benchmark::Backend::kNonRendering
@ kNonRendering
DeserializePictureBench::onGetName
const char * onGetName() override
Definition:
RecordingBench.cpp:59
DeserializePictureBench::onGetSize
SkISize onGetSize() override
Definition:
RecordingBench.cpp:67
DeserializePictureBench::DeserializePictureBench
DeserializePictureBench(const char *name, sk_sp< SkData > encodedPicture)
Definition:
RecordingBench.cpp:54
DeserializePictureBench::onDraw
void onDraw(int loops, SkCanvas *) override
Definition:
RecordingBench.cpp:71
DeserializePictureBench::isSuitableFor
bool isSuitableFor(Backend) override
Definition:
RecordingBench.cpp:63
PictureCentricBench::onGetSize
SkISize onGetSize() override
Definition:
RecordingBench.cpp:30
PictureCentricBench::fName
SkString fName
Definition:
RecordingBench.h:25
PictureCentricBench::fSrc
sk_sp< const SkPicture > fSrc
Definition:
RecordingBench.h:24
PictureCentricBench::PictureCentricBench
PictureCentricBench(const char *name, const SkPicture *)
Definition:
RecordingBench.cpp:14
PictureCentricBench::onGetName
const char * onGetName() override
Definition:
RecordingBench.cpp:22
PictureCentricBench::isSuitableFor
bool isSuitableFor(Backend) override
Definition:
RecordingBench.cpp:26
RecordingBench::RecordingBench
RecordingBench(const char *name, const SkPicture *, bool useBBH)
Definition:
RecordingBench.cpp:37
RecordingBench::onDraw
void onDraw(int loops, SkCanvas *) override
Definition:
RecordingBench.cpp:42
SkCanvas
Definition:
SkCanvas.h:106
SkPictureRecorder
Definition:
SkPictureRecorder.h:32
SkPictureRecorder::beginRecording
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
Definition:
SkPictureRecorder.cpp:35
SkPictureRecorder::finishRecordingAsPicture
sk_sp< SkPicture > finishRecordingAsPicture()
Definition:
SkPictureRecorder.cpp:67
SkPicture
Definition:
SkPicture.h:44
SkPicture::cullRect
virtual SkRect cullRect() const =0
SkPicture::MakeFromData
static sk_sp< SkPicture > MakeFromData(const SkData *data, const SkDeserialProcs *procs=nullptr)
Definition:
SkPicture.cpp:160
SkPicture::playback
virtual void playback(SkCanvas *canvas, AbortCallback *callback=nullptr) const =0
SkRTreeFactory
Definition:
SkBBHFactory.h:62
SkRefCnt
Definition:
SkRefCnt.h:119
SkString::c_str
const char * c_str() const
Definition:
SkString.h:133
sk_sp< SkData >
sk_sp::get
T * get() const
Definition:
SkRefCnt.h:303
i
int i
Definition:
fl_socket_accessible.cc:18
flutter::name
DEF_SWITCHES_START aot vmservice shared library name
Definition:
switches.h:32
std
Definition:
ref_ptr.h:256
SkISize
Definition:
SkSize.h:16
SkISize::Make
static constexpr SkISize Make(int32_t w, int32_t h)
Definition:
SkSize.h:20
SkRect::height
constexpr float height() const
Definition:
SkRect.h:769
SkRect::width
constexpr float width() const
Definition:
SkRect.h:762
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:55:54 for Flutter Engine by
1.9.4