Flutter Engine
The Flutter Engine
third_party
skia
bench
MSKPBench.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2021 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/MSKPBench.h
"
9
#include "
include/core/SkCanvas.h
"
10
#include "
include/gpu/GrDirectContext.h
"
11
#include "
include/gpu/GrRecordingContext.h
"
12
#include "
tools/MSKPPlayer.h
"
13
14
MSKPBench::MSKPBench
(
SkString
name
, std::unique_ptr<MSKPPlayer> player)
15
:
fName
(
name
), fPlayer(
std
::move(player)) {}
16
17
MSKPBench::~MSKPBench
() =
default
;
18
19
void
MSKPBench::onDraw
(
int
loops,
SkCanvas
* canvas) {
20
for
(
int
i
= 0;
i
< loops; ++
i
) {
21
for
(
int
f
= 0;
f
< fPlayer->numFrames(); ++
f
) {
22
canvas->
save
();
23
canvas->
clipIRect
(
SkIRect::MakeSize
(fPlayer->frameDimensions(
f
)));
24
fPlayer->playFrame(canvas,
f
);
25
canvas->
restore
();
26
if
(
auto
dContext =
GrAsDirectContext
(canvas->
recordingContext
())) {
27
dContext->flushAndSubmit();
28
}
29
}
30
// Ensure each loop replays all offscreen layer draws from scratch.
31
fPlayer->rewindLayers();
32
}
33
}
34
35
const
char
*
MSKPBench::onGetName
() {
return
fName.
c_str
(); }
36
37
SkISize
MSKPBench::onGetSize
() {
38
auto
dims = fPlayer->maxDimensions();
39
return
{dims.width(), dims.height()};
40
}
41
42
void
MSKPBench::onPreDraw
(
SkCanvas
* canvas) {
43
// We don't benchmark creation of the backing stores for layers so ensure they're all created.
44
fPlayer->allocateLayers(canvas);
45
}
46
47
void
MSKPBench::onPostDraw
(
SkCanvas
*) {
48
// nanobench can tear down the 3D API context/device before destroying the benchmarks.
49
fPlayer->resetLayers();
50
}
fName
const char * fName
Definition:
FontCacheBench.cpp:71
GrDirectContext.h
GrRecordingContext.h
GrAsDirectContext
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
Definition:
GrRecordingContext.h:281
MSKPBench.h
MSKPPlayer.h
SkCanvas.h
MSKPBench::onPostDraw
void onPostDraw(SkCanvas *) override
Definition:
MSKPBench.cpp:47
MSKPBench::onPreDraw
void onPreDraw(SkCanvas *) override
Definition:
MSKPBench.cpp:42
MSKPBench::~MSKPBench
~MSKPBench() override
MSKPBench::onGetName
const char * onGetName() override
Definition:
MSKPBench.cpp:35
MSKPBench::MSKPBench
MSKPBench(SkString name, std::unique_ptr< MSKPPlayer > player)
Definition:
MSKPBench.cpp:14
MSKPBench::onGetSize
SkISize onGetSize() override
Definition:
MSKPBench.cpp:37
MSKPBench::onDraw
void onDraw(int loops, SkCanvas *) override
Definition:
MSKPBench.cpp:19
SkCanvas
Definition:
SkCanvas.h:106
SkCanvas::restore
void restore()
Definition:
SkCanvas.cpp:461
SkCanvas::clipIRect
void clipIRect(const SkIRect &irect, SkClipOp op=SkClipOp::kIntersect)
Definition:
SkCanvas.h:991
SkCanvas::recordingContext
virtual GrRecordingContext * recordingContext() const
Definition:
SkCanvas.cpp:1637
SkCanvas::save
int save()
Definition:
SkCanvas.cpp:447
SkString
Definition:
SkString.h:118
SkString::c_str
const char * c_str() const
Definition:
SkString.h:133
i
int i
Definition:
fl_socket_accessible.cc:18
flutter::name
DEF_SWITCHES_START aot vmservice shared library name
Definition:
switches.h:32
skcms_private::f
float f
Definition:
skcms_Transform.h:121
std
Definition:
ref_ptr.h:256
SkIRect::MakeSize
static constexpr SkIRect MakeSize(const SkISize &size)
Definition:
SkRect.h:66
SkISize
Definition:
SkSize.h:16
Generated on Sun Jun 23 2024 21:55:53 for Flutter Engine by
1.9.4