Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
graphite
AtlasProvider.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2023 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 "
src/gpu/graphite/AtlasProvider.h
"
9
10
#include "
include/gpu/graphite/Recorder.h
"
11
#include "
src/gpu/graphite/ComputePathAtlas.h
"
12
#include "
src/gpu/graphite/DrawContext.h
"
13
#include "
src/gpu/graphite/Log.h
"
14
#include "
src/gpu/graphite/RasterPathAtlas.h
"
15
#include "
src/gpu/graphite/RecorderPriv.h
"
16
#include "
src/gpu/graphite/RendererProvider.h
"
17
#include "
src/gpu/graphite/TextureProxy.h
"
18
#include "
src/gpu/graphite/text/TextAtlasManager.h
"
19
20
namespace
skgpu::graphite
{
21
22
AtlasProvider::PathAtlasFlagsBitMask
AtlasProvider::QueryPathAtlasSupport
(
const
Caps
* caps) {
23
// The raster-backend path atlas is always supported.
24
PathAtlasFlagsBitMask
flags
=
PathAtlasFlags::kRaster
;
25
if
(
RendererProvider::IsVelloRendererSupported
(caps)) {
26
flags
|=
PathAtlasFlags::kCompute
;
27
}
28
return
flags
;
29
}
30
31
AtlasProvider::AtlasProvider
(
Recorder
* recorder)
32
: fTextAtlasManager(
std
::make_unique<
TextAtlasManager
>(recorder))
33
, fRasterPathAtlas(
std
::make_unique<
RasterPathAtlas
>(recorder))
34
, fPathAtlasFlags(QueryPathAtlasSupport(recorder->
priv
().caps())) {}
35
36
std::unique_ptr<ComputePathAtlas>
AtlasProvider::createComputePathAtlas
(
Recorder
* recorder)
const
{
37
if
(this->
isAvailable
(
PathAtlasFlags::kCompute
)) {
38
return
ComputePathAtlas::CreateDefault
(recorder);
39
}
40
return
nullptr
;
41
}
42
43
RasterPathAtlas
*
AtlasProvider::getRasterPathAtlas
()
const
{
44
return
fRasterPathAtlas.get();
45
}
46
47
sk_sp<TextureProxy>
AtlasProvider::getAtlasTexture
(
Recorder
* recorder,
48
uint16_t
width
,
49
uint16_t
height
,
50
SkColorType
colorType
,
51
uint16_t
identifier
,
52
bool
requireStorageUsage) {
53
uint64_t
key
=
static_cast<
uint64_t
>
(
width
) << 48 |
54
static_cast<
uint64_t
>
(
height
) << 32 |
55
static_cast<
uint64_t
>
(
colorType
) << 16 |
56
static_cast<
uint64_t
>
(
identifier
);
57
auto
iter = fTexturePool.find(
key
);
58
if
(iter != fTexturePool.end()) {
59
return
iter->second;
60
}
61
62
// We currently only make the distinction between a storage texture (written by a
63
// compute pass) and a plain sampleable texture (written via upload) that won't be
64
// used as a render attachment.
65
const
Caps
* caps = recorder->
priv
().
caps
();
66
auto
textureInfo = requireStorageUsage
67
? caps->
getDefaultStorageTextureInfo
(
colorType
)
68
: caps->
getDefaultSampledTextureInfo
(
colorType
,
69
Mipmapped::kNo
,
70
recorder->
priv
().
isProtected
(),
71
Renderable::kNo
);
72
sk_sp<TextureProxy>
proxy =
TextureProxy::Make
(caps,
73
recorder->
priv
().
resourceProvider
(),
74
SkISize::Make
((int32_t)
width
, (int32_t)
height
),
75
textureInfo,
76
"AtlasProviderTexture"
,
77
Budgeted::kYes
);
78
if
(!proxy) {
79
return
nullptr
;
80
}
81
82
fTexturePool[
key
] = proxy;
83
return
proxy;
84
}
85
86
void
AtlasProvider::clearTexturePool
() {
87
fTexturePool.clear();
88
}
89
90
void
AtlasProvider::recordUploads
(
DrawContext
* dc) {
91
if
(!fTextAtlasManager->recordUploads(dc)) {
92
SKGPU_LOG_E
(
"TextAtlasManager uploads have failed -- may see invalid results."
);
93
}
94
95
if
(fRasterPathAtlas) {
96
fRasterPathAtlas->recordUploads(dc);
97
}
98
}
99
100
void
AtlasProvider::postFlush
() {
101
fTextAtlasManager->postFlush();
102
if
(fRasterPathAtlas) {
103
fRasterPathAtlas->postFlush();
104
}
105
}
106
107
}
// namespace skgpu::graphite
AtlasProvider.h
ComputePathAtlas.h
DrawContext.h
Log.h
SKGPU_LOG_E
#define SKGPU_LOG_E(fmt,...)
Definition:
Log.h:38
RasterPathAtlas.h
RecorderPriv.h
Recorder.h
RendererProvider.h
SkColorType
SkColorType
Definition:
SkColorType.h:19
colorType
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
Definition:
SkImageGeneratorNDK.cpp:53
TextAtlasManager.h
TextureProxy.h
SkEnumBitMask< PathAtlasFlags >
sk_sp
Definition:
SkRefCnt.h:220
skgpu::graphite::AtlasProvider::isAvailable
bool isAvailable(PathAtlasFlags atlasType) const
Definition:
AtlasProvider.h:57
skgpu::graphite::AtlasProvider::QueryPathAtlasSupport
static PathAtlasFlagsBitMask QueryPathAtlasSupport(const Caps *)
Definition:
AtlasProvider.cpp:22
skgpu::graphite::AtlasProvider::clearTexturePool
void clearTexturePool()
Definition:
AtlasProvider.cpp:86
skgpu::graphite::AtlasProvider::getAtlasTexture
sk_sp< TextureProxy > getAtlasTexture(Recorder *, uint16_t width, uint16_t height, SkColorType, uint16_t identifier, bool requireStorageUsage)
Definition:
AtlasProvider.cpp:47
skgpu::graphite::AtlasProvider::postFlush
void postFlush()
Definition:
AtlasProvider.cpp:100
skgpu::graphite::AtlasProvider::recordUploads
void recordUploads(DrawContext *)
Definition:
AtlasProvider.cpp:90
skgpu::graphite::AtlasProvider::AtlasProvider
AtlasProvider(Recorder *)
Definition:
AtlasProvider.cpp:31
skgpu::graphite::AtlasProvider::createComputePathAtlas
std::unique_ptr< ComputePathAtlas > createComputePathAtlas(Recorder *recorder) const
Definition:
AtlasProvider.cpp:36
skgpu::graphite::AtlasProvider::PathAtlasFlags::kRaster
@ kRaster
skgpu::graphite::AtlasProvider::PathAtlasFlags::kCompute
@ kCompute
skgpu::graphite::AtlasProvider::getRasterPathAtlas
RasterPathAtlas * getRasterPathAtlas() const
Definition:
AtlasProvider.cpp:43
skgpu::graphite::Caps
Definition:
Caps.h:71
skgpu::graphite::Caps::getDefaultStorageTextureInfo
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
skgpu::graphite::Caps::getDefaultSampledTextureInfo
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
skgpu::graphite::ComputePathAtlas::CreateDefault
static std::unique_ptr< ComputePathAtlas > CreateDefault(Recorder *)
Definition:
ComputePathAtlas.cpp:417
skgpu::graphite::DrawContext
Definition:
DrawContext.h:44
skgpu::graphite::RasterPathAtlas
Definition:
RasterPathAtlas.h:25
skgpu::graphite::RecorderPriv::isProtected
Protected isProtected() const
Definition:
RecorderPriv.h:52
skgpu::graphite::RecorderPriv::caps
const Caps * caps() const
Definition:
RecorderPriv.h:31
skgpu::graphite::RecorderPriv::resourceProvider
ResourceProvider * resourceProvider()
Definition:
RecorderPriv.h:33
skgpu::graphite::Recorder
Definition:
Recorder.h:75
skgpu::graphite::Recorder::priv
RecorderPriv priv()
Definition:
RecorderPriv.h:106
skgpu::graphite::RendererProvider::IsVelloRendererSupported
static bool IsVelloRendererSupported(const Caps *)
Definition:
RendererProvider.cpp:35
skgpu::graphite::TextAtlasManager
Definition:
TextAtlasManager.h:29
skgpu::graphite::TextureProxy::Make
static sk_sp< TextureProxy > Make(const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
Definition:
TextureProxy.cpp:159
identifier
static SkString identifier(const FontFamilyDesc &family, const FontDesc &font)
Definition:
create_test_font.cpp:298
flags
FlutterSemanticsFlag flags
Definition:
fl_accessible_node.cc:106
priv
FlPixelBufferTexturePrivate * priv
Definition:
fl_pixel_buffer_texture.cc:30
key
int key
Definition:
keyboard_key_handler_unittests.cc:114
skgpu::graphite
Definition:
BoundsManagerBench.cpp:27
skgpu::Budgeted::kYes
@ kYes
skgpu::Renderable::kNo
@ kNo
skgpu::Mipmapped::kNo
@ kNo
std
Definition:
ref_ptr.h:256
height
int32_t height
Definition:
serialization_callbacks.cc:1
width
int32_t width
Definition:
serialization_callbacks.cc:0
SkISize::Make
static constexpr SkISize Make(int32_t w, int32_t h)
Definition:
SkSize.h:20
Generated on Sun Jun 23 2024 21:56:25 for Flutter Engine by
1.9.4