Flutter Engine
The Flutter Engine
third_party
skia
bench
CreateBackendTextureBench.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2020 Google LLC
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/Benchmark.h
"
9
#include "
include/core/SkCanvas.h
"
10
#include "
include/gpu/GrBackendSurface.h
"
11
#include "
include/gpu/GrDirectContext.h
"
12
13
using namespace
skia_private
;
14
15
class
CreateBackendTextureBench
:
public
Benchmark
{
16
private
:
17
SkString
fName;
18
TArray<GrBackendTexture>
fBackendTextures;
19
skgpu::Mipmapped
fMipmapped;
20
21
public
:
22
CreateBackendTextureBench
(
skgpu::Mipmapped
mipmapped) : fMipmapped(mipmapped) {
23
fName
.printf(
"create_backend_texture%s"
,
24
mipmapped ==
skgpu::Mipmapped::kYes
?
"_mipped"
:
""
);
25
}
26
27
private
:
28
bool
isSuitableFor(
Backend
backend
)
override
{
return
Backend::kGanesh
==
backend
; }
29
30
const
char
* onGetName()
override
{
return
fName
.c_str(); }
31
32
void
onDraw(
int
loops,
SkCanvas
* canvas)
override
{
33
auto
context = canvas->
recordingContext
()->
asDirectContext
();
34
35
fBackendTextures.
reserve_exact
(fBackendTextures.
size
() + loops);
36
37
static
const
int
kSize
= 16;
38
for
(
int
i
= 0;
i
< loops; ++
i
) {
39
fBackendTextures.
push_back
(
40
context->createBackendTexture(
kSize
,
41
kSize
,
42
kRGBA_8888_SkColorType
,
43
SkColors::kRed
,
44
fMipmapped,
45
GrRenderable::kNo
,
46
GrProtected::kNo
,
47
nullptr
,
48
nullptr
,
49
/*label=*/
"DrawBackendTextureBench"
));
50
}
51
}
52
53
void
onPerCanvasPostDraw(
SkCanvas
* canvas)
override
{
54
auto
context = canvas->
recordingContext
()->
asDirectContext
();
55
56
context->
flush
();
57
context->submit(
GrSyncCpu::kYes
);
58
59
for
(
int
i
= 0;
i
< fBackendTextures.
size
(); ++
i
) {
60
if
(fBackendTextures[
i
].isValid()) {
61
context->deleteBackendTexture(fBackendTextures[
i
]);
62
}
63
}
64
fBackendTextures.
clear
();
65
}
66
};
67
68
DEF_BENCH
(
return
new
CreateBackendTextureBench
(
skgpu::Mipmapped::kNo
);)
69
DEF_BENCH
(
return
new
CreateBackendTextureBench
(
skgpu::Mipmapped::kYes
);)
Benchmark.h
DEF_BENCH
#define DEF_BENCH(code)
Definition:
Benchmark.h:20
backend
const char * backend
Definition:
CommonFlagsConfig.cpp:42
fName
const char * fName
Definition:
FontCacheBench.cpp:71
GrBackendSurface.h
GrDirectContext.h
GrSyncCpu::kYes
@ kYes
SkCanvas.h
kRGBA_8888_SkColorType
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition:
SkColorType.h:24
Benchmark
Definition:
Benchmark.h:36
Benchmark::Backend
Backend
Definition:
Benchmark.h:44
Benchmark::Backend::kGanesh
@ kGanesh
CreateBackendTextureBench
Definition:
CreateBackendTextureBench.cpp:15
CreateBackendTextureBench::CreateBackendTextureBench
CreateBackendTextureBench(skgpu::Mipmapped mipmapped)
Definition:
CreateBackendTextureBench.cpp:22
GrContext_Base::asDirectContext
virtual GrDirectContext * asDirectContext()
Definition:
GrContext_Base.h:35
GrDirectContext::flush
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
Definition:
GrDirectContext.cpp:432
SkCanvas
Definition:
SkCanvas.h:106
SkCanvas::recordingContext
virtual GrRecordingContext * recordingContext() const
Definition:
SkCanvas.cpp:1637
SkString
Definition:
SkString.h:118
skia_private::TArray< GrBackendTexture >
skia_private::TArray::clear
void clear()
Definition:
SkTArray.h:425
skia_private::TArray::size
int size() const
Definition:
SkTArray.h:421
skia_private::TArray::reserve_exact
void reserve_exact(int n)
Definition:
SkTArray.h:181
skia_private::TArray::push_back
T & push_back()
Definition:
SkTArray.h:205
i
int i
Definition:
fl_socket_accessible.cc:18
kSize
constexpr int kSize
Definition:
largeclippedpath.cpp:12
SkColors::kRed
constexpr SkColor4f kRed
Definition:
SkColor.h:440
skgpu::Renderable::kNo
@ kNo
skgpu::Mipmapped
Mipmapped
Definition:
GpuTypes.h:53
skgpu::Mipmapped::kYes
@ kYes
skgpu::Mipmapped::kNo
@ kNo
skgpu::Protected::kNo
@ kNo
skia_private
Definition:
SkTArray.h:32
Generated on Sun Jun 23 2024 21:55:53 for Flutter Engine by
1.9.4